Age | Commit message (Collapse) | Author | Files | Lines |
|
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): Add proper handling
of the node.
* rust-backend.h (lookup_field): Declare it.
* rust-gcc.cc (lookup_field): Add forked implementation from gcc/c/.
gcc/testsuite/ChangeLog:
* rust/execute/torture/offset_of1.rs: New test.
|
|
gcc/testsuite/ChangeLog:
* rust/execute/torture/const-generics-1.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
This old can_eq interface was an old method to try and check if types can match up
by taking into account generics but its not maintained properly and we already have
a new wrapper Resolver::types_compatable (type, type, locus, emit_errors) which
just calls unify_site_and infer with commit false. There are only a few places left
to update.
One minor downside is that i need to remove const in some places because the unify
interface is non const. Ideally we would want to avoid writing a seperate const unify
anyway so i think this is not ideal but fine for us.
gcc/rust/ChangeLog:
* typecheck/rust-autoderef.cc: remove useless assertion
* typecheck/rust-coercion.cc (TypeCoercionRules::coerce_unsafe_ptr): refactor
(TypeCoercionRules::coerce_borrowed_pointer): remove FIXME this is fine
* typecheck/rust-hir-inherent-impl-overlap.h: use types_compatable
* typecheck/rust-hir-path-probe.cc (PathProbeType::PathProbeType): remove const
(PathProbeType::Probe): likewise
(PathProbeImplTrait::PathProbeImplTrait): likewise
(PathProbeImplTrait::Probe): likewise
* typecheck/rust-hir-path-probe.h: likewise
* typecheck/rust-hir-type-check-base.cc (walk_types_to_constrain): likewise
* typecheck/rust-hir-type-check-base.h: likewise
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): use types_compatable
* typecheck/rust-hir-type-check.h: remove const
* typecheck/rust-typecheck-context.cc (TypeCheckContext::insert_associated_impl_mapping):
likewise
(TypeCheckContext::lookup_associated_impl_mapping_for_self): remove can_Eq
* typecheck/rust-tyty-bounds.cc (TypeBoundPredicate::is_equal): likewise
* typecheck/rust-tyty-subst.cc (SubstitutionArg::get_tyty): remove const version
* typecheck/rust-tyty-subst.h: likewise
* typecheck/rust-tyty.cc (BaseType::get_root): likewise
* typecheck/rust-tyty.h: likewise
gcc/testsuite/ChangeLog:
* rust/compile/generics8.rs: extra error message
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
The substitution code was not taking into account the const generic
arguments for checking the max bounds of total available parameters.
Fixes Rust-GCC#3546
gcc/rust/ChangeLog:
* typecheck/rust-tyty-subst.cc: fix check for total arguments
gcc/testsuite/ChangeLog:
* rust/compile/issue-3546.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
We already support const infer so this just creates a fresh tyty::infer_var
for the const element type and then a ConstKind::Infer type for the const
type wrapper and the existing plumbing handles this.
Fixes Rust-GCC#3885
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): create infer variable
gcc/testsuite/ChangeLog:
* rust/compile/issue-3885.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
In order to support const generics we map the declarations to a ConstType this
means we reuse all our existing type coercion, unification code and generic
substitutions code to support this with minimal impact.
This patch adds support for:
1. Default const generics
2. Infer const generics
3. ADTType suport
4. unconstrained checks
5. ensure types of the const generic and default
6. validation if passing a const argument to a type argument
Lots of test cases now work and new ones added. More work is needed to support this
on functions and method resolution of impls like Foo<1> vs Foo<2> once thats in we
can look to support some of the const generic array impls next.
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc: useful debug
* backend/rust-compile-stmt.cc (CompileStmt::visit): likewise
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): fold the capacity into ConstType
* hir/tree/rust-hir-generic-param.h: make const
* hir/tree/rust-hir-path.h: take into account const arguments now
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal): needs const
* typecheck/rust-hir-type-check-base.h: add error handling for const supported locations
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): const type the arrays
* typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): update
(TypeCheckImplItem::visit): likewise
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): likewise
(TypeCheckItem::resolve_impl_block_substitutions): likewise
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): wrap up const type
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): likewise
(TypeResolveGenericParam::visit): likewise
(TypeResolveGenericParam::apply_trait_bounds): remove HIR::Generic from Param
* typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): cleanup
* typecheck/rust-tyty-subst.cc (SubstitutionParamMapping::SubstitutionParamMapping):
handle const generics
(SubstitutionParamMapping::get_type_representation): likewise
(SubstitutionParamMapping::param_has_default_ty): likewise
(SubstitutionParamMapping::get_default_ty): likewise
(SubstitutionRef::infer_substitions): likewise
* typecheck/rust-tyty-subst.h: likewise
* typecheck/rust-tyty-util.cc (TyVar::get_implicit_const_infer_var): new helper
* typecheck/rust-tyty-util.h (class ConstType): likewise
* typecheck/rust-tyty.cc (BaseType::is_concrete): check for array const concrete
(ArrayType::as_string): update to const
(ArrayType::handle_substitions): likewise
(ParamType::ParamType): likewise
(ParamType::get_generic_param): likewise
(ParamType::clone): likewise
(ConstType::ConstType): likewise
(ConstType::set_value): likewise
(ConstType::clone): likewise
(ConstType::get_generic_param): likewise
(generate_tree_str): new helper to pretty print gimple
(ConstType::get_name): uses the generate_tree_str
(ConstType::handle_substitions): handle const infer's
* typecheck/rust-tyty.h (RUST_TYTY): likewise
* typecheck/rust-unify.cc (UnifyRules::expect_array): likewise
(UnifyRules::expect_const): likewise
gcc/testsuite/ChangeLog:
* rust/compile/const_generics_3.rs: this works now
* rust/compile/const_generics_5.rs: likewise
* rust/compile/const_generics_8.rs: move the failure to another test case
* rust/compile/const_generics_10.rs: New test.
* rust/compile/const_generics_11.rs: New test.
* rust/compile/const_generics_12.rs: New test.
* rust/compile/const_generics_13.rs: New test.
* rust/compile/const_generics_14.rs: New test.
* rust/compile/const_generics_15.rs: New test.
* rust/compile/const_generics_16.rs: New test.
* rust/compile/const_generics_9.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
We assert that struct expressions during code-gen must be of TyTy::ADTType
but we can simply just check for this and return error_mark_node to make
this safe.
Fixes Rust-GCC#3960
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): check for ADTType instead of assert
gcc/testsuite/ChangeLog:
* rust/compile/issue-3960.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/testsuite/ChangeLog:
* rust/compile/auto_traits2.rs:
emove warning for unused `self` parameter
* rust/compile/derive-debug1.rs:
emove warning for unused `self` parameter
* rust/compile/derive_macro1.rs:
Remove warning for unused `self` parameter
* rust/compile/format_args_basic_expansion.rs:
Remove warning for unused `self` parameter
* rust/compile/format_args_extra_comma.rs:
Remove warning for unused `self` parameter
* rust/compile/issue-2043.rs:
Remove warning for unused `self` parameter
* rust/compile/issue-2166.rs:
Remove warning for unused `self` parameter
* rust/compile/issue-2238.rs:
Remove warning for unused `self` parameter
* rust/compile/issue-2907.rs:
Remove warning for unused `self` parameter
* rust/compile/min_specialization1.rs:
Remove warning for unused `self` parameter
* rust/compile/name_resolution2.rs:
Remove warning for unused `self` parameter
* rust/compile/name_resolution4.rs:
Remove warning for unused `self` parameter
* rust/compile/torture/generics29.rs:
Remove warning for unused `self` parameter
* rust/compile/torture/generics30.rs:
Remove warning for unused `self` parameter
* rust/compile/torture/traits3.rs:
Remove warning for unused `self` parameter
* rust/compile/torture/traits7.rs:
Remove warning for unused `self` parameter
* rust/execute/torture/impl_trait3.rs:
Remove warning for unused `self` parameter
* rust/execute/torture/min_specialization2.rs:
Remove warning for unused `self` parameter
* rust/execute/torture/trait10.rs:
Remove warning for unused `self` parameter
* rust/execute/torture/trait11.rs:
Remove warning for unused `self` parameter
* rust/execute/torture/trait12.rs:
Remove warning for unused `self` parameter
* rust/execute/torture/trait13.rs:
Remove warning for unused `self` parameter
* rust/execute/torture/trait9.rs:
Remove warning for unused `self` parameter
Signed-off-by: Ryutaro Okada <1015ryu88@gmail.com>
|
|
gcc/rust/ChangeLog:
* Make-lang.in:
* ast/rust-expression-yeast.cc (ExpressionYeast::dispatch_loops): Call DesugarWhileLet.
* ast/rust-desugar-while-let.cc: New file.
* ast/rust-desugar-while-let.h: New file.
gcc/testsuite/ChangeLog:
* rust/compile/while_let1.rs: New test.
|
|
gcc/rust/ChangeLog:
* hir/tree/rust-hir-expr.h (class OffsetOf): New.
* hir/tree/rust-hir-expr.cc: Define its methods.
* hir/tree/rust-hir-expr-abstract.h: Add ExprType::OffsetOf.
* hir/tree/rust-hir-full-decls.h (class OffsetOf): Declare it.
* backend/rust-compile-block.h: Add handling for OffsetOf.
* 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 (RUST_BIR_BUILDER_EXPR_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 (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.
* hir/rust-hir-dump.cc (Dump::visit): Likewise.
* hir/rust-hir-dump.h: Likewise.
* hir/tree/rust-hir-visitor.cc (DefaultHIRVisitor::walk): Likewise.
* hir/tree/rust-hir-visitor.h: Likewise.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
* typecheck/rust-hir-type-check-expr.h (RUST_HIR_TYPE_CHECK_EXPR): Likewise.
gcc/testsuite/ChangeLog:
* rust/compile/offset_of2.rs: New test.
|
|
gcc/rust/ChangeLog:
* Make-lang.in: Compile the offset_of handler.
* lang.opt: Add -frust-assume-builtin-offset-of option.
* ast/rust-ast.h: Add has_str() for const_TokenPtr.
* expand/rust-macro-builtins.cc: Map offset_of as builtin.
* expand/rust-macro-builtins.h: Declare it.
* expand/rust-macro-expand.cc (MacroExpander::expand_invoc): Add hack for calling builtin
offset_of!().
* resolve/rust-early-name-resolver-2.0.cc (Early::visit): Likewise.
* expand/rust-macro-builtins-offset-of.cc: New file.
gcc/testsuite/ChangeLog:
* rust/compile/offset_of1.rs: New test.
|
|
A missing comma between inline assembly templates did not throw an error
and looped indefinitely.
gcc/rust/ChangeLog:
* expand/rust-macro-builtins-asm.cc (parse_format_strings): Emit an
error when expecting a comma.
gcc/testsuite/ChangeLog:
* rust/compile/issue-4006.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/testsuite/ChangeLog:
* rust/execute/inline_asm_inout_ident.rs: New test.
* rust/execute/inline_asm_inout_var.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
006t.original output from compiling testsuite/rust/compile/match-slicepattern-slice.rs:
...
RUSTTMP.3 = slice;
if (RUSTTMP.3.len == 1 && *(RUSTTMP.3.data + 0 * 4) == 1)
{
{
struct () RUSTTMP.4;
{
}
goto <D.129>;
}
}
if (RUSTTMP.3.len == 2 && *(RUSTTMP.3.data + 1 * 4) == 2)
{
{
struct () RUSTTMP.5;
{
}
goto <D.129>;
}
}
if (1)
{
{
struct () RUSTTMP.6;
{
}
goto <D.129>;
}
}
<D.129>:;
...
gcc/rust/ChangeLog:
* rust-backend.h: New slice_index_expression function.
* rust-gcc.cc: Implementation of slice_index_expression to generate tree node for
accessing slice elements.
* backend/rust-compile-pattern.cc: Implement SlicePattern check expression & binding
compilation against SliceType scrutinee.
Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
|
|
gcc/rust/ChangeLog:
* Make-lang.in: Compile it.
* ast/rust-expression-yeast.cc (ExpressionYeast::dispatch): Dispatch to try-block
desugar.
* ast/rust-desugar-try-block.cc: New file.
* ast/rust-desugar-try-block.h: New file.
gcc/testsuite/ChangeLog:
* rust/compile/try_block1.rs: New test.
|
|
gcc/rust/ChangeLog:
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Handle defered consts.
* hir/tree/rust-hir-expr.cc (AnonConst::AnonConst): Likewise.
(AnonConst::operator=): Likewise.
* hir/tree/rust-hir-expr.h: Likewise.
* hir/tree/rust-hir-visitor.cc (DefaultHIRVisitor::walk): Likewise.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
gcc/testsuite/ChangeLog:
* rust/compile/deferred_const_inference.rs: New test.
|
|
gcc/rust/ChangeLog:
* resolve/rust-early-name-resolver-2.0.cc (Early::resolve_glob_import): Adapt for enums.
(Early::finalize_glob_import): Likewise.
* resolve/rust-early-name-resolver-2.0.h: Likewise.
* resolve/rust-finalize-imports-2.0.cc (GlobbingVisitor::go): Likewise.
(GlobbingVisitor::visit_module_container): New function.
(GlobbingVisitor::visit_enum_container): New function.
* resolve/rust-finalize-imports-2.0.h: Declare them.
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Insert enums as potential
containers.
gcc/testsuite/ChangeLog:
* rust/compile/glob_import_enum.rs: New test.
|
|
When we have generic paths like T::foobar during codegen sometimes we need
to enforce an extra lookup for this generic parameter type to the mono
morphized underlying type.
Fixes Rust-GCC#3915
Fixes Rust-GCC#1247
gcc/rust/ChangeLog:
* backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): do another lookup
gcc/testsuite/ChangeLog:
* rust/compile/issue-3915.rs: New test.
* rust/execute/torture/sip-hasher.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
In the test case:
fn test (len: usize) -> u64 {
let mut i = 0;
let mut out = 0;
if i + 3 < len {
out = 123;
}
out
}
The issue is to determine the correct type of 'i', out is simple because it hits a
coercion site in the resturn position for u64. But 'i + 3', 'i' is an integer infer
variable and the same for the literal '3'. So when it comes to resolving the type for
the Add expression we hit the resolve the operator overload code and because of this:
macro_rules! add_impl {
($($t:ty)*) => ($(
impl Add for $t {
type Output = $t;
#[inline]
#[rustc_inherit_overflow_checks]
fn add(self, other: $t) -> $t { self + other }
}
)*)
}
add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
This means the resolution for 'i + 3' is ambigious because it could be any of these Add
implementations. But because we unify against the '< len' where len is defined as usize
later in the resolution we determine 'i' is actually a usize. Which means if we defer the
resolution of this operator overload in the ambigious case we can simply resolve it at the
end.
Fixes Rust-GCC#3916
gcc/rust/ChangeLog:
* hir/tree/rust-hir-expr.cc (OperatorExprMeta::OperatorExprMeta): track the rhs
* hir/tree/rust-hir-expr.h: likewise
* hir/tree/rust-hir-path.h: get rid of old comments
* typecheck/rust-hir-trait-reference.cc (TraitReference::get_trait_substs): return
references instead of copy
* typecheck/rust-hir-trait-reference.h: update header
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::ResolveOpOverload): write ambigious
operator overloads to a table and try to resolve it at the end
* typecheck/rust-hir-type-check-expr.h: new static helper
* typecheck/rust-hir-type-check.h (struct DeferredOpOverload): new model to defer resolution
* typecheck/rust-typecheck-context.cc (TypeCheckContext::lookup_operator_overload): new
(TypeCheckContext::compute_ambigious_op_overload): likewise
(TypeCheckContext::compute_inference_variables): likewise
gcc/testsuite/ChangeLog:
* rust/compile/issue-3916.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Rust seems to allow duplicate HIR::Item 'main' functions but it needs
to be a root item to be the true main entry point. This means we can
use the canonical path to determine if this is a root one where
its CrateName::main or CrateName::Module::main.
Fixes Rust-GCC#3978
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc: check the canonical path
gcc/testsuite/ChangeLog:
* rust/compile/issue-3978.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_simple_path): Be more
careful about skipping SCOPE_RESOLUTION tokens.
(Parser::parse_simple_path_segment): Allow parsing from a
starting offset.
(Parser::parse_use_tree): Handle a non-skipped SCOPE_RESOLUTION
token.
* parse/rust-parse.h (Parser::parse_simple_path_segment): Add
parameter for parsing from a starting offset.
gcc/testsuite/ChangeLog:
* rust/compile/parse_simple_path_fail_1.rs: New test.
* rust/compile/parse_simple_path_fail_2.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
Fixes Rust-GCC#3524
gcc/testsuite/ChangeLog:
* rust/compile/issue-3524.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): Add a catch for const/static.
gcc/testsuite/ChangeLog:
* rust/compile/loop_constant_context.rs: New test.
* rust/compile/issue-3618.rs:
Signed-off-by: lishin <lishin1008@gmail.com>
|
|
scrutinee
Example GIMPLE output from compiling testsuite/rust/compile/match-pattern-array.rs:
...
a[0] = 0;
a[1] = 1;
RUSTTMP.3 = a;
_1 = RUSTTMP.3[0];
_2 = _1 == 0;
_3 = RUSTTMP.3[1];
_4 = _3 == 1;
_5 = _2 & _4;
if (_5 != 0) goto <D.122>; else goto <D.123>;
<D.122>:
{
{
}
}
goto <D.117>;
}
<D.123>:
...
gcc/rust/ChangeLog:
* rust-backend.h: New size_constant_expression function.
* rust-gcc.cc: Implementation of size_constant_expression function to generate tree node
for array access.
* backend/rust-compile-pattern.h: Remove empty visits for SlicePattern.
* backend/rust-compile-pattern.cc: Implement SlicePattern check expression & binding
compilation against ArrayType scrutinee.
Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
|
|
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-pattern.cc(TypeCheckPattern::visit(SlicePattern)):
Implement size checking for SlicePattern when type checking against array parent
Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
|
|
We have more complex test cases already but this will close out this issue.
Fixes Rust-GCC#2005
gcc/testsuite/ChangeLog:
* rust/execute/torture/issue-2005.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Fixes Rust-GCC#1048
gcc/testsuite/ChangeLog:
* rust/compile/issue-1048.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Fixes Rust-GCC#3144
gcc/testsuite/ChangeLog:
* rust/compile/issue-3144.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
Fixes Rust-GCC#3599
gcc/testsuite/ChangeLog:
* rust/compile/issue-3599.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
We just had a typo returning ok true when it should have been false.
Fixes Rust-GCC#3876
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::visit): fix typo
gcc/testsuite/ChangeLog:
* rust/compile/issue-3876.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
This case:
let i = 1;
let j = i as i64;
'i' is meant to default to i32 but the inference was making both of these
i64 because the code was prefering coercion logic which can end up with a
default unify which causes the ?integer to unify with i64 making them both
i64.
But all we need to do is allow the simple cast rules to run first then
fallback to coercions but special consideration has to be made to ensure
that if there are dyn objects needed then this needs a unsize coercion, but
also we need to ensure the underlying types are a valid simple cast too
otherwise these also need to fallback to the coercion code.
Fixes Rust-GCC#2680
gcc/rust/ChangeLog:
* typecheck/rust-casts.cc (TypeCastRules::resolve): optional emit_error flag
(TypeCastRules::check): try the simple cast rules then fallback to coercions
(TypeCastRules::check_ptr_ptr_cast): ensure the underlying's
(TypeCastRules::emit_cast_error): make this a static helper
* typecheck/rust-casts.h: new emit_error prototype
gcc/testsuite/ChangeLog:
* rust/compile/issue-2680.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
This was a nasty issue to debug, the issue was very eager type bounds
checking. So for example:
pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs>
The super trait of PartialEq<Rhs> is a generic substitution and we reuse
our bounds code here for normal generic bounds and generics an invalid
bounds check was occuring when PartialEq<Rhs> was getting substituted becase
this is a trait doing proper bounds checking is not valid here because this
is telling us about the bounds in this case.
Fixes Rust-GCC#3836
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait): track is super trait
* typecheck/rust-hir-type-bounds.h: refactor bounds scan
* typecheck/rust-hir-type-check-base.h: track from super trait
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): likewise
* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::is_bound_satisfied_for_type): refactor
(TypeBoundsProbe::scan): likewise
(TypeBoundPredicate::apply_generic_arguments): likewise
* typecheck/rust-tyty-subst.cc: optional bounds checking on parm subst
* typecheck/rust-tyty-subst.h: likewise
* typecheck/rust-tyty.h: likewise
gcc/testsuite/ChangeLog:
* rust/compile/derive_partial_ord1.rs: this is now fully supported
* rust/execute/torture/basic_partial_ord1.rs: add missing i32 impl
* rust/execute/torture/basic_partial_ord2.rs: likewise
* rust/compile/issue-3836.rs: New test.
* rust/execute/torture/issue-3836.rs: New test.
* rust/execute/torture/partial-ord-6.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
This is an invalid test case but we just need a guard for the missing
borrow expression.
Fixes Rust-GCC#3874
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc (TokenCollector::visit): check for missing borrow
* ast/rust-expr.h: add helper
gcc/testsuite/ChangeLog:
* rust/compile/issue-3874.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
This patch adds proper folding to the const expression for array capacity we
already have the const folding mechanics and the query system needed to handle cases
where the capacity is a function call in a const context. This leverages and pulls the
gcc tree capacity into the TyTy::ArrayType so it can be used for more typechecking and
eventually doing more const generics work.
Addresses Rust-GCC#3885
Fixes Rust-GCC#3882
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc (HIRCompileBase::query_compile_const_expr): new wrapper
* backend/rust-compile-base.h: add prototype
* backend/rust-compile-context.cc (Context::get): singleton helper
* backend/rust-compile-context.h: likewise
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): handle infer's that can default
* rust-session-manager.cc (Session::compile_crate): create the gcc context earlier for tychk
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal): const fold it
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): likewise
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): likewise
* typecheck/rust-tyty.cc (BaseType::monomorphized_clone): fix constructor call
(ArrayType::as_string): print capacity
(ArrayType::clone): fix constructor call
* typecheck/rust-tyty.h: track capacity
* typecheck/rust-unify.cc (UnifyRules::expect_array): check the capacities
gcc/testsuite/ChangeLog:
* rust/compile/all-cast.rs: shows array capacity now
* rust/compile/arrays2.rs: likewise
* rust/compile/const3.rs: fix error message
* rust/compile/const_generics_3.rs: disable until typecheck we get proper errors now!
* rust/compile/usize1.rs: proper capacity error message
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Check that the WhileLet has a label
before visiting it.
gcc/testsuite/ChangeLog:
* rust/compile/while_let_without_label.rs: New test.
|
|
gcc/testsuite/ChangeLog:
* rust/compile/additional-trait-bounds2nr2.rs: Remove
-frust-name-resolution-2.0 usage.
* rust/compile/const_generics_3.rs: Likewise.
* rust/compile/enum_variant_name.rs: Likewise.
* rust/compile/generics9.rs: Likewise.
* rust/compile/invalid_label_name.rs: Likewise.
* rust/compile/issue-3304.rs: Likewise.
* rust/compile/macros/mbe/macro-issue3708.rs: Likewise.
* rust/compile/macros/mbe/macro-issue3709-2.rs: Likewise.
* rust/compile/name_resolution10.rs: Likewise.
* rust/compile/name_resolution11.rs: Likewise.
* rust/compile/name_resolution12.rs: Likewise.
* rust/compile/name_resolution13.rs: Likewise.
* rust/compile/name_resolution14.rs: Likewise.
* rust/compile/name_resolution15.rs: Likewise.
* rust/compile/name_resolution16.rs: Likewise.
* rust/compile/name_resolution17.rs: Likewise.
* rust/compile/name_resolution18.rs: Likewise.
* rust/compile/name_resolution20.rs: Likewise.
* rust/compile/name_resolution22.rs: Likewise.
* rust/compile/name_resolution23.rs: Likewise.
* rust/compile/name_resolution24.rs: Likewise.
* rust/compile/name_resolution25.rs: Likewise.
* rust/compile/name_resolution6.rs: Likewise.
* rust/compile/name_resolution7.rs: Likewise.
* rust/compile/name_resolution8.rs: Likewise.
* rust/compile/name_resolution9.rs: Likewise.
* rust/compile/nested_macro_definition.rs: Likewise.
* rust/compile/pub_restricted_1.rs: Likewise.
* rust/compile/pub_restricted_2.rs: Likewise.
* rust/compile/self-in-impl.rs: Likewise.
* rust/compile/self_import_namespace.rs: Likewise.
* rust/compile/use_1.rs: Likewise.
* rust/compile/xfail/name_resolution21.rs: Likewise.
* rust/execute/torture/name_resolution.rs: Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* lang.opt (frust-name-resolution-2.0): Enable by default.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/compile.exp: Removed.
* rust/compile/nr2/exclude: Removed.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
Example GIMPLE output of the match statement for match-restpattern-tuple-1.rs:
...
RUSTTMP.2 = x;
_1 = RUSTTMP.2.__0;
_2 = _1 == 1;
_3 = RUSTTMP.2.__3;
_4 = _3 == 4;
_5 = _2 & _4;
if (_5 != 0) goto <D.109>; else goto <D.110>;
<D.109>:
{
{
}
goto <D.104>;
}
<D.110>:
if (1 != 0) goto <D.111>; else goto <D.112>;
<D.111>:
{
{
}
goto <D.104>;
}
<D.112>:
<D.104>:
...
gcc/rust/ChangeLog:
* backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit(TuplePattern)):
Implement check expression compilation for TuplePatternItems::RANGED.
Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
|
|
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-pattern.cc (visit(TuplePattern)): Fix
incorrect logic for field size checking.
gcc/testsuite/ChangeLog:
* rust/compile/tuple_mismatch.rs: Include RestPattern in test.
Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
|
|
This prioritizes resolution in the language prelude over resolution as a
module.
gcc/rust/ChangeLog:
* resolve/rust-forever-stack.hxx (ForeverStack::resolve_path):
Resolve final segments which point to modules.
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):
Avoid inserting module names into ribs in the type namespace.
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: Remove issue-3315-2.rs.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
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/testsuite/ChangeLog:
* rust/compile/macros/builtin/recurse2.rs: Match "abheyho\0" as
well as "abheyho", to handle slight differences in assembly
output for null-terminated strings.
Signed-off-by: Owen Avery <powerboat9.gamer@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>
|
|
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>
|
|
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>
|