Commit graph

208087 commits

Author SHA1 Message Date
Raiki Tamura
f2900e86b9 gccrs: Add tests for v0 mangling
gcc/rust/ChangeLog:

	* backend/rust-mangle.cc (v0_identifier): Fix broken encoding.
	(v0_scope_path): Modify paramter.
	(v0_path): Fix namespace for modules.

gcc/testsuite/ChangeLog:

	* rust/compile/v0-mangle1.rs: New test.

Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2024-01-16 19:09:19 +01:00
Pierre-Emmanuel Patry
05ddae991b gccrs: Add new test for closure in closure parsing
This new test highlight the fix of #2656.

gcc/testsuite/ChangeLog:

	* rust/compile/closure_in_closure.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:19 +01:00
Pierre-Emmanuel Patry
906e55530a gccrs: Break OR tokens in closure parameter list context
The parser was unable to process as closure inside a closure because the
lexer could not differentiate an OR from two PIPE tokens.

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_closure_expr_pratt): Fix
	closure parsing function to handle consecutive parameter lists.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:18 +01:00
Pierre-Emmanuel Patry
2dfff621d9 gccrs: Add new regression test for macro matcher behavior
Add a new test to highlight the fix introduced for #2653.

gcc/testsuite/ChangeLog:

	* rust/compile/macro-issue2653.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:18 +01:00
Pierre-Emmanuel Patry
3c3e05ad03 gccrs: Add path to macro fragment follow restrictions
The previous follow set rules did not allow PATH fragment, changing this
allow gccrs to accept more valid rust macros.

gcc/rust/ChangeLog:

	* ast/rust-macro.h: Add PATH fragment to follow set restrictions.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:18 +01:00
Pierre-Emmanuel Patry
1e841fd604 gccrs: Add a new test for mbe named macro_rules
Macro rules named macro_rules may cause some problems if not handled
correctly. This new test ensure we always compile those macros named
macro_rules correctly as well as other macro definitions.

gcc/testsuite/ChangeLog:

	* rust/compile/macro57.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:17 +01:00
Pierre-Emmanuel Patry
46c84b7805 gccrs: Add new regression test
This new test highlight the fix for #2651.

gcc/testsuite/ChangeLog:

	* rust/compile/macro_rules_macro_rules.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:17 +01:00
Pierre-Emmanuel Patry
68a8a55037 gccrs: Allow macro named macro_rules
Change the constraints around macro rules declaration in order to allow
macro_rules named macro as well as tighter constraint around macro rules
definitions.

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::is_macro_rules_def): Add a function
	that checks tokens given by the lexer represents an accurate macro
	definition. This will reduce code duplication.
	(Parser::parse_item): Replace condition with call to new checking
	function.
	(Parser::parse_stmt): Likewise.
	* parse/rust-parse.h: Add function prototype for is_macro_rules_def.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:17 +01:00
Pierre-Emmanuel Patry
3d43c98bf8 gccrs: Add new regression test
Add a new test to highlight fix of #2658.

gcc/testsuite/ChangeLog:

	* rust/compile/while_break_expr.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:16 +01:00
Pierre-Emmanuel Patry
c53cef37b8 gccrs: Add a new regression test
Add a new test to highlight the fix made for #2660.

gcc/testsuite/ChangeLog:

	* rust/compile/range_from_expr_for_loop.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:16 +01:00
Pierre-Emmanuel Patry
dff99b7464 gccrs: Fix RangeFromExpr parsing in for loops
Those ranges were looking for a curly brace after the brace, leading
to an error when using range from expr in for loops.

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_expr): Fix range from expr.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:16 +01:00
Pierre-Emmanuel Patry
c7eb1002c6 gccrs: Add a new regression test for macro call "default"
This test highlight the fix required for #2655.

gcc/testsuite/ChangeLog:

	* rust/compile/parse_item_default_macro.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:15 +01:00
Pierre-Emmanuel Patry
1e039d2f84 gccrs: Allow call to macro named "default" at item level
The parser was too agressive and did reject any line beginning with
default even if this was a macro call.

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_item): Relax constraints
	around default identifier at item scope to accept "default" macros.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:15 +01:00
Pierre-Emmanuel Patry
10af70269c gccrs: Add a new regression test
New regression test to highlight behavior of #2652.

