Age | Commit message (Collapse) | Author | Files | Lines |
|
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>
|
|
Fixes Rust-GCC#1486
gcc/testsuite/ChangeLog:
* rust/execute/torture/issue-1481.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.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>
|
|
Our non-torture execute tests haven't actually been running.
gcc/testsuite/ChangeLog:
* rust/execute/black_box.rs: Return 0 from main.
* rust/execute/match-identifierpattern-enum.rs: Move to...
* rust/execute/xfail/match-identifierpattern-enum.rs: ...here.
* rust/execute/execute.exp: New file.
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.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-clone.h: Add missing override qualifiers to DeriveVisitor methods.
* expand/rust-derive-copy.h: Likewise.
* expand/rust-derive-eq.h: Likewise.
* expand/rust-derive-hash.h: Likewise.
* expand/rust-derive-partial-eq.h: Likewise.
|
|
gcc/rust/ChangeLog:
* resolve/rust-rib.h: Add missing switch cases.
|
|
There was a complex recurisve type query hierarchy here but the type was
resolved so we can just do an early return here
gcc/rust/ChangeLog:
* typecheck/rust-type-util.cc (query_type): early return.
gcc/testsuite/ChangeLog:
* rust/execute/torture/basic_partial_ord1.rs: New test.
* rust/execute/torture/basic_partial_ord2.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Fixes Rust-GCC#3660
gcc/rust/ChangeLog:
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): reuse GCC's build_array_type
gcc/testsuite/ChangeLog:
* rust/compile/const_generics_3.rs:
* rust/compile/issue-3660.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-late-name-resolver-2.0.cc
(visit_identifier_as_pattern): Make sure to map identifiers
inside or-bindings to prior identifiers.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc: Rename to_bind to subpattern.
* ast/rust-ast-visitor.cc: Ditto.
* ast/rust-pattern.cc: Ditto.
* ast/rust-pattern.h: Ditto.
* backend/rust-compile-pattern.cc: Ditto.
* expand/rust-cfg-strip.cc: Ditto.
* hir/rust-ast-lower-pattern.cc: Ditto.
* hir/rust-hir-dump.cc: Ditto.
* hir/tree/rust-hir-pattern.h: Ditto.
* hir/tree/rust-hir.cc: Ditto.
* typecheck/rust-hir-type-check-pattern.cc: Ditto.
Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-pattern.cc: Add CheckExpr compilation for
IdentifierPattern with subpattern.
* backend/rust-compile-pattern.h: Modify IdentifierPattern's
visit func to support the above.
* typecheck/rust-hir-type-check-pattern.cc: Add typechecking
support for the changes above.
Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-default-resolver.cc
(DefaultResolver::visit_closure_params): New member function
definition.
(DefaultResolver::visit): New visiting function definition for
ClosureExpr called from visiting functions for ClosureExprInner
and ClosureExprInnerTyped.
* resolve/rust-default-resolver.h
(DefaultResolver::visit_closure_params): New member function
declaration.
(DefaultResolver::visit): New visiting function declaration for
ClosureExpr.
* resolve/rust-late-name-resolver-2.0.cc (add_captures): Remove
function.
(Late::visit): New visiting function definition for ClosureExpr,
remove visiting function definitions for ClosureExprInner and
ClosureExprInnerTyped.
(Late::visit_closure_params): New member function definition.
* resolve/rust-late-name-resolver-2.0.h (Late::visit): New
visiting function declaration for ClosureExpr, remove visiting
function declarations for ClosureExprInner and
ClosureExprInnerTyped.
(Late::visit_closure_params): New member function declaration.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-forever-stack.hxx (ForeverStack::resolve_path):
Handle single segment paths "crate", "self", and "super".
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove entries.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove entries.
* rust/compile/pub_restricted_1.rs: Adjust expected error
messages and only run with name resolution 2.0 enabled.
* rust/compile/pub_restricted_2.rs: Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Use
visit_identifier_as_pattern to handle IdentifierPattern and
StructPatternFieldIdent.
(visit_identifier_as_pattern): New function.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-expr.h (ClosureExpr::get_definition_expr): New
virtual member function.
(ClosureExprInner::get_definition_expr): Add override specifier.
(ClosureExprInnerTyped::get_definition_block): Rename to...
(ClosureExprInnerTyped::get_definition_expr): ...here and add
override specifier.
* ast/rust-ast-collector.cc (TokenCollector::visit): Handle
rename of ClosureExprInnerTyped::get_definition_block to
ClosureExprInnerTyped::get_definition_expr.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise.
* expand/rust-cfg-strip.cc (CfgStrip::visit): Likewise.
* expand/rust-expand-visitor.cc (ExpandVisitor::visit):
Likewise.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise.
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit):
Likewise.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit):
Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
This should improve our canonical path handling, without requiring
further tweaks to ForeverStack. This may also help if, in the future, we
have to move canonical path calculation to later compilation phases for
proper handling of generics.
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc
(HIRCompileBase::compile_function): Since canonical paths
returned from nr2.0 now include the crate name, avoid prepending
the crate name again.
* backend/rust-compile-implitem.cc (CompileTraitItem::visit):
Use NameResolutionContext::to_canonical_path instead of
ForeverStack::to_canonical_path.
* backend/rust-compile-item.cc (CompileItem::visit): 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.cc
(TraitItemReference::get_type_from_fn): Likewise.
* resolve/rust-default-resolver.cc (DefaultResolver::visit): Add
Crate and EnumItem instance visitors, handle canonical path
context scoping.
* resolve/rust-default-resolver.h (DefaultResolver::visit): Add
Crate and EnumItem instance visitors.
* resolve/rust-early-name-resolver-2.0.cc (Early::go): Visit
instances of Crate using the virtual member function visit.
* resolve/rust-forever-stack.h
(ForeverStack::to_canonical_path): Remove function declaration.
* resolve/rust-forever-stack.hxx
(ForeverStack::to_canonical_path): Remove function definition.
* resolve/rust-late-name-resolver-2.0.cc (Late::go): Visit
instances of Crate using the virtual member function visit.
* resolve/rust-name-resolution-context.cc
(CanonicalPathRecordCrateRoot::as_path): New function definition.
(CanonicalPathRecordNormal::as_path): Likewise.
(CanonicalPathRecordLookup::as_path): Likewise.
(CanonicalPathRecordImpl::as_path): Likewise.
(CanonicalPathRecordTraitImpl::as_path): Likewise.
(NameResolutionContext::NameResolutionContext): Initialize
member variable canonical_ctx.
* resolve/rust-name-resolution-context.h: Include "rust-item.h".
(class NameResolutionContext): Forward declare class.
(class CanonicalPathRecord): New class.
(class CanonicalPathRecordWithParent): Likewise.
(class CanonicalPathRecordCrateRoot): Likewise.
(class CanonicalPathRecordNormal): Likewise.
(class CanonicalPathRecordLookup): Likewise.
(class CanonicalPathRecordImpl): Likewise.
(class CanonicalPathRecordTraitImpl): Likewise.
(class CanonicalPathCtx): Likewise.
(NameResolutionContext::canonical_ctx): New member variable.
(NameResolutionContext::to_canonical_path): New member function.
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::go):
Visit instances of Crate with the virtual member function visit.
(TopLevel::visit): Handle canonical path context scoping for
external crates, use DefaultResolver::visit when visiting
instances of StructStruct.
* util/rust-canonical-path.h (CanonicalPath::new_seg): Take path
parameter by-value, as a duplicate instance will be constructed
regardless.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove canonical_paths1.rs.
|
|
gcc/rust/ChangeLog:
* hir/rust-ast-lower-pattern.cc: Lower of IdentifierPattern's to_bind to HIR.
* hir/rust-hir-dump.cc: Update IdentifierPattern's dump to properly show to_bind's full
full properties.
Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
|
|
Fixes an ICE when a raw byte string is not terminated
Fixes Rust-GCC#3731
gcc/rust/ChangeLog:
* lex/rust-lex.cc (Lexer::parse_raw_byte_string):
Fix infinite looping when a raw byte string is not terminated.
gcc/testsuite/ChangeLog:
* rust/compile/torture/unended-raw-byte-string.rs:
New test to ensure correct error message for unended raw byte string.
Signed-off-by: Vishruth Thimmaiah <vishruththimmaiah@gmail.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-default-resolver.cc (DefaultResolver::visit): Use
visit_impl_type to visit the self types of impl blocks.
* resolve/rust-default-resolver.h
(DefaultResolver::visit_impl_type): New member function
declaration.
* resolve/rust-late-name-resolver-2.0.cc (Late::Late):
Initialize member variable block_big_self.
(Late::visit_impl_type): New member function definition.
(Late::visit): Check for Self while inside impl block self
types.
* resolve/rust-late-name-resolver-2.0.h (Late::visit_impl_type):
New member function.
(Late::block_big_self): New member variable.
gcc/testsuite/ChangeLog:
* rust/compile/issue-3671.rs: Remove usage of Self.
* rust/compile/nr2/exclude: Remove issue-3671.rs.
* rust/compile/self-in-impl.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-forever-stack.h
(enum ResolutionMode): New.
(ForeverStack::get): Add a private overload that takes a
starting node as a parameter.
(ForeverStack::resolve_path): Replace boolean parameter
has_opening_scope_resolution with ResolutionMode parameter mode.
* resolve/rust-forever-stack.hxx
(ForeverStack::resolve_path): Likewise.
(ForeverStack::get): Add a private overload that takes a
starting node as a parameter.
* resolve/rust-late-name-resolver-2.0.cc
(Late::visit): Add Visibility visitor.
* resolve/rust-late-name-resolver-2.0.h
(Late::visit): Likewise.
* resolve/rust-name-resolution-context.h
(NameResolutionContext::resolve_path): Rework overloading a bit
and accept ResolutionMode parameter.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove entries.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|