Age | Commit message (Collapse) | Author | Files | Lines |
|
There are two cases when initilizing an array, this is the
const context which means we need to build the array ctor,
which means using lots of memory, its super inefficient
because we are using a big wrapper over the GCC internals here
but preallocating the vectors here causes a:
terminate called after throwing an instance of 'std::bad_alloc'
So this is a handy error condition to rely on for this senario.
Fixes Rust-GCC#3713
Fixes Rust-GCC#3727
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::array_copied_expr): prealloc the vector
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Add a new HIR LlvmInlineAsm HIR node as well as some structures to
represent it's options and operands. Lower AST::LlvmInlineAsm node to it
and then create a tree from that node.
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc (TokenCollector::visit): Remove unreachable
code.
* ast/rust-expr.h (struct LlvmOperand): Add LlvmOperand struct to
represent input and outputs.
(class LlvmInlineAsm): Add input, output and clobber operands.
(struct TupleTemplateStr): Add locus getter.
* backend/rust-compile-block.h: Add visit for LlvmInlineAsm.
* backend/rust-compile-expr.cc (CompileExpr::visit): Add llvm inline
asm stmt compilation.
* backend/rust-compile-expr.h: Add function prototype.
* backend/rust-compile-asm.h (class CompileLlvmAsm): Add llvm asm hir
not to gimple.
* backend/rust-compile-asm.cc (CompileLlvmAsm::CompileLlvmAsm): Add
constructor.
(CompileLlvmAsm::construct_operands): Add function to construct operand
tree.
(CompileLlvmAsm::construct_clobbers): Add function to construct clobber
tree.
(CompileLlvmAsm::tree_codegen_asm): Generate the whole tree for a given
llvm inline assembly node.
* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit):
Add visit function.
* checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Add function
prototype.
* checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Add visit
function.
* checks/errors/borrowck/rust-bir-builder-struct.h: Likewise.
* checks/errors/borrowck/rust-function-collector.h: Likewise.
* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit):
Likewise.
* checks/errors/privacy/rust-privacy-reporter.h: Add visit function
prototype.
* checks/errors/rust-const-checker.cc (ConstChecker::visit): Add visit
function.
* checks/errors/rust-const-checker.h: Add visit function prototype.
* checks/errors/rust-hir-pattern-analysis.cc (PatternChecker::visit):
Add visit function.
* checks/errors/rust-hir-pattern-analysis.h: Add visit function
prototype.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Add
visit function.
* checks/errors/rust-unsafe-checker.h: Add function prototype.
* expand/rust-macro-builtins-asm.cc (parse_llvm_templates): Parse
templates.
(parse_llvm_arguments): Add function to parse non template tokens.
(parse_llvm_operands): Add function to parse operands, either input or
output.
(parse_llvm_outputs): Add function to parse and collect llvm asm
outputs.
(parse_llvm_inputs): Likewise with inputs.
(parse_llvm_clobbers): Add function to parse llvm asm clobbers.
(parse_llvm_options): Add function to parse llvm asm options.
(parse_llvm_asm): Add function to parse llvm asm.
* expand/rust-macro-builtins-asm.h (class LlvmAsmContext): Add context
for llvm asm parser.
(parse_llvm_outputs): Add function prototype.
(parse_llvm_inputs): Likewise.
(parse_llvm_clobbers): Likewise.
(parse_llvm_options): Likewise.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Lower AST llvm
asm node to HIR.
* hir/rust-ast-lower-expr.h: Add function prototype.
* hir/rust-hir-dump.cc (Dump::visit): Add visit function.
* hir/rust-hir-dump.h: Add function prototype.
* hir/tree/rust-hir-expr-abstract.h: Add HIR llvm asm node kind.
* hir/tree/rust-hir-expr.h (struct LlvmOperand): Add LlvmOperand type
to represent input and outputs.
(class LlvmInlineAsm): Add LlvmInlineAsm hir node.
* hir/tree/rust-hir-full-decls.h (class LlvmInlineAsm): Add
LlvmInlineAsm hir node forward declaration.
* hir/tree/rust-hir-visitor.h: Add visit functions for LlvmInlineAsm
hir node.
* hir/tree/rust-hir.cc (LlvmInlineAsm::accept_vis): Add hir node
visitor related functions.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
Type check input and output operands.
* typecheck/rust-hir-type-check-expr.h: Add function prototype.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Visit input and
output operand expressions.
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Resolve input
and output expressions.
* resolve/rust-ast-resolve-expr.h: Add function prototypes.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-builder.cc (Builder::self_ref_param): Remove error state
and use optional.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Check label
before visiting.
* ast/rust-ast.cc (ContinueExpr::as_string): Retrieve label value.
(Lifetime::as_string): Retrieve lifetime value.
(ReferenceType::as_string): Likewise.
(SelfParam::as_string): Likewise.
* ast/rust-ast.h: Remove lifetime and LifetimeParam error state.
* ast/rust-desugar-for-loops.cc (DesugarForLoops::DesugarCtx::make_break_arm):
Use optional instead of error state.
* ast/rust-expr.h (class ContinueExpr): Make label optional.
* ast/rust-item.h (class SelfParam): Make lifetime optional.
* ast/rust-type.h (class ReferenceType): Likewise.
* backend/rust-compile-base.cc: Use optional for self param instead
of error state.
* backend/rust-compile-base.h: Update function prototype.
* expand/rust-derive-clone.cc (DeriveClone::clone_fn): Use optional.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_self): Lower
lifetime only if it exists.
* hir/rust-ast-lower-block.h: Lower loop label only if it exists.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise.
* hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::visit): Remove
references to error state.
(ASTLowerTraitItem::visit): Lower self param only if it exists.
* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Use nullopt
for default value instead of SelfParam error state.
* hir/rust-ast-lower.cc (ASTLoweringExprWithBlock::visit): Lower label
only if it exists.
* hir/rust-hir-dump.cc (Dump::do_traitfunctiondecl): Print self only if
it exists.
(Dump::visit): Liewise.
* hir/tree/rust-hir-bound.h: Remove error state.
* hir/tree/rust-hir-expr.cc (ContinueExpr::ContinueExpr): Use optional
in constructor for loop label.
(BreakExpr::BreakExpr): Likewise.
* hir/tree/rust-hir-expr.h (class ContinueExpr): Remove error state
implementation.
(class BreakExpr): Likewise.
* hir/tree/rust-hir-generic-param.h: Likewise.
* hir/tree/rust-hir-item.cc (SelfParam::SelfParam): Make lifetime
optional.
(Function::Function): Make self param optional.
* hir/tree/rust-hir-item.h (class Function): Likewise.
* hir/tree/rust-hir-type.cc (ReferenceType::ReferenceType): Make
lifetime optional.
* hir/tree/rust-hir-type.h (class ReferenceType): Likewise.
* hir/tree/rust-hir.cc (ContinueExpr::as_string): Use new getter.
(BreakExpr::as_string): Likewise.
(Lifetime::as_string): Likewise.
(ReferenceType::as_string): Likewise.
(TraitFunctionDecl::as_string): Likewise.
(SelfParam::as_string): Remove error state checking.
* parse/rust-parse-impl.h (Parser::parse_generic_param): Adapt to
optional.
(Parser::parse_lifetime_params): Likewise.
(Parser::parse_lifetime_params_objs): Likewise.
(Parser::parse_lifetime_param): Likewise.
(Parser::parse_lifetime_where_clause_item): Likewise.
(Parser::parse_type_param_bound): Likewise.
(Parser::parse_lifetime_bounds): Likewise.
(Parser::parse_path_generic_args): Likewise.
(Parser::parse_self_param): Likewise.
(Parser::parse_break_expr): Likewise.
(Parser::parse_continue_expr): Likewise.
(Parser::parse_reference_type_inner): Likewise.
* parse/rust-parse.h (class ParseLifetimeParamError): Add new class for
lifetime param parsing errors.
(class ParseLifetimeError): Add new class for lifetime parsing errors.
(enum ParseSelfError): Add new class for self param parsing errors.
* typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit):
Use unchecked getter in checked context. And make anonymous region.
* typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn):
Likewise.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
This patch adds support for raw references which enforce the pointer
type away from a reference type.
Fixes Rust-GCC#3667
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc (HIRCompileBase::address_expression): allow optional type
* backend/rust-compile-base.h: update prototype
* backend/rust-compile-expr.cc (CompileExpr::visit): update borrow expr
* backend/rust-compile-extern.h: remove unused debug
* backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): update usage
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): lower raw ref
* hir/tree/rust-hir-expr.cc (BorrowExpr::BorrowExpr): add flag for raw ref
* hir/tree/rust-hir-expr.h (class BorrowExpr): add new raw ref field
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): add handle for raw ref
gcc/testsuite/ChangeLog:
* rust/compile/issue-3667.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
We need to setup the main_identifier_node for MAIN_DECL_P checks in the
middle-end. But it is valid to have a main function/method on impl blocks.
So we need to flag if this is a "root" item or not, which is one that is
jsut an HIR::Function on part of the Crate::items as oppposed to a
HIR::Function which is part of an HIR::ImplBlock as part of the HIR::Crate.
Some small cleanups have been added here too.
Fixes Rust-GCC#3648
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc: new flag is_root_item
* backend/rust-compile-base.h: update prototype
* backend/rust-compile-implitem.cc (CompileTraitItem::visit): update call
* backend/rust-compile-implitem.h: remove old debug internal error
* backend/rust-compile-item.cc (CompileItem::visit): update call
* backend/rust-compile-item.h: remove old debug
* backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): update calls
* backend/rust-compile.cc: likewise
* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait):
remove assertion and error
gcc/testsuite/ChangeLog:
* rust/compile/issue-3648.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-resolve-path.cc: Evaluate the enum's discriminant in a const context
gcc/testsuite/ChangeLog:
* rust/compile/enum_discriminant1.rs: New test.
Signed-off-by: Ryutaro Okada <1015ryu88@gmail.com>
|
|
Since 898d55ad7e2 was fixed to remove the VIEW_CONVERT_EXPR from
array expressions we can now turn on the array element access
const expr.
Fixes Rust-GCC#3563
gcc/rust/ChangeLog:
* backend/rust-constexpr.cc (eval_store_expression): turn this back on
gcc/testsuite/ChangeLog:
* rust/compile/issue-3563.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Array expressions are still getting turned into VIEW_CONVERT_EXPR's becuase
TYPE_MAIN_VARIANT is not set so then we might as well reuse the type-hasher
to sort this out.
Fixes Rust-GCC#3588
gcc/rust/ChangeLog:
* backend/rust-compile-context.h: only push named types
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): run the type hasher
gcc/testsuite/ChangeLog:
* rust/compile/issue-3588.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Fixes Rust-GCC#3552
gcc/rust/ChangeLog:
* backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): check for Expr trait
* hir/rust-hir-dump.cc (Dump::visit): expr is optional
gcc/testsuite/ChangeLog:
* rust/compile/issue-3552.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
This has been a pet peeve of mine for a while because the gimple never
emitted the struct () name properly it was always empty which for record
types they always require a real locus or they dont get a proper name.
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc (HIRCompileBase::unit_expression): pass ctx
* backend/rust-compile-base.h: cant be static
* backend/rust-compile-intrinsic.cc (try_handler_inner): pass ctx
* backend/rust-compile-type.cc
(TyTyResolveCompile::get_unit_type): update to grab the first locus
(TyTyResolveCompile::visit): pass ctx
* backend/rust-compile-type.h: likewise
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
We need to reuse the existing compile_constant_item helper which handles
the case if this is a simple expression, fn-call or a block expression.
The patch extracts out this helper as a static method so this can be used
in more places.
Fixes Rust-GCC#3566
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc (HIRCompileBase::address_expression): new helper constexpr
* backend/rust-compile-base.h: prototype
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): call constexpr helper
gcc/testsuite/ChangeLog:
* rust/compile/issue-3566-1.rs: New test.
* rust/compile/issue-3566-2.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
We need to check for error_mark_node when doing adjustments from coercion
sites otherwise we hit assetions as part of the coercion. That fixes the
ICE but the reason for the error_mark_node is because the array element
value.
Fixes Rust-GCC#3567
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::array_value_expr): add value chk for array expr
gcc/testsuite/ChangeLog:
* rust/compile/issue-3567.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Just a small refactor to remove a visitor which is not needed.
gcc/rust/ChangeLog:
* backend/rust-compile-resolve-path.cc (ResolvePathRef::Compile): remove visitor
(ResolvePathRef::ResolvePathRef): likewise
(ResolvePathRef::visit): likewise
* backend/rust-compile-resolve-path.h (class ResolvePathRef): likewise
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc
(assume_handler): Fix copy/paste error.
* typecheck/rust-hir-type-check-pattern.cc
(TypeCheckPattern::visit): Fix spelling mistake.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
This completes the initial setup and boilerplate for the new type in the
typesystem. This is not functional yet but its a big patch already.
gcc/rust/ChangeLog:
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): new tyty::OpaqueType
* backend/rust-compile-type.h: likewise
* checks/errors/borrowck/rust-bir-fact-collector.h: likewise
* checks/errors/borrowck/rust-bir-place.h: likewise
* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::check_base_type_privacy):
likewise
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): likewise
* typecheck/rust-hir-type-check-type.h: likewise
* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit): likewise
* typecheck/rust-substitution-mapper.h: likewise
* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::assemble_sized_builtin): likewise
* typecheck/rust-tyty-call.h: likewise
* typecheck/rust-tyty-cmp.h (class OpaqueCmp): likewise
* typecheck/rust-tyty-variance-analysis-private.h: likewise
* typecheck/rust-tyty-visitor.h: likewise
* typecheck/rust-tyty.cc (TypeKindFormat::to_string): likewise
(BaseType::is_unit): likewise
(BaseType::destructure): likewise
(BaseType::has_substitutions_defined): likewise
(BaseType::needs_generic_substitutions): likewise
(OpaqueType::OpaqueType): likewise
(OpaqueType::can_resolve): likewise
(OpaqueType::accept_vis): likewise
(OpaqueType::as_string): likewise
(OpaqueType::get_name): likewise
(OpaqueType::can_eq): likewise
(OpaqueType::clone): likewise
(OpaqueType::resolve): likewise
(OpaqueType::is_equal): likewise
(OpaqueType::handle_substitions): likewise
* typecheck/rust-tyty.h (enum TypeKind): likewise
(class OpaqueType): likewise
* typecheck/rust-unify.cc (UnifyRules::go): likewise
(UnifyRules::expect_inference_variable): likewise
(UnifyRules::expect_adt): likewise
(UnifyRules::expect_str): likewise
(UnifyRules::expect_reference): likewise
(UnifyRules::expect_pointer): likewise
(UnifyRules::expect_param): likewise
(UnifyRules::expect_array): likewise
(UnifyRules::expect_slice): likewise
(UnifyRules::expect_fndef): likewise
(UnifyRules::expect_fnptr): likewise
(UnifyRules::expect_tuple): likewise
(UnifyRules::expect_bool): likewise
(UnifyRules::expect_char): likewise
(UnifyRules::expect_int): likewise
(UnifyRules::expect_uint): likewise
(UnifyRules::expect_float): likewise
(UnifyRules::expect_isize): likewise
(UnifyRules::expect_usize): likewise
(UnifyRules::expect_placeholder): likewise
(UnifyRules::expect_projection): likewise
(UnifyRules::expect_dyn): likewise
(UnifyRules::expect_opaque): likewise
* typecheck/rust-unify.h: likewise
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Addresses Rust-GCC#3352
gcc/rust/ChangeLog:
* backend/rust-compile-type.cc (TyTyResolveCompile::get_implicit_enumeral_node_type):
use repr
(TyTyResolveCompile::visit): update prototype
* backend/rust-compile-type.h: likewise
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Addresses Rust-GCC#3348
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc (variant_count_handler): new intrinsic
gcc/testsuite/ChangeLog:
* rust/execute/torture/enum_intrinsics2.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
This is pretty nasty piece of rust in my opinion the return type of this
intrinsic results into a lang item associated type:
<T as DiscriminantKind>::Discriminant
This is a special case which needs to support mapping onto the repr type
of the associated ADT that is passed in, but defaults to iszie otherwise.
This patch assumes we only come accross this case in a HIR::CALL_EXPR, so
and makes assumutions that its always of this function signiture. I will
do some checking in libcore to verify that assumption. More work is needed
to parse the repr type on enums but the code is there to support this when
its in to change the types etc.
Addresses Rust-GCC#3348
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc (discriminant_value_handler): new handler
* typecheck/rust-hir-trait-resolve.cc (TraitItemReference::resolve_item): track the defid
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::parse_repr_options): default isize
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): special case CallExpr
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): parse repr options enum
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): remove bad diagnostic
* typecheck/rust-tyty.cc (PlaceholderType::PlaceholderType): track defid
(PlaceholderType::clone): likewise
(PlaceholderType::get_def_id): likeiwse
* typecheck/rust-tyty.h: placeholder track defid
* util/rust-lang-item.cc: add new lang items
* util/rust-lang-item.h: likewise
gcc/testsuite/ChangeLog:
* rust/execute/torture/enum_intrinsics1.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
When we have paths such as Try::from_error the Try references the Trait
and then from_error references the from_error trait item. So this resolves
directly to a trait implementation which has the type:
fn <Self> (v: placeholder) -> Self
Remember that a path such as: Try::from_error gets handled by doing a
clever substitution: <T? as Try>::from_error
The main piece here is that we resolve this function type and for
monomoprhization we know this is a trait call but we know that all trait's
have an implicit Self type param which in this case is Result<i32, i32>
so when it comes to knowing which impl block this is we got rid of the old
bad insert/lookup receiver hack and use the specified type to know which
impl block we are talking about to generate the function.
The hard part here is inside rust-compil-item.cc, where we have the
'concete' type which is the trait item fntype of:
fn <Result<i32, i32>> (v : i32) -> Result<i32,i32>
This does not really match the signiture of the impl item for Result
which is:
fn <T, E> (v: i32) -> Result<T, E>
So what we need to do is actually infer this by inputing inference
variables on the impl fntype then unify'ing the trait object to this to
compute the types of this to monomorphize this.
Fixes Rust-GCC#3381
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): remove receiver interface
* backend/rust-compile-item.cc (CompileItem::visit): monomorphize trait to impl item
* backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): use trait item Self
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): remove receiver interface
(TypeCheckExpr::resolve_fn_trait_call): likewise
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::visit): likewise
(TypeCheckExpr::resolve_segments): likewise
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): likewise
* typecheck/rust-hir-type-check.h: likewise
* typecheck/rust-typecheck-context.cc (TypeCheckContext::insert_receiver): remove
(TypeCheckContext::lookup_receiver): remove
gcc/testsuite/ChangeLog:
* rust/execute/torture/issue-3381.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc
(CompileExpr::generate_closure_function): Take
NameResolutionContext by reference instead of by value.
* backend/rust-compile-item.cc
(CompileItem::visit): Likewise.
* backend/rust-compile-resolve-path.cc
(ResolvePathRef::resolve): Likewise.
* checks/lints/rust-lint-marklive.cc
(MarkLive::find_ref_node_id): Likewise.
* typecheck/rust-hir-type-check-enumitem.cc
(TypeCheckEnumItem::visit): Likewise.
* typecheck/rust-hir-type-check-implitem.cc
(TypeCheckImplItem::visit): Likewise.
* typecheck/rust-hir-type-check-item.cc
(TypeCheckItem::visit): Likewise.
* typecheck/rust-hir-type-check-path.cc
(TypeCheckExpr::resolve_root_path): Likewise.
* typecheck/rust-hir-type-check-type.cc
(TypeCheckType::resolve_root_path): Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
Fixes Rust-GCC#3174
gcc/rust/ChangeLog:
* backend/rust-compile-pattern.cc (CompilePatternBindings::visit): make recursive
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): handle ref flag
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: nr2 cant handle this
* rust/compile/issue-3174.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
This will be crucial for more complex gimple debugging to make it easier
to follow the code vs the original rust code.
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): disable overflow checks
* lang.opt: new flag
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve): Do
not use query system for unit struct but compile it's constructor
instead.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
Query mode was a hack to catch up some compile errors early, it was
deemed to be removed at some time. Recent changes to NR1 highlighted
an incompatibility with it hence it's removal.
gcc/rust/ChangeLog:
* backend/rust-compile-item.h: Remove query mode.
* backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile):
Likewise.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-resolve-path.cc (ResolvePathRef::visit): Call into
resolve_path_like instead.
(ResolvePathRef::resolve_path_like): New.
(ResolvePathRef::resolve): Call into resolve_with_node_id.
* backend/rust-compile-resolve-path.h: Declare new functions and document them.
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-resolve-path.cc (ResolvePathRef::visit): Adapt visitor to lang item
HIR::PathInExpressions.
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::visit): Likewise.
|
|
When we lookup here it returns an optional which can lead to a crash
because it needs a guard if it has a value.
gcc/rust/ChangeLog:
* backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): add guard
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: these tests now work it seems
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (check_match_scrutinee): Allow anything to be used as a
match scrutinee, not just ADTs.
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc: add the new `catch_unwind` variant
of the `try` intrinsic: this variant can be seen on Rust 1.78+
and returns `()` instead of `i32`.
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc: add `try` intrinsic handler.
* lang.opt: add `-frust-panic` option.
* rust-lang.cc: enable exception handler code generation.
* rust-session-manager.cc: add getter and setter for panic
strategy option.
* rust-session-manager.h: Likewise.
Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
|
|
Unify rules are not the same as coercion rules. The coercion of ! is
allowed to any type but not for a unify site which is different.
Match arms are another least upper bound coercion.
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): implement coercion
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): this is an LUB
* typecheck/rust-unify.cc (UnifyRules::go): remove unify ! coercion
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
This changes our enum type layout so for example:
enum Foo {
A,
B,
C(char),
D { x: i32, y: i32 },
}
Used to get layed out like this in gccrs:
union {
struct A { int RUST$ENUM$DISR; };
struct B { int RUST$ENUM$DISR; };
struct C { int RUST$ENUM$DISR; char __0; };
struct D { int RUST$ENUM$DISR; i64 x; i64 y; };
}
This has some issues notably with the constexpr because this is just a
giant union it means its not simple to constify what enum variant we are
looking at because the discriminant is a mess.
This now gets layed out as:
struct {
int RUST$ENUM$DISR;
union {
struct A { };
struct B { };
struct C { char __0; };
struct D { i64 x; i64 y; };
} payload;
}
This layout is much cleaner and allows for our constexpr to work properly.
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): new layout
* backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit): likewise
(CompilePatternBindings::visit): likewise
* backend/rust-compile-resolve-path.cc: likewise
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): implement new layout
* rust-gcc.cc (constructor_expression): get rid of useless assert
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
The Eq and Partial Ord are very similar to the operator overloads
we support for add/sub/etc... but they differ in that usually the
function call name matches the name of the lang item. This time
we need to have support to send in a new path for the method call
on the lang item we want instead of just the name of the lang item.
NOTE: this test case doesnt work correctly yet we need to support
the derive of partial eq on enums to generate the correct comparison
code for that.
Fixes Rust-GCC#3302
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): handle partial_eq possible call
* backend/rust-compile-expr.h: handle case where lang item calls differ from name
* hir/tree/rust-hir-expr.cc (OperatorExprMeta::OperatorExprMeta): new helper
* hir/tree/rust-hir-expr.h: likewise
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): handle partial_eq
(TypeCheckExpr::resolve_operator_overload): likewise
* typecheck/rust-hir-type-check-expr.h: likewise
* util/rust-lang-item.cc (LangItem::ComparisonToLangItem): map comparison to lang item
(LangItem::ComparisonToSegment): likewise
* util/rust-lang-item.h: new lang items PartialOrd and Eq
* util/rust-operators.h (enum class): likewise
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: nr2 cant handle this
* rust/compile/cmp1.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Since our bootstrap requirement has been bumped to C++14, we don't need
a custom implementation of std::make_unique anymore.
gcc/rust/ChangeLog:
* ast/rust-ast-builder-type.cc: Remove inclusion of
rust-make-unique.h.
* ast/rust-ast-builder.cc: Likewise.
(Builder::array): Use std::make_unique instead of
Rust::make_unique.
* ast/rust-ast.cc (Attribute::get_traits_to_derive): Likewise.
* ast/rust-macro.h: Remove inclusion of rust-make-unique.h.
(MacroRulesDefinition::mbe): Use std::make_unique instead of
Rust::make_unique.
(MacroRulesDefinition::decl_macro): Likewise.
* ast/rust-path.h
(PathInExpression::PathInExpression): Likewise.
(QualifiedPathInExpression::QualifiedPathInExpression):
Likewise.
* backend/rust-compile-pattern.cc
(CompilePatternCheckExpr::visit): Likewise.
* expand/rust-derive-copy.cc
(DeriveCopy::copy_impl): Likewise.
* expand/rust-expand-format-args.cc
(expand_format_args): Likewise.
* expand/rust-macro-builtins-asm.cc: Remove inclusion of
rust-make-unique.h.
(parse_asm): Use std::make_unique instead of Rust::make_unique.
* hir/rust-ast-lower-expr.cc
(ASTLoweringExpr::visit): Likewise.
* hir/tree/rust-hir-expr.cc
(StructExprStructFields::StructExprStructFields): Likewise.
(StructExprStructFields::operator=): Likewise.
* hir/tree/rust-hir.cc
(TypePath::to_trait_bound): Likewise.
* lex/rust-token.h: Remove inclusion of rust-make-unique.h.
(Token::Token): Use std::make_unique instead of
Rust::make_unique.
* metadata/rust-import-archive.cc: Remove inclusion of
rust-make-unique.h.
(Import::find_archive_export_data): Use std::make_unique instead
of Rust::make_unique.
* metadata/rust-imports.cc: Remove inclusion of
rust-make-unique.h.
(Import::find_export_data): Use std::make_unique instead of
Rust::make_unique.
(Import::find_object_export_data): Likewise.
* parse/rust-parse-impl.h: Remove inclusion of
rust-make-unique.h.
(Parser::parse_function_param): Use std::make_unique instead of
Rust::make_unique.
(Parser::parse_self_param): Likewise.
(Parser::parse_array_expr): Likewise.
* typecheck/rust-hir-type-check-enumitem.cc
(TypeCheckEnumItem::visit): Likewise.
* typecheck/rust-hir-type-check-implitem.cc
(TypeCheckTopLevelExternItem::visit): Likewise.
(TypeCheckImplItem::visit): Likewise.
* typecheck/rust-hir-type-check-type.cc
(TypeResolveGenericParam::visit): Likewise.
* typecheck/rust-hir-type-check.cc: Remove inclusion of
rust-make-unique.h.
(TraitItemReference::get_type_from_fn): Use std::make_unique
instead of Rust::make_unique.
* typecheck/rust-tyty-bounds.cc
(TypeCheckBase::get_predicate_from_bound): Likewise.
* util/rust-make-unique.h: Removed.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
In order to handle the tuple pattern of: fn test ((x _) : (i32, i32)) -> i32 { x }
we need to recognize that ABI wise this function still takes a tuple as the parameter
to this function its just how we can address the "pattern" of the tuple changes.
So reall if this was C it would look like:
void test (struct tuple_type __prameter)
{
return __parameter.0
}
The code here reuses our existing pattern code so that we generate these implicit
bindings of the paramter with a field access so any time x is referenced it's really
just emplacing __parameter.0 for the field access into the struct which is a tuple.
Fixes Rust-GCC#2847
gcc/rust/ChangeLog:
* backend/rust-compile-fnparam.cc (CompileFnParam::visit): compile tuple patterns
(CompileSelfParam::compile): update return type
(CompileFnParam::create_tmp_param_var): return Bvariable not tree to stop ICE
* backend/rust-compile-fnparam.h: update prototype
* backend/rust-compile-pattern.cc (CompilePatternBindings::visit): implement TuplePattern
* backend/rust-compile-pattern.h: update prototype
gcc/testsuite/ChangeLog:
* rust/compile/issue-2847.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
These are ported from the c-family code c-warn.cc and c/c-typchk.cc
Fixes Rust-GCC#2394
gcc/rust/ChangeLog:
* backend/rust-constexpr.cc (eval_store_expression): check for null
(eval_call_expression): remove bad warning
* rust-gcc.cc (arithmetic_or_logical_expression): add warnings
gcc/testsuite/ChangeLog:
* rust/compile/issue-2394.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
The code here was wrongly assuming the decl type from the folding of the
expression would be the type of the constant decl. This is not the case for
unsized coercions for slices, where the expression here is a reference to
an array then we require the coercion to fix the result up to the expected
type.
Fixes Rust-GCC#1525
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc: apply coercion site to result
* backend/rust-compile-base.h: update prototype
* backend/rust-compile-implitem.cc (CompileTraitItem::visit): send in coercion info
* backend/rust-compile-item.cc (CompileItem::visit): likewise
gcc/testsuite/ChangeLog:
* rust/compile/issue-1525.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Both TraitItemFunc::has_definition() and TraitItemFunc::has_block_defined()
were exactly the same implementation, so remove one.
gcc/rust/ChangeLog:
* hir/tree/rust-hir-item.h: Remove TraitItemFunc::has_block_defined()
* backend/rust-compile-implitem.cc (CompileTraitItem::visit):
Call TraitItemFunc::has_definition() instead.
* checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise.
* checks/errors/rust-hir-pattern-analysis.cc (PatternChecker::visit): Likewise.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise.
* typecheck/rust-hir-trait-resolve.cc (ResolveTraitItemToRef::visit): Likewise.
|
|
We cannot apply aligned or packed after layout_type is called you need
to set this up first then call it.
Fixes Rust-GCC#3260
gcc/rust/ChangeLog:
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): call lauout type directly
* rust-backend.h (struct_type): add optional layout parameter
(union_type): likewise
(fill_in_fields): likewise
* rust-gcc.cc (struct_type): likewise
(union_type): likewise
(fill_in_fields): only layout if we required
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc: Prepend crate name to function's ir
name.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove passing tests from exclude list.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
This is a special case in Rust and the ! type can unify with pretty much
anything its almost a inference variable and a unit-type for special cases.
Fixes Rust-GCC/gccrs#3231
Fixes Rust-GCC/gccrs#2567
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (check_match_scrutinee): check for empty match
(CompileExpr::visit): fix assertion
* checks/errors/rust-hir-pattern-analysis.cc (check_match_usefulness): check for empty
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): resolve to !
gcc/testsuite/ChangeLog:
* rust/compile/exhaustiveness1.rs: remove bad check
* rust/compile/issue-2567-1.rs: New test.
* rust/compile/issue-2567-2.rs: New test.
* rust/compile/issue-2567-3.rs: New test.
* rust/compile/issue-3231.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
System includes shall use rust-system header instead.
gcc/rust/ChangeLog:
* ast/rust-stmt.h: Remove stdlib include and use rust-system instead.
* backend/rust-compile-expr.cc: Likewise.
* backend/rust-mangle-legacy.cc: Likewise.
* backend/rust-mangle-v0.cc: Likewise.
* hir/rust-hir-dump.cc: Likewise.
* typecheck/rust-hir-type-check-type.cc: Likewise.
* typecheck/rust-tyty.cc: Likewise.
* typecheck/rust-tyty.h: Likewise.
* util/rust-common.h: Likewise.
* util/rust-token-converter.cc: Likewise.
* util/rust-token-converter.h: Likewise.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): Change call.
(CompileExpr::resolve_operator_overload): Update function arguments.
* backend/rust-compile-expr.h: Change the function's prototype to use
a reference wrapper instead of a reference within the optional.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
A variant being moved lead to a null being created and a segfault later
down the line.
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): Call getter
instead of size function.
* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit):
Only check privacy if the type is present.
* hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Use an optional.
* hir/tree/rust-hir-generic-param.h: Assert type before getting it.
* hir/tree/rust-hir-item.h: Assert pointers before dereference, fix
has_type condition.
* hir/tree/rust-hir-path.h: Add more assertions.
* hir/tree/rust-hir-stmt.cc: Change constructor with optionals.
* hir/tree/rust-hir-stmt.h: Use optionals over smart pointers to
emphasize these fields might be missing.
* hir/tree/rust-hir.cc (LetStmt::as_string): Use getters.
* typecheck/rust-hir-type-check-expr.cc: Clone structures to prevent
parent's fields from being nulled by the move operation.
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Use
optionals.
* typecheck/rust-tyty.cc: Likewise.
* typecheck/rust-tyty.h: Likewise.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
The HIR made heavy use of pair and other unamed types which can be
difficult to read.
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc: Use FnParam getter.
* backend/rust-compile-expr.cc (CompileExpr::visit): Likewise.
* backend/rust-compile-intrinsic.cc: Likewise.
* backend/rust-compile-type.cc: Likewise.
* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit):
Only visit childrens if not missing.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Use
a reference instead of a raw pointer.
* hir/tree/rust-hir-expr.h: Add presence function for return
expression.
* hir/tree/rust-hir-item.h: Remove take_param_name.
* hir/tree/rust-hir.h: Make mapping getter const.
* typecheck/rust-hir-dot-operator.cc (MethodResolver::Select): Use
getter.
* typecheck/rust-hir-type-check-expr.cc: Likewise.
* typecheck/rust-hir-type-check-implitem.cc: Use FnParam vector instead
of std::pair of Pattern and BaseType.
* typecheck/rust-hir-type-check-item.cc: Likewise.
* typecheck/rust-hir-type-check.cc: Likewise.
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Use getters.
(TypeCheckMethodCallExpr::check): Likewise.
* typecheck/rust-tyty-cmp.h: Likewise.
* typecheck/rust-tyty.cc: Use FnParam.
* typecheck/rust-tyty.h (class FnParam): Add FnParam to handle function
parameters instead of handling std::pairs.
* typecheck/rust-unify.cc (UnifyRules::expect_fndef): Use getters.
(UnifyRules::expect_fnptr): Likewise.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
Attempt to use references and smart pointers whenever possible.
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc (HIRCompileBase::compile_function_body):
Remove usage of get function to retrieve a raw pointer.
* backend/rust-compile-base.h:
Change API usage from raw pointer to a reference.
* backend/rust-compile-block.cc (CompileBlock::compile): Likewise.
(CompileBlock::visit): Likewise.
(CompileConditionalBlocks::visit): Likewise.
* backend/rust-compile-block.h: Likewise.
* backend/rust-compile-expr.cc (CompileExpr::Compile): Likewise.
(CompileExpr::visit): Likewise.
(check_match_scrutinee): Likewise.
(CompileExpr::array_value_expr): Likewise.
(CompileExpr::array_copied_expr): Likewise.
(CompileExpr::generate_closure_function): Likewise.
(CompileExpr::generate_possible_fn_trait_call): Likewise.
* backend/rust-compile-expr.h: Likewise.
* backend/rust-compile-fnparam.cc (CompileFnParam::compile): Likewise.
(CompileFnParam::visit): Likewise.
* backend/rust-compile-fnparam.h: Likewise.
* backend/rust-compile-implitem.cc (CompileTraitItem::visit): Likewise.
* backend/rust-compile-intrinsic.cc (compile_fn_params): Likewise.
* backend/rust-compile-item.cc (CompileItem::visit): Likewise.
* backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit):
Likewise.
(compile_range_pattern_bound): Likewise.
(CompilePatternBindings::visit): Likewise.
(CompilePatternLet::visit): Likewise.
* backend/rust-compile-pattern.h: Likewise.
* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve):
Likewise.
(HIRCompileBase::query_compile): Likewise.
* backend/rust-compile-stmt.cc (CompileStmt::visit): Likewise.
* backend/rust-compile-struct-field-expr.cc (CompileStructExprField::Compile):
Likewise.
(CompileStructExprField::visit): Likewise.
* backend/rust-compile-struct-field-expr.h: Likewise.
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Likewise.
* backend/rust-compile-var-decl.h: Likewise.
* backend/rust-compile.cc: Likewise.
* backend/rust-mangle-v0.cc (v0_inherent_or_trait_impl_path): Likewise.
* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit):
Likewise.
* checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Likewise.
* checks/errors/borrowck/rust-bir-builder-pattern.h: Likewise.
* checks/errors/borrowck/rust-bir-builder-struct.h: Likewise.
* checks/errors/borrowck/rust-bir-builder.h: Likewise.
* checks/errors/borrowck/rust-function-collector.h: Likewise.
* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::check_type_privacy):
Likewise.
(PrivacyReporter::visit): Likewise.
* checks/errors/privacy/rust-privacy-reporter.h: Likewise.
* checks/errors/privacy/rust-reachability.cc (ReachabilityVisitor::visit):
Likewise.
* checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit):
Likewise.
* checks/lints/rust-lint-marklive.cc (MarkLive::visit): Likewise.
* checks/lints/rust-lint-marklive.h: Likewise.
* hir/rust-hir-dump.cc (Dump::visit): Likewise.
* hir/tree/rust-hir-expr.h: Likewise.
* hir/tree/rust-hir-item.h: Likewise.
* hir/tree/rust-hir-path.h: Likewise.
* hir/tree/rust-hir-pattern.h: Likewise.
* hir/tree/rust-hir-stmt.h: Likewise.
* hir/tree/rust-hir-type.h: Likewise.
* hir/tree/rust-hir.h: Likewise.
* typecheck/rust-autoderef.cc: Likewise.
* typecheck/rust-hir-dot-operator.cc (MethodResolver::select):
Likewise.
* typecheck/rust-hir-inherent-impl-overlap.h: Likewise.
* typecheck/rust-hir-path-probe.cc (PathProbeType::process_impl_item_candidate):
Likewise.
(PathProbeImplTrait::process_trait_impl_items_for_candidates): Likewise.
* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait):
Likewise.
(TraitItemReference::resolve_item): Likewise.
* typecheck/rust-hir-type-check-base.cc: Likewise.
* typecheck/rust-hir-type-check-base.h: Likewise.
* typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::Resolve):
Likewise.
(TypeCheckEnumItem::visit): Likewise.
* typecheck/rust-hir-type-check-enumitem.h: Likewise.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::Resolve):
Likewise.
(TypeCheckExpr::visit): Likewise.
(TypeCheckExpr::resolve_fn_trait_call): Likewise.
* typecheck/rust-hir-type-check-expr.h: Likewise.
* typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::Resolve):
Likewise.
(TypeCheckTopLevelExternItem::visit): Likewise.
(TypeCheckImplItem::visit): Likewise.
(TypeCheckImplItemWithTrait::visit): Likewise.
* typecheck/rust-hir-type-check-implitem.h: Likewise.
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Likewise.
(TypeCheckItem::resolve_impl_item): Likewise.
(TypeCheckItem::resolve_impl_block_substitutions): Likewise.
(TypeCheckItem::resolve_impl_block_self): Likewise.
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::visit): Likewise.
(TypeCheckExpr::resolve_segments): Likewise.
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::Resolve):
Likewise.
(TypeCheckPattern::visit): Likewise.
(ClosureParamInfer::Resolve): Likewise.
(ClosureParamInfer::visit): Likewise.
* typecheck/rust-hir-type-check-pattern.h: Likewise.
* typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::Resolve):
Likewise.
(TypeCheckStmt::visit): Likewise.
* typecheck/rust-hir-type-check-stmt.h: Likewise.
* typecheck/rust-hir-type-check-struct-field.h: Likewise.
* typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::TypeCheckStructExpr):
Likewise.
(TypeCheckStructExpr::Resolve): Likewise.
(TypeCheckStructExpr::resolve): Likewise.
(TypeCheckStructExpr::visit): Likewise.
* typecheck/rust-hir-type-check-type.cc (TypeCheckResolveGenericArguments::resolve):
Likewise.
(TypeCheckType::Resolve): Likewise.
(TypeCheckType::visit): Likewise.
(TypeCheckType::resolve_root_path): Likewise.
(TypeResolveGenericParam::Resolve): Likewise.
(TypeResolveGenericParam::visit): Likewise.
(ResolveWhereClauseItem::visit): Likewise.
* typecheck/rust-hir-type-check-type.h: Likewise.
* typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn):
Likewise.
* typecheck/rust-hir-type-check.h: Likewise.
* typecheck/rust-type-util.cc (query_type): Likewise.
* typecheck/rust-typecheck-context.cc (TypeCheckContextItem::TypeCheckContextItem):
Likewise.
* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::scan): Likewise.
(TypeCheckBase::get_predicate_from_bound): Likewise.
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Likewise.
(TypeCheckMethodCallExpr::go): Likewise.
(TypeCheckMethodCallExpr::check): Likewise.
* typecheck/rust-tyty-subst.cc: Likewise.
* typecheck/rust-tyty.cc (BaseType::monomorphized_clone): Likewise.
(VariantDef::VariantDef): Remove copy constructor.
(VariantDef::operator=): Change to move operator.
(VariantDef::get_discriminant): Replace return type to a reference
instead of a reference to a unique pointer.
(VariantDef::clone): Change to references.
(VariantDef::monomorphized_clone): Likewise.
(FnType::as_string): Likewise.
(FnType::clone): Likewise.
* typecheck/rust-tyty.h: Likewise.
* util/rust-hir-map.cc (Mappings::insert_hir_impl_block): Likewise.
* backend/rust-compile-asm.cc: Use a reference instead of the raw
pointer value.
* checks/errors/borrowck/rust-bir-builder-pattern.cc: Use references.
* checks/errors/rust-hir-pattern-analysis.cc: Likewise.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
Fixes a couple of warnings thrown by clang, with mismatched class/struct
usages and unused members.
gcc/rust/ChangeLog:
* ast/rust-expr.h: Remove invalid usage of `struct`.
* backend/rust-compile-asm.h: Remove unused `translated` member.
* backend/rust-compile-asm.cc (CompileAsm::CompileAsm): Remove usage
of `translated` member.
* checks/errors/rust-unsafe-checker.h: Mark visitor as `override`.
* hir/tree/rust-hir-expr.h (struct AnonConst): Remove unused `locus`
member.
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-context.cc
(Context::setup_builtins): Use TypeCheckContext::get_builtins
instead of Resolver::get_builtin_types,
TypeCheckContext::lookup_type_by_node_id, and
TypeCheckContext::lookup_type.
* typecheck/rust-hir-type-check.h
(TypeCheckContext::get_builtins): Add.
* typecheck/rust-typecheck-context.cc
(TypeCheckContext::get_builtins): Add.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
Replace the "regular" AST->HIR lowering for IfLet* with a desugaring
into a MatchExpr.
Desugar a simple if let:
if let Some(y) = some_value {
bar();
}
into:
match some_value {
Some(y) => {bar();},
_ => ()
}
Same applies for IfLetExprConseqElse (if let with an else block).
Desugar:
if let Some(y) = some_value {
bar();
} else {
baz();
}
into:
match some_value {
Some(y) => {bar();},
_ => {baz();}
}
Fixes https://github.com/Rust-GCC/gccrs/issues/1177
gcc/rust/ChangeLog:
* backend/rust-compile-block.h: Adjust after removal of
HIR::IfLetExpr and HIR::IfLetExprConseqElse.
* backend/rust-compile-expr.h: Likewise.
* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc
(ExprStmtBuilder::visit): Likewise.
* checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Likewise.
* checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h:
Likewise.
* checks/errors/borrowck/rust-bir-builder-struct.h: Likewise.
* checks/errors/borrowck/rust-function-collector.h: Likewise.
* checks/errors/privacy/rust-privacy-reporter.cc
(PrivacyReporter::visit): Likewise.
* checks/errors/privacy/rust-privacy-reporter.h: Likewise.
* checks/errors/rust-const-checker.cc (ConstChecker::visit):
Likewise.
* checks/errors/rust-const-checker.h: Likewise.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit):
Likewise.
* checks/errors/rust-unsafe-checker.h: Likewise.
* hir/rust-ast-lower-block.h (ASTLoweringIfLetBlock::translate):
Change return type.
* hir/rust-ast-lower.cc (ASTLoweringIfLetBlock::desugar_iflet):
New.
(ASTLoweringIfLetBlock::visit(AST::IfLetExpr &)): Adjust and use
desugar_iflet.
* hir/rust-ast-lower.h: Add comment.
* hir/rust-hir-dump.cc (Dump::do_ifletexpr): Remove.
(Dump::visit(IfLetExpr&)): Remove.
(Dump::visit(IfLetExprConseqElse&)): Remove.
* hir/rust-hir-dump.h (Dump::do_ifletexpr): Remove.
(Dump::visit(IfLetExpr&)): Remove.
(Dump::visit(IfLetExprConseqElse&)): Remove.
* hir/tree/rust-hir-expr.h (class IfLetExpr): Remove.
(class IfLetExprConseqElse): Remove.
* hir/tree/rust-hir-full-decls.h (class IfLetExpr): Remove.
(class IfLetExprConseqElse): Remove.
* hir/tree/rust-hir-visitor.h: Adjust after removal of
HIR::IfLetExpr and HIR::IfLetExprConseqElse.
* hir/tree/rust-hir.cc (IfLetExpr::as_string): Remove.
(IfLetExprConseqElse::as_string): Remove.
(IfLetExpr::accept_vis): Remove.
(IfLetExprConseqElse::accept_vis): Remove.
* hir/tree/rust-hir.h: Adjust after removal of HIR::IfLetExpr and
HIR::IfLetExprConseqElse.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
Likewise.
* typecheck/rust-hir-type-check-expr.h: Likewise.
* checks/errors/rust-hir-pattern-analysis.cc
(PatternChecker::visit (IfLetExpr &)): Remove.
(PatternChecker::visit (IfLetExprConseqElse &)): Remove.
* checks/errors/rust-hir-pattern-analysis.h (visit(IfLetExpr &)): Remove.
(visit(IfLetExprConseqElse &)): Remove.
gcc/testsuite/ChangeLog:
* rust/compile/if_let_expr.rs: Adjust.
* rust/compile/if_let_expr_simple.rs: New test.
* rust/compile/iflet.rs: New test.
* rust/execute/torture/iflet.rs: New test.
* rust/compile/nr2/exclude: Add iflet.rs and if_let_expr_simple.rs
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-implitem.cc
(CompileTraitItem::visit): Use name resolver 2.0 (when enabled)
to obtain canonical paths for instances of TraitItemConst and
TraitItemFunc.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|