gcc/testsuite/ChangeLog:

	* rust/compile/parse_generic_path_expr.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:14 +01:00
Pierre-Emmanuel Patry
061c5d2e24 gccrs: Fix path expr segment parsing with generic path
When a token was identified as bit left shift it slipped through the
parser and resulted in an error.

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_path_expr_segment): Accept
	left shift tokens in order to let generic parsing function split the
	token.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:14 +01:00
Owen Avery
292aec084c gccrs: Replace get_pattern_node_id with get_node_id
gcc/rust/ChangeLog:

	* ast/rust-ast.h
	(Pattern::get_pattern_node_id): Rename to...
	(Pattern::get_node_id): ...here.
	* ast/rust-macro.h
	(MacroInvocation::get_pattern_node_id): Rename to...
	(MacroInvocation::get_node_id): ...here.
	* ast/rust-path.h
	(PathInExpression::get_pattern_node_id): Remove.
	(QualifiedPathInExpression::get_pattern_node_id): Remove.
	* ast/rust-pattern.h
	(LiteralPattern::get_pattern_node_id): Remove.
	(IdentifierPattern::get_pattern_node_id): Remove.
	(WildcardPattern::get_pattern_node_id): Remove.
	(RestPattern::get_pattern_node_id): Rename to...
	(RestPattern::get_node_id): ...here.
	(RangePattern::get_pattern_node_id): Remove.
	(ReferencePattern::get_pattern_node_id): Remove.
	(StructPattern::get_pattern_node_id): Remove.
	(TupleStructPattern::get_pattern_node_id): Remove.
	(TuplePattern::get_pattern_node_id): Remove.
	(GroupedPattern::get_pattern_node_id): Remove.
	(SlicePattern::get_pattern_node_id): Remove.
	(AltPattern::get_pattern_node_id): Remove.
	* resolve/rust-early-name-resolver.cc
	(EarlyNameResolver::visit):
	Use get_node_id instead of get_pattern_node_id.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16 19:09:14 +01:00
Pierre-Emmanuel Patry
4c835425d0 gccrs: Add regression test
This new test highlight the fix for issue #2657.

gcc/testsuite/ChangeLog:

	* rust/compile/match_break.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:14 +01:00
Pierre-Emmanuel Patry
863431f5a0 gccrs: Add comma for expr delimiter to fix match arms
Add a comma as an expr delimiter, this will allow correct parsing of
match arm expressions.

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_expr): Add comma delimiter.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:13 +01:00
Pierre-Emmanuel Patry
378c26f5a3 gccrs: Add regression test
Add a new test to highlight fix for #2648.

gcc/testsuite/ChangeLog:

	* rust/compile/parse_pub_unit_type.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:12 +01:00
Pierre-Emmanuel Patry
f209a01840 gccrs: Fix pub unit type parsing
Public unit types where not parsed correctly due to visibility specifiers
within parenthesis. Fixes #2648.

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_visibility): Relax constraints
	over public visibility return condition in order to accept pub unit
	types.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:12 +01:00
Jakub Dupak
f97a9841dc gccrs: TyTy: use new subclass API
gcc/rust/ChangeLog:

	* typecheck/rust-tyty.cc (BaseType::is_unit): Refactor.
	(BaseType::satisfies_bound): Refactor.
	(BaseType::get_root): Refactor.
	(BaseType::destructure): Refactor.
	(BaseType::monomorphized_clone): Refactor.
	(BaseType::is_concrete): Refactor.
	(InferType::InferType): Refactor.
	(InferType::clone): Refactor.
	(InferType::apply_primitive_type_hint): Refactor.
	(StructFieldType::is_equal): Refactor.
	(ADTType::is_equal): Refactor.
	(handle_substitions): Refactor.
	(ADTType::handle_substitions): Refactor.
	(TupleType::TupleType): Refactor.
	(TupleType::is_equal): Refactor.
	(TupleType::handle_substitions): Refactor.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16 19:09:12 +01:00
Jakub Dupak
47b88c0338 gccrs: TyTy: TyTy improved subclass casting and checking
Associate each subclass with its kind and create cast/match+cast
methods.

