Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
Switching to default constructors for poly_int exposed some
unused variables that weren't previously diagnosed.
gcc/
* dwarf2out.cc (mem_loc_descriptor): Remove unused variables.
* tree-affine.cc (expr_to_aff_combination): Likewise.
gcc/cp/
* constexpr.cc (cxx_fold_indirect_ref): Remove unused variables.
gcc/rust/
* backend/rust-constexpr.cc (rs_fold_indirect_ref): Remove unused
variables.
|
|
|
|
gcc/ChangeLog:
* doc/tm.texi: Regenerate.
* doc/tm.texi.in: Document TARGET_RUST_OS_INFO.
gcc/rust/ChangeLog:
* rust-session-manager.cc (Session::init): Call
targetrustm.rust_os_info.
* rust-target.def (rust_os_info): New hook.
|
|
gcc/ChangeLog:
* doc/tm.texi: Regenerate.
* doc/tm.texi.in: Add @node for Rust language and ABI, and document
TARGET_RUST_CPU_INFO.
gcc/rust/ChangeLog:
* rust-lang.cc (rust_add_target_info): Remove sorry.
* rust-session-manager.cc: Replace include of target.h with
include of tm.h and rust-target.h.
(Session::init): Call targetrustm.rust_cpu_info.
* rust-target.def (rust_cpu_info): New hook.
* rust-target.h (rust_add_target_info): Declare.
|
|
gcc/ChangeLog:
* Makefile.in (tm_rust_file_list, tm_rust_include_list, TM_RUST_H,
RUST_TARGET_DEF, RUST_TARGET_H, RUST_TARGET_OBJS): New variables.
(tm_rust.h, cs-tm_rust.h, default-rust.o,
rust/rust-target-hooks-def.h, s-rust-target-hooks-def-h): New rules.
(s-tm-texi): Also check timestamp on rust-target.def.
(generated_files): Add TM_RUST_H and rust-target-hooks-def.h.
(build/genhooks.o): Also depend on RUST_TARGET_DEF.
* config.gcc (tm_rust_file, rust_target_objs, target_has_targetrustm):
New variables.
* configure: Regenerate.
* configure.ac (tm_rust_file_list, tm_rust_include_list,
rust_target_objs): Add substitutes.
* doc/tm.texi: Regenerate.
* doc/tm.texi.in (targetrustm): Document.
(target_has_targetrustm): Document.
* genhooks.cc: Include rust/rust-target.def.
* config/default-rust.cc: New file.
gcc/rust/ChangeLog:
* rust-target-def.h: New file.
* rust-target.def: New file.
* rust-target.h: New file.
|
|
|
|
gcc/rust/ChangeLog:
* Make-lang.in: Removed rust-gcc-diagnostics object file.
* rust-diagnostics.cc (rust_be_get_quotechars): Added from original file.
(rust_be_internal_error_at): Likewise.
(rust_be_error_at): Likewise.
(class rust_error_code_rule): Likewise.
(rust_be_warning_at): Likewise.
(rust_be_fatal_error): Likewise.
(rust_be_inform): Likewise.
(rust_be_debug_p): Likewise.
* rust-gcc-diagnostics.cc: Removed.
Signed-off-by: Parthib Datta <parthibdutta02@gmail.com>
|
|
|
|
gcc/rust/ChangeLog:
* rust-diagnostics.cc (rust_error_at): New overload.
* rust-diagnostics.h (struct ErrorCode): New struct.
(rust_error_at): New.
(rust_be_error_at): Likewise.
* rust-gcc-diagnostics.cc (class rust_error_code_rule): New class.
(rust_be_error_at): New function.
* typecheck/rust-casts.cc (TypeCastRules::emit_cast_error): Emit E0054
when reporting invalid cast error.
gcc/testsuite/ChangeLog:
* rust/compile/bad_as_bool_char.rs: Add error code to testcase.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
|
|
RISC-V lowers the TYPE_PRECISION for MODE_VECTOR_BOOL vectors in order
to distinguish between VNx1BI, VNx2BI, VNx4BI and VNx8BI.
This patch adjusts uses of MODE_VECTOR_BOOL to use GET_MODE_PRECISION
instead of GET_MODE_BITSIZE.
The RISC-V tests are provided by Juzhe.
Co-Authored-By: Juzhe-Zhong <juzhe.zhong@rivai.ai>
gcc/c-family/ChangeLog:
* c-common.cc (c_common_type_for_mode): Use GET_MODE_PRECISION.
gcc/ChangeLog:
* simplify-rtx.cc (native_encode_rtx): Ditto.
(native_decode_vector_rtx): Ditto.
(simplify_const_vector_byte_offset): Ditto.
(simplify_const_vector_subreg): Ditto.
* tree.cc (build_truth_vector_type_for_mode): Ditto.
* varasm.cc (output_constant_pool_2): Ditto.
gcc/fortran/ChangeLog:
* trans-types.cc (gfc_type_for_mode): Ditto.
gcc/go/ChangeLog:
* go-lang.cc (go_langhook_type_for_mode): Ditto.
gcc/lto/ChangeLog:
* lto-lang.cc (lto_type_for_mode): Ditto.
gcc/rust/ChangeLog:
* backend/rust-tree.cc (c_common_type_for_mode): Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/vls-vlmax/bitmask-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/bitmask-10.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/bitmask-11.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/bitmask-12.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/bitmask-13.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/bitmask-14.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/bitmask-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/bitmask-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/bitmask-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/bitmask-5.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/bitmask-6.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/bitmask-7.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/bitmask-8.c: New test.
* gcc.target/riscv/rvv/autovec/vls-vlmax/bitmask-9.c: New test.
|
|
|
|
This was noticed when fixing the gccgo usage of the macro, the
rust usage is very similar.
TARGET_AIX is defined as a non-zero value on linux/powerpc64le
which may cause unexpected behavior. TARGET_AIX_OS should be
used to toggle AIX specific behavior.
2023-06-22 Paul E. Murphy <murphyp@linux.ibm.com>
gcc/rust/
* rust-object-export.cc [TARGET_AIX]: Rename and update usage to
TARGET_AIX_OS.
|
|
|
|
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h
(Parser::parse_stmt): Handle unsafe expression statements.
gcc/testsuite/ChangeLog:
* rust/compile/issue-1422.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h
(Parser::parse_expr_stmt): Remove hypothetical unsafe + expr_stmt_without_block handling.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
Addresses #1567
Created a AST node InlineAsm similar to the one found in rustc.
As there is no Symbol struct/class in gccrs I have made every instance
of Symbol a string.
gcc/rust/ChangeLog:
* ast/rust-ast-full-decls.h (class InlineAsm):Added class declaration.
* ast/rust-expr.h (class InlineAsm):Added class definition.
Signed-off-by: M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>
|
|
The class now allows for more variants including a `Hint` one which
then gets emitted by calling `rust_inform`. This allows us to display
hints/tips/notes in backtracking contexts such as the parser.
gcc/rust/ChangeLog:
* rust-diagnostics.h (struct Error): Add new Kind enum and various new
static constructors to allow for hints as well.
* rust-diagnostics.cc (Error::Error): Use new `kind` field properly.
* checks/errors/privacy/rust-visibility-resolver.cc
(VisibilityResolver::resolve_module_path): Use new Error API.
* expand/rust-macro-builtins.cc (MacroBuiltin::include_handler): Likewise.
* expand/rust-macro-expand.cc (parse_many): Likewise.
(transcribe_type): Likewise.
* parse/rust-parse-impl.h (Parser::parse_crate): Likewise.
* rust-session-manager.cc (Session::handle_crate_name): Likewise.
* ast/rust-ast.cc (Module::load_items): Likewise.
|
|
gcc/rust/ChangeLog:
* ast/rust-ast.h: Keep location in TraitItem base class
* ast/rust-item.h (class TraitItemFunc): Use base class location instead.
(class TraitItemMethod): Likewise.
(class TraitItemConst): Likewise.
(class TraitItemType): Likewise.
* ast/rust-macro.h: Likewise.
|
|
gcc/rust/Changelog:
* hir/tree/rust-hir-full-test.cc: Moved to...
* hir/tree/rust-hir.cc: ...here.
* Make-lang.in: Rename rust-hir-full-test.
Signed-off-by: SainiAditya1 <Adityasaini10012001@outlook.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc
(Dump::visit): Add AltPattern visitor.
* ast/rust-ast-dump.h:
(Dump::visit): Add AltPattern visitor.
* ast/rust-ast-full-decls.h
(class AltPattern): Add declaration.
* ast/rust-ast-visitor.h:
(ASTVisitor::visit): Add AltPattern visitor.
* ast/rust-ast.cc
(AltPattern::as_string): Add definition.
(AltPattern::accept_vis): Add definition.
* ast/rust-pattern.h
(class AltPattern): Add declaration.
* checks/errors/rust-feature-gate.h:
(FeatureGate::visit) Add AltPattern visitor
* expand/rust-attribute-visitor.cc
(AttrVisitor::visit): Add AltPattern visitor.
* expand/rust-attribute-visitor.h:
(AttrVisitor::visit): Add AltPattern visitor.
* hir/rust-ast-lower-base.cc
(ASTLoweringBase::visit): Add AltPattern visitor.
* hir/rust-ast-lower-base.h:
(ASTLoweringBase::visit): Add AltPattern visitor.
* resolve/rust-ast-resolve-base.cc
(ResolverBase::visit): Add AltPattern visitor.
* resolve/rust-ast-resolve-base.h:
(ResolverBase::visit): Add AltPattern visitor.
* resolve/rust-early-name-resolver.cc
(EarlyNameResolver::visit): Add AltPattern visitor.
* resolve/rust-early-name-resolver.h:
(EarlyNameResolver::visit): Add AltPattern visitor.
* util/rust-attributes.cc
(AttributeChecker::visit): Add AltPattern visitor.
* util/rust-attributes.h:
(AttributeChecker::visit): Add AltPattern visitor.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-pattern.h: Fix formatting.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (MacroBuiltin::include_handler): Do not
return nullptr token in expansion of `include!()`
gcc/testsuite/ChangeLog:
* rust/compile/empty.in: New test.
* rust/compile/include_empty.rs: New test.
|
|
gcc/rust/ChangeLog:
* checks/errors/rust-feature-gate.h: Add trailing newline before EOF.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
When implementing general bounds checking as part of unify calls, we did
not check associated types on bounds which lead to alot of missed error
checking. This now recursively checks the bounds and the associated types
with a decent error message. This also required us to implement the Sized
marker trait to keep existing test-cases happy.
Fixes #1725
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-reference.cc (TraitReference::clear_associated_types): make const
(TraitReference::clear_associated_type_projections): new interface
* typecheck/rust-hir-trait-reference.h:
* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait): refactor
(TraitItemReference::associated_type_reset): reset projections
* typecheck/rust-hir-type-bounds.h:
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): fix bounds
* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::TypeBoundsProbe): refactor into cc file
(TypeBoundsProbe::Probe): refactor
(TypeBoundsProbe::is_bound_satisfied_for_type): likewise
(TypeBoundsProbe::assemble_sized_builtin): add builtin for Sized
(TypeCheckBase::get_predicate_from_bound): refactor
(TypeBoundPredicate::lookup_associated_type): refactor
* typecheck/rust-tyty-subst.cc (SubstitutionRef::lookup_associated_impl)
(SubstitutionRef::prepare_higher_ranked_bounds): new interface to clear hanging bounds
(SubstitutionRef::monomorphize): refactor
* typecheck/rust-tyty-subst.h:
* typecheck/rust-tyty.cc (BaseType::get_locus): helper
(BaseType::satisfies_bound): ensure bounds are satisfied and assoicated types
(ParamType::ParamType): new field in constructor
(ParamType::clone): update clone
(ParamType::set_implicit_self_trait): new interface
(ParamType::is_implicit_self_trait): likewise
* typecheck/rust-tyty.h: cleanup
* util/rust-hir-map.cc (Mappings::Mappings): builtin marker
(Mappings::~Mappings): delete marker
(Mappings::lookup_builtin_marker): lookup
* util/rust-hir-map.h: update header
gcc/testsuite/ChangeLog:
* rust/compile/issue-1725-1.rs: New test.
* rust/compile/issue-1725-2.rs: New test.
|
|
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* hir/tree/rust-hir-item.h: implement virtual function
* hir/tree/rust-hir.h: add virtual function
|
|
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* Make-lang.in: add new dependancy
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::query_type): refactor
* typecheck/rust-hir-type-check-base.h: refactor
* typecheck/rust-hir-type-check.h (RUST_HIR_TYPE_CHECK): refactor
* typecheck/rust-type-util.cc: New file.
* typecheck/rust-type-util.h: New file.
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc
(MacroBuiltin::include_str_handler): Add check for valid UTF-8.
gcc/testsuite/ChangeLog:
* rust/compile/builtin_macro_include_str.rs:
Include test of invalid UTF-8.
* rust/compile/invalid_utf8: File with invalid UTF-8.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h
(Parser::parse_grouped_or_tuple_pattern): Add support for empty tuple patterns.
gcc/testsuite/ChangeLog:
* rust/compile/parse_empty_tuple_pattern.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
RAIIFile constructor was accepting directory filename. This lead to
unattended directory opening in some part of the code (load_file_bytes)
wich resulted in ice. Since RAIIFile are used for the lexer, removing
the ability to open directories with RAIIFile fixes those issues and
prevent future mistakes.
gcc/rust/ChangeLog:
* lex/rust-lex.h: Add file type check.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* backend/rust-compile-pattern.cc
(CompilePatternLet::visit): Simplify WildcardPattern compilation for let statements.
* backend/rust-compile-var-decl.h:
(CompileVarDecl::visit): Remove variable declaration for WildcardPattern.
* resolve/rust-ast-resolve-pattern.h:
(PatternDeclaration::visit): Remove name resolution for WildcardPattern.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
gcc/rust/ChangeLog:
* typecheck/rust-tyty-call.cc
(TypeCheckCallExpr::visit): Add variadic argument type checking.
(TypeCheckCallExpr::visit): Fix comment spelling ("varadic").
gcc/testsuite/ChangeLog:
* rust/execute/torture/overflow1.rs: Fix test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
This commit implemented a feature gate to check `intrinsics`.
gcc/rust/ChangeLog:
* checks/errors/rust-feature-gate.cc: Add implementation for
`void FeatureGate::visit (AST::ExternBlock &block)`. Add `valid_feature`
construction process in `FeatureGate::check`.
* checks/errors/rust-feature-gate.h: Add declaration for
`void FeatureGate::visit (AST::ExternBlock &block)`. Add private
variable `valid_feature`.
* checks/errors/rust-feature.h: Change `issue` to `m_issue`.
gcc/testsuite/ChangeLog:
* rust/compile/const-issue1440.rs: Add crate feature: `intrinsics`.
* rust/compile/feature_intrinsics.rs: New file.
* rust/compile/issue-1031.rs: Add crate feature: `intrinsics`.
* rust/compile/issue-1130.rs: Add crate feature: `intrinsics`.
* rust/compile/issue-1131.rs: Add crate feature: `intrinsics`.
* rust/compile/issue-1237.rs: Add crate feature: `intrinsics`.
* rust/compile/issue-1289.rs: Add crate feature: `intrinsics`.
* rust/compile/rust-const-blog-issue.rs: Add crate feature: `intrinsics`.
* rust/compile/torture/intrinsics-3.rs: Add crate feature: `intrinsics`.
* rust/compile/torture/intrinsics-4.rs: Add crate feature: `intrinsics`.
* rust/compile/torture/intrinsics-5.rs: Add crate feature: `intrinsics`.
* rust/compile/torture/intrinsics-6.rs: Add crate feature: `intrinsics`.
* rust/compile/torture/intrinsics-7.rs: Add crate feature: `intrinsics`.
* rust/compile/torture/issue-1024.rs: Add crate feature: `intrinsics`.
* rust/compile/torture/issue-1075.rs: Add crate feature: `intrinsics`.
* rust/compile/torture/issue-1432.rs: Add crate feature: `intrinsics`.
* rust/compile/unsafe10.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/atomic_load.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/atomic_store.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/copy_nonoverlapping1.rs: Add crate feature:
`intrinsics`.
* rust/execute/torture/issue-1120.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/issue-1133.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/issue-1232.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/slice-magic.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/slice-magic2.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/str-layout1.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/transmute1.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/wrapping_op1.rs: Add crate feature: `intrinsics`.
* rust/execute/torture/wrapping_op2.rs: Add crate feature: `intrinsics`.
Signed-off-by: Xiao Ma <mxlol233@outlook.com>
|
|
gcc/rust/ChangeLog:
* ast/rust-ast-fragment.cc: Update copyright years.
* ast/rust-ast-fragment.h: Likewise.
* ast/rust-macro.cc: Likewise.
* checks/errors/rust-feature-gate.cc: Likewise.
* checks/errors/rust-feature-gate.h: Likewise.
* checks/errors/rust-feature.cc: Likewise.
* checks/errors/rust-feature.h: Likewise.
* hir/rust-ast-lower-expr.cc: Likewise.
* hir/rust-ast-lower-type.cc: Likewise.
* resolve/rust-early-name-resolver.cc: Likewise.
* resolve/rust-early-name-resolver.h: Likewise.
* rust-gcc.h: Likewise.
* typecheck/rust-hir-path-probe.cc: Likewise.
* typecheck/rust-hir-trait-reference.cc: Likewise.
* typecheck/rust-tyty-bounds.h: Likewise.
* typecheck/rust-tyty-subst.cc: Likewise.
* typecheck/rust-tyty-subst.h: Likewise.
* typecheck/rust-tyty-util.cc: Likewise.
* typecheck/rust-tyty-util.h: Likewise.
* typecheck/rust-unify.cc: Likewise.
* typecheck/rust-unify.h: Likewise.
* util/rust-inline-visitor.h: Likewise.
|
|
The compiler's warning message about the safety flag did not match
cargo-gccrs environment variable name anymore.
gcc/rust/ChangeLog:
* rust-session-manager.cc (Session::compile_crate): Update the
environment variable name.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
Move function body to their own cc file instead of keeping them in the
header file.
gcc/rust/ChangeLog:
* Make-lang.in: Add `rust-hir-trait-reference.o`.
* typecheck/rust-hir-trait-reference.h: Remove multiple function body.
* typecheck/rust-hir-trait-reference.cc: Add multiple function body.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-expand.cc (MacroExpander::expand_eager_invocations):
Add documentation explaining the algorithm.
|
|
This commit changes our macro expansion system from an eager and recursive
macro expansion to a fixed-point like system. Instead of, when seeing
a macro invocation, expanding it and all of the macros within it, we
now perform multiple passes of expansion on the entire crate.
This, however, leads to a problem. Rust macros are expanded lazily, but
Rust builtin macros should be expanded eagerly. Due to this, we must
work around the lazy expansion in builtin macros and perform eager
expansion for each pass of the fixed-point, before finally expanding
the builtin when there are no longer any inner macro invocations.
To perform proper macro scoping, the ENR now keeps track of the current
scope (`current_scope` member) and resolves macros accordingly.
This is done through the use of the `scoped` method, which creates a new
scope, runs a specified lambda and then exits the scope. This prevents
pushing/popping errors that we've seen happen already in similar
contexts.
We might think about generalizing it to other classes, providing a
`Scoped<EntryFn, ExitFn>` class or similar
gcc/rust/ChangeLog:
* ast/rust-macro.cc: New file.
* Make-lang.in: Add `rust-macro.o` object
* ast/rust-ast-fragment.cc (Fragment::Fragment): Change API around
the construction of AST fragments.
(Fragment::operator=): Correct `Fragment::operator=` to take into
account the fragment tokens.
(Fragment::create_error): Use new constructor.
(Fragment::complete): Remove in favor of new constructor.
(Fragment::unexpanded): Remove as that Fragment type is no longer used
or possible.
(Fragment::get_tokens): Add helper to access a fragment's tokens.
* ast/rust-ast-fragment.h (enum class): Remove `FragmentKind::Unused`
* ast/rust-ast.cc (MacroInvocation::as_string): Display
builtin macro invocations properly.
* ast/rust-ast.h: Fix `DelimTokenTree` class copy constructors and
handling of its token vector.
* ast/rust-macro.h (class MacroMatcher): Format.
(class MetaItemSeq): Likewise.
(builtin_macro_from_string): Get a `BuiltinMacroKind` from a given
string, i.e the name of the macro (`assert!`, `cfg!` and so on).
* expand/rust-attribute-visitor.cc (AttrVisitor::visit): Do not expand
macros recursively anymore.
(AttrVisitor::maybe_expand_expr): Likewise.
(AttrVisitor::maybe_expand_type): Likewise.
* expand/rust-attribute-visitor.h: Likewise, and remove
`expand_macro_fragment_recursively` function.
* expand/rust-macro-builtins.cc (make_token): Add shorthand for
returning `std::unique_ptr<AST::Token>`s.
(make_macro_invocation): Add shorthand for returning fragments
containing builtin macro invocations.
(try_expand_macro_expression): Do not expand macros recursively.
(try_expand_single_string_literal): Likewise.
(try_expand_many_expr): Likewise.
(parse_single_string_literal): Error out more appropriately.
(MacroBuiltin::compile_error_handler): Add explanation for eager
invocation
(MacroBuiltin::file_handler): Return the proper tokens associated with
macro invocation, and builtin macros in the case of necessary eager
expansion.
(MacroBuiltin::column_handler): Likewise.
(MacroBuiltin::include_bytes_handler): Likewise.
(MacroBuiltin::include_str_handler): Likewise.
(MacroBuiltin::concat_handler): Likewise.
(MacroBuiltin::env_handler): Likewise.
(MacroBuiltin::cfg_handler): Likewise.
(MacroBuiltin::include_handler): Likewise.
(MacroBuiltin::line_handler): Likewise.
* expand/rust-macro-expand.cc (MacroExpander::expand_eager_invocations):
Add function to expand eager invocations *once* in the fixed point
pipeline.
(MacroExpander::expand_invoc): Call into `expand_eager_invocations` for
builtin macro invocations.
(MacroExpander::expand_crate): Use new `AttrVisitor` API.
(parse_many): Return tokens in `AST::Fragment`.
(transcribe_expression): Likewise.
(transcribe_type): Likewise.
* expand/rust-macro-expand.h (struct MacroExpander): Add `has_changed`
flag for fixed point checking.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::EarlyNameResolver):
Keep track of the current macro scope.
(EarlyNameResolver::go): Use `scoped` API.
(EarlyNameResolver::visit): Likewise.
* resolve/rust-early-name-resolver.h: Add `scoped` API.
* rust-session-manager.cc (Session::expansion): Perform macro expansion
in a fixed-point fashion.
gcc/testsuite/ChangeLog:
* rust/compile/macro17.rs: Fix testsuite for new recursion errors.
* rust/compile/macro44.rs: Fix invalid testcase assertions.
* rust/compile/builtin_macro_recurse.rs: Fix invalid test.
* rust/compile/builtin_macro_recurse2.rs: New test.
* rust/compile/macro46.rs: New test.
|
|
gcc/rust/ChangeLog:
* expand/rust-macro-invoc-lexer.cc (MacroInvocLexer::get_token_slice):
Add API to retrieve token slices when lexing macro expansions.
* expand/rust-macro-invoc-lexer.h: Declare `get_token_slice`.
|
|
gcc/rust/ChangeLog:
* parse/rust-parse.h: Move `parse_macro_invocation` to public API.
|
|
gcc/rust/ChangeLog:
* ast/rust-item.h (class BlockExpr): Remove forward declaration of
class `BlockExpr`.
|
|
gcc/rust/ChangeLog:
* hir/tree/rust-hir-pattern.h
(TuplePatternItemsRanged::get_lower_patterns): Add method.
(TuplePatternItemsRanged::get_upper_patterns): Add method.
* backend/rust-compile-pattern.cc
(CompilePatternLet::visit): Implement TuplePattern visitor.
* backend/rust-compile-pattern.h
(CompilePatternLet::visit): Move TuplePattern visitor out of header file.
gcc/testsuite/ChangeLog:
* rust/execute/torture/let-pattern-1.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
|
|
Existing tests are updated to use libcore copy and clone implementation.
Addresses #1725
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-unify.cc (UnifyRules::go): ensure the bounds are checked
gcc/testsuite/ChangeLog:
* rust/compile/torture/intrinsics-4.rs: implement Copy trait
* rust/compile/torture/intrinsics-5.rs: likewise
* rust/execute/torture/atomic_load.rs: likewise
* rust/execute/torture/atomic_store.rs: likewise
* rust/bounds1.rs: New test.
|
|
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): remove error message
gcc/testsuite/ChangeLog:
* rust/compile/func3.rs: update test case
|
|
This updates the higher ranked trait bounds computation to handle ambigious
cases. When we have a slice for example:
let slice = &a[1..3];
This works by reusing the Index operator overload from libcore, so when the
index range of 1..3 is computed, the type system needs to compute what the
types of index are; this works by integer inference variables
Range<<integer>> that need to be unified with the impl Index for
Range<Usize> which computes the real type of usize for the index. This is
fine but what happens when we have the Copy and Clone traits bounds which
have implementations for all the primitive types i8, i16, i32, i64...
which is valid for any integer inference variable so the code prior to this
patch would have grabbed the first impl it would have found and used it
which is incorrect. When we have integer or float inference variables we
need to look for their respective defaults or emit an ambigious type bound
error.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-reference.h: add const infterface
* typecheck/rust-tyty-subst.cc (SubstitutionParamMapping::get_generic_param): make const
(SubstitutionRef::monomorphize): fix issue
* typecheck/rust-tyty-subst.h: constify interface
|
|
We need these lang items to be defined and later down the line the mappings
will be used to implement proper copy and clone logic.
Fixes #1786
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* util/rust-lang-item.h:
gcc/testsuite/ChangeLog:
* rust/compile/issue-1786.rs: New test.
|
|
When we check if this is concrete the guard checks to ensure the argument
is non null but the check here is wrongly returning early when the check
is non null meaning when it is null and therefore not concrete it will
end up doing a null dereference.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-tyty-subst.cc (SubstitutionArg::is_conrete): fix check
|
|
This refactors the unification systems to be a consistent interface using
switch statements and simple functions instead of the old clunky visitor
system. This is more maintainable as it is harder to miss cases when we
can take advantages of switch statements.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* Make-lang.in: update names
* backend/rust-compile-expr.cc (CompileExpr::resolve_method_address):
update to use new interface
* typecheck/rust-coercion.cc (TypeCoercionRules::coerce_borrowed_pointer): likewise
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::unify_site): likewise
* typecheck/rust-tyty.cc (BaseType::destructure): likewise
(InferType::unify): removed old unify interface
(ErrorType::unify): likewise
(ADTType::unify): likewise
(TupleType::unify): likewise
(FnType::unify): likewise
(FnPtr::unify): likewise
(ClosureType::unify): likewise
(ArrayType::unify): likewise
(SliceType::unify): likewise
(BoolType::unify): likewise
(IntType::unify): likewise
(UintType::unify): likewise
(FloatType::unify): likewise
(USizeType::unify): likewise
(ISizeType::unify): likewise
(CharType::unify): likewise
(ReferenceType::unify): likewise
(PointerType::unify): likewise
(ParamType::unify): likewise
(StrType::unify): likewise
(NeverType::unify): likewise
(PlaceholderType::unify): likewise
(ProjectionType::unify): likewise
(DynamicObjectType::unify): likewise
* typecheck/rust-tyty.h: update destructure interface
* typecheck/rust-tyty-rules.h: Removed.
* typecheck/rust-unify.cc: New file.
* typecheck/rust-unify.h: New file.
gcc/testsuite/ChangeLog:
* rust/compile/never_type_err1.rs: Moved to...
* rust/compile/never_type1.rs: ...here. It now works
|
|
During CallExpr argument type checking we may be calling a default
implementation of a trait function this will require any possible
associated types to be resolved and setup. This monomoprhization call does
this but it will premtivly do extra unification of types which will throw
off type checking later on. This fix is required for my work into type
bounds checking.
Fixes #1773
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-reference.h: change interface to return self
* typecheck/rust-hir-trait-resolve.cc: likewise
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_segments): likewise
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): remove monomorphization hack
gcc/testsuite/ChangeLog:
* rust/compile/issue-1773.rs: New test.
|