Age | Commit message (Collapse) | Author | Files | Lines |
|
gcc/testsuite/ChangeLog:
* rust/execute/torture/const_block1.rs: New test.
|
|
gcc/rust/ChangeLog:
* hir/tree/rust-hir-expr.h: New classes.
* hir/tree/rust-hir-full-decls.h: Likewise.
* hir/tree/rust-hir.cc: Handle AnonConst and ConstBlock.
* backend/rust-compile-block.cc: Likewise.
* backend/rust-compile-block.h: Likewise.
* backend/rust-compile-expr.cc (CompileExpr::visit): Likewise.
* 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-hir-pattern-analysis.cc (PatternChecker::visit): Likewise.
* checks/errors/rust-hir-pattern-analysis.h: Likewise.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise.
* checks/errors/rust-unsafe-checker.h: Likewise.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise.
(translate_operand_out): Likewise.
(translate_operand_inout): Likewise.
(translate_operand_const): Likewise.
* hir/rust-ast-lower-expr.h: Likewise.
* hir/rust-hir-dump.cc (Dump::visit): Likewise.
* hir/rust-hir-dump.h: Likewise.
* hir/tree/rust-hir-expr-abstract.h: Likewise.
* hir/tree/rust-hir-expr.cc (AnonConst::AnonConst): Likewise.
(AnonConst::operator=): Likewise.
(ConstBlock::ConstBlock): Likewise.
(ConstBlock::operator=): Likewise.
* hir/tree/rust-hir-visitor.h:
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
(typecheck_inline_asm_operand): Likewise.
* typecheck/rust-hir-type-check-expr.h: Likewise.
|
|
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_const_block_expr): New function.
* parse/rust-parse.h: Declare it.
|
|
gcc/rust/ChangeLog:
* ast/rust-expr.h: Declare AnonConst and ConstBlock and use them.
* ast/rust-ast-full-decls.h: Likewise.
* ast/rust-ast.cc: Add implementation for AnonConst and ConstBlock.
* ast/rust-ast.h: Likewise.
* ast/rust-ast-collector.cc (TokenCollector::visit): Likewise.
* ast/rust-ast-collector.h: Likewise.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise.
* ast/rust-ast-visitor.h: Likewise.
* expand/rust-derive.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* hir/rust-ast-lower-expr.cc (translate_operand_const): Likewise.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise.
* resolve/rust-ast-resolve-base.h: Likewise.
* resolve/rust-ast-resolve-expr.h: Likewise.
* resolve/rust-ast-resolve-expr.cc: Likewise.
|
|
The unify code was a bit dumb here where we always set emit_error to false for any
subtypes for example in comparing tuples we always emitted the whole tuple didnt
match the other tuple but really its much better to say expected bool got i32 because
the element types didn't match.
gcc/rust/ChangeLog:
* typecheck/rust-coercion.cc (TypeCoercionRules::coerce_unsized): dont emit error here
* typecheck/rust-unify.cc (UnifyRules::resolve_subtype): new helper to handle emit error
(UnifyRules::expect_adt): call resolve_subtype
(UnifyRules::expect_reference): likewise
(UnifyRules::expect_pointer): likewise
(UnifyRules::expect_array): likewise
(UnifyRules::expect_slice): likewise
(UnifyRules::expect_fndef): likewise
(UnifyRules::expect_fnptr): likewise
(UnifyRules::expect_tuple): likewise
(UnifyRules::expect_closure): likewise
(UnifyRules::expect_opaque): likeiwse
* typecheck/rust-unify.h: add new helper to header
gcc/testsuite/ChangeLog:
* rust/compile/traits9.rs: update errors
* rust/compile/unify-errors1.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-default-resolver.cc
(DefaultResolver::visit_if_let_patterns): New function
definition.
(DefaultResolver::visit): New IfLetExpr visitor definition.
* resolve/rust-default-resolver.h
(DefaultResolver::visit_if_let_patterns): New function
declaration.
(DefaultResolver::visit): New IfLetExpr visitor declaration.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Remove
IfLetExpr visitor definition.
(Late::visit_if_let_patterns): New function definition.
* resolve/rust-late-name-resolver-2.0.h (Late::visit): Remove
IfLetExpr visitor declaration.
(Late::visit_if_let_patterns): New function declaration.
* resolve/rust-name-resolution-context.h (BindingSource::IfLet):
New enumerator.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
This was upstreamed as part of ea34614225d4d255e58f63206eb12178b870cb4c
but never made it to our downstream repo. I've added Philip as a
co-author, since he wrote the upstream commit.
gcc/rust/ChangeLog:
* rust-lang.cc: Remove direct inclusion of "config.h" and
"system.h", move inclusion of "rust-system.h" upwards.
Co-authored-by: Philip Herron <herron.philip@googlemail.com>
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
This is the initial patch for RPIT, we can build on this to handle the
more complex cases but there are enough distinct changes going on here
that it should just get merged now.
RPIT is really a sneaky generic so for example:
fn foo() -> impl Bar {
Baz
}
This is represented as: fn () -> OpaqueType Bar. But when we handle the
coercion site for Baz on impl Bar when we type resolve the function we
know that the underlying type is Baz. Note this function is _not_ generic
so its using this special OpaqueType and keeping track of the underlying type
in its ty_ref reference hir-id which will resolve to Baz.
This also means if we have a case where maybe this was in an if statement:
fn foo(a: i32) -> impl Bar {
if a > 10 {
Baz
} else {
Qux
}
}
The rules of impl Bar is that Baz is handled but Baz and Qux are different
underlying types so this is not allowed. The reason is impl traits are not
generic and although from a programmer perspective the callers dont know what
the underlying type is, the compiler _knows_ what it is. So really when
you call a function and get its return position impl trait the compiler knows
what to do and does all whats nessecary to handle calling functions using that
type etc.
gcc/rust/ChangeLog:
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): we need to resolve the
underlying type
* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit): just clone
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit):
ensure we monomphize to get the underlying
* typecheck/rust-tyty.cc (BaseType::destructure): handle opaque types
(OpaqueType::resolve): this is much simpler now
(OpaqueType::handle_substitions): no longer needed
* typecheck/rust-tyty.h: update header
* typecheck/rust-unify.cc (UnifyRules::expect_opaque): unify rules for opaque
gcc/testsuite/ChangeLog:
* rust/compile/bad-rpit1.rs: New test.
* rust/execute/torture/impl_rpit1.rs: New test.
* rust/execute/torture/impl_rpit2.rs: New test.
* rust/execute/torture/impl_rpit3.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
When working on rpit we needed to change to use a monomorphized clone of
the result of function calls. This ended up causing a verify gimple issue
with tuples because:
fn test<A, B>(a: A, b: B) -> (A, B)
When passing for example:
let a = test::<i32, i32> (123, 456) -> (A=i32, B=i32)
The resulting gimple types became:
const struct (A=i32, B=i32) vs struct (i32, i32)
We removed the VIEW_CONVERT_EXPR support to auto fix this stuff a good
while ago because it hides these kinds of issues because the type hasher
included the A=i32, B=i32 vs the i32, i32 name so updating this to use
get_name instead keeps the naming the same as well as the fields meaning
these types are 100% equivilant and therefore no conversion is required.
This only occurs because tuples are not named types we should really add
more rust specific info on our gimple TYPES.
gcc/rust/ChangeLog:
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): use get_name
* typecheck/rust-tyty.cc (TupleType::get_name): likewise
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Cloning inference variables is very expensive because it means we are indirectly
creating an implicit new inference variable added to the reference chain.
gcc/rust/ChangeLog:
* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::check_base_type_privacy):
no need for unreachable here
* typecheck/rust-unify.cc (UnifyRules::commit): dont clone infer vars
(UnifyRules::expect_inference_variable): likewise
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
This is just a simple refactor to pull all the logic outside of the
closure which makes it more readable.
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check.h: new function
* typecheck/rust-typecheck-context.cc (TypeCheckContext::compute_inference_variables):
call the new helper
(TypeCheckContext::compute_infer_var): refactored code
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
This is similar to 9faba024ef18b9c4d67f22bd3b020b5e445fad0a, but it
applies to execute tests.
gcc/testsuite/ChangeLog:
* rust/execute/torture/for-loop1.rs: Adjust paths.
* rust/execute/torture/for-loop2.rs: Likewise.
* rust/execute/torture/iter1.rs: Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/testsuite/ChangeLog:
* rust/execute/torture/builtin_abort.rs: Fix path to
intrinsics::abort.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
Undefined attribute macros have no proc macro definition, which results
in a failing `rust_assert`. This changes that assert to an if statement,
that returns early if there is no proc macro definition. Fixes #3661.
gcc/rust/ChangeLog:
* resolve/rust-early-name-resolver-2.0.cc (Early::visit_attributes): rust_assert to if
gcc/testsuite/ChangeLog:
* rust/compile/issue-3661.rs: Test NR2 has expected behavior
Signed-off-by: Tom Schollenberger <tss2344@g.rit.edu>
|
|
This should be unnecessary, since even C++11 has implicit move.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_expr_stmt): Avoid
reference binding and remove std::move in return statements.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-visitor.cc
(DefaultASTVisitor::visit): Only visit the path of an instance
of Visibility if the instance has a path.
* ast/rust-ast.h
(SimplePath::SimplePath): Make sure constructors are explicit.
* resolve/rust-early-name-resolver-2.0.cc
(Early::visit_attributes): Pass entire paths to
NameResolutionContext::resolve_path.
(Early::visit): Likewise and avoid copying a path.
* resolve/rust-forever-stack.hxx
(ForeverStack::resolve_path): Assert that at least one path
segment has been passed in.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* Make-lang.in (GRS_OBJS): Remove rust-macro.o.
* ast/rust-macro.cc: Removed.
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
|
|
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h
(Parser::parse_attr_input): Handle more delimeter tokens and the
END_OF_FILE token.
(Parser::skip_after_end_attribute): Handle the END_OF_FILE
token.
gcc/testsuite/ChangeLog:
* rust/compile/macros/mbe/meta-param.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* hir/rust-ast-lower-item.cc
(ASTLoweringItem::visit): Keep going after a duplicate field is
found.
gcc/testsuite/ChangeLog:
* rust/execute/same_field_name.rs: Move to...
* rust/compile/same_field_name.rs: ...here and adjust expected
errors.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* checks/errors/borrowck/rust-bir-builder-internal.h: Include
"rust-immutable-name-resolution-context.h" and "options.h".
(AbstractBuilder::resolve_label): Use the 2.0 name resolver when
it's enabled.
(AbstractBuilder::resolve_variable): Likewise.
(AbstractBuilder::resolve_variable_or_fn): Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
This patch ensuers we reuse the Builder for new type to
ensure we create a new type from scratch ensuring consistent
new node-ids.
gcc/rust/ChangeLog:
* expand/rust-derive-default.cc (DeriveDefault::visit_struct): use builder
(DeriveDefault::visit_tuple): likewise
* expand/rust-derive-eq.cc (DeriveEq::visit_tuple): likewise
(DeriveEq::visit_struct): likewise
(DeriveEq::visit_enum): likewise
(DeriveEq::visit_union): likewise
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: these are fixed now
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Since r14-6076, the LANG_HOOKS_COMMON_ATTRIBUTE_TABLE should not be used and
LANG_HOOKS_ATTRIBUTE_TABLE replaces it.
Add the "cold" attribute to fix PR120018 (and the matching "hot" attribute).
Replace some gcc_assert() by explicit warnings (same as D frontend).
Add some clang-format off/on comment around code that's not correctly
formatted.
gcc/rust/ChangeLog:
PR rust/120018
* rust-attribs.cc (handle_noreturn_attribute): Reindent declaration.
(handle_leaf_attribute): Likewise.
(handle_const_attribute): Likewise.
(handle_malloc_attribute): Likewise.
(handle_pure_attribute): Likewise.
(handle_novops_attribute): Likewise.
(handle_nonnull_attribute): Likewise.
(handle_nothrow_attribute): Likewise.
(handle_type_generic_attribute): Likewise.
(handle_transaction_pure_attribute): Likewise.
(handle_returns_twice_attribute): Likewise.
(handle_fnspec_attribute): Likewise.
(handle_omp_declare_simd_attribute): Likewise.
(handle_cold_attribute): New.
(handle_hot_attribute): New.
(attribute_spec::exclusions attr_cold_hot_exclusions): New.
(grs_langhook_common_attributes): Make it static.
(grs_langhook_common_attribute_table): New.
(grs_langhook_gnu_attributes): New.
(grs_langhook_gnu_attribute_table): New.
(handle_malloc_attribute): Make it static.
(handle_fnspec_attribute): Likewise.
(handle_pure_attribute): Replace gcc_assert by explicit warning.
(handle_novops_attribute): Likewise.
(handle_nothrow_attribute): Likewise.
(handle_returns_twice_attribute): Likewise.
(handle_omp_declare_simd_attribute): Likewise and make it static.
* rust-lang.cc (grs_langhook_gnu_attribute_table): New.
(grs_langhook_common_attribute_table): Adjust type to new hook.
(LANG_HOOKS_COMMON_ATTRIBUTE_TABLE): Remove.
(LANG_HOOKS_ATTRIBUTE_TABLE): New.
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
|
|
gcc/rust/ChangeLog:
* ast/rust-path.cc
(TypePath::make_debug_string): Add definition.
* ast/rust-path.h
(TypePath::make_debug_string): Add declaration.
* resolve/rust-default-resolver.cc
(DefaultResolver::visit): Adjust InherentImpl and TraitImpl
visitors to better handle associated item scope.
* resolve/rust-default-resolver.h
(DefaultResolver::maybe_insert_big_self): Add.
* resolve/rust-late-name-resolver-2.0.cc
(Late::visit): Adjust type path resolution errors.
* resolve/rust-rib.h
(Rib::Kind): Add Generics kind.
* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::visit): Remove InherentImpl and TraitImpl visitor
overrides.
(TopLevel::maybe_insert_big_self): Add override in order to add
a definition of 'Self'.
* resolve/rust-toplevel-name-resolver-2.0.h
(TopLevel::visit): Remove InherentImpl and TraitImpl visitor
overrides.
(TopLevel::maybe_insert_big_self): Add override.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove entries.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc (TokenCollector::visit): Implement for InlineAsm.
* ast/rust-ast-full-decls.h (enum class): Move InlineAsmOption enum inside InlineAsm.
* ast/rust-expr.h (enum class): Likewise.
(class InlineAsm): Likewise.
* expand/rust-macro-builtins-asm.cc (check_and_set): Likewise.
(parse_options): Likewise.
* expand/rust-macro-builtins-asm.h (check_and_set): Likewise.
* hir/tree/rust-hir-expr.cc (InlineAsm::InlineAsm): Likewise.
* hir/tree/rust-hir-expr.h: Likewise.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
|
|
Empty loops have no body which means this is a NULL_TREE during const
evaluation which needs a check. Fixes Rust-GCC #3618.
gcc/rust/ChangeLog:
* backend/rust-constexpr.cc (eval_constant_expression): Check if t is a NULL_TREE
gcc/testsuite/ChangeLog:
* rust/compile/issue-3618.rs: Test empty loops error properly.
Signed-off-by: Tom Schollenberger <tss2344@g.rit.edu>
|
|
When using impl traits in argument position (APIT), they are desugared into generics,
and supplying explicit generic arguments is not allowed. This commit adds the error
diagnostic E0632 for attempting to pass generic arguments to impl traits, completing
the implementation of the APIT feature.
gcc/rust/ChangeLog:
* ast/rust-desugar-apit.cc: track if this is a impl-trait generic
* ast/rust-item.h (class TypeParam): add field to track if from impl trait
* hir/rust-ast-lower-type.cc (ASTLowerGenericParam::visit): likewise
* hir/tree/rust-hir-item.cc (TypeParam::TypeParam): upate hir as well
(TypeParam::operator=): likewise
* hir/tree/rust-hir-item.h (class TypeParam): likewise
* typecheck/rust-tyty-subst.cc (SubstitutionParamMapping::get_generic_param): add error
* typecheck/rust-tyty-subst.h: add const getter for the associated TypeParm
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: nr2 cant handle this
* rust/compile/impl_trait_generic_arg.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-visitor.cc
(DefaultASTVisitor::visit): Make call to EnumItem visitor from
EnumItem derived class visitors non-virtual.
* ast/rust-collect-lang-items.cc
(CollectLangItems::visit): Handle visitation of classes derived
from EnumItem.
* ast/rust-collect-lang-items.h
(CollectLangItems::visit): Likewise.
* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::visit): Call DefaultResolver::visit on EnumItem
instances.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-pattern.cc
(CompilePatternCheckExpr::visit): Fix GENERIC generation in
light of enum layout changes since this code was written.
(CompilePatternBindings::handle_struct_pattern_ident_pat):
Delegate handling of child patterns to another
CompilePatternBindings::Compile call.
(CompilePatternBindings::make_struct_access): Make field name
parameter const qualified.
* backend/rust-compile-pattern.h
(CompilePatternBindings::make_struct_access): Likewise.
gcc/testsuite/ChangeLog:
* rust/execute/torture/struct-pattern-match.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
This reverts commit 92323dd3bb16f21194891ce463fc865598c6980f.
|
|
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-item.cc
(ResolveItem::visit): Use the return values of
CanonicalPath::inherent_impl_seg and
CanonicalPath::trait_impl_projection_seg more directly.
* util/rust-canonical-path.h
(CanonicalPath::trait_impl_projection_seg): Append "<impl "
instead of "<" to the beginning of the returned path segment.
(CanonicalPath::inherent_impl_seg): Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
Argument position impl traits are simply syntatic sugar for generics. This
adds a new desugar pass to do this. So for example:
fn foo(a: impl Value, b: impl Value) -> i32
Is desugared into:
fn foo<T: Value, U: Value> (a: T, b: U) -> i32
So it just works like any normal generic function. There are more complex cases such as:
fn foo(_value: impl Bar<Baz = impl Foo>) -> i32
Which has a generic argument binding which needs to be turned into a where constraint:
fn foo<T, U>(_value: T) -> i32
where
T: Bar<Baz = U>,
U: Foo,
Fixes Rust-GCC#2015
Fixes Rust-GCC#1487
Fixes Rust-GCC#3454
Fixes Rust-GCC#1482
gcc/rust/ChangeLog:
* Make-lang.in: new desugar file
* ast/rust-ast.cc (ImplTraitTypeOneBound::as_string): its a unique_ptr now
(FormatArgs::set_outer_attrs): reformat
* ast/rust-path.h: remove has_generic_args assertion (can be empty because of desugar)
* ast/rust-type.h (class ImplTraitTypeOneBound): add copy ctor and use unique_ptr
* hir/rust-ast-lower-type.cc (ASTLoweringType::visit): update to use unique_ptr
* parse/rust-parse-impl.h (Parser::parse_type): reuse the existing unique_ptr instead
(Parser::parse_type_no_bounds): likewise
(Parser::parse_pattern): likewise
* resolve/rust-ast-resolve-type.cc (ResolveType::visit): its a unique_ptr now
* rust-session-manager.cc (Session::compile_crate): call desugar
* ast/rust-desugar-apit.cc: New file.
* ast/rust-desugar-apit.h: New file.
gcc/testsuite/ChangeLog:
* rust/compile/issue-2015.rs: fully supported now
* rust/compile/nr2/exclude: nr2 cant handle some of these
* rust/compile/issue-1487.rs: New test.
* rust/compile/issue-3454.rs: New test.
* rust/execute/torture/impl_desugar-2.rs: New test.
* rust/execute/torture/impl_desugar.rs: New test.
* rust/execute/torture/impl_trait1.rs: New test.
* rust/execute/torture/impl_trait2.rs: New test.
* rust/execute/torture/impl_trait3.rs: New test.
* rust/execute/torture/impl_trait4.rs: New test.
* rust/execute/torture/issue-1482.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Rust only allows impl traits to be used in the return position of
functions.
Fixes Rust-GCC#1485
gcc/rust/ChangeLog:
* hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::visit): allow impl type
* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): likewise
* hir/rust-ast-lower-type.cc (ASTLoweringType::ASTLoweringType): new flag for impl trait
(ASTLoweringType::translate): pass flag
(ASTLoweringType::visit): track impl trait tag
(ASTLoweringType::emit_impl_trait_error): new diagnostic
* hir/rust-ast-lower-type.h: add new field
gcc/testsuite/ChangeLog:
* rust/compile/impl_trait_diag.rs: New test.
* rust/compile/issue-1485.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/testsuite/ChangeLog:
* rust/execute/torture/derive-partialeq2.rs: Add missing terminating nul char.
Co-authored-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-partial-eq.cc (DerivePartialEq::match_enum_tuple): Remove debug call.
(DerivePartialEq::match_enum_struct): Add proper implementation.
(DerivePartialEq::visit_enum): Call it.
gcc/testsuite/ChangeLog:
* rust/execute/torture/derive-partialeq2.rs: New test.
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-builder.cc (Builder::struct_pattern_ident_pattern): New.
* ast/rust-ast-builder.h: New declaration.
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit): Remove old invalid
checks.
|
|
Allow matching on a struct instance and rebinding its fields to new names:
match X {
Foo {
field0: new_name0,
field1: new_name1,
} => {
do_something(new_name0, new_name1);
},
}
This will enable us to finish derives for PartialEq and PartialOrd but
isn't a complete implementation of these patterns yet.
gcc/rust/ChangeLog:
* backend/rust-compile-pattern.cc (CompilePatternBindings::make_struct_access):
New function.
(CompilePatternBindings::visit): Properly implement patterns mentioned above
and call make_struct_accesss.
* backend/rust-compile-pattern.h: New declaration.
gcc/testsuite/ChangeLog:
* rust/execute/torture/struct_pattern1.rs: New test.
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-pattern.h: Split struct pattern compilation into three functions.
* backend/rust-compile-pattern.cc: Implement them.
|
|
gcc/rust/ChangeLog:
* resolve/rust-late-name-resolver-2.0.cc (Late::Late): False initialize the
funny_error field.
|
|
Fixes PR#119641
gcc/rust/ChangeLog:
* checks/errors/borrowck/rust-bir-place.h
(IndexVec::size_type): Add.
(IndexVec::MAX_INDEX): Add.
(IndexVec::size): Change the return type to the type of the
internal value used by the index type.
(PlaceDB::lookup_or_add_variable): Use the return value from the
PlaceDB::add_place call.
* checks/errors/borrowck/rust-bir.h
(struct BasicBlockId): Move this definition before the
definition of the struct Function.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
Default visitor should visit all it's children.
gcc/rust/ChangeLog:
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Visit visibility.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-visitor.cc
(DefaultASTVisitor::visit): Visit the loop labels of
WhileLetLoopExpr instances before visiting their scrutinee
expressions.
* resolve/rust-early-name-resolver-2.0.cc
(Early::resolve_glob_import): Pass the glob import's path
directly to NameResolutionContext::resolve_path.
* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::visit): Remove unnecessary call to
Identifier::as_string.
(flatten_glob): Improve handling of cases where a glob use tree
has no path.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
Both nodes had the same id, this led to a resolution conflict.
gcc/rust/ChangeLog:
* expand/rust-derive-clone.cc (DeriveClone::clone_enum_struct): Clone
path to avoid using the same nodeid.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove now passing test from exclusion
list.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
This commit introduce a new public function to visit function parameters
in the default visitor. It allows visitors derived from DefaultVisitor
to override only a small part of the default visitor.
gcc/rust/ChangeLog:
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit_function_params):
Add specialized function to visit function parameters.
(DefaultASTVisitor::visit): Remove parameter visit and call specialized
function instead.
* ast/rust-ast-visitor.h: Add function prototye.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Remove
function.
(Late::visit_function_params): Override specialized visit function.
* resolve/rust-late-name-resolver-2.0.h: Add overriden function
prototype.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove passing test from exclusion list.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
Binding context may be stacked when a new binding group is introduced
within a const expression.
gcc/rust/ChangeLog:
* resolve/rust-name-resolution-context.h: Use BindingLayer instead.
* resolve/rust-name-resolution-context.cc (BindingLayer::BindingLayer):
Add new constructor for binding layer.
(BindingLayer::bind_test): Add a function to test a binding constraint.
(BindingLayer::push): Push a new binding group.
(BindingLayer::and_binded): Add function to test and-binding
constraint.
(BindingLayer::or_binded): Add function to test or-binding constraints.
(BindingLayer::insert_ident): Insert a new identifier in the current
binding group.
(BindingLayer::merge): Merge current binding group with it's parent.
(BindingLayer::get_source): Get the source of the current binding
group.
* resolve/rust-late-name-resolver-2.0.cc: Use stacked context for
binding group.
* util/rust-stacked-contexts.h: Add mutable peek function.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add binding
creation in visitor.
* resolve/rust-late-name-resolver-2.0.h: Add function prototypes.
* resolve/rust-name-resolution-context.h: Add binding context.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
We need to differentiate bindings types, so the same binding cannot be
reused multiple time in a product binding.
gcc/rust/ChangeLog:
* resolve/rust-name-resolution-context.h (struct Binding): Add Binding
struct to differentiate Or and Product bindings in patterns.
(enum class): Add Binding kind.
(class BindingContext): Add binding context with Binding stack.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast.h: Add hash function.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast.h: Add equality operator.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|