gcc/rust/ChangeLog:

	* typecheck/rust-tyty.cc (InferType::InferType): Use static constant for kind information.
	(ErrorType::ErrorType): Use static constant for kind information.
	(TupleType::TupleType): Use static constant for kind information.
	(BoolType::BoolType): Use static constant for kind information.
	(IntType::IntType): Use static constant for kind information.
	(UintType::UintType): Use static constant for kind information.
	(FloatType::FloatType): Use static constant for kind information.
	(USizeType::USizeType): Use static constant for kind information.
	(ISizeType::ISizeType): Use static constant for kind information.
	(CharType::CharType): Use static constant for kind information.
	(ReferenceType::ReferenceType): Use static constant for kind information.
	(PointerType::PointerType): Use static constant for kind information.
	(ParamType::ParamType): Use static constant for kind information.
	(StrType::StrType): Use static constant for kind information.
	(NeverType::NeverType): Use static constant for kind information.
	(PlaceholderType::PlaceholderType): Use static constant for kind information.
	* typecheck/rust-tyty.h: Add static kind information to all TyTy classes.
	Create safe cast and check methods.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16 19:09:12 +01:00
Pierre-Emmanuel Patry
b2ad5eae79 gccrs: Add a regression test for global path parsing
Add a new test to highlight fix for #2649.

gcc/testsuite/ChangeLog:

	* rust/compile/parse_global_path_generic.rs: New test.
2024-01-16 19:09:12 +01:00
Pierre-Emmanuel Patry
1265069570 gccrs: Fix type param bound parsing with opening scope
The function parsing type param bounds had a problem with scope
resolution opening token.

gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h (Parser::parse_type_param_bound): Add missing
	case for lifetime switch.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:12 +01:00
Pierre-Emmanuel Patry
80199b328c gccrs: Change debug log call to as_string function
This will ensure an accurate representation of the token. Also update the
as_string function to represent accurately scope resolution tokens.

gcc/rust/ChangeLog:

	* lex/rust-token.cc (Token::as_string): Update function to output scope
	resolution tokens correctly.
	* parse/rust-parse-impl.h (Parser::parse_generic_param): Change call to
	as_string.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:09:11 +01:00
Raiki Tamura
44f71ed313 gccrs: Initial implementation of v0 mangling
gcc/rust/ChangeLog:

	* backend/rust-compile-context.h: Modify declaration.
	* backend/rust-mangle.cc (struct V0Path): New struct.
	(v0_path): New function.
	(legacy_mangle_name): Take Context as argument.
	(v0_numeric_prefix): Fix type strings.
	(v0_complex_type_prefix): New function.
	(v0_add_integer_62): Deleted
	(v0_integer_62): New function.
	(v0_add_opt_integer_62): Deleted.
	(v0_opt_integer_62): New function.
	(v0_add_disambiguator): Deleted.
	(v0_disambiguator): New function.
	(v0_type_prefix): Support more types.
	(v0_generic_args): New function.
	(v0_add_identifier): Deleted.
	(v0_identifier): New function.
	(v0_type_path): New function.
	(v0_function_path): New function.
	(v0_scope_path): New function.
	(v0_crate_path): New function.
	(v0_inherent_or_trait_impl_path): New function.
	(v0_mangle_item): Use v0_path.
	(Mangler::mangle_item): Take Context as argument.
	* backend/rust-mangle.h (class Context): Add forward declaration.
	* hir/tree/rust-hir-item.h: Fix include.

Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2024-01-16 19:04:38 +01:00
Owen Avery
aaea26f377 gccrs: Rename cloning methods in TupleStructItems and TuplePatternItems
gcc/rust/ChangeLog:

	* hir/tree/rust-hir-pattern.h
	(TupleStructItems::clone_tuple_struct_items_impl): Rename to...
	(TupleStructItems::clone_tuple_items_impl): ...here.
	(TupleStructItemsNoRange::clone_tuple_struct_items_impl): Rename to...
	(TupleStructItemsNoRange::clone_tuple_items_impl): ...here.
	(TupleStructItemsRange::clone_tuple_struct_items_impl): Rename to...
	(TupleStructItemsRange::clone_tuple_items_impl): ...here.

	(TuplePatternItems::clone_tuple_pattern_items_impl): Rename to...
	(TuplePatternItems::clone_tuple_items_impl): ...here.
	(TuplePatternItemsMultiple::clone_tuple_pattern_items_impl): Rename to...
	(TuplePatternItemsMultiple::clone_tuple_items_impl): ...here.
	(TuplePatternItemsRanged::clone_tuple_pattern_items_impl): Rename to...
	(TuplePatternItemsRanged::clone_tuple_items_impl): ...here.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16 19:04:38 +01:00
