Skip to content

Commit 583f358

Browse files
committed
Auto merge of #3885 - rust-lang:rustup-2024-09-14, r=RalfJung
Automatic Rustup
2 parents 20862e4 + 94d4991 commit 583f358

File tree

423 files changed

+5453
-2989
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

423 files changed

+5453
-2989
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,7 @@
5151
path = src/tools/enzyme
5252
url = https://github.com/EnzymeAD/Enzyme.git
5353
shallow = true
54+
[submodule "src/gcc"]
55+
path = src/gcc
56+
url = https://github.com/rust-lang/gcc.git
57+
shallow = true

LICENSES/GCC-exception-3.1.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
GCC RUNTIME LIBRARY EXCEPTION
2+
3+
Version 3.1, 31 March 2009
4+
5+
Copyright © 2009 Free Software Foundation, Inc. <https://fsf.org/>
6+
7+
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
8+
9+
This GCC Runtime Library Exception ("Exception") is an additional permission under section 7 of the GNU General Public License, version 3 ("GPLv3"). It applies to a given file (the "Runtime Library") that bears a notice placed by the copyright holder of the file stating that the file is governed by GPLv3 along with this Exception.
10+
11+
When you use GCC to compile a program, GCC may combine portions of certain GCC header files and runtime libraries with the compiled program. The purpose of this Exception is to allow compilation of non-GPL (including proprietary) programs to use, in this way, the header files and runtime libraries covered by this Exception.
12+
0. Definitions.
13+
14+
A file is an "Independent Module" if it either requires the Runtime Library for execution after a Compilation Process, or makes use of an interface provided by the Runtime Library, but is not otherwise based on the Runtime Library.
15+
16+
"GCC" means a version of the GNU Compiler Collection, with or without modifications, governed by version 3 (or a specified later version) of the GNU General Public License (GPL) with the option of using any subsequent versions published by the FSF.
17+
18+
"GPL-compatible Software" is software whose conditions of propagation, modification and use would permit combination with GCC in accord with the license of GCC.
19+
20+
"Target Code" refers to output from any compiler for a real or virtual target processor architecture, in executable form or suitable for input to an assembler, loader, linker and/or execution phase. Notwithstanding that, Target Code does not include data in any format that is used as a compiler intermediate representation, or used for producing a compiler intermediate representation.
21+
22+
The "Compilation Process" transforms code entirely represented in non-intermediate languages designed for human-written code, and/or in Java Virtual Machine byte code, into Target Code. Thus, for example, use of source code generators and preprocessors need not be considered part of the Compilation Process, since the Compilation Process can be understood as starting with the output of the generators or preprocessors.
23+
24+
A Compilation Process is "Eligible" if it is done using GCC, alone or with other GPL-compatible software, or if it is done without using any work based on GCC. For example, using non-GPL-compatible Software to optimize any GCC intermediate representations would not qualify as an Eligible Compilation Process.
25+
1. Grant of Additional Permission.
26+
27+
You have permission to propagate a work of Target Code formed by combining the Runtime Library with Independent Modules, even if such propagation would otherwise violate the terms of GPLv3, provided that all Target Code was generated by Eligible Compilation Processes. You may then convey such a combination under terms of your choice, consistent with the licensing of the Independent Modules.
28+
2. No Weakening of GCC Copyleft.
29+
30+
The availability of this Exception does not imply any general presumption that third-party software is unaffected by the copyleft requirements of the license of GCC.

LICENSES/GPL-2.0-only.txt

Lines changed: 133 additions & 0 deletions
Large diffs are not rendered by default.

LICENSES/GPL-3.0-or-later.txt

Lines changed: 202 additions & 0 deletions
Large diffs are not rendered by default.

LICENSES/ISC.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ISC License
2+
3+
<copyright notice>
4+
5+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

REUSE.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,37 @@ SPDX-FileCopyrightText = [
168168
"2003-2019 University of Illinois at Urbana-Champaign.",
169169
]
170170
SPDX-License-Identifier = "NCSA AND Apache-2.0 WITH LLVM-exception"
171+
172+
[[annotations]]
173+
path = "src/gcc/**"
174+
precedence = "override"
175+
SPDX-FileCopyrightText = [
176+
"Copyright (C) 1997-2024 Free Software Foundation, Inc.",
177+
]
178+
SPDX-License-Identifier = "GPL-3.0-or-later"
179+
180+
[[annotations]]
181+
path = "src/gcc/gcc/testsuite/**"
182+
precedence = "override"
183+
SPDX-FileCopyrightText = [
184+
"Copyright (C) 2000-2024 Free Software Foundation, Inc.",
185+
]
186+
SPDX-License-Identifier = "GPL-2.0-only"
187+
188+
[[annotations]]
189+
path = "src/gcc/gcc/testsuite/c-c++-common/analyzer/*.c"
190+
precedence = "override"
191+
SPDX-FileCopyrightText = [
192+
"Copyright (c) 2007-2011 Atheros Communications Inc.",
193+
"Copyright (c) 2011-2012,2017 Qualcomm Atheros, Inc.",
194+
"Copyright (c) 2016-2017 Erik Stromdahl <erik.stromdahl@gmail.com>",
195+
]
196+
SPDX-License-Identifier = "ISC"
197+
198+
[[annotations]]
199+
path = "src/gcc/libstdc++-v3/config/os/aix/os_defines.h"
200+
precedence = "override"
201+
SPDX-FileCopyrightText = [
202+
"Copyright (C) 2000-2024 Free Software Foundation, Inc.",
203+
]
204+
SPDX-License-Identifier = "GCC-exception-3.1"

compiler/rustc_ast/src/ast.rs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,14 +1188,7 @@ impl Expr {
11881188
///
11891189
/// Does not ensure that the path resolves to a const param, the caller should check this.
11901190
pub fn is_potential_trivial_const_arg(&self) -> bool {
1191-
let this = if let ExprKind::Block(block, None) = &self.kind
1192-
&& let [stmt] = block.stmts.as_slice()
1193-
&& let StmtKind::Expr(expr) = &stmt.kind
1194-
{
1195-
expr
1196-
} else {
1197-
self
1198-
};
1191+
let this = self.maybe_unwrap_block();
11991192

12001193
if let ExprKind::Path(None, path) = &this.kind
12011194
&& path.is_potential_trivial_const_arg()
@@ -1206,6 +1199,17 @@ impl Expr {
12061199
}
12071200
}
12081201

1202+
pub fn maybe_unwrap_block(&self) -> &Expr {
1203+
if let ExprKind::Block(block, None) = &self.kind
1204+
&& let [stmt] = block.stmts.as_slice()
1205+
&& let StmtKind::Expr(expr) = &stmt.kind
1206+
{
1207+
expr
1208+
} else {
1209+
self
1210+
}
1211+
}
1212+
12091213
pub fn to_bound(&self) -> Option<GenericBound> {
12101214
match &self.kind {
12111215
ExprKind::Path(None, path) => Some(GenericBound::Trait(
@@ -2602,12 +2606,12 @@ impl CoroutineKind {
26022606
}
26032607
}
26042608

2605-
pub fn is_async(self) -> bool {
2606-
matches!(self, CoroutineKind::Async { .. })
2607-
}
2608-
2609-
pub fn is_gen(self) -> bool {
2610-
matches!(self, CoroutineKind::Gen { .. })
2609+
pub fn as_str(self) -> &'static str {
2610+
match self {
2611+
CoroutineKind::Async { .. } => "async",
2612+
CoroutineKind::Gen { .. } => "gen",
2613+
CoroutineKind::AsyncGen { .. } => "async gen",
2614+
}
26112615
}
26122616

26132617
pub fn closure_id(self) -> NodeId {
@@ -3486,7 +3490,7 @@ impl From<ForeignItemKind> for ItemKind {
34863490
fn from(foreign_item_kind: ForeignItemKind) -> ItemKind {
34873491
match foreign_item_kind {
34883492
ForeignItemKind::Static(box static_foreign_item) => {
3489-
ItemKind::Static(Box::new(static_foreign_item.into()))
3493+
ItemKind::Static(Box::new(static_foreign_item))
34903494
}
34913495
ForeignItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind),
34923496
ForeignItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind),
@@ -3500,9 +3504,7 @@ impl TryFrom<ItemKind> for ForeignItemKind {
35003504

35013505
fn try_from(item_kind: ItemKind) -> Result<ForeignItemKind, ItemKind> {
35023506
Ok(match item_kind {
3503-
ItemKind::Static(box static_item) => {
3504-
ForeignItemKind::Static(Box::new(static_item.into()))
3505-
}
3507+
ItemKind::Static(box static_item) => ForeignItemKind::Static(Box::new(static_item)),
35063508
ItemKind::Fn(fn_kind) => ForeignItemKind::Fn(fn_kind),
35073509
ItemKind::TyAlias(ty_alias_kind) => ForeignItemKind::TyAlias(ty_alias_kind),
35083510
ItemKind::MacCall(a) => ForeignItemKind::MacCall(a),

compiler/rustc_ast/src/entry.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,16 @@ pub fn entry_point_type(
4545
EntryPointType::Start
4646
} else if attr::contains_name(attrs, sym::rustc_main) {
4747
EntryPointType::RustcMainAttr
48-
} else {
49-
if let Some(name) = name
50-
&& name == sym::main
51-
{
52-
if at_root {
53-
// This is a top-level function so it can be `main`.
54-
EntryPointType::MainNamed
55-
} else {
56-
EntryPointType::OtherMain
57-
}
48+
} else if let Some(name) = name
49+
&& name == sym::main
50+
{
51+
if at_root {
52+
// This is a top-level function so it can be `main`.
53+
EntryPointType::MainNamed
5854
} else {
59-
EntryPointType::None
55+
EntryPointType::OtherMain
6056
}
57+
} else {
58+
EntryPointType::None
6159
}
6260
}

compiler/rustc_ast_lowering/src/asm.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
220220
let parent_def_id = self.current_def_id_parent;
221221
let node_id = self.next_node_id();
222222
// HACK(min_generic_const_args): see lower_anon_const
223-
if !self.tcx.features().const_arg_path
224-
|| !expr.is_potential_trivial_const_arg()
225-
{
223+
if !expr.is_potential_trivial_const_arg() {
226224
self.create_def(
227225
parent_def_id,
228226
node_id,

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
387387
let node_id = self.next_node_id();
388388

389389
// HACK(min_generic_const_args): see lower_anon_const
390-
if !self.tcx.features().const_arg_path || !arg.is_potential_trivial_const_arg() {
390+
if !arg.is_potential_trivial_const_arg() {
391391
// Add a definition for the in-band const def.
392392
self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, f.span);
393393
}

compiler/rustc_ast_lowering/src/index.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,24 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
7878

7979
// Make sure that the DepNode of some node coincides with the HirId
8080
// owner of that node.
81-
if cfg!(debug_assertions) {
82-
if hir_id.owner != self.owner {
83-
span_bug!(
84-
span,
85-
"inconsistent HirId at `{:?}` for `{:?}`: \
81+
if cfg!(debug_assertions) && hir_id.owner != self.owner {
82+
span_bug!(
83+
span,
84+
"inconsistent HirId at `{:?}` for `{:?}`: \
8685
current_dep_node_owner={} ({:?}), hir_id.owner={} ({:?})",
87-
self.tcx.sess.source_map().span_to_diagnostic_string(span),
88-
node,
89-
self.tcx
90-
.definitions_untracked()
91-
.def_path(self.owner.def_id)
92-
.to_string_no_crate_verbose(),
93-
self.owner,
94-
self.tcx
95-
.definitions_untracked()
96-
.def_path(hir_id.owner.def_id)
97-
.to_string_no_crate_verbose(),
98-
hir_id.owner,
99-
)
100-
}
86+
self.tcx.sess.source_map().span_to_diagnostic_string(span),
87+
node,
88+
self.tcx
89+
.definitions_untracked()
90+
.def_path(self.owner.def_id)
91+
.to_string_no_crate_verbose(),
92+
self.owner,
93+
self.tcx
94+
.definitions_untracked()
95+
.def_path(hir_id.owner.def_id)
96+
.to_string_no_crate_verbose(),
97+
hir_id.owner,
98+
)
10199
}
102100

103101
self.nodes[hir_id.local_id] = ParentedNode { parent: self.parent_node, node };

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -628,13 +628,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
628628
.map_or(Const::No, |attr| Const::Yes(attr.span)),
629629
_ => Const::No,
630630
}
631+
} else if self.tcx.is_const_trait(def_id) {
632+
// FIXME(effects) span
633+
Const::Yes(self.tcx.def_ident_span(def_id).unwrap())
631634
} else {
632-
if self.tcx.is_const_trait(def_id) {
633-
// FIXME(effects) span
634-
Const::Yes(self.tcx.def_ident_span(def_id).unwrap())
635-
} else {
636-
Const::No
637-
}
635+
Const::No
638636
}
639637
} else {
640638
Const::No

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,7 +2335,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23352335
span: Span,
23362336
) -> &'hir hir::ConstArg<'hir> {
23372337
let ct_kind = match res {
2338-
Res::Def(DefKind::ConstParam, _) if self.tcx.features().const_arg_path => {
2338+
Res::Def(DefKind::ConstParam, _) => {
23392339
let qpath = self.lower_qpath(
23402340
ty_id,
23412341
&None,
@@ -2410,8 +2410,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24102410
self.resolver.get_partial_res(expr.id).and_then(|partial_res| partial_res.full_res());
24112411
debug!("res={:?}", maybe_res);
24122412
// FIXME(min_generic_const_args): for now we only lower params to ConstArgKind::Path
2413-
if self.tcx.features().const_arg_path
2414-
&& let Some(res) = maybe_res
2413+
if let Some(res) = maybe_res
24152414
&& let Res::Def(DefKind::ConstParam, _) = res
24162415
&& let ExprKind::Path(qself, path) = &expr.kind
24172416
{
@@ -2442,7 +2441,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24422441
/// See [`hir::ConstArg`] for when to use this function vs
24432442
/// [`Self::lower_anon_const_to_const_arg`].
24442443
fn lower_anon_const_to_anon_const(&mut self, c: &AnonConst) -> &'hir hir::AnonConst {
2445-
if self.tcx.features().const_arg_path && c.value.is_potential_trivial_const_arg() {
2444+
if c.value.is_potential_trivial_const_arg() {
24462445
// HACK(min_generic_const_args): see DefCollector::visit_anon_const
24472446
// Over there, we guess if this is a bare param and only create a def if
24482447
// we think it's not. However we may can guess wrong (see there for example)

compiler/rustc_ast_passes/messages.ftl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ ast_passes_body_in_extern = incorrect `{$kind}` inside `extern` block
4040
4141
ast_passes_bound_in_context = bounds on `type`s in {$ctx} have no effect
4242
43-
ast_passes_const_and_async = functions cannot be both `const` and `async`
44-
.const = `const` because of this
45-
.async = `async` because of this
46-
.label = {""}
47-
4843
ast_passes_const_and_c_variadic = functions cannot be both `const` and C-variadic
4944
.const = `const` because of this
5045
.variadic = C-variadic because of this
5146
47+
ast_passes_const_and_coroutine = functions cannot be both `const` and `{$coroutine_kind}`
48+
.const = `const` because of this
49+
.coroutine = `{$coroutine_kind}` because of this
50+
.label = {""}
51+
5252
ast_passes_const_bound_trait_object = const trait bounds are not allowed in trait object types
5353
5454
ast_passes_const_without_body =

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -447,13 +447,13 @@ impl<'a> AstValidator<'a> {
447447
fn check_item_safety(&self, span: Span, safety: Safety) {
448448
match self.extern_mod_safety {
449449
Some(extern_safety) => {
450-
if matches!(safety, Safety::Unsafe(_) | Safety::Safe(_)) {
451-
if extern_safety == Safety::Default {
452-
self.dcx().emit_err(errors::InvalidSafetyOnExtern {
453-
item_span: span,
454-
block: Some(self.current_extern_span().shrink_to_lo()),
455-
});
456-
}
450+
if matches!(safety, Safety::Unsafe(_) | Safety::Safe(_))
451+
&& extern_safety == Safety::Default
452+
{
453+
self.dcx().emit_err(errors::InvalidSafetyOnExtern {
454+
item_span: span,
455+
block: Some(self.current_extern_span().shrink_to_lo()),
456+
});
457457
}
458458
}
459459
None => {
@@ -1418,21 +1418,16 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
14181418

14191419
// Functions cannot both be `const async` or `const gen`
14201420
if let Some(&FnHeader {
1421-
constness: Const::Yes(cspan),
1421+
constness: Const::Yes(const_span),
14221422
coroutine_kind: Some(coroutine_kind),
14231423
..
14241424
}) = fk.header()
14251425
{
1426-
let aspan = match coroutine_kind {
1427-
CoroutineKind::Async { span: aspan, .. }
1428-
| CoroutineKind::Gen { span: aspan, .. }
1429-
| CoroutineKind::AsyncGen { span: aspan, .. } => aspan,
1430-
};
1431-
// FIXME(gen_blocks): Report a different error for `const gen`
1432-
self.dcx().emit_err(errors::ConstAndAsync {
1433-
spans: vec![cspan, aspan],
1434-
cspan,
1435-
aspan,
1426+
self.dcx().emit_err(errors::ConstAndCoroutine {
1427+
spans: vec![coroutine_kind.span(), const_span],
1428+
const_span,
1429+
coroutine_span: coroutine_kind.span(),
1430+
coroutine_kind: coroutine_kind.as_str(),
14361431
span,
14371432
});
14381433
}

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -657,16 +657,17 @@ pub(crate) enum TildeConstReason {
657657
}
658658

659659
#[derive(Diagnostic)]
660-
#[diag(ast_passes_const_and_async)]
661-
pub(crate) struct ConstAndAsync {
660+
#[diag(ast_passes_const_and_coroutine)]
661+
pub(crate) struct ConstAndCoroutine {
662662
#[primary_span]
663663
pub spans: Vec<Span>,
664664
#[label(ast_passes_const)]
665-
pub cspan: Span,
666-
#[label(ast_passes_async)]
667-
pub aspan: Span,
665+
pub const_span: Span,
666+
#[label(ast_passes_coroutine)]
667+
pub coroutine_span: Span,
668668
#[label]
669669
pub span: Span,
670+
pub coroutine_kind: &'static str,
670671
}
671672

672673
#[derive(Diagnostic)]

0 commit comments

Comments
 (0)