Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci improvements #1

Open
wants to merge 52 commits into
base: master
Choose a base branch
from
Open

Ci improvements #1

wants to merge 52 commits into from

Conversation

jdupak
Copy link
Owner

@jdupak jdupak commented Oct 28, 2023

Thank you for making Rust GCC better!

If your PR fixes an issue, you can add "Fixes #issue_number" into this
PR description and the git commit message. This way the issue will be
automatically closed when your PR is merged. If your change addresses
an issue but does not fully fix it please mark it as "Addresses #issue_number"
in the git commit message.

Here is a checklist to help you with your PR.

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

*Please write a comment explaining your change. This is the message
that will be part of the merge commit.

jdupak and others added 30 commits October 3, 2023 07:02
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 <[email protected]>
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 <[email protected]>
gcc/rust/ChangeLog:

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

Signed-off-by: Jakub Dupak <[email protected]>
gcc/testsuite/ChangeLog:

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

Signed-off-by: Jakub Dupak <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Add a new test to highlight fix for Rust-GCC#2649.

gcc/testsuite/ChangeLog:

	* rust/compile/parse_global_path_generic.rs: New test.
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 <[email protected]>
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 <[email protected]>
Public unit types where not parsed correctly due to visibility specifiers
within parenthesis. Fixes Rust-GCC#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 <[email protected]>
Add a new test to highlight fix for Rust-GCC#2648.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
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 <[email protected]>
This new test highlight the fix for issue Rust-GCC#2657.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
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 <[email protected]>
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 <[email protected]>
New regression test to highlight behavior of Rust-GCC#2652.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
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 <[email protected]>
This test highlight the fix required for Rust-GCC#2655.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
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 <[email protected]>
Add a new test to highlight the fix made for Rust-GCC#2660.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
Add a new test to highlight fix of Rust-GCC#2658.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
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 <[email protected]>
This new test highlight the fix for Rust-GCC#2651.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
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 <[email protected]>
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 <[email protected]>
Add a new test to highlight the fix introduced for Rust-GCC#2653.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
P-E-P and others added 21 commits October 17, 2023 22:19
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 <[email protected]>
This new test highlight the fix of Rust-GCC#2656.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
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 <[email protected]>
gcc/rust/ChangeLog:

	* ast/rust-ast.h
	(class AssociatedItem):
	New, based on TraitItem, InherentImplItem, and TraitImplItem classes.
	(class TraitItem): Inherit from AssociatedItem.
	(class InherentImplItem): Likewise.
	(class TraitImplItem): Likewise.
	* ast/rust-item.h
	(class Method): Update cloning functions.
	(class Function): Likewise.
	(class TypeAlias): Likewise.
	(class ConstantItem): Likewise.
	(class TraitItemFunc): Likewise.
	(class TraitItemMethod): Likewise.
	(class TraitItemConst): Likewise.
	(class TraitItemType): Likewise.
	* ast/rust-macro.h
	(class MacroInvocation): Likewise.

Signed-off-by: Owen Avery <[email protected]>
gcc/rust/ChangeLog:

	* ast/rust-ast-builder.cc (AstBuilder::block): Add label arg to constructor call.
	* ast/rust-expr.h (class LoopLabel): Move before BlockExpr.
	(class BlockExpr): Add LoopLabel member.
	* expand/rust-derive-clone.cc (DeriveClone::clone_fn): Add label arg to constructor call.
	* parse/rust-parse-impl.h (Parser::parse_block_expr): Add label parameter.
	(Parser::parse_labelled_loop_expr): Add label arg to constructor call.
	* parse/rust-parse.h: Add label arg to constructor call.

Signed-off-by: Jakub Dupak <[email protected]>
gcc/rust/ChangeLog:

	* hir/rust-ast-lower.cc (ASTLoweringBlock::visit): Call loop lowering and add it to constr.
	* hir/tree/rust-hir-expr.h (class LoopLabel): Move before BlockExpr and add to BlockExpr.
gcc/rust/ChangeLog:

	* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Resolve using loop logic.

Signed-off-by: Jakub Dupak <[email protected]>
gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Add loop ctx.

Signed-off-by: Jakub Dupak <[email protected]>
gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::visit): Bail on labelled block.