Owen Avery
4e2110cac3 gccrs: Adjust methods for TuplePatternItems to match TupleStructItems
gcc/rust/ChangeLog:

	* hir/tree/rust-hir-pattern.h
	(TuplePatternItems::get_pattern_type): Rename to...
	(TuplePatternItems::get_item_type): ...here.
	(TuplePatternItemsMultiple::get_pattern_type): Rename to...
	(TuplePatternItemsMultiple::get_item_type): ...here.
	(TuplePatternItemsRanged::get_pattern_type): Rename to...
	(TuplePatternItemsRanged::get_item_type): ...here.

	* backend/rust-compile-expr.cc: Adjust calls to renamed methods.
	* backend/rust-compile-pattern.cc: Likewise.
	* typecheck/rust-hir-type-check-pattern.cc: Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16 19:04:38 +01:00
Marc Poulhiès
08b785601b gccrs: minor changes (typo and minor refactor)
Fix a typo and merge 2 if clauses using the same condition.

gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::visit): Merge 2 if clauses.
	* backend/rust-compile-extern.h: Fix typo in comment.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16 19:04:38 +01:00
Jakub Dupak
c20d7924f1 gccrs: Add test for parser bug
gcc/testsuite/ChangeLog:

	* rust/compile/issue-2645.rs: New test.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16 19:04:38 +01:00
Jakub Dupak
6f15aac219 gccrs: Fix parser bug on tupplestruct pattern
gcc/rust/ChangeLog:

	* parse/rust-parse-impl.h: Add missing token consumption

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16 19:04:38 +01:00
Mohammed Rizan Farooqui
bf96760f96 gccrs: Removed unnecessary comments
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins.cc (MacroBuiltin::include_str_handler): Comment removed
	(MacroBuiltin::env_handler): Comment removed
	(MacroBuiltin::cfg_handler): Comment removed
	(MacroBuiltin::line_handler): Comment removed

Signed-off-by: Mohammed Rizan Farooqui <rizanfarooqui@gmail.com>
2024-01-16 19:04:37 +01:00
Jakub Dupak
982f93fe13 gccrs: Fix type confusion in coercion
There was a mismatch between a manual discriminant test and the static cast.

gcc/rust/ChangeLog:

	* backend/rust-compile.cc (HIRCompileBase::coercion_site1): Fix wrong cast

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16 19:04:37 +01:00
Pierre-Emmanuel Patry
5757c304b5 gccrs: Fix ICE when emitting an error during cfg strip
When an error was emitted during the cfg strip pass by the crate loader,
it was ignored and the error state propagated until another pass
(name resolver).

gcc/rust/ChangeLog:

	* rust-session-manager.cc (Session::expansion): Add early break on
	error.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:04:37 +01:00
Raiki Tamura
1e1e3814ff gccrs: Fix CanonicalPath for inherent impl
gcc/rust/ChangeLog:

	* util/rust-canonical-path.h: Add new segment kind for inherent impl.
	* resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Use it.
	* resolve/rust-ast-resolve-toplevel.h: Use it.

Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2024-01-16 19:04:37 +01:00
Owen Avery
b9a046cf4c gccrs: Fix spelling
gcc/rust/ChangeLog:

	* ast/rust-expr.h: Fix spelling of "doesn't".
	* backend/rust-compile-expr.cc: Fix spelling of "accessors".
	* backend/rust-compile-implitem.h: Fix spelling of "normal".
	* backend/rust-constexpr.cc: Fix spelling of "actual".

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16 19:04:37 +01:00
Marc Poulhiès
af2be5b555 gccrs: Add debug helper to dump HIR
Add simple debug wrapper to dump HIR nodes on stderr.
Similar to what we already have for AST.

gcc/rust/ChangeLog:

	* hir/rust-hir-dump.cc (Dump::debug): New.
	(debug): New.
	* hir/rust-hir-dump.h (debug): New.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16 19:04:37 +01:00
Philip Herron
e47a980566 gccrs: port over readonly_error from c-family for lvalue assignment checks
Fixes #2391

gcc/rust/ChangeLog:

	* Make-lang.in: fixup formatting
	* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): remove old check
	* rust-session-manager.cc (Session::compile_crate): call new lint
	* resolve/rust-ast-verify-assignee.h: Removed.
	* checks/errors/rust-readonly-check.cc: New file.
	* checks/errors/rust-readonly-check.h: New file.

gcc/testsuite/ChangeLog:

	* rust/compile/wrong_lhs_assignment.rs: update error message
	* rust/compile/issue-2391.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16 19:04:37 +01:00
Muhammad Mahad
718b65a93d gccrs: [E0617] attempt for invalid type variable in variadic function
There are some certain rust types must be cast before
passing them to a variadic function, because of arcane
ABI rules dictated by the C standard. To fix the error,
cast the value to the type specified by the error message.

gcc/rust/ChangeLog:

	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit):
	Added ErrorCode & more fixit hints.

gcc/testsuite/ChangeLog:

	* rust/compile/variadic.rs: Added new checks.

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
2024-01-16 19:04:37 +01:00
Philip Herron
95703bb75e gccrs: Remove HIR::ForLoopExpr
This will end up getting desugared into a LoopExpr with a MatchExpr body.

gcc/rust/ChangeLog:

	* backend/rust-compile-block.h: remove HIR::ForLoopExpr
	* backend/rust-compile-expr.h: likewise
	* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): likewise
	* checks/errors/privacy/rust-privacy-reporter.h: likewise
	* checks/errors/rust-const-checker.cc (ConstChecker::visit): likewise
	* checks/errors/rust-const-checker.h: likewise
	* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): likewise
	* checks/errors/rust-unsafe-checker.h: likewise
	* checks/lints/rust-lint-marklive.h: likewise
	* hir/rust-ast-lower.cc (ASTLoweringExprWithBlock::visit): likewise
	* hir/rust-hir-dump.cc (Dump::visit): likewise
	* hir/rust-hir-dump.h: likewise
	* hir/tree/rust-hir-expr.h (class ForLoopExpr): likewise
	* hir/tree/rust-hir-full-decls.h (class ForLoopExpr): likewise
	* hir/tree/rust-hir-visitor.h: likewise
	* hir/tree/rust-hir.cc (ForLoopExpr::as_string): likewise
	(ForLoopExpr::accept_vis): likewise
	* typecheck/rust-hir-type-check-expr.h: likewise

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2024-01-16 19:04:37 +01:00
Marc Poulhiès
0a99bfe15a gccrs: Minor typo fix
Fix varadic -> variadic

gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::visit): Fix typo in varIadic.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Likewise.
	* rust-backend.h (function_type_varadic): Rename into ...
	(function_type_variadic): ... this.
	* rust-gcc.cc (function_type_varadic): Rename into ...
	(function_type_variadic): ... this.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Likewise.
	* typecheck/rust-tyty.h (is_varadic): Renamed into ...
	(is_variadic): ... this.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16 19:04:37 +01:00
Pierre-Emmanuel Patry
0a2219668d gccrs: Add license text to libproc_macro rust interface
The license text was missing in rust files producing the libproc_macro
interface to the libproc_macro_internal library.

libgrust/ChangeLog:

	* libproc_macro/bridge.rs: Add license text.
	* libproc_macro/bridge/ffistring.rs: Likewise.
	* libproc_macro/bridge/group.rs: Likewise.
	* libproc_macro/bridge/ident.rs: Likewise.
	* libproc_macro/bridge/literal.rs: Likewise.
	* libproc_macro/bridge/punct.rs: Likewise.
	* libproc_macro/bridge/span.rs: Likewise.
	* libproc_macro/bridge/token_stream.rs: Likewise.
	* libproc_macro/group.rs: Likewise.
	* libproc_macro/ident.rs: Likewise.
	* libproc_macro/lib.rs: Likewise.
	* libproc_macro/literal.rs: Likewise.
	* libproc_macro/punct.rs: Likewise.
	* libproc_macro/span.rs: Likewise.
	* libproc_macro/token_stream.rs: Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16 19:04:36 +01:00
