Age | Commit message (Collapse) | Author | Files | Lines |
|
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>
|
|
gcc/rust/ChangeLog:
* typecheck/rust-autoderef.cc
(insert_implicit_type): Update single-parameter call to
pass explicit HirId.
* typecheck/rust-hir-type-check-expr.cc: Same.
* typecheck/rust-hir-type-check-pattern.cc: Same.
* typecheck/rust-hir-type-check.h: Removed call
to the duplicate interface.
* typecheck/rust-typecheck-context.cc
(TypeCheckContext::insert_implicit_type): Removed the
interface with no HirId field.
Signed-off-by: Guransh Singh <guransh766@gmail.com>
|
|
This was a bad diagnostic added when I was working on slices and iterators
also the name of the function is also bad. This is all about setting up
associated types based on the current context of the bounds assocated with
the associated trait bounds on this function.
The tell tale is that this didnt have an associated rust error code so
this is most definetly not the correct error diagnostic.
Fixes Rust-GCC#3403
gcc/rust/ChangeLog:
* typecheck/rust-tyty-subst.cc (SubstitutionRef::monomorphize): remove diagnostic
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: nr2 cant handle this
* rust/compile/issue-3403.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* rust-session-manager.cc (Session::compile_crate): Call the visitor.
|
|
gcc/rust/ChangeLog:
* ast/rust-desugar-for-loops.cc: New file.
* ast/rust-desugar-for-loops.h: New file.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Make lowering of for-loops an
unreachable.
* Make-lang.in: Compile it.
gcc/testsuite/ChangeLog:
* rust/compile/for-loop1.rs: New test.
* rust/compile/for-loop2.rs: New test.
* rust/execute/torture/for-loop1.rs: New test.
* rust/execute/torture/for-loop2.rs: New test.
* rust/compile/nr2/exclude: Exclude for-loop1.rs
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-builder.h: Mark all arguments as &&.
* ast/rust-ast-builder.cc (Builder::let): Likewise.
|
|
gcc/rust/ChangeLog:
* util/rust-unwrap-segment.cc: New file.
* util/rust-unwrap-segment.h: New file.
* Make-lang.in: Add rust-unwrap-segment.o to the object list.
* resolve/rust-forever-stack.hxx: Include rust-unwrap-segment.h.
(ForeverStack::find_starting_point): Use unwrap_type_segment.
(ForeverStack::resolve_segments): Likewise.
(ForeverStack::resolve_path): Likewise.
* resolve/rust-late-name-resolver-2.0.cc
(Late::visit): Resolve type paths using
NameResolutionContext::resolve_path.
* resolve/rust-name-resolution-context.h
(NameResolutionContext::resolve_path): Use
unwrap_segment_node_id.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove entries.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins-asm.cc (strip_double_quotes): Special case empty
strings ("\"\"").
(parse_reg_operand): Remove use of the `struct` keyword.
(parse_reg_operand_in): Likewise.
(parse_reg_operand_out): Likewise.
* expand/rust-macro-builtins.cc: Add llvm_asm! built-in macro as an alias to asm!.
|
|
We already lost some time on this unusual pattern, a comment will
hopefully prevent this from happening again.
gcc/rust/ChangeLog:
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Add
warning about current code.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
This was fixed as part of: c63ecb2f032
Fixes Rust-GCC#3402
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: nr2 cant handle this
* rust/compile/issue-3402-1.rs: New test.
* rust/compile/issue-3402-2.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* expand/rust-derive.cc (DeriveVisitor::derive): Call DeriveDefault.
* expand/rust-derive-default.cc: New file.
* expand/rust-derive-default.h: New file.
* Make-lang.in: Compile them.
gcc/testsuite/ChangeLog:
* rust/compile/derive-default1.rs: New test.
* rust/execute/torture/derive-default1.rs: New test.
* rust/compile/nr2/exclude: Exclude them.
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-builder.cc (Builder::qualified_path_in_expression): New.
(Builder::function): Change the return type.
* ast/rust-ast-builder.h: Declare qualified_path_in_expression functions.
* expand/rust-derive-debug.cc (DeriveDebug::stub_debug_fn): Adapt to new APIs.
|
|
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>
|
|
When passing generics around we try to adjust them because there are cases
where the names are adjusted from other generics this can fail for traits
because of the implicit Self and we just need to continue on without
adjustment.
Fxies Rust-GCC#3382
gcc/rust/ChangeLog:
* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit):
continue on for trait item mode.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: nr2 cant handle this.
* rust/compile/issue-3382.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
This guards against a crash but i think this should actually be treated
as if its a generic type like below. But for now this addresses a crash which can occur.
gcc/rust/ChangeLog:
* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::check_base_type_privacy):
Add guard for placeholder
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Addresses Rust-GCC#3382 and Rust-GCC#3381
gcc/rust/ChangeLog:
* typecheck/rust-type-util.cc (coercion_site): allow inference vars
gcc/testsuite/ChangeLog:
* rust/compile/reference1.rs: fix error message
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
It is valid for the query to fail here so its valid to not assert here.
gcc/rust/ChangeLog:
* typecheck/rust-hir-path-probe.cc (PathProbeType::visit): remove assertion
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
We needed to check for the optional has a value here or not it leads to an
ICE.
gcc/rust/ChangeLog:
* typecheck/rust-tyty.cc (ClosureType::setup_fn_once_output): add checks for lang items
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* resolve/rust-early-name-resolver-2.0.cc
(Early::resolve_glob_import): Use
NameResolutionContext::resolve_path instead of
ForeverStack::resolve_path.
(Early::visit): Likewise.
(Early::visit_attributes): Likewise.
* resolve/rust-early-name-resolver-2.0.h
(Early::resolve_path_in_all_ns): Likewise.
* resolve/rust-late-name-resolver-2.0.cc
(Late::visit): Likewise, insert segment resolutions not
handled by NameResolutionContext::resolve_path, and avoid throwing
an error when path resolution could be finished by the typechecker.
* resolve/rust-name-resolution-context.h
(NameResolutionContext::resolve_path): Add.
* typecheck/rust-hir-type-check-path.cc
(TypeCheckExpr::resolve_root_path): Use segment node ids instead
of the path node id to look up segment resolutions when using
the 2.0 resolver, as is done with the 1.0 resolver.
* typecheck/rust-hir-type-check-type.cc
(TypeCheckType::resolve_root_path): Likewise.
* resolve/rust-forever-stack.h
(ForeverStack::resolve_path): Add callback parameter for
inserting segment resolutions.
(ForeverStack::find_starting_point): Likewise.
(ForeverStack::resolve_segments): Likewise.
* resolve/rust-forever-stack.hxx
(ForeverStack::find_starting_point): Likewise.
(ForeverStack::resolve_segments): Likewise.
(ForeverStack::resolve_path): Likewise and avoid resolving
inside TraitOrImpl ribs.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove entries.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.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>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-builder.h: Declare it.
* ast/rust-ast-builder.cc (Builder::return_expr): Define it.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-debug.cc: New file.
* expand/rust-derive-debug.h: New file.
* Make-lang.in: Compile them.
* expand/rust-derive.cc (DeriveVisitor::derive): Call into DeriveDebug.
gcc/testsuite/ChangeLog:
* rust/compile/derive-debug1.rs: New test.
* rust/compile/nr2/exclude: Exclude it.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive-clone.cc: Cleanup using DeriveVisitor::setup_impl_generics.
* expand/rust-derive-copy.cc: Likewise.
|
|
gcc/rust/ChangeLog:
* expand/rust-derive.cc (DeriveVisitor::setup_impl_generics): New method.
* expand/rust-derive.h: Declare it, define DeriveVisitor::ImplGenerics struct.
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-builder.cc: New methods.
* ast/rust-ast-builder.h: Declare them.
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-builder.cc (Builder::type_path): New functions.
* ast/rust-ast-builder.h: Declare them.
|
|
gcc/rust/ChangeLog:
* checks/lints/rust-lint-scan-deadcode.h: Check if the field name starts with an
underscore before warning.
|
|
These lang items are used when deriving Eq and PartialEq, and will be checked when compiling pattern matching.
gcc/rust/ChangeLog:
* util/rust-lang-item.cc: New items.
* util/rust-lang-item.h: Likewise.
gcc/testsuite/ChangeLog:
* rust/compile/structural-eq-peq.rs: New test.
|
|
gcc/rust/ChangeLog:
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Special case lang item paths.
|
|
gcc/rust/ChangeLog:
* resolve/rust-forever-stack.hxx
(ForeverStack::dfs_rib): Fix const implementation.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins-utility.cc: Add macro expansion for
option_env with eager expansion
* expand/rust-macro-builtins.cc: Add option_env to builtin list
* expand/rust-macro-builtins.h: Add option_env handler to header
file
* resolve/rust-late-name-resolver-2.0.cc: Prevent NR2.0 from
recursing into lang-item segments
gcc/testsuite/ChangeLog:
* rust/compile/macros/builtin/option_env1.rs: Add success case for option_env
* rust/compile/macros/builtin/option_env2.rs: Add failure case for option_env
* rust/execute/torture/builtin_macro_option_env.rs: Add
execution case for option_env
|
|
Collapses all of the OperatorExprs into Expr instead of first having to check for OperatorExpr and
then check for each OperatorExpr::Kind.
gcc/rust/ChangeLog:
* ast/rust-ast.h: Add new Expr::Kinds.
* ast/rust-expr.h: Implement missing get_expr_kind(), Add get_function_expr_ptr()
|
|
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>
|
|
gcc/rust/ChangeLog:
* util/rust-lang-item.h: Declare it.
* util/rust-lang-item.cc: Use it.
|
|
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>
|
|
Those tests are now passing.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove some tests.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.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>
|
|
We need to query all namespaces and error out at a later stage if the
retrieved item is wrong.
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait):
Query all namespaces.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
Those function should not change anything within the foreverstack, it
can therefore be made const.
gcc/rust/ChangeLog:
* resolve/rust-forever-stack.h: Make debug functions const.
* resolve/rust-forever-stack.hxx: Likewise.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
We're reusing the value, it could therefore not be taken be should be
cloned.
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit):
Clone expr instead of taking it.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
Those test are now passing.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove passing tests.
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>
|
|
We missed the name namespace for unit struct in the old resolver.
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-toplevel.h: Add struct to name namespace.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
It might be necessary to compare both name resolution' internal states
during the transition. This new debug representation could help with
that.
gcc/rust/ChangeLog:
* resolve/rust-name-resolver.h: Add new degug dump for old name
resolver.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
Labels were using the wrong namespace.
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Change label
push function from type rib to label rib.
* resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit):
Likewise.
(ResolveItem::visit): Likewise.
(ResolveExternItem::visit): Likewise.
* resolve/rust-ast-resolve-stmt.h: Likewise.
* resolve/rust-ast-resolve.cc (NameResolution::go): 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:
* ast/rust-path.h: New function.
|
|
gcc/rust/ChangeLog:
* checks/lints/rust-lint-marklive.cc (MarkLive::visit): Adapt to lang items.
|