Signed-off-by: Jakub Dupak <[email protected]>
gcc/rust/ChangeLog:

	* hir/rust-ast-lower-implitem.h
	(ASTLoweringImplItem::translate): Take AssociatedItem as parameter.
	(ASTLoweringTraitItem::translate): Likewise.

Signed-off-by: Owen Avery <[email protected]>
gcc/rust/ChangeLog:

	* resolve/rust-ast-resolve-implitem.h
	(ResolveToplevelImplItem::go): Take AssociatedItem as parameter.
	(ResolveTopLevelTraitItems::go): Likewise.
	* resolve/rust-ast-resolve-item.cc
	(ResolveTraitItems::go): Likewise.
	(ResolveItem::resolve_impl_item): Likewise.
	(ResolveImplItems::go): Likewise.
	* resolve/rust-ast-resolve-item.h
	(ResolveTraitItems::go): Likewise.
	(ResolveItem::resolve_impl_item): Likewise.
	(ResolveImplItems::go): Likewise.

Signed-off-by: Owen Avery <[email protected]>
gcc/rust/ChangeLog:

	* hir/tree/rust-hir-path.h: Avoid copy in getter.
	* hir/tree/rust-hir-pattern.h: Avoid copy in getter.
	* hir/tree/rust-hir.h: Avoid copy in getter.

Signed-off-by: Jakub Dupak <[email protected]>
gcc/rust/ChangeLog:

	* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Implement for tuple pat.
	* resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::visit): Implement for tupple pat.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Jakub Dupak <[email protected]>
gcc/rust/ChangeLog:

	* hir/tree/rust-hir-expr.h: Add getter for name.

Signed-off-by: Jakub Dupak <[email protected]>
Unify with the name used in Expr to allow convenient template over
everything that has mappings.

gcc/rust/ChangeLog:

	* backend/rust-compile-base.cc: Rename method.
	* backend/rust-compile-expr.cc (sort_tuple_patterns): Rename method.
	* backend/rust-compile-pattern.cc (CompilePatternCaseLabelExpr::visit): Rename method.
	(CompilePatternBindings::visit): Rename method.
	(CompilePatternLet::visit): Rename method.
	* backend/rust-compile-stmt.cc (CompileStmt::visit): Rename method.
	* backend/rust-compile-var-decl.h: Rename method.
	* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate): Rename method.
	* hir/rust-hir-dump.cc (Dump::visit): Rename method.
	* hir/tree/rust-hir-path.h: Rename method.
	* hir/tree/rust-hir-pattern.h: Rename method.
	* hir/tree/rust-hir.h: Rename method.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::Resolve): Rename method.
	(TypeCheckPattern::visit): Rename method.
	(ClosureParamInfer::visit): Rename method.
	* typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Rename method.
	* util/rust-hir-map.cc (Mappings::insert_hir_pattern): Rename method.

Signed-off-by: Jakub Dupak <[email protected]>
Use more a consistent name.

gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::visit): Rename method.
	* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Rename method.
	* checks/errors/rust-const-checker.cc (ConstChecker::visit): Rename method.
	* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Rename method.
	* hir/rust-hir-dump.cc (Dump::visit): Rename method.
	* hir/tree/rust-hir-expr.h: Rename method.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Rename method.
	* typecheck/rust-tyty.h: Rename method.
gcc/rust/ChangeLog:

	* hir/tree/rust-hir-path.h: Avoid copy in getter.

Signed-off-by: Jakub Dupak <[email protected]>
Const with no value expression may exist either in trait or in disabled
blocks. This means we should be able to parse those correctly.

gcc/rust/ChangeLog:

	* ast/rust-item.h: Add a new constructor for const with no value
	expression.
	* parse/rust-parse-impl.h (Parser::parse_const_item): Allow const with
	no expression value.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
Highlight issue 2665's fix for const with no value expression.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
Overridden virtual methods were not marked as such.

gcc/rust/ChangeLog:

	* ast/rust-pattern.h: Add override modifier to overriding methods.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
ChangeLog:

	* .github/workflows/ccpp.yml: Add concurency group.

Signed-off-by: Jakub Dupak <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants