]>
git.ipfire.org Git - people/ms/gcc.git/log
Arthur Cohen [Wed, 1 Mar 2023 10:03:24 +0000 (11:03 +0100)]
hir: Refactor ASTLoweringStmt to source file.
gcc/rust/ChangeLog:
* Make-lang.in: Add rust-ast-lower-stmt.o
* hir/rust-ast-lower-stmt.h: Move definitions to...
* hir/rust-ast-lower-stmt.cc: ...here.
mxlol233 [Wed, 1 Mar 2023 11:31:19 +0000 (19:31 +0800)]
Add feature gate definition for `extern_types`.
This commit add a basic implementation to gating `ExternalTypeItem` AST node.
gcc/rust/ChangeLog:
* checks/errors/rust-feature-gate.cc: Add definition
for `extern_types`.
* checks/errors/rust-feature-gate.h: Likewise.
* checks/errors/rust-feature.cc: Likewise.
* checks/errors/rust-feature.h: Likewise.
gcc/testsuite/ChangeLog:
* rust/compile/feature_extern_types.rs:New file.
Signed-off-by: Xiao Ma <mxlol233@outlook.com>
Owen Avery [Mon, 27 Feb 2023 16:18:56 +0000 (11:18 -0500)]
Fix assignment operator overloads for AST and HIR patterns
gcc/rust/ChangeLog:
* ast/rust-pattern.h
(StructPatternElements::operator=): Clear vector before inserting.
(TupleStructItemsNoRange::operator=): Clear vector before inserting.
(TupleStructItemsRange::operator=): Clear vectors before inserting.
(TuplePatternItemsMultiple::operator=): Clear vector before inserting.
(TuplePatternItemsRanged::operator=): Clear vectors before inserting.
(SlicePattern::operator=): Clear vector before inserting.
(AltPattern::operator=): Clear vector before inserting.
* hir/tree/rust-hir-pattern.h
(StructPatternElements::operator=): Clear vector before inserting.
(TupleStructItemsNoRange::operator=): Clear vector before inserting.
(TupleStructItemsRange::operator=): Clear vectors before inserting.
(TuplePatternItemsMultiple::operator=): Clear vector before inserting.
(TuplePatternItemsRanged::operator=): Clear vectors before inserting.
(SlicePattern::operator=): Clear vector before inserting.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
bl7awy [Tue, 28 Feb 2023 17:53:01 +0000 (20:53 +0300)]
typecheck: Fix casting error behind generics
gcc/rust/ChangeLog:
* typecheck/rust-casts.cc (TypeCastRules::cast_rules): Perform destructure on `from` type.
gcc/testsuite/ChangeLog:
* rust/compile/cast_generics.rs: New test.
Signed-off-by: Mahmoud Mohamed <mahadelr19@gmail.com>
Owen Avery [Mon, 27 Feb 2023 16:02:02 +0000 (11:02 -0500)]
Change struct StructPatternElements into class
gcc/rust/ChangeLog:
* ast/rust-pattern.h
(struct StructPatternElements): Change to class.
(class StructPatternElements): Change from struct.
* hir/tree/rust-hir-pattern.h
(struct StructPatternElements): Change to class.
(class StructPatternElements): Change from struct.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Mon, 27 Feb 2023 15:23:19 +0000 (10:23 -0500)]
Replace gcc_unreachable with rust_sorry_at
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-pattern.cc
(TypeCheckPattern::visit): Improve error messages.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Owen Avery [Mon, 20 Feb 2023 21:05:41 +0000 (16:05 -0500)]
Fix formatting
gcc/rust/ChangeLog:
* hir/tree/rust-hir-pattern.h
(class TupleStructItemsNoRange): Fix formatting.
(class TupleStructItemsRange): Fix formatting.
(class TuplePatternItemsMultiple): Fix formatting.
(class TuplePatternItemsRanged): Fix formatting.
(class SlicePattern): Fix formatting.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Pierre-Emmanuel Patry [Tue, 28 Feb 2023 16:34:31 +0000 (17:34 +0100)]
ast: Add RestPattern AST node
Add the RestPattern AST node representing ".." code in some rust
context. This commit also provides the different visitors for this node.
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add visitor.
* ast/rust-ast-dump.h: Add visitor prototype.
* ast/rust-ast-full-decls.h (class RestPattern): Add forward
declaration for class RestPattern.
* ast/rust-ast-visitor.h: Add visitor prototype.
* ast/rust-ast.cc (RestPattern::accept_vis): Add function to
accept a foreign visitor.
* ast/rust-pattern.h (class RestPattern): Add class RestPattern.
* checks/errors/rust-feature-gate.h: Add visitor prototype.
* expand/rust-attribute-visitor.cc (AttrVisitor::visit): Add
visitor implementation.
* expand/rust-attribute-visitor.h: Add visitor prototype.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Add
visitor implementation.
* hir/rust-ast-lower-base.h: Add visitor prototype.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Add
visitor implementation.
* resolve/rust-ast-resolve-base.h: Add visitor prototype.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit):
Add visitor implementation.
* resolve/rust-early-name-resolver.h: Add visitor prototype.
* util/rust-attributes.cc (AttributeChecker::visit): Add visitor
implementation.
* util/rust-attributes.h: Add visitor prototype.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Philip Herron [Tue, 28 Feb 2023 19:07:11 +0000 (19:07 +0000)]
gccrs: Remove cmp_autoderef_mode hack from old autoderef
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-tyty-cmp.h: remove
* typecheck/rust-tyty.cc (set_cmp_autoderef_mode): likewise
(reset_cmp_autoderef_mode): likewise
* typecheck/rust-tyty.h (set_cmp_autoderef_mode): likewise
(reset_cmp_autoderef_mode): likewise
Philip Herron [Mon, 27 Feb 2023 19:16:00 +0000 (19:16 +0000)]
gccrs: Fix method resolution to use TryCoerce
Rust allows us to call generic pointer methods on pointers so in non
generic contexts the old code using the bad can_eq interface couldn't
handle this case. So taking advantage of our new unify_and interface to try
and infer when required we can start using our TryCoerce interface to reuse
existing code to assemble possible candidates more acurately using the
existing coercion rules.
Fixes #1901 #878
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-coercion.cc (TypeCoercionRules::Coerce): Add new try_flag
(TypeCoercionRules::TypeCoercionRules): set new try flag
(TypeCoercionRules::do_coercion): default to a final unify_and in the else case
(TypeCoercionRules::coerce_unsafe_ptr): cannot coerce to a ptr from ref during autoderef
(TypeCoercionRules::coerce_borrowed_pointer): respect coerceable mutability
* typecheck/rust-coercion.h: update header
* typecheck/rust-hir-dot-operator.cc (MethodResolver::select): use new TryCoerce interface
(MethodResolver::append_adjustments): ensure we maintain adjustment mappings
* typecheck/rust-hir-dot-operator.h: add new method append_adjustments
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): extra logging
gcc/testsuite/ChangeLog:
* rust/compile/issue-1901.rs: New test.
Philip Herron [Mon, 27 Feb 2023 17:39:09 +0000 (17:39 +0000)]
gccrs: bug-fix implicit inference checks
When generating implicit inference variables we can miss cases where the
other side might be another inference variable too but it runs the risk of
generating unending inference cycles needing more info but if they other
side is a non general inference variables like <integer> or <float> this
is safe to do so and allows us to infer mroe cases.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-unify.cc (UnifyRules::go): fix inference check
Philip Herron [Mon, 27 Feb 2023 17:05:13 +0000 (17:05 +0000)]
gccrs: autoderef unconstify so we can use in non const contexts
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* backend/rust-compile-base.h: unconsify
* backend/rust-compile.cc (HIRCompileBase::coercion_site): likewise
(HIRCompileBase::coercion_site1): likewise
* typecheck/rust-autoderef.cc (Adjuster::try_deref_type): likewise
(Adjuster::try_raw_deref_type): likewise
(Adjuster::try_unsize_type): likewise
(AutoderefCycle::cycle): likewise
(AutoderefCycle::try_autoderefed): likewise
* typecheck/rust-autoderef.h: likewise
* typecheck/rust-coercion.cc (TypeCoercionRules::select): likewise
* typecheck/rust-coercion.h: likewise
* typecheck/rust-hir-dot-operator.cc (MethodResolver::Probe): likewise
(MethodResolver::select): likewise
* typecheck/rust-hir-dot-operator.h: likewise
Philip Herron [Mon, 27 Feb 2023 16:38:41 +0000 (16:38 +0000)]
gccrs: Only emit errors during type-bounds checking when required
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-unify.cc (UnifyRules::go): respect the emit_errors flag
Philip Herron [Mon, 27 Feb 2023 14:16:29 +0000 (14:16 +0000)]
gccrs: Make coercion sites autoderef cycle optional
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-casts.cc (TypeCastRules::check): update to new interface
* typecheck/rust-coercion.cc (TypeCoercionRules::Coerce): likewise
(TypeCoercionRules::TryCoerce): likewise
(TypeCoercionRules::TypeCoercionRules): likewise
* typecheck/rust-coercion.h: likewise
* typecheck/rust-type-util.cc (coercion_site): likewise
Philip Herron [Mon, 27 Feb 2023 13:34:30 +0000 (13:34 +0000)]
gccrs: Allow infer vars on the lhs too
We should allow implicit inference on the expected side too not just the
receiver.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-unify.cc (UnifyRules::go): allow lhs infer vars
Philip Herron [Sun, 26 Feb 2023 22:08:26 +0000 (22:08 +0000)]
gccrs: Generic pointers are coerceable
This is a complex type-system change where it begins out journey to get
rid of our can_eq interface. Rust allows:
let x:*mut T
let y = x as *mut u8;
Which requires us to consider find a way to infer what T should be so as
to keep unify happy. This means we need to introduce a new unify_and
interface where we can optionally inject inference variables as well as
only commit the inference variable joins when they are sucsessful.
So for this case we can then inject an implicit inference variables for T
that can unify against u8 to make this a valid type-resolution.
Fixes #1930
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::resolve_method_address): update to new inteface
* typecheck/rust-coercion.cc (TypeCoercionRules::coerce_unsafe_ptr): likewise
(TypeCoercionRules::coerce_borrowed_pointer): likewise
* typecheck/rust-hir-type-check.h: likewise
* typecheck/rust-type-util.cc (unify_site_and): new interface to allow for infer and commit
* typecheck/rust-type-util.h (unify_site_and): likewise
* typecheck/rust-typecheck-context.cc (TypeCheckContext::clear_type): new interface
* typecheck/rust-unify.cc (UnifyRules::UnifyRules): update
(UnifyRules::Resolve): new optional flags for commit and infer
(UnifyRules::go): likewise
(UnifyRules::expect_adt): refactor to use new interface
(UnifyRules::expect_reference): likewise
(UnifyRules::expect_pointer): likewise
(UnifyRules::expect_array): likewise
(UnifyRules::expect_slice): likewise
(UnifyRules::expect_fndef): likewise
(UnifyRules::expect_fnptr): likewise
(UnifyRules::expect_tuple): likewise
(UnifyRules::expect_closure): likewise
* typecheck/rust-unify.h: refactor interface
gcc/testsuite/ChangeLog:
* rust/compile/issue-1930.rs: New test.
Philip Herron [Sun, 26 Feb 2023 18:30:49 +0000 (18:30 +0000)]
gccrs: refactor unify commit as a static function from unify code
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-unify.cc (UnifyRules::Resolve): refactor
(UnifyRules::commit): refactor
* typecheck/rust-unify.h: likewise
Philip Herron [Sun, 26 Feb 2023 22:36:20 +0000 (22:36 +0000)]
gccrs: Fix ICE in ADTType::is_concrete
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-tyty.cc (ADTType::is_concrete): need to consider if is a num_variant
* typecheck/rust-tyty.h: refactor to cc file
Pierre-Emmanuel Patry [Mon, 27 Feb 2023 13:08:10 +0000 (14:08 +0100)]
testsuite: Add test with missing semicolon
Add a test to the testsuite in order to verify the presence of a
semicolon at the end of an external type item declaration.
gcc/testsuite/ChangeLog:
* rust/compile/extern_type_item_missing_semi.rs: New failing
test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Mon, 27 Feb 2023 13:07:00 +0000 (14:07 +0100)]
testsuite: Add extern type item test
Add a test for extern type item declaration.
gcc/testsuite/ChangeLog:
* rust/compile/extern_type_item.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Pierre-Emmanuel Patry [Mon, 27 Feb 2023 09:10:51 +0000 (10:10 +0100)]
parser: Parse external type item
Add the code to parse type item declaration within an extern block.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_external_type_item):
Add function to parser an external type item.
(Parser::parse_external_item):
Add identification and parsing for external type items.
* parse/rust-parse.h:
Add parser_external_type_item prototype.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
omkar-mohanty [Thu, 16 Feb 2023 04:40:24 +0000 (10:10 +0530)]
Implement and test include_str eager expansion
builtins: Implement eager expansion for include_str!()
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc
(MacroBuiltin::include_str_handler): eager expansion
(make_macro_path_str): macto to string
(parse_single_string_literal): check for eager invocation
(MacroBuiltin::assert_handler): eager expansion
(MacroBuiltin::include_bytes_handler): eager expansion
(MacroBuiltin::include_str_handler): eager expansion
(MacroBuiltin::compile_error_handler): eager expansion
(MacroBuiltin::include_handler): eager expansion
gcc/testsuite/ChangeLog:
* rust/compile/builtin_macro_eager3.rs: New test.
Signed-off-by: omkar-mohanty <franzohouser@gmail.com>
Arthur Cohen [Thu, 23 Feb 2023 14:11:04 +0000 (15:11 +0100)]
parser: Parse `default` impl Functions and Methods
gcc/rust/ChangeLog:
* ast/rust-item.h (class Method): Add `is_default` field.
(class Function): Likewise.
* parse/rust-parse-impl.h (Parser::parse_item): Add nice error when
parsing `default` outside of an `impl` block
(Parser::parse_trait_impl_item): Allow parsing functions
or methods when seeing `default`.
gcc/testsuite/ChangeLog:
* rust/compile/parse_invalid_specialization.rs: New test.
* rust/compile/parse_specialization.rs: New test.
* rust/compile/default_not_a_kw.rs: New test.
Pierre-Emmanuel Patry [Thu, 23 Feb 2023 18:00:07 +0000 (19:00 +0100)]
typecheck: Refactor cast_site
Refactor cast_site to be a simple function in rust-type-util.h.
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::cast_site):
Remove cast_site.
* typecheck/rust-hir-type-check-base.h: Remove cast_site
prototype.
* typecheck/rust-type-util.cc (cast_site): Add cast_site.
* typecheck/rust-type-util.h (cast_site): Add cast_site
prototype.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Arthur Cohen [Thu, 23 Feb 2023 15:59:20 +0000 (16:59 +0100)]
ast: Add proper visitors for ExternalTypeItem
gcc/rust/ChangeLog:
* ast/rust-item.h: Add non-const `get_visibility` to ExternalTypeItem.
* ast/rust-ast-dump.cc (Dump::visit): Add implementation for ExternalTypeItem.
* expand/rust-attribute-visitor.cc (AttrVisitor::visit): Likewise.
Arthur Cohen [Thu, 23 Feb 2023 15:50:39 +0000 (16:50 +0100)]
ast: Add ExternalTypeItem node
gcc/rust/ChangeLog:
* ast/rust-item.h (class ExternalTypeItem): New class.
* ast/rust-ast.cc (ExternalTypeItem::as_string): New function.
(ExternalTypeItem::accept_vis): Likewise.
* ast/rust-ast-full-decls.h (class ExternalTypeItem): Declare class.
* ast/rust-ast-dump.cc (Dump::visit): Add base visitor for ExternalTypeItem.
* ast/rust-ast-dump.h: Likewise.
* ast/rust-ast-visitor.h: Likewise.
* checks/errors/rust-feature-gate.h: Likewise.
* expand/rust-attribute-visitor.cc (AttrVisitor::visit): Likewise.
* expand/rust-attribute-visitor.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise.
* resolve/rust-ast-resolve-base.h: Likewise.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise.
* resolve/rust-early-name-resolver.h: Likewise.
* util/rust-attributes.cc (AttributeChecker::visit): Likewise.
* util/rust-attributes.h: Likewise.
Arthur Cohen [Tue, 21 Feb 2023 12:51:54 +0000 (13:51 +0100)]
macro_invoc_lexer: Add `split_current_token` implementation
gcc/rust/ChangeLog:
* expand/rust-macro-invoc-lexer.cc (MacroInvocLexer::split_current_token):
Add proper implementation.
gcc/testsuite/ChangeLog:
* rust/compile/expand_macro_qual_path_in_type.rs: New test.
Arthur Cohen [Thu, 23 Feb 2023 15:02:43 +0000 (16:02 +0100)]
Merge remote-tracking branch 'upstream/tschwinge/merge-upstream'
Arthur Cohen [Wed, 15 Feb 2023 15:53:41 +0000 (16:53 +0100)]
parser: Add parsing of auto traits
This adds enough handling to start parsing `auto` traits but not handle
them in the AST, lowering phase or HIR yet.
The feature is named `optin_builtin_traits` in Rust 1.49 but changes to
`auto_traits` later down the line. So we'll need to take care of this later
on.
Finally, this also changes the way the lexer detects if a string is a
keyword or not. We relied on a call to `std::lower_bound` to figure
out if a string was contained in an array or not, and this ended up
causing issues when adding new keywords. We can instead switch to a
simple hashmap and search for the key. The code *might* be less
optimized (unsure) but it is definitely simpler and easier to read.
Fixes #1814
gcc/rust/ChangeLog:
* ast/rust-item.h (class Trait): Add `has_auto` field.
* checks/errors/rust-feature.cc: Add handling for `feature(optin_builtin_traits)`
* checks/errors/rust-feature.h: Likewise.
* lex/rust-lex.cc: Fix keyword classification using hashmap.
* lex/rust-token.h: Add `auto` keyword token.
* parse/rust-parse-impl.h (Parser::parse_vis_item): Parse auto traits
on `auto` keyword.
gcc/testsuite/ChangeLog:
* rust/compile/auto_trait_invalid.rs: New test.
* rust/compile/auto_trait_valid.rs: New test.
Pierre-Emmanuel Patry [Wed, 22 Feb 2023 09:44:16 +0000 (10:44 +0100)]
typecheck: Refactor coercion_site
Refactor coercion_site to be a simple function in rust-type-util.h
instead of a static function in TypeCheckBase.
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-resolve.cc (TraitItemReference::resolve_item):
Remove TypeCheckBase namespace qualifier.
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::coercion_site):
Remove coercion_site function.
* typecheck/rust-hir-type-check-base.h: Remove coercion_site
prototype.
* typecheck/rust-type-util.cc (coercion_site): Add coercion_site
function.
* typecheck/rust-type-util.h (coercion_site): Add coercion_site
prototype.
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit):
Remove TypeCheckBase namespace qualifier.
(TypeCheckMethodCallExpr::check): Remove TypeCheckBase namespace
qualifier.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Thomas Schwinge [Wed, 22 Feb 2023 07:43:44 +0000 (08:43 +0100)]
Merge upstream (dummy), 2023-02-21 "Rust front-end update"
In #1908 'Merge upstream, last commit before 2023-02-21 "Rust front-end update"'
we merged commit
ecc863e85efe259c799515de0c38c2297b0e3bd7 from upstream GCC
master branch.
This one now merges the 2023-02-21 "Rust front-end update", commits
ecc863e85efe259c799515de0c38c2297b0e3bd7 ..
ecb409b23b86363fa085ec32e89e1aeda002cb70 :
-
7e7a95880443 gccrs: Fix missing dead code analysis ICE on local enum definition
-
708085446189 gccrs: visibility: Rename get_public_vis_type -> get_vis_type
-
1e8eb1022009 gccrs: dump: Emit visibility when dumping items
-
543ba35905b9 gccrs: Add catch for recusive type queries
-
d072b4a5164e gccrs: testing: try loop in const function
-
980bd25e2560 gccrs: ast: dump assignment and compound assignment expr
-
aeed747093c2 gccrs: ast: dump If expressions
-
00e0684a78a3 gccrs: builtins: Move implementation into source file
-
79434fabf762 gccrs: Track DefId on ADT variants
-
31b77593edbf gccrs: Ensure uniqueness on Path probe's
-
a5d3586a9b15 gccrs: Support looking up super traits for trait items
-
8d02ef57a691 gccrs: ast: dump: add emit_generic_params helper
-
4c807ef70db1 gccrs: ast: dump: add format_{tuple,struct}_field helpers
-
0a762d204980 gccrs: ast: dump structs, enums and unions
-
ab6d8ad3f595 gccrs: intrinsics: Add data prefetching intrinsics
-
570415e75c42 gccrs: fix ICE on missing closing paren
-
a08f265625e5 gccrs: mappings: Add MacroInvocation -> MacroRulesDef mappings
-
295cd2650888 gccrs: rust-ast-resolve-item: Add note about resolving glob uses
-
2f1035fc91ce gccrs: ast: Add accept_vis() method to `GenericArg`
-
522197469179 gccrs: early-name-resolver: Add simple macro name resolution
-
13556413e384 gccrs: Support type resolution on super traits on dyn objects
-
f49e25282413 gccrs: Add mappings for fn_once lang item
-
2d7661e76e12 gccrs: Add ABI mappings for rust-call to map to ABI::RUST
-
59bee4d4663e gccrs: Method resolution must support multiple candidates
-
b1510ce0fc77 gccrs: ast: dump: fix extra newline in block without tail
-
0a9114c151b8 gccrs: ast: dump: minor fixups to IfExpr formatting
-
c091fd5f4a2d gccrs: ast: dump: ComparisonExpr and LazyBooleanExpr
-
f26e9ca3e9aa gccrs: ast: dump: ArrayExpr
-
d1db46191ea5 gccrs: ast: dump: various simple Exprs
-
173f98ae49d8 gccrs: ast: dump: RangeExprs
-
74065c000e33 gccrs: Refactor TraitResolver to not require a visitor
-
acbaadfa46d0 gccrs: ast: dump TypeAlias
-
8f0b1526e04c gccrs: Support outer attribute handling on trait items just like normal items
-
421494b5929f gccrs: dump: Emit visibility when dumping items
-
31150a6366db gccrs: dump: Dump items within modules
-
2f16df1b4433 gccrs: dump: Fix module dumping
-
e535b7b3e385 gccrs: ast: Module: unloaded module and inner attributes
-
ec28fdb6aad3 gccrs: dump: Dump macro rules definition
-
643ec1c253d9 gccrs: Add check for recursive trait cycles
-
e2647e5e5ad1 gccrs: ast: Refactor ASTFragment -> Fragment class
-
68e743090df6 gccrs: rust: Replace uses of ASTFragment -> Fragment
-
b326cced19e5 gccrs: ast: Improve Fragment API
-
ed75e142a708 gccrs: Add missing fn_once_output langitem
-
870dd9d5d3c5 gccrs: Refactor expression hir lowering into cc file
-
9e19f329e523 gccrs: Formatting cleanup in HIR lowering pattern
-
977e0e5227d4 gccrs: Add name resolution for closures
-
4d021d9e019d gccrs: Refactor method call type checking
-
898240946ca2 gccrs: Add closures to lints and error checking
-
740a1997228d gccrs: Initial Type resolution for closures
-
699e7e862763 gccrs: Closure support at CallExpr
-
12e94515f894 gccrs: Add missing name resolution to Function type-path segments
-
875f722de5ea gccrs: Add missing hir lowering to function type-path segments
-
51d180fcd7e6 gccrs: Add missing type resolution for function type segments
-
21d19d2cf606 gccrs: Support Closure calls as generic trait bounds
-
a8531cd9a82a gccrs: Implement the inline visitor
-
6ef1089ec27e gccrs: rust: Allow gccrs to build on x86_64-apple-darwin with clang/libc++
-
4d39d3912ffe gccrs: builtins: Rename all bang macro handlers
-
782e070374ac gccrs: intrinsics: Add `sorry_handler` intrinsic handler
-
514284ecd97f gccrs: constexpr: Add `rust_sorry_at` in places relying on init values
-
a7c8f7ee3433 gccrs: intrinsics: Add early implementation for atomic_store_{seqcst, relaxed, release}
-
1c586a1d1c12 gccrs: intrinsics: Add unchecked operation intrinsics
-
cb2cf21cf336 gccrs: intrinsics: Use lambdas for wrapping_<op> intrinsics
-
f4c818c623c0 gccrs: intrinsics: Cleanup error handling around atomic_store_*
-
5b5a0ca77179 gccrs: intrinsics: Implement atomic_load intrinsics
-
aedd97a537cb gccrs: ast: visitor pattern -> overload syntax compatibility layer
-
3b5fb3f89b0f gccrs: ast: transform helper methods to visits and add methods to simplify repeated patterns
-
a56faba96369 gccrs: ast: refer correctly to arguments in docs-strings
-
04a16c58e343 gccrs: ast: Dump unit struct
-
2fc013036041 gccrs: add lang item "phantom_data"
-
b84222899cac gccrs: add Location to AST::Visibility
-
85f69a9b6abd gccrs: typecheck: Fix overzealous `delete` call
-
907d11194ed9 gccrs: ast: add visit overload for references
-
bd2240d30f80 gccrs: ast: Dump where clause and recursively needed nodes
-
59fb0747cc2c gccrs: ast: Dump slice type
-
140a2aed7e1c gccrs: ast: Dump array type
-
971d16cbfade gccrs: ast: Dump raw pointer type
-
c4c859bff8d0 gccrs: ast: Dump never type
-
91409d27d5c5 gccrs: ast: Dump tuple type
-
ee0166fa1b88 gccrs: ast: Dump inferred type
-
ae1f6b3a96dd gccrs: ast: Dump bare function type
-
ca06115eac10 gccrs: ast: Dump impl trait type one bound
-
638f65b20832 gccrs: ast: Dump impl trait type
-
7ed4a0ebc1d1 gccrs: ast: Dump trait object type
-
e311e9b7c591 gccrs: ast: Dump parenthesised type
-
0bb33cb5741e gccrs: ast: Dump trait object type one bound
-
1acb7e02ed82 gccrs: ast: Dump type param type
-
b8863414eda2 gccrs: ast: Dump generic parameters
-
ce13edd879da gccrs: ast: Remove unused include in rust-ast-dump.cc
-
0e44abb1b509 gccrs: ast: Dump remove /* stmp */ comment to not clutter the dump
-
567494f7030b gccrs: ast: Dump no comma after self in fn params if it is the last one
-
78c70a50f744 gccrs: Remove default location. Add visibility location to create_* functions
-
0ef795c3278e gccrs: Improve lexer dump
-
01af669357c4 gccrs: Get rid of make builtin macro
-
32a4659c5e40 gccrs: Refactor name resolver to take a Rib::ItemType
-
f7c258b29118 gccrs: Add closure binding's tracking to name resolution
-
eb1202224f8e gccrs: Add capture tracking to the type info for closures
-
92389b46a96c gccrs: Add initial support for argument capture of closures
-
e7a69d4533ad gccrs: Fix undefined behaviour issues on macos
-
03df9a040c97 gccrs: Skip this debug test case which is failing on the latest mac-os devtools and its only for debug info
-
9f455ed820cc gccrs: Cleanup unused parameters to fix the bootstrap build
-
b9203d82ad27 gccrs: Repair 'gcc/rust/lang.opt' comment
-
064bbd0fe104 gccrs: const evaluator: Remove get_nth_callarg
-
ecb409b23b86 gccrs: add math intrinsics
..., and:
-
e28c5b33b987 Update copyright years.
This merge is done with 'git merge --strategy=ours', so effectively doesn't
merge any changes. Rationale: those commits are taken from GCC/Rust master
branch, and any remaining changes we'd either like to persist, or assess
individually, later.
Pierre-Emmanuel Patry [Tue, 21 Feb 2023 16:29:53 +0000 (17:29 +0100)]
typecheck: Refactor unify_site
Refactor unify_site to be a simple function in rust-type-util.h.
gcc/rust/ChangeLog:
* typecheck/rust-autoderef.cc: Remove TypeCheckBase qualifier.
* typecheck/rust-hir-trait-resolve.cc: Remove TypeCheckBase
qualifier.
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::unify_site):
Remove unify_site.
* typecheck/rust-hir-type-check-base.h: Remove unify_site
header.
* typecheck/rust-hir-type-check.cc (TypeResolution::Resolve):
Remove TypeCheckBase qualifier.
* typecheck/rust-type-util.cc (unify_site): Add unify_site
function.
* typecheck/rust-type-util.h (unify_site): Add unify_site
prototype.
* typecheck/rust-tyty-call.cc (TypeCheckMethodCallExpr::check):
Remove TypeCheckBase qualifier.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Arthur Cohen [Tue, 21 Feb 2023 13:08:10 +0000 (14:08 +0100)]
ci: Run GCC 4.8 job in Ubuntu 18.04 container
We should probably think about building GCC 4.8 from source from time
to time and hosting the image on our Dockerhub, but I think this is okay
as well for now.
ChangeLog:
* .github/workflows/ccpp.yml: Run GCC 4.8 action in ubuntu 18.04 container
Thomas Schwinge [Tue, 21 Feb 2023 21:37:04 +0000 (22:37 +0100)]
Adjust '.github/bors_log_expected_warnings'
Thomas Schwinge [Tue, 21 Feb 2023 20:13:49 +0000 (21:13 +0100)]
Thomas Schwinge [Tue, 21 Feb 2023 19:48:38 +0000 (20:48 +0100)]
Merge commit '
7b8916a6fd098546e4e53e53b37a5153664ba17f ' into HEAD [#1819, #1864, #1885]
Thomas Schwinge [Tue, 21 Feb 2023 19:47:19 +0000 (20:47 +0100)]
Thomas Schwinge [Tue, 21 Feb 2023 12:49:42 +0000 (13:49 +0100)]
Update copyright years.
... which accidentally had gotten reverted in recent
commit
r13-6156-g1e8eb102200902e12c1b00e867e338be0a92c292
"gccrs: dump: Emit visibility when dumping items".
Raiki Tamura [Thu, 15 Dec 2022 17:27:59 +0000 (02:27 +0900)]
gccrs: add math intrinsics
gcc/rust/ChangeLog:
* backend/rust-builtins.cc (BuiltinsContext::setup_math_fns): New functions.
gcc/testsuite/ChangeLog:
* rust/compile/torture/intrinsics-math.rs: New test.
Arthur Cohen [Thu, 17 Nov 2022 15:50:58 +0000 (16:50 +0100)]
gccrs: const evaluator: Remove get_nth_callarg
We only used one path of the C++ folder's get_nth_callarg function:
CALL_EXPR_ARG. Replace all calls to get_nth_callarg by macro calls to
CALL_EXPR_ARG
gcc/rust/ChangeLog:
* backend/rust-constexpr.cc (get_nth_callarg): Remove function.
(rs_bind_parameters_in_call): Use CALL_EXPR_ARG instead.
(potential_constant_expression_1): Likewise.
Thomas Schwinge [Wed, 7 Dec 2022 08:18:26 +0000 (09:18 +0100)]
gccrs: Repair 'gcc/rust/lang.opt' comment
... lost in #1527 commit
138a6260124740208b8f3aff2e38617f43b05fe8
"rust: Add -frust-compile-until option".
gcc/rust/ChangeLog:
* lang.opt: Fix ordering of file.
Philip Herron [Mon, 5 Dec 2022 02:20:55 +0000 (02:20 +0000)]
gccrs: Cleanup unused parameters to fix the bootstrap build
gcc/rust/ChangeLog:
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Remove unused parameters.
* backend/rust-constexpr.cc (constant_value_1): Likewise.
(fold_non_dependent_init): Likewise.
* backend/rust-tree.cc (publicly_uniquely_derived_p): Likewise.
(instantiation_dependent_expression_p): Likewise.
(type_has_nontrivial_copy_init): Likewise.
(is_normal_capture_proxy): Likewise.
(resolve_nondeduced_context): Likewise.
(undeduced_auto_decl): Likewise.
(require_deduced_type): Likewise.
* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise.
* checks/errors/privacy/rust-reachability.cc (ReachabilityVisitor::visit): Likewise.
* checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::visit): Likewise.
* checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise.
* checks/lints/rust-lint-marklive.cc (MarkLive::go): Likewise.
* checks/lints/rust-lint-unused-var.cc (unused_var_walk_fn): Likewise.
* expand/rust-macro-builtins.cc (try_expand_single_string_literal): Likewise.
(try_expand_many_expr): Likewise.
(parse_single_string_literal): Likewise.
(MacroBuiltin::assert_handler): Likewise.
(MacroBuiltin::file_handler): Likewise.
(MacroBuiltin::column_handler): Likewise.
(MacroBuiltin::concat_handler): Likewise.
(MacroBuiltin::env_handler): Likewise.
(MacroBuiltin::line_handler): Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise.
(ASTLoweringBase::handle_doc_item_attribute): Likewise.
* hir/rust-hir-dump.cc (Dump::visit): Likewise.
* hir/tree/rust-hir-full-test.cc (ConstGenericParam::accept_vis): Likewise.
* lex/rust-lex.cc (Lexer::parse_utf8_escape): Likewise.
(Lexer::parse_string): Likewise.
(Lexer::parse_char_or_lifetime): Likewise.
* lex/rust-lex.h: Likewise.
* metadata/rust-export-metadata.cc: Likewise.
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Likewise.
* resolve/rust-ast-resolve-type.cc (ResolveType::visit): Likewise.
(ResolveTypeToCanonicalPath::visit): Likewise.
* resolve/rust-ast-verify-assignee.h: Likewise.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise.
* typecheck/rust-hir-type-check-expr.h: Likewise.
* typecheck/rust-hir-type-check-item.h: Likewise.
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Likewise.
* typecheck/rust-tyty-rules.h: Likewise.
* util/rust-attributes.cc (AttributeChecker::visit): Likewise.
Philip Herron [Mon, 5 Dec 2022 00:31:18 +0000 (00:31 +0000)]
gccrs: Skip this debug test case which is failing on the latest mac-os devtools and its only for debug info
gcc/testsuite/ChangeLog:
* rust/debug/chartype.rs: Skip testcases on Darwin architectures.
Philip Herron [Mon, 7 Nov 2022 13:43:04 +0000 (13:43 +0000)]
gccrs: Fix undefined behaviour issues on macos
This adds missing copy constructors to HIR::PathExprSegment which were
wrongly defaulting to empty vectors when apply specified generic arguments
to method calls.
gcc/rust/ChangeLog:
* hir/tree/rust-hir-expr.h: Add const `get_method_name`.
* hir/tree/rust-hir-full-decls.h (struct GenericArgs): Move from `struct`...
(class GenericArgs): ...to `class`.
* hir/tree/rust-hir-path.h (struct GenericArgs): Likewise.
(class GenericArgs): Clear `type_args` in copy constructor.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Reorder
debug print.
* typecheck/rust-tyty.h: Add default constructors for `SubstitutionArgumentMappings`.
Philip Herron [Fri, 21 Oct 2022 14:43:54 +0000 (15:43 +0100)]
gccrs: Add initial support for argument capture of closures
When we have a closure expression that captures a parent function's
variable we must setup the closure data to contain this. Ignoring
moveability and mutability requires for now, this patch creates the closure
structure with fields for each of the captured variables. When it comes to
compilation of the closure expression in order to support nested closures
we must setup a context of implicit mappings so that for all path
resolution we hit this implicit closure mappings lookups code before any
lookup_var_decl as this decl will not exist so the order here is important
during path resolution which is a similar problem to match expression
destructuring.
Fixes #195
gcc/rust/ChangeLog:
* backend/rust-compile-context.cc (Context::push_closure_context): New function.
(Context::pop_closure_context): Likewise.
(Context::insert_closure_binding): Likewise.
(Context::lookup_closure_binding): Likewise.
* backend/rust-compile-context.h: Declare new functions and closure mappings.
* backend/rust-compile-expr.cc (CompileExpr::visit): Visit captures properly.
(CompileExpr::generate_closure_function): Compile captures properly.
* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve): Check for
closure bindings.
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Compile capture list's
types as well.
gcc/testsuite/ChangeLog:
* rust/execute/torture/closure3.rs: New test.
Philip Herron [Fri, 21 Oct 2022 14:39:52 +0000 (15:39 +0100)]
gccrs: Add capture tracking to the type info for closures
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Pass captures
properly to `TyTy::ClosureType` constructor.
* typecheck/rust-tyty.cc (ClosureType::as_string): Fix string representation.
(ClosureType::clone): Pass `captures` argument.
* typecheck/rust-tyty.h: Add `captures` field.
Philip Herron [Fri, 21 Oct 2022 12:40:40 +0000 (13:40 +0100)]
gccrs: Add closure binding's tracking to name resolution
When we have a closure block referencing variables in a parent function,
we must track what these are. We do this by having a context of closures
so if we have a variable reference and its declared in a rib whose node id
is less than the node id of the closure's node id we know it must be a
captured variable. We also need to iterate all possible closure contexts
as we might be in the case of a nested closure.
Addresses #195
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Use proper closure
contexts.
* resolve/rust-name-resolver.cc (Scope::lookup_decl_type): New function.
(Scope::lookup_rib_for_decl): Likewise.
(Resolver::insert_resolved_name): Insert captured items.
(Resolver::push_closure_context): New function.
(Resolver::pop_closure_context): Likewise.
(Resolver::insert_captured_item): Likewise.
(Resolver::decl_needs_capture): Likewise.
(Resolver::get_captures): Likewise.
* resolve/rust-name-resolver.h: Declare new functions.
Philip Herron [Fri, 21 Oct 2022 11:54:52 +0000 (12:54 +0100)]
gccrs: Refactor name resolver to take a Rib::ItemType
This allows us to track the type of declaration that is stored within a
Rib.
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Add Rib argument.
(ResolveExpr::resolve_closure_param): Likewise.
* resolve/rust-ast-resolve-implitem.h: Likewise.
* resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): Likewise.
(ResolveItem::visit): Likewise.
* resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::visit): Likewise.
* resolve/rust-ast-resolve-pattern.h: Likewise.
* resolve/rust-ast-resolve-stmt.h: Likewise.
* resolve/rust-ast-resolve-toplevel.h: Likewise.
* resolve/rust-ast-resolve-type.h: Likewise.
* resolve/rust-name-resolver.cc (Rib::lookup_decl_type): Likewise.
(Scope::insert): Likewise.
(Resolver::insert_builtin_types): Likewise.
* resolve/rust-name-resolver.h: Likewise.
Philip Herron [Fri, 21 Oct 2022 12:01:43 +0000 (13:01 +0100)]
gccrs: Get rid of make builtin macro
This macro is a mess and a helper method is much better for this case.
gcc/rust/ChangeLog:
* resolve/rust-name-resolver.cc (MKBUILTIN_TYPE): Remove macro.
(Rib::Rib): Remove `mappings` field.
(Resolver::generate_builtins): Use `setup_builtin` instead of macro.
(Resolver::setup_builtin): New function.
* resolve/rust-name-resolver.h: Declare `setup_builtin`, add FIXME
comment.
Raiki Tamura [Wed, 16 Nov 2022 08:15:24 +0000 (17:15 +0900)]
gccrs: Improve lexer dump
gcc/rust/ChangeLog:
* lex/rust-lex.cc (Lexer::Lexer): Add `dump_lex` boolean flag.
(Lexer::skip_token): Dump tokens if flag is enabled.
(Lexer::dump_and_skip): New function.
* lex/rust-lex.h: Include optional.h and declare functions.
* parse/rust-parse-impl.h (Parser::debug_dump_lex_output): Remove old
unused function.
* parse/rust-parse.h: Likewise.
* rust-session-manager.cc (Session::compile_crate): Pass lexer dump
option to lexer.
(Session::dump_lex): New function.
* util/rust-optional.h: Add missing constructor.
Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
Dave [Wed, 16 Nov 2022 23:06:44 +0000 (17:06 -0600)]
gccrs: Remove default location. Add visibility location to create_* functions
gcc/rust/ChangeLog:
* ast/rust-item.h: Remoe default location for Visibility class.
* parse/rust-parse-impl.h (Parser::parse_visibility): Pass proper location
when instantiating visibilities.
Jakub Dupak [Wed, 16 Nov 2022 13:16:51 +0000 (14:16 +0100)]
gccrs: ast: Dump no comma after self in fn params if it is the last one
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Fix dumping of fn params.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Wed, 16 Nov 2022 13:03:07 +0000 (14:03 +0100)]
gccrs: ast: Dump remove /* stmp */ comment to not clutter the dump
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Remove extraneous string when
dumping statements.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Wed, 16 Nov 2022 12:59:16 +0000 (13:59 +0100)]
gccrs: ast: Remove unused include in rust-ast-dump.cc
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc: Remove unused include.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Wed, 16 Nov 2022 12:58:50 +0000 (13:58 +0100)]
gccrs: ast: Dump generic parameters
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
* ast/rust-ast-dump.h: Likewise.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Tue, 15 Nov 2022 17:39:41 +0000 (18:39 +0100)]
gccrs: ast: Dump type param type
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Tue, 15 Nov 2022 16:02:00 +0000 (17:02 +0100)]
gccrs: ast: Dump trait object type one bound
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Tue, 15 Nov 2022 14:52:34 +0000 (15:52 +0100)]
gccrs: ast: Dump parenthesised type
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Tue, 15 Nov 2022 14:49:05 +0000 (15:49 +0100)]
gccrs: ast: Dump trait object type
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Tue, 15 Nov 2022 14:44:48 +0000 (15:44 +0100)]
gccrs: ast: Dump impl trait type
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Tue, 15 Nov 2022 14:42:08 +0000 (15:42 +0100)]
gccrs: ast: Dump impl trait type one bound
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Mon, 7 Nov 2022 16:09:33 +0000 (17:09 +0100)]
gccrs: ast: Dump bare function type
+ Return FunctionQualifiers as ref to work in ast dump
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
* ast/rust-ast-dump.h: Add missing getter declaration.
* ast/rust-ast-full-test.cc (BareFunctionType::as_string): Fix bare function
string representation.
* ast/rust-type.h (class BareFunctionType): Declare said getter.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Sun, 6 Nov 2022 20:29:56 +0000 (21:29 +0100)]
gccrs: ast: Dump inferred type
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add missing visitor.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Sun, 6 Nov 2022 20:27:49 +0000 (21:27 +0100)]
gccrs: ast: Dump tuple type
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add missing tuple type visitor.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Sun, 6 Nov 2022 20:23:12 +0000 (21:23 +0100)]
gccrs: ast: Dump never type
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add missing never type visitor.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Sun, 6 Nov 2022 20:21:34 +0000 (21:21 +0100)]
gccrs: ast: Dump raw pointer type
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add missing RawPointer visitor.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Sun, 6 Nov 2022 19:54:40 +0000 (20:54 +0100)]
gccrs: ast: Dump array type
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add missing array visitor
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Sun, 6 Nov 2022 19:49:17 +0000 (20:49 +0100)]
gccrs: ast: Dump slice type
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add missing slice visitor.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Fri, 4 Nov 2022 22:48:12 +0000 (23:48 +0100)]
gccrs: ast: Dump where clause and recursively needed nodes
This is currently needed for lifetimes to use the existing infrastructure.
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add missing visitors.
* ast/rust-ast-dump.h: Likewise.
* ast/rust-ast.h: Add `get_lifetime_bounds` method.
* ast/rust-item.h: Add missing getter for lifetimes.
* ast/rust-type.h: Likewise.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Fri, 4 Nov 2022 22:30:24 +0000 (23:30 +0100)]
gccrs: ast: add visit overload for references
This is currently needed for lifetimes to use the existing infrastructure.
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add new reference visitor wrapper.
* ast/rust-ast-dump.h: Declare it.
* ast/rust-item.h: Add mutable visibility getters.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Arthur Cohen [Wed, 2 Nov 2022 08:52:01 +0000 (09:52 +0100)]
gccrs: typecheck: Fix overzealous `delete` call
gcc/rust/ChangeLog:
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Fix extra call
to `delete`.
Dave [Thu, 10 Nov 2022 05:17:50 +0000 (23:17 -0600)]
gccrs: add Location to AST::Visibility
gcc/rust/ChangeLog:
* ast/rust-item.h: Add location member.
* hir/rust-ast-lower.cc (translate_visibility): Pass location argument.
* hir/tree/rust-hir-item.h: Fix constructor to accept Location argument.
Raiki Tamura [Wed, 9 Nov 2022 09:49:12 +0000 (18:49 +0900)]
gccrs: add lang item "phantom_data"
gcc/rust/ChangeLog:
* util/rust-lang-item.h: Add handling for `phantom_data` lang item.
gcc/testsuite/ChangeLog:
* rust/compile/torture/phantom_data.rs: New test.
Jakub Dupak [Fri, 28 Oct 2022 15:58:39 +0000 (17:58 +0200)]
gccrs: ast: Dump unit struct
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add handling for unit structures.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Fri, 28 Oct 2022 15:27:16 +0000 (17:27 +0200)]
gccrs: ast: refer correctly to arguments in docs-strings
gcc/rust/ChangeLog:
* ast/rust-ast-dump.h: Fix documentation.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Thu, 27 Oct 2022 23:37:48 +0000 (01:37 +0200)]
gccrs: ast: transform helper methods to visits and add methods to simplify repeated patterns
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::go): Use new API.
(Dump::format_function_param): Refactor.
(Dump::visit_items_joined_by_separator): New function.
(Dump::emit_attrib): Refactor.
(Dump::visit_as_line): New function.
(Dump::visit_items_as_lines): Likewise.
(Dump::visit_items_as_block): Likewise.
(Dump::visit): Use new API.
(Dump::emit_visibility): Likewise.
(Dump::emit_indented_string): Likewise.
(Dump::emit_generic_params): Likewise.
(Dump::format_tuple_field): Likewise.
(Dump::format_struct_field): Likewise.
(Dump::format_function_common): Likewise.
(Dump::visit_function_common): Likewise.
* ast/rust-ast-dump.h: Declare new functions and add documentation.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Jakub Dupak [Thu, 27 Oct 2022 20:27:55 +0000 (22:27 +0200)]
gccrs: ast: visitor pattern -> overload syntax compatibility layer
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::visit): Add new visit function for overloading.
* ast/rust-ast-dump.h: Add documentation for layer.
Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Arthur Cohen [Wed, 26 Oct 2022 15:00:55 +0000 (17:00 +0200)]
gccrs: intrinsics: Implement atomic_load intrinsics
gcc/rust/ChangeLog:
* backend/rust-builtins.cc (BuiltinsContext::setup_atomic_fns): Declare atomic
load intrinsics.
* backend/rust-compile-intrinsic.cc (atomic_load_handler_inner): New handler.
(atomic_load_handler): Likewise.
(unchecked_op_handler): Remove `static` function qualifier.
(build_atomic_builtin_name): Handle load intrinsics.
(atomic_store_handler_inner): New handler.
gcc/testsuite/ChangeLog:
* rust/compile/torture/intrinsics-3.rs:
* rust/execute/torture/atomic_load.rs: New test.
Arthur Cohen [Wed, 26 Oct 2022 14:35:12 +0000 (16:35 +0200)]
gccrs: intrinsics: Cleanup error handling around atomic_store_*
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc (check_for_basic_integer_type): New function.
(build_atomic_builtin_name): Use HIR Type instead of `tree`.
(atomic_store_handler_inner): Cleanup error handling.
(unchecked_op_inner): Likewise.
gcc/testsuite/ChangeLog:
* rust/compile/torture/intrinsics-5.rs: Fix error message.
Arthur Cohen [Wed, 26 Oct 2022 14:06:53 +0000 (16:06 +0200)]
gccrs: intrinsics: Use lambdas for wrapping_<op> intrinsics
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc (wrapping_op_handler): Refactor to return
an `std::function`.
(wrapping_op_handler_inner): Rename.
(wrapping_add_handler): Remove function.
(wrapping_sub_handler): Likewise.
(wrapping_mul_handler): Likewise.
Arthur Cohen [Wed, 26 Oct 2022 13:57:54 +0000 (15:57 +0200)]
gccrs: intrinsics: Add unchecked operation intrinsics
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc (is_basic_integer_type): New function.
(unchecked_op_inner): New handler.
(unchecked_op_handler): New handler.
gcc/testsuite/ChangeLog:
* rust/compile/torture/intrinsics-6.rs: New test.
* rust/compile/torture/intrinsics-7.rs: New test.
Arthur Cohen [Tue, 25 Oct 2022 09:24:10 +0000 (11:24 +0200)]
gccrs: intrinsics: Add early implementation for atomic_store_{seqcst, relaxed, release}
gcc/rust/ChangeLog:
* backend/rust-builtins.cc (BuiltinsContext::setup_atomic_fns): New function.
(BuiltinsContext::setup): Call `setup_atomic_fns`.
* backend/rust-builtins.h: Declare `setup_atomic_fns`.
* backend/rust-compile-intrinsic.cc (atomic_store_handler_inner): New function.
(atomic_store_handler): New handler.
(make_unsigned_long_tree): Add helper around making unsigned long trees.
(prefetch_data_handler): Use `make_unsigned_long_tree`.
(build_atomic_builtin_name): New function.
gcc/testsuite/ChangeLog:
* rust/compile/torture/intrinsics-4.rs: New test.
* rust/compile/torture/intrinsics-5.rs: New test.
* rust/execute/torture/atomic_store.rs: New test.
Arthur Cohen [Mon, 24 Oct 2022 11:20:41 +0000 (13:20 +0200)]
gccrs: constexpr: Add `rust_sorry_at` in places relying on init values
gcc/rust/ChangeLog:
* backend/rust-constexpr.cc (build_anon_member_initialization): Workaround uninitialized
values.
(build_data_member_initialization): Likewise.
Arthur Cohen [Tue, 25 Oct 2022 08:48:43 +0000 (10:48 +0200)]
gccrs: intrinsics: Add `sorry_handler` intrinsic handler
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc (sorry_handler): New intrinsic handler.
gcc/testsuite/ChangeLog:
* rust/compile/torture/intrinsics-3.rs: New test.
Arthur Cohen [Mon, 24 Oct 2022 15:28:11 +0000 (17:28 +0200)]
gccrs: builtins: Rename all bang macro handlers
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc (MacroBuiltin::assert): Rename to...
(MacroBuiltin::assert_handler): ..this.
(MacroBuiltin::file): Rename to...
(MacroBuiltin::file_handler): ..this.
(MacroBuiltin::column): Rename to...
(MacroBuiltin::column_handler): ..this.
(MacroBuiltin::include_bytes): Rename to...
(MacroBuiltin::include_bytes_handler): ..this.
(MacroBuiltin::include_str): Rename to...
(MacroBuiltin::include_str_handler): ..this.
(MacroBuiltin::compile_error): Rename to...
(MacroBuiltin::compile_error_handler): ..this.
(MacroBuiltin::concat): Rename to...
(MacroBuiltin::concat_handler): ..this.
(MacroBuiltin::env): Rename to...
(MacroBuiltin::env_handler): ..this.
(MacroBuiltin::cfg): Rename to...
(MacroBuiltin::cfg_handler): ..this.
(MacroBuiltin::include): Rename to...
(MacroBuiltin::include_handler): ..this.
(MacroBuiltin::line): Rename to...
(MacroBuiltin::line_handler): ..this.
* expand/rust-macro-builtins.h: Rename all handlers.
* util/rust-hir-map.cc (Mappings::insert_macro_def): Use new handler
names.
Simon Cook [Tue, 12 Apr 2022 14:45:56 +0000 (16:45 +0200)]
gccrs: rust: Allow gccrs to build on x86_64-apple-darwin with clang/libc++
gcc/rust/ChangeLog:
* util/rust-inline-visitor.h: Remove some offending system includes.
YizhePKU [Tue, 13 Apr 2021 07:28:36 +0000 (07:28 +0000)]
gccrs: Implement the inline visitor
gcc/rust/ChangeLog:
* util/rust-inline-visitor.h: New file.
Philip Herron [Thu, 20 Oct 2022 17:31:02 +0000 (18:31 +0100)]
gccrs: Support Closure calls as generic trait bounds
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::visit): Refactor checking of closures.
(CompileExpr::generate_possible_fn_trait_call): New function.
* backend/rust-compile-expr.h: Declare `generate_possible_fn_trait_call`.
gcc/testsuite/ChangeLog:
* rust/execute/torture/closure2.rs: New test.
Philip Herron [Thu, 20 Oct 2022 17:05:43 +0000 (18:05 +0100)]
gccrs: Add missing type resolution for function type segments
gcc/rust/ChangeLog:
* typecheck/rust-tyty-bounds.cc (TypeCheckBase::get_predicate_from_bound): Add missing
implementation.
Philip Herron [Thu, 20 Oct 2022 16:59:27 +0000 (17:59 +0100)]
gccrs: Add missing hir lowering to function type-path segments
gcc/rust/ChangeLog:
* Make-lang.in: Compile rust-ast-lower-type.cc.
* ast/rust-path.h: Add `get_locus` method to `TypePathFunction`.
* hir/rust-ast-lower-base.cc (ASTLowerTypePath::visit): Move implementation to
rust-ast-lower-type.cc.
(ASTLowerQualifiedPathInType::visit): Likewise.
(ASTLoweringType::visit): Likewise.
* hir/rust-ast-lower-type.h: Move implementations to source file.
* hir/tree/rust-hir-path.h: Likewise.
* hir/rust-ast-lower-type.cc: New file.
Philip Herron [Thu, 20 Oct 2022 16:59:03 +0000 (17:59 +0100)]
gccrs: Add missing name resolution to Function type-path segments
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Add missing handling of
function case.
Philip Herron [Wed, 19 Oct 2022 17:02:36 +0000 (18:02 +0100)]
gccrs: Closure support at CallExpr
gcc/rust/ChangeLog:
* backend/rust-compile-context.h: Add new functions: `insert_closure_decl` and
`lookup_closure_decl`.
* backend/rust-compile-expr.cc (CompileExpr::visit): Start compiling Closures properly.
(CompileExpr::generate_closure_function): New function.
(CompileExpr::generate_closure_fntype): Likewise.
* backend/rust-compile-expr.h: Declare `generate_closure_function` and
`generate_closure_fntype`.
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Visit closure types properly.
* backend/rust-mangle.cc (legacy_mangle_name): Add support for closures.
* backend/rust-tree.h (RS_CLOSURE_FLAG): Add new tree macro.
(RS_CLOSURE_TYPE_P): And checking for it on tree nodes.
* typecheck/rust-tyty.cc (ClosureType::is_equal): Add implementation.
gcc/testsuite/ChangeLog:
* rust/execute/torture/closure1.rs: New test.
Philip Herron [Tue, 18 Oct 2022 12:21:40 +0000 (13:21 +0100)]
gccrs: Initial Type resolution for closures
gcc/rust/ChangeLog:
* hir/tree/rust-hir-expr.h: Add `get_params` method.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Typecheck closure nodes.
(TypeCheckExpr::resolve_fn_trait_call): New function.
* typecheck/rust-hir-type-check-expr.h: Declare `resolve_fn_trait_call` and
`resolve_possible_fn_trait_call_method_name`.
* typecheck/rust-hir-type-check.h: Declare `get_context_type`.
* typecheck/rust-tyctx.cc (TypeCheckContextItem::get_context_type): New function.
* typecheck/rust-tyty-cmp.h: Visit closures properly.
* typecheck/rust-tyty-rules.h: Likewise.
* typecheck/rust-tyty.cc (BaseType::bounds_compatible): Add commented out assertin.
(ClosureType::as_string): Implement it.
(ClosureType::clone): Fix closure cloning.
(ClosureType::setup_fn_once_output): New function.
* typecheck/rust-tyty.h: Improve `ClosureType` class and declare `setup_fn_once_output`.
Philip Herron [Wed, 19 Oct 2022 17:30:36 +0000 (18:30 +0100)]
gccrs: Add closures to lints and error checking
gcc/rust/ChangeLog:
* checks/errors/rust-const-checker.cc (ConstChecker::visit): Visit closures properly.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise.
* checks/lints/rust-lint-marklive.h: Likewise.
Philip Herron [Wed, 19 Oct 2022 09:59:18 +0000 (10:59 +0100)]
gccrs: Refactor method call type checking
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Simplify method
call type checking by removing visitor and instead using one static cast. Use the
new interface.
* typecheck/rust-tyty-call.cc (TypeCheckMethodCallExpr::visit): Likewise.
(TypeCheckMethodCallExpr::go): Likewise.
(TypeCheckMethodCallExpr::check): Likewise.
* typecheck/rust-tyty-call.h (class TypeCheckMethodCallExpr): Likewise.
(class Argument): Likewise.
Philip Herron [Mon, 17 Oct 2022 16:51:15 +0000 (17:51 +0100)]
gccrs: Add name resolution for closures
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Visit closure properly when
name resolving.
(ResolveExpr::resolve_closure_param): Implement closure name resolving.
* resolve/rust-ast-resolve-expr.h: Declare visitors for closure types.
Philip Herron [Mon, 17 Oct 2022 16:27:01 +0000 (17:27 +0100)]
gccrs: Formatting cleanup in HIR lowering pattern
gcc/rust/ChangeLog:
* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::ASTLoweringPattern):
Improve formatting.
(ASTLoweringPattern::translate): Likewise.
* hir/rust-ast-lower-pattern.h: Likewise.
* resolve/rust-ast-resolve-expr.h: Likewise.
Philip Herron [Mon, 17 Oct 2022 15:51:05 +0000 (16:51 +0100)]
gccrs: Refactor expression hir lowering into cc file
gcc/rust/ChangeLog:
* Make-lang.in: Add new object file for expression lowering.
* ast/rust-expr.h: Move implementation of expr lowering to source file.
* backend/rust-compile-block.h: Likewise.
* backend/rust-compile-expr.cc (CompileExpr::visit): Likewise.
* 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.
* hir/rust-ast-lower-base.h: Likewise.
* hir/rust-ast-lower-expr.h (RUST_AST_LOWER_EXPR): Likewise.
* hir/rust-ast-lower.cc (ASTLoweringBase::lower_closure_param): Likewise.
* hir/rust-hir-dump.cc (Dump::visit): Likewise.
* hir/rust-hir-dump.h: Likewise.
* hir/tree/rust-hir-expr.h (class ClosureExpr): Likewise.
(class ClosureExprInner): Likewise.
(class ClosureExprInnerTyped): Likewise.
* hir/tree/rust-hir-full-decls.h (class ClosureExprInner): Likewise.
(class ClosureExprInnerTyped): Likewise.
* hir/tree/rust-hir-full-test.cc (ClosureExprInnerTyped::as_string): Likewise.
(ClosureExprInner::as_string): Likewise.
(ClosureExprInner::accept_vis): Likewise.
(ClosureExpr::accept_vis): Likewise.
(ClosureExprInnerTyped::accept_vis): Likewise.
* hir/tree/rust-hir-visitor.h: Likewise.
* hir/tree/rust-hir.h (class Expr): Likewise.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
* typecheck/rust-hir-type-check-expr.h: Likewise.
* hir/rust-ast-lower-expr.cc: New file.
Philip Herron [Mon, 17 Oct 2022 15:50:34 +0000 (16:50 +0100)]
gccrs: Add missing fn_once_output langitem
gcc/rust/ChangeLog:
* util/rust-lang-item.h: Add handling for `fn_once_output`.
Arthur Cohen [Wed, 19 Oct 2022 12:53:43 +0000 (14:53 +0200)]
gccrs: ast: Improve Fragment API
gcc/rust/ChangeLog:
* ast/rust-ast-fragment.cc (Fragment::Fragment): Add better APIs.
(Fragment::complete): New function.
(Fragment::unexpanded): New function.
* ast/rust-ast-fragment.h: Declare new APIs and add documentation.
* expand/rust-attribute-visitor.h: Use new Fragment API.
* expand/rust-macro-builtins.cc (MacroBuiltin::file): Likewise.
(MacroBuiltin::column): Likewise.
(MacroBuiltin::include_bytes): Likewise.
(MacroBuiltin::include_str): Likewise.
(MacroBuiltin::concat): Likewise.
(MacroBuiltin::env): Likewise.
(MacroBuiltin::cfg): Likewise.
(MacroBuiltin::include): Likewise.
(MacroBuiltin::line): Likewise.
* expand/rust-macro-expand.cc (parse_many): Likewise.
(transcribe_expression): Likewise.
(transcribe_type): Likewise.
* expand/rust-macro-expand.h (struct MacroExpander): Likewise.