Age | Commit message (Collapse) | Author | Files | Lines |
|
gcc/rust/ChangeLog:
* resolve/rust-late-name-resolver-2.0.cc
(visit_identifier_as_pattern): Handle is_ref and is_mut.
(Late::visit): Likewise.
* resolve/rust-name-resolution-context.cc
(BindingLayer::insert_ident): Likewise.
(BindingLayer::bind_test): Handle changes to BindingLayer
fields.
(BindingLayer::merge): Likewise and emit more error messages.
* resolve/rust-name-resolution-context.h
(struct IdentifierMode): New.
(Binding::has_expected_bindings): New field.
(Binding::set): Rename field to...
(Binding::idents): ...here and convert from a set to a map.
(Binding::Binding): Initialize has_expected_bindings.
(BindingLayer::insert_ident): Adjust parameters.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove torture/alt_patterns1.rs.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-expr.h: Add getter to locus field.
* ast/rust-pattern.h (tokenid_to_rangekind): Likewise.
* hir/tree/rust-hir-item.h: Likewise.
* hir/tree/rust-hir-visibility.h: Likewise.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
This ensures Session::load_extern_crate doesn't try to use the old name
resolver when nr2.0 is enabled, while also ensuring that nr2.0 handles
external crates.
gcc/rust/ChangeLog:
* resolve/rust-default-resolver.cc
(DefaultResolver::visit_extern_crate): New function.
(DefaultResolver::visit): New visitor function for ExternCrate.
* resolve/rust-default-resolver.h
(DefaultResolver::visit_extern_crate): New function.
(DefaultResolver::visit): New visitor function for ExternCrate.
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):
Adjust ExternCrate visitor and rename to...
(TopLevel::visit_extern_crate): ...here.
* resolve/rust-toplevel-name-resolver-2.0.h (TopLevel::visit):
Remove ExternCrate visitor override.
(TopLevel::visit_extern_crate): New function.
* rust-session-manager.cc (Session::load_extern_crate): Only run
name resolution 1.0 if name resolution 2.0 is disabled.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
This patch implements the previously unimplemented type checking for RANGED item
type for TuplePattern, which serves as the start for implementing compilation of
RestPattern.
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit(TuplePattern)):
Implement type checking for ItemType::RANGED.
Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
|
|
gcc/rust/ChangeLog:
* rust-lang.cc: Move version check from C++11 to C++14.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* Make-lang.in: Scaffolding new rust-hir-visitor files
* hir/tree/rust-hir-visitor.h (DefaultHIRVisitor): Declare default HIR visitor
* hir/tree/rust-hir-visitor.cc (DefaultHIRVisitor): Define default HIR visitor
Signed-off-by: Ryutaro Okada <1015ryu88@gmail.com>
|
|
This should make it easier for us to hand identifiers off to the
back end.
gcc/rust/ChangeLog:
* Make-lang.in (GRS_OBJS): Add rust-ggc.o.
* backend/rust-compile-base.cc
(HIRCompileBase::compile_function): Adjust call to
Backend::function.
(HIRCompileBase::compile_constant_item): Likewise and adjust
initialization of Backend::typed_identifier.
* backend/rust-compile-expr.cc (CompileExpr::visit): Adjust call
to Backend::label.
* backend/rust-compile-type.cc (TyTyResolveCompile::visit):
Adjust initialization of Backend::typed_identifier.
* rust-backend.h: Add includes.
(Backend::GGC::Ident): Use Rust::GGC::Ident.
(struct typed_identifier): Store name as a GGC::Ident rather
than a std::string and adjust constructors.
(named_type): Take GGC::Ident/tl::optional<GGC::Ident> rather
than std::string.
(global_variable): Likewise.
(local_variable): Likewise.
(parameter_variable): Likewise.
(static_chain_variable): Likewise.
(label): Likewise.
(function): Likewise.
* rust-gcc.cc (named_type): Likewise.
(global_variable): Likewise.
(local_variable): Likewise.
(parameter_variable): Likewise.
(static_chain_variable): Likewise.
(label): Likewise.
(function): Likewise.
(function_defer_statement): Adjust call to Backend::label.
(get_identifier_from_string): Remove function.
(fill_in_fields): Handle adjustments to typed_identifier.
* util/rust-ggc.cc: New file.
* util/rust-ggc.h: New file.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* hir/tree/rust-hir-item.h (SelfParam::get_lifetime): Add getter
for non const lifetime object
Signed-off-by: Ryutaro Okada <1015ryu88@gmail.com>
|
|
gcc/rust/ChangeLog:
* hir/tree/rust-hir-expr.h (MatchArm::get_outer_attrs): Add getter for outer attributions
Signed-off-by: Ryutaro Okada <1015ryu88@gmail.com>
|
|
There was a sily bug where if you reorder this test case to declare A before B
this test would work but its meant to work in any order. So this fixes the bug
during code gen to fall back to our query compile system if this is needed.
Fixes Rust-GCC#3525
gcc/rust/ChangeLog:
* backend/rust-compile-resolve-path.cc: if this fails fall back to query compile
gcc/testsuite/ChangeLog:
* rust/compile/issue-3525.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Closure calls are not const so this is invalid. This patch fixes two bugs
1. Make the look at the parent context optional for generics
2. Ensure we look for non const calls during call expr code-gen
Fixes Rust-GCC#3551
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): add const call check
* backend/rust-compile-item.cc (CompileItem::visit): ensure we upfront compile types where
possible
* backend/rust-compile-item.h: update header
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): make parent ctx optional
gcc/testsuite/ChangeLog:
* rust/compile/issue-3551.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Code for TupleStructPattern compilation previously only assumes that it is derived from
an enum. This commit adds a check for that, and compiles non-enum TupleStructPatterns
similarly to TuplePatterns if it is not an enum.
gcc/rust/ChangeLog:
* backend/rust-compile-pattern.cc(CompilePatternCheckExpr::visit(TupleStructPattern)):
Fix error thrown when compiling non-enum TupleStructPattern.
Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-default-resolver.cc (DefaultResolver::visit):
Call DefaultASTVisitor::visit even on ConstantItem instances
without expressions.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove issue-3642.rs.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
Its valid to unify a closure to an fnptr as we are working on the
fn traits. There are still other issues but this is part of the patch set.
gcc/rust/ChangeLog:
* typecheck/rust-unify.cc (UnifyRules::expect_fnptr): add unify rules
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Ensure proper ordering when resolving trait references to prevent
incorrect type resolution in certain contexts.
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-reference.cc (TraitReference::on_resolved): ensure associated
types are done first
* typecheck/rust-hir-type-check-type.cc: Update call site.
gcc/testsuite/ChangeLog:
* rust/compile/silly-order-bug.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
When resolving type bounds, we need to examine super traits to properly
determine if type bindings are valid in the current context.
gcc/rust/ChangeLog:
* typecheck/rust-tyty-bounds.cc: Check super traits for type bindings.
* typecheck/rust-tyty.h: Add helper methods for bound checking.
|
|
Rename assemble_sized_builtin to assemble_marker_builtins and reorganize
the type matching to properly handle function pointers and closures with
their associated traits (Fn, FnMut, FnOnce).
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-bounds.h: Rename method.
* typecheck/rust-tyty-bounds.cc: Refactor marker trait assembly
and add proper Fn trait handling for function types.
|
|
Refactor the dot operator implementation to improve code organization
and maintainability while preserving existing functionality.
gcc/rust/ChangeLog:
* typecheck/rust-hir-dot-operator.cc: Major refactoring and cleanup.
* typecheck/rust-hir-dot-operator.h: Add new helper methods.
|
|
Prevent infinite loops when projecting associated types by properly
handling cyclical references with placeholder types.
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-resolve.cc: Add cyclical projection
protection.
|
|
When type checking expressions that involve references, we need to
examine the bounds of the referenced type to properly resolve traits
and methods.
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-expr.cc: Look at bounds behind
references.
* typecheck/rust-hir-type-check-expr.h: Add helper method.
|
|
This fixes some issues with name resolution 2.0.
gcc/rust/ChangeLog:
* rust-session-manager.cc (Session::compile_crate): Move
AST desugaring to...
(Session::expansion): ...here and add a final TopLevel pass
afterwards.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove entries.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
This is an invalid test case and doesnt work with rustc, we dont fully pick
up the errors. Nr2 does handle this and puts out an extra good diagnostic
but the old NR doesnt so for now i added this to the exclude list and then
when we remove old name resolver this issue goes away.
Fixes Rust-GCC#3642
gcc/rust/ChangeLog:
* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): check for has_expr
* hir/rust-hir-dump.cc (Dump::visit): likewise
* hir/tree/rust-hir-item.h: add has_expr helper
* resolve/rust-ast-resolve-item.cc (ResolveItem::visit): check for has_expr
* resolve/rust-ast-resolve-stmt.h: likewise
* typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): likewise
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: nr2 puts out an extra error
* rust/compile/issue-3642.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
The 2.0 name resolver is provided through
ImmutableNameResolutionContext after it is done being mutated. The
typechecker attempts to use ImmutableNameResolutionContext, so it needs
to be run after ImmutableNameResolutionContext has been initialized
(after all name resolution has been completed). Additionally, although I
haven't seen any issues with lowering AST to HIR before name resolution
2.0 is complete, it makes sense to perform all lowering in lockstep as
well.
gcc/rust/ChangeLog:
* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Add
visitor for ExternCrate.
* hir/rust-ast-lower-item.h (ASTLoweringItem::visit): Likewise.
* rust-session-manager.cc (Session::load_extern_crate): Avoid
lowering or type resolving external crates here.
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit):
Add visitor for ExternCrate.
* typecheck/rust-hir-type-check-item.h (TypeCheckItem::visit):
Replace empty definition with a declaration.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
There is still an issue with derive on PartialOrd but this adds good tests
and fixes a bug we had handling the default Rhs = Self generic type param
substitutions on the comparison traits.
gcc/rust/ChangeLog:
* typecheck/rust-tyty.cc (ParamType::handle_substitions): make this consistent
gcc/testsuite/ChangeLog:
* rust/compile/bug-with-default-generic.rs: New test.
* rust/execute/torture/partial-eq-1.rs: New test.
* rust/execute/torture/partial-eq-2.rs: New test.
* rust/execute/torture/partial-eq-3.rs: New test.
* rust/execute/torture/partial-eq-4.rs: New test.
* rust/execute/torture/partial-ord-1.rs: New test.
* rust/execute/torture/partial-ord-2.rs: New test.
* rust/execute/torture/partial-ord-3.rs: New test.
* rust/execute/torture/partial-ord-4.rs: New test.
* rust/execute/torture/partial-ord-5.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-late-name-resolver-2.0.cc (Late::visit(IdentifierPattern)):
Remove redundant subpattern check.
Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-pattern.cc: Add support for IdentifierPattern's
subpattern under CompilePatternBindings.
Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-pattern.cc: Implement name resolution for
IdentifierPattern's subpattern.
* resolve/rust-late-name-resolver-2.0.cc: Ditto, but for nr2.
Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc: Rename get_pattern_to_bind to get_subpattern
* ast/rust-ast-visitor.cc: Ditto.
* ast/rust-pattern.h: Ditto.
* expand/rust-cfg-strip.cc: Ditto.
* hir/rust-ast-lower-pattern.cc: Ditto.
Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-default-resolver.cc (DefaultResolver::visit):
Adjust scoping of trait definitions and their generic
parameters.
* resolve/rust-forever-stack.hxx (ForeverStack::get): Prevent
lookups inside TraitOrImpl ribs.
(ForeverStack::resolve_segments): Prevent lookups of the first
segment inside TraitOrImpl ribs.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove entries.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* hir/rust-hir-dump.cc: Change pattern dumps to use visit_field.
Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
|
|
gcc/rust/ChangeLog:
* expand/rust-derive.cc: Fix formatting after fork update.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-cmp-common.cc (EnumMatchBuilder::tuple): Create two different
variant paths.
(EnumMatchBuilder::strukt): Likewise.
* expand/rust-derive-cmp-common.h: Change API.
* expand/rust-derive-ord.cc (DeriveOrd::visit_enum): Use new EnumMatchBuilder API.
* expand/rust-derive-partial-eq.cc (DerivePartialEq::visit_enum): Likewise.
gcc/testsuite/ChangeLog:
* rust/compile/derive_partial_ord1.rs: New test.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-ord.cc (DeriveOrd::make_cmp_arms): Use new make_equal function.
(DeriveOrd::make_equal): New function.
(DeriveOrd::recursive_match): Handle the unit struct/tuple case.
* expand/rust-derive-ord.h: Declare make_equal.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-ord.cc (DeriveOrd::cmp_call): Use references.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-ord.cc (DeriveOrd::make_cmp_arms): Fix condition.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-ord.cc: Finish implementation for enums.
* expand/rust-derive-ord.h: Likewise.
|
|
And use the new EnumMatchBuilder class to do so.
gcc/rust/ChangeLog:
* expand/rust-derive-partial-eq.cc (DerivePartialEq::eq_fn): Change signature.
(DerivePartialEq::visit_tuple): Use new eq_fn API.
(DerivePartialEq::visit_struct): Likewise.
(DerivePartialEq::visit_enum): Implement proper discriminant comparison.
* expand/rust-derive-partial-eq.h: Change eq_fn signature.
gcc/testsuite/ChangeLog:
* rust/execute/torture/derive-partialeq2.rs: Add declaration for
discriminant_value.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-cmp-common.h (class EnumMatchBuilder): New helper class.
* expand/rust-derive-cmp-common.cc (EnumMatchBuilder::tuple): New function.
(EnumMatchBuilder::strukt): New function.
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-builder.h: Put `loc` member in public.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-ord.cc (DeriveOrd::cmp_call): New function.
(DeriveOrd::recursive_match): Use it.
(DeriveOrd::visit_enum): Likewise.
* expand/rust-derive-ord.h: Declare it.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-hash.cc (DeriveHash::visit_enum): Use new APIs.
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-builder.cc (Builder::discriminant_value): New function.
* ast/rust-ast-builder.h: Declare it.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-ord.cc (is_last): Remove.
(DeriveOrd::visit_tuple): Fix implementation.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-cmp-common.cc (SelfOther::indexes): Fix formatting.
(SelfOther::fields): Make iterator const.
* expand/rust-derive-cmp-common.h (struct SelfOther): New declaration for indexes.
* expand/rust-derive-partial-eq.cc (DerivePartialEq::visit_tuple): Use the new API.
(DerivePartialEq::visit_struct): Likewise.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-ord.cc (DeriveOrd::make_cmp_arms): New function.
(is_last): Likewise.
(recursive_match): Likewise.
(DeriveOrd::recursive_match): Likewise.
(DeriveOrd::visit_struct): Add proper implementation.
(DeriveOrd::visit_union): Likewise.
* expand/rust-derive-ord.h: Declare these new functions.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-partial-eq.cc (DerivePartialEq::tuple_indexes): Remove.
(DerivePartialEq::field_acccesses): Remove.
(DerivePartialEq::visit_tuple): Use new API.
(DerivePartialEq::visit_struct): Likewise.
* expand/rust-derive-partial-eq.h: Remove declarations.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-cmp-common.cc: New file.
* expand/rust-derive-cmp-common.h: New file.
* Make-lang.in: Compile them.
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-builder.cc (Builder::block): New function.
(Builder::match_case): Likewise.
* ast/rust-ast-builder.h: Declare them.
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-builder.cc (Builder::new_const_param): New function.
* ast/rust-ast-builder.h (vec): New function for creating 3 elts vector.
* expand/rust-derive.cc: Use the new_const_param builder.
* ast/rust-path.h: Add get_default_value() method.
|
|
gcc/rust/ChangeLog:
* Make-lang.in: Compile it.
* expand/rust-derive.cc (DeriveVisitor::derive): Call them.
* expand/rust-derive-ord.cc: New file.
* expand/rust-derive-ord.h: New file.
|