Marc Poulhiès
5a5c9f5221 gccrs: trivial typo fix.
Fix subsititions -> substitutions

gcc/rust/ChangeLog:

	* backend/rust-compile-base.cc (HIRCompileBase::compile_function):
	Fix typo in substitutions.
	(HIRCompileBase::resolve_method_address): Likewise.
	* backend/rust-compile-extern.h (CompileExternItem::visit):
	Likewise.
	* backend/rust-compile-implitem.cc (CompileTraitItem::visit):
	Likewise.
	* backend/rust-compile-intrinsic.cc (maybe_override_ctx):
	Likewise.
	* backend/rust-compile-item.cc (CompileItem::visit): Likewise.
	* backend/rust-compile-resolve-path.cc
	(HIRCompileBase::query_compile): Likewise.
	* typecheck/rust-coercion.cc (TypeCoercionRules::do_coercion):
	Likewise.
	* typecheck/rust-hir-type-check-item.cc
	(TypeCheckItem::ResolveImplBlockSelfWithInference): Likewise.
	* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::visit):
	Likewise.
	* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit):
	Likewise.
	* typecheck/rust-tyty.cc (BaseType::has_subsititions_defined):
	Renamed into ...
	(BaseType::has_substitutions_defined): ... this.
	(ADTType::is_equal): Fix typo in substitutions.
	(handle_substitions): Likewise.
	(FnType::is_equal): Likewise.
	(FnType::handle_substitions): Likewise.
	* typecheck/rust-tyty.h (has_subsititions_defined): Renamed into
	...
	(has_substitutions_defined): ... this.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16 19:04:36 +01:00
Owen Avery
b786f697dd gccrs: Add intrinsics::assume
gcc/rust/ChangeLog:

	* backend/rust-compile-intrinsic.cc
	(get_identifier): Add declaration.
	(assume_handler): New.
	(generic_intrinsics): Add assume_handler entry.

gcc/testsuite/ChangeLog:

	* rust/compile/assume.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16 19:04:36 +01:00
Owen Avery
a05079fa6c gccrs: Memoize Backend::wchar_type
gcc/rust/ChangeLog:

	* rust-gcc.cc
	(Backend::wchar_type): Store static wchar tree.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16 19:04:36 +01:00
Owen Avery
bf6fcd8790 gccrs: Remove unused complex number support
gcc/rust/ChangeLog:

	* rust-backend.h
	(complex_type): Remove.
	(complex_constant_expression): Remove.
	(real_part_expression): Remove.
	(imag_part_expression): Remove.
	(complex_expression): Remove.
	* rust-gcc.cc
	(complex_type): Remove.
	(complex_constant_expression): Remove.
	(real_part_expression): Remove.
	(imag_part_expression): Remove.
	(complex_expression): Remove.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16 19:04:36 +01:00
Owen Avery
879ba4e8ca gccrs: Use namespace definition to simplify function declarations
gcc/rust/ChangeLog:

	* rust-gcc.cc
	(namespace Backend):
	Use namespace definition instead of qualified names.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16 19:04:36 +01:00
liushuyu
9924c7485d gccrs: rust-compile-intrinsic: add copy intrinsics ...
... also made `copy_nonoverlapping` handler more generic

gcc/rust/ChangeLog:
	* backend/rust-compile-intrinsic.cc: add `copy`
	intrinsics and make `copy_nonoverlapping` handler more generic

Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
2024-01-16 19:04:36 +01:00
liushuyu
4985bfcc6d gccrs: rust-builtins: add likely and unlikey intrinsics
gcc/rust/ChangeLog:
	* backend/rust-builtins.cc: add `expect` builtin definition.
	* backend/rust-compile-intrinsic.cc: add `likely` and `unlikely`
	intrinsics handler.

Signed-off-by: Zixing Liu <liushuyu011@gmail.com>
2024-01-16 19:04:36 +01:00
Owen Avery
b1b42beea3 gccrs: Rename "rust_error_codes.def" to "rust-error-codes.def"
gcc/rust/ChangeLog:

	* rust_error_codes.def: Moved to...
	* rust-error-codes.def: ...here...
	* rust-diagnostics.h: ...and update references.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16 19:04:36 +01:00