Synchronize development branch with GCC's master branch#3761
Synchronize development branch with GCC's master branch#3761CohenArthur merged 10000 commits intomasterfrom
Conversation
135065f to
64035a8
Compare
|
Wouldn't it be easier to put commits adjusting the expected warnings after the merge commit? Doesn't really matter either way, of course. |
ae5132f to
e57faeb
Compare
c10203f to
3f3712f
Compare
Not sure why you would want that? The goal is to have everything in one sequence between the upstream base and the merge commit. The regular sync will take the commits added after the merge by the pull request and move them between the base and the new merge. |
ad76a74 to
7808bcd
Compare
|
What should the |
|
It looks like the formatting for |
|
Are some of the clang-format-off sections added to |
|
Also, it looks like there are some non-trivial changes to the headers included by |
I guess we could yes, good catch.
Erm, you've already mentioned that on the Zulip, here's my copy of the answer for completeness :) [snip snip 8<---8<----] .... I think it has not been discarded, but more squashed with other changes with the initial upstreaming, and we may have introduced this small change in the process: diff --git a/gcc/rust/rust-lang.cc b/gcc/rust/rust-lang.cc
index df06026387c..f3a155dbad1 100644
--- a/gcc/rust/rust-lang.cc
+++ b/gcc/rust/rust-lang.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2024 Free Software Foundation, Inc.
+// Copyright (C) 2020-2025 Free Software Foundation, Inc.
// This file is part of GCC.
@@ -16,9 +16,8 @@
// along with GCC; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
+#include "rust-system.h"
#include "rust-diagnostics.h"
-#include "config.h"
-#include "system.h"
#include "coretypes.h"
#include "target.h"
#include "tree.h"
@@ -32,7 +31,6 @@
#include "convert.h"
#include "langhooks.h"
#include "langhooks-def.h"
-
#include "selftest.h"
#include "rust-cfg-parser.h"
#include "rust-privacy-ctx.h"
@@ -66,7 +64,6 @@
* e.g. HIR conversion.
*/
-#include "rust-system.h"
#include "rust-session-manager.h"
#include "rust-tree.h"I think it's OK. |
I think it's not very important, as long as we add stuff at the end. The vscode part could be dropped as it has been added upstream. |
|
The gitignore change looks like: # ADDITIONS from GCCRS front-end
-.vscode/*
-test.code-workspace
-
-gcc/rust/test3-tiny/*
-.clang-format.swap
which can probably be removed as I don't think we are building rust crate in the source tree anymore (cc @P-E-P ?) |
28d5521 to
9a8bf81
Compare
I agree we should remove those
Yeah we're not building it in tree anymore, libformat_parser is now built in |
aa8fa16 to
98aa652
Compare
gcc/testsuite/ChangeLog: * rust/execute/torture/builtin_abort.rs: Fix path to intrinsics::abort. Signed-off-by: Owen Avery <[email protected]>
This is similar to 9faba02, but it applies to execute tests. gcc/testsuite/ChangeLog: * rust/execute/torture/for-loop1.rs: Adjust paths. * rust/execute/torture/for-loop2.rs: Likewise. * rust/execute/torture/iter1.rs: Likewise. Signed-off-by: Owen Avery <[email protected]>
Signed-off-by: Parthib <[email protected]>
This is just a simple refactor to pull all the logic outside of the closure which makes it more readable. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check.h: new function * typecheck/rust-typecheck-context.cc (TypeCheckContext::compute_inference_variables): call the new helper (TypeCheckContext::compute_infer_var): refactored code Signed-off-by: Philip Herron <[email protected]>
…hese tmps Cloning inference variables is very expensive because it means we are indirectly creating an implicit new inference variable added to the reference chain. gcc/rust/ChangeLog: * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::check_base_type_privacy): no need for unreachable here * typecheck/rust-unify.cc (UnifyRules::commit): dont clone infer vars (UnifyRules::expect_inference_variable): likewise Signed-off-by: Philip Herron <[email protected]>
When working on rpit we needed to change to use a monomorphized clone of the result of function calls. This ended up causing a verify gimple issue with tuples because: fn test<A, B>(a: A, b: B) -> (A, B) When passing for example: let a = test::<i32, i32> (123, 456) -> (A=i32, B=i32) The resulting gimple types became: const struct (A=i32, B=i32) vs struct (i32, i32) We removed the VIEW_CONVERT_EXPR support to auto fix this stuff a good while ago because it hides these kinds of issues because the type hasher included the A=i32, B=i32 vs the i32, i32 name so updating this to use get_name instead keeps the naming the same as well as the fields meaning these types are 100% equivilant and therefore no conversion is required. This only occurs because tuples are not named types we should really add more rust specific info on our gimple TYPES. gcc/rust/ChangeLog: * backend/rust-compile-type.cc (TyTyResolveCompile::visit): use get_name * typecheck/rust-tyty.cc (TupleType::get_name): likewise Signed-off-by: Philip Herron <[email protected]>
This is the initial patch for RPIT, we can build on this to handle the
more complex cases but there are enough distinct changes going on here
that it should just get merged now.
RPIT is really a sneaky generic so for example:
fn foo() -> impl Bar {
Baz
}
This is represented as: fn () -> OpaqueType Bar. But when we handle the
coercion site for Baz on impl Bar when we type resolve the function we
know that the underlying type is Baz. Note this function is _not_ generic
so its using this special OpaqueType and keeping track of the underlying type
in its ty_ref reference hir-id which will resolve to Baz.
This also means if we have a case where maybe this was in an if statement:
fn foo(a: i32) -> impl Bar {
if a > 10 {
Baz
} else {
Qux
}
}
The rules of impl Bar is that Baz is handled but Baz and Qux are different
underlying types so this is not allowed. The reason is impl traits are not
generic and although from a programmer perspective the callers dont know what
the underlying type is, the compiler _knows_ what it is. So really when
you call a function and get its return position impl trait the compiler knows
what to do and does all whats nessecary to handle calling functions using that
type etc.
gcc/rust/ChangeLog:
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): we need to resolve the
underlying type
* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit): just clone
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit):
ensure we monomphize to get the underlying
* typecheck/rust-tyty.cc (BaseType::destructure): handle opaque types
(OpaqueType::resolve): this is much simpler now
(OpaqueType::handle_substitions): no longer needed
* typecheck/rust-tyty.h: update header
* typecheck/rust-unify.cc (UnifyRules::expect_opaque): unify rules for opaque
gcc/testsuite/ChangeLog:
* rust/compile/bad-rpit1.rs: New test.
* rust/execute/torture/impl_rpit1.rs: New test.
* rust/execute/torture/impl_rpit2.rs: New test.
* rust/execute/torture/impl_rpit3.rs: New test.
Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit_if_let_patterns): New function definition. (DefaultResolver::visit): New IfLetExpr visitor definition. * resolve/rust-default-resolver.h (DefaultResolver::visit_if_let_patterns): New function declaration. (DefaultResolver::visit): New IfLetExpr visitor declaration. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Remove IfLetExpr visitor definition. (Late::visit_if_let_patterns): New function definition. * resolve/rust-late-name-resolver-2.0.h (Late::visit): Remove IfLetExpr visitor declaration. (Late::visit_if_let_patterns): New function declaration. * resolve/rust-name-resolution-context.h (BindingSource::IfLet): New enumerator. Signed-off-by: Owen Avery <[email protected]>
The unify code was a bit dumb here where we always set emit_error to false for any subtypes for example in comparing tuples we always emitted the whole tuple didnt match the other tuple but really its much better to say expected bool got i32 because the element types didn't match. gcc/rust/ChangeLog: * typecheck/rust-coercion.cc (TypeCoercionRules::coerce_unsized): dont emit error here * typecheck/rust-unify.cc (UnifyRules::resolve_subtype): new helper to handle emit error (UnifyRules::expect_adt): call resolve_subtype (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 (UnifyRules::expect_opaque): likeiwse * typecheck/rust-unify.h: add new helper to header gcc/testsuite/ChangeLog: * rust/compile/traits9.rs: update errors * rust/compile/unify-errors1.rs: New test. Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog: * ast/rust-expr.h: Declare AnonConst and ConstBlock and use them. * ast/rust-ast-full-decls.h: Likewise. * ast/rust-ast.cc: Add implementation for AnonConst and ConstBlock. * ast/rust-ast.h: Likewise. * ast/rust-ast-collector.cc (TokenCollector::visit): Likewise. * ast/rust-ast-collector.h: Likewise. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise. * ast/rust-ast-visitor.h: Likewise. * expand/rust-derive.h: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise. * hir/rust-ast-lower-base.h: Likewise. * hir/rust-ast-lower-expr.cc (translate_operand_const): Likewise. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise. * resolve/rust-ast-resolve-base.h: Likewise. * resolve/rust-ast-resolve-expr.h: Likewise. * resolve/rust-ast-resolve-expr.cc: Likewise.
gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_const_block_expr): New function. * parse/rust-parse.h: Declare it.
gcc/rust/ChangeLog: * hir/tree/rust-hir-expr.h: New classes. * hir/tree/rust-hir-full-decls.h: Likewise. * hir/tree/rust-hir.cc: Handle AnonConst and ConstBlock. * backend/rust-compile-block.cc: Likewise. * backend/rust-compile-block.h: Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise. * backend/rust-compile-expr.h: Likewise. * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Likewise. * checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Likewise. * checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Likewise. * checks/errors/borrowck/rust-bir-builder-struct.h: Likewise. * checks/errors/borrowck/rust-function-collector.h: Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.h: Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise. * checks/errors/rust-const-checker.h: Likewise. * checks/errors/rust-hir-pattern-analysis.cc (PatternChecker::visit): Likewise. * checks/errors/rust-hir-pattern-analysis.h: Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.h: Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise. (translate_operand_out): Likewise. (translate_operand_inout): Likewise. (translate_operand_const): Likewise. * hir/rust-ast-lower-expr.h: Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * hir/rust-hir-dump.h: Likewise. * hir/tree/rust-hir-expr-abstract.h: Likewise. * hir/tree/rust-hir-expr.cc (AnonConst::AnonConst): Likewise. (AnonConst::operator=): Likewise. (ConstBlock::ConstBlock): Likewise. (ConstBlock::operator=): Likewise. * hir/tree/rust-hir-visitor.h: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. (typecheck_inline_asm_operand): Likewise. * typecheck/rust-hir-type-check-expr.h: Likewise.
gcc/testsuite/ChangeLog: * rust/execute/torture/const_block1.rs: New test.
d7a30a0 to
459d71e
Compare
The change to ASTLoweringExternItem is necessary, since with this patch Identifier can be implicitly converted to std::string. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Handle changed type of ConstantItem::identifier. * ast/rust-ast.cc (ConstantItem::as_string): Likewise. * ast/rust-ast.h (operator const std::string &): New member function. * ast/rust-item.h (ConstantItem::identifier): Change type from std::string to Identifier. (ConstantItem::ConstantItem): Handle changed type of identifier field. (ConstantItem::is_unnamed): Likewise. (ConstantItem::get_identifier): Likewise. * hir/rust-ast-lower-extern.h (ASTLoweringExternItem::visit): Avoid discarding location of wildcard patterns. * lex/rust-token.cc: Include "rust-ast.h". (Token::make_identifier): Add overload accepting an Identifier instance. * lex/rust-token.h (class Identifier): Add forward declaration in order to... (Token::make_identifier): ...declare an overload for this static member function. Signed-off-by: Owen Avery <[email protected]>
Stops an ICE from occuring when path attribute is empty Fixes #3607. gcc/rust/ChangeLog: * parse/rust-parse.cc (Rust::extract_module_path): Handle empty or whitespace-only path attributes. gcc/testsuite/ChangeLog: * rust/compile/torture/extern_mod2.rs: New test to ensure an error is emitted for empty path attributes. Signed-off-by: Vishruth Thimmaiah <[email protected]>
gcc/rust/ChangeLog: * resolve/rust-forever-stack.h (enum ResolutionMode): New. (ForeverStack::get): Add a private overload that takes a starting node as a parameter. (ForeverStack::resolve_path): Replace boolean parameter has_opening_scope_resolution with ResolutionMode parameter mode. * resolve/rust-forever-stack.hxx (ForeverStack::resolve_path): Likewise. (ForeverStack::get): Add a private overload that takes a starting node as a parameter. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add Visibility visitor. * resolve/rust-late-name-resolver-2.0.h (Late::visit): Likewise. * resolve/rust-name-resolution-context.h (NameResolutionContext::resolve_path): Rework overloading a bit and accept ResolutionMode parameter. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <[email protected]>
gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Use visit_impl_type to visit the self types of impl blocks. * resolve/rust-default-resolver.h (DefaultResolver::visit_impl_type): New member function declaration. * resolve/rust-late-name-resolver-2.0.cc (Late::Late): Initialize member variable block_big_self. (Late::visit_impl_type): New member function definition. (Late::visit): Check for Self while inside impl block self types. * resolve/rust-late-name-resolver-2.0.h (Late::visit_impl_type): New member function. (Late::block_big_self): New member variable. gcc/testsuite/ChangeLog: * rust/compile/issue-3671.rs: Remove usage of Self. * rust/compile/nr2/exclude: Remove issue-3671.rs. * rust/compile/self-in-impl.rs: New test. Signed-off-by: Owen Avery <[email protected]>
Fixes an ICE when a raw byte string is not terminated Fixes #3731 gcc/rust/ChangeLog: * lex/rust-lex.cc (Lexer::parse_raw_byte_string): Fix infinite looping when a raw byte string is not terminated. gcc/testsuite/ChangeLog: * rust/compile/torture/unended-raw-byte-string.rs: New test to ensure correct error message for unended raw byte string. Signed-off-by: Vishruth Thimmaiah <[email protected]>
gcc/rust/ChangeLog: * hir/rust-ast-lower-pattern.cc: Lower of IdentifierPattern's to_bind to HIR. * hir/rust-hir-dump.cc: Update IdentifierPattern's dump to properly show to_bind's full full properties. Signed-off-by: Yap Zhi Heng <[email protected]>
This should improve our canonical path handling, without requiring further tweaks to ForeverStack. This may also help if, in the future, we have to move canonical path calculation to later compilation phases for proper handling of generics. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::compile_function): Since canonical paths returned from nr2.0 now include the crate name, avoid prepending the crate name again. * backend/rust-compile-implitem.cc (CompileTraitItem::visit): Use NameResolutionContext::to_canonical_path instead of ForeverStack::to_canonical_path. * backend/rust-compile-item.cc (CompileItem::visit): Likewise. * typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit): Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Likewise. * typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): Likewise. * resolve/rust-default-resolver.cc (DefaultResolver::visit): Add Crate and EnumItem instance visitors, handle canonical path context scoping. * resolve/rust-default-resolver.h (DefaultResolver::visit): Add Crate and EnumItem instance visitors. * resolve/rust-early-name-resolver-2.0.cc (Early::go): Visit instances of Crate using the virtual member function visit. * resolve/rust-forever-stack.h (ForeverStack::to_canonical_path): Remove function declaration. * resolve/rust-forever-stack.hxx (ForeverStack::to_canonical_path): Remove function definition. * resolve/rust-late-name-resolver-2.0.cc (Late::go): Visit instances of Crate using the virtual member function visit. * resolve/rust-name-resolution-context.cc (CanonicalPathRecordCrateRoot::as_path): New function definition. (CanonicalPathRecordNormal::as_path): Likewise. (CanonicalPathRecordLookup::as_path): Likewise. (CanonicalPathRecordImpl::as_path): Likewise. (CanonicalPathRecordTraitImpl::as_path): Likewise. (NameResolutionContext::NameResolutionContext): Initialize member variable canonical_ctx. * resolve/rust-name-resolution-context.h: Include "rust-item.h". (class NameResolutionContext): Forward declare class. (class CanonicalPathRecord): New class. (class CanonicalPathRecordWithParent): Likewise. (class CanonicalPathRecordCrateRoot): Likewise. (class CanonicalPathRecordNormal): Likewise. (class CanonicalPathRecordLookup): Likewise. (class CanonicalPathRecordImpl): Likewise. (class CanonicalPathRecordTraitImpl): Likewise. (class CanonicalPathCtx): Likewise. (NameResolutionContext::canonical_ctx): New member variable. (NameResolutionContext::to_canonical_path): New member function. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::go): Visit instances of Crate with the virtual member function visit. (TopLevel::visit): Handle canonical path context scoping for external crates, use DefaultResolver::visit when visiting instances of StructStruct. * util/rust-canonical-path.h (CanonicalPath::new_seg): Take path parameter by-value, as a duplicate instance will be constructed regardless. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove canonical_paths1.rs.
ChangeLog: * .github/alpine_32bit_log_warnings: Adjust with latest warnings. * .github/glibcxx_ubuntu64b_log_expected_warnings: Likewise. * .github/log_expected_warnings: Likewise. Signed-off-by: Marc Poulhiès <[email protected]>
…based This branch has a no-op merge as the last commit: - one arm is the "current" development branch from github - the other arm is a rebased version of the "current" master branch onto a recent GCC's master The merge is obtained with "git merge --strategy=ours" to only keep the changes from second arm.
This branch has a no-op merge as the last commit:
The merge is obtained with "git merge --strategy=ours" to only keep the changes from second arm.