Skip to content

Commit 073a143

Browse files
Merge branch 'master' into issue-129599-fix
2 parents 16bc569 + 5fe0e40 commit 073a143

File tree

1,161 files changed

+16764
-10468
lines changed

Some content is hidden

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

1,161 files changed

+16764
-10468
lines changed

.gitmodules

+4
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

+30
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

+133
Large diffs are not rendered by default.

LICENSES/GPL-3.0-or-later.txt

+202
Large diffs are not rendered by default.

LICENSES/ISC.txt

+7
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

+34
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 <[email protected]>",
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_arena/src/lib.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -614,34 +614,34 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
614614

615615
pub trait ArenaAllocatable<'tcx, C = rustc_arena::IsNotCopy>: Sized {
616616
#[allow(clippy::mut_from_ref)]
617-
fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut Self;
617+
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut Self;
618618
#[allow(clippy::mut_from_ref)]
619-
fn allocate_from_iter<'a>(
620-
arena: &'a Arena<'tcx>,
619+
fn allocate_from_iter(
620+
arena: &'tcx Arena<'tcx>,
621621
iter: impl ::std::iter::IntoIterator<Item = Self>,
622-
) -> &'a mut [Self];
622+
) -> &'tcx mut [Self];
623623
}
624624

625625
// Any type that impls `Copy` can be arena-allocated in the `DroplessArena`.
626626
impl<'tcx, T: Copy> ArenaAllocatable<'tcx, rustc_arena::IsCopy> for T {
627627
#[inline]
628628
#[allow(clippy::mut_from_ref)]
629-
fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut Self {
629+
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut Self {
630630
arena.dropless.alloc(self)
631631
}
632632
#[inline]
633633
#[allow(clippy::mut_from_ref)]
634-
fn allocate_from_iter<'a>(
635-
arena: &'a Arena<'tcx>,
634+
fn allocate_from_iter(
635+
arena: &'tcx Arena<'tcx>,
636636
iter: impl ::std::iter::IntoIterator<Item = Self>,
637-
) -> &'a mut [Self] {
637+
) -> &'tcx mut [Self] {
638638
arena.dropless.alloc_from_iter(iter)
639639
}
640640
}
641641
$(
642642
impl<'tcx> ArenaAllocatable<'tcx, rustc_arena::IsNotCopy> for $ty {
643643
#[inline]
644-
fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut Self {
644+
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut Self {
645645
if !::std::mem::needs_drop::<Self>() {
646646
arena.dropless.alloc(self)
647647
} else {
@@ -651,10 +651,10 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
651651

652652
#[inline]
653653
#[allow(clippy::mut_from_ref)]
654-
fn allocate_from_iter<'a>(
655-
arena: &'a Arena<'tcx>,
654+
fn allocate_from_iter(
655+
arena: &'tcx Arena<'tcx>,
656656
iter: impl ::std::iter::IntoIterator<Item = Self>,
657-
) -> &'a mut [Self] {
657+
) -> &'tcx mut [Self] {
658658
if !::std::mem::needs_drop::<Self>() {
659659
arena.dropless.alloc_from_iter(iter)
660660
} else {
@@ -667,7 +667,7 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
667667
impl<'tcx> Arena<'tcx> {
668668
#[inline]
669669
#[allow(clippy::mut_from_ref)]
670-
pub fn alloc<T: ArenaAllocatable<'tcx, C>, C>(&self, value: T) -> &mut T {
670+
pub fn alloc<T: ArenaAllocatable<'tcx, C>, C>(&'tcx self, value: T) -> &mut T {
671671
value.allocate_on(self)
672672
}
673673

@@ -691,7 +691,7 @@ pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
691691

692692
#[allow(clippy::mut_from_ref)]
693693
pub fn alloc_from_iter<T: ArenaAllocatable<'tcx, C>, C>(
694-
&self,
694+
&'tcx self,
695695
iter: impl ::std::iter::IntoIterator<Item = T>,
696696
) -> &mut [T] {
697697
T::allocate_from_iter(self, iter)

compiler/rustc_ast/src/ast.rs

+31-18
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(
@@ -2418,11 +2422,22 @@ impl InlineAsmOperand {
24182422
}
24192423
}
24202424

2425+
#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable_Generic)]
2426+
pub enum AsmMacro {
2427+
/// The `asm!` macro
2428+
Asm,
2429+
/// The `global_asm!` macro
2430+
GlobalAsm,
2431+
/// The `naked_asm!` macro
2432+
NakedAsm,
2433+
}
2434+
24212435
/// Inline assembly.
24222436
///
24232437
/// E.g., `asm!("NOP");`.
24242438
#[derive(Clone, Encodable, Decodable, Debug)]
24252439
pub struct InlineAsm {
2440+
pub asm_macro: AsmMacro,
24262441
pub template: Vec<InlineAsmTemplatePiece>,
24272442
pub template_strs: Box<[(Symbol, Option<Symbol>, Span)]>,
24282443
pub operands: Vec<(InlineAsmOperand, Span)>,
@@ -2591,12 +2606,12 @@ impl CoroutineKind {
25912606
}
25922607
}
25932608

2594-
pub fn is_async(self) -> bool {
2595-
matches!(self, CoroutineKind::Async { .. })
2596-
}
2597-
2598-
pub fn is_gen(self) -> bool {
2599-
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+
}
26002615
}
26012616

26022617
pub fn closure_id(self) -> NodeId {
@@ -3475,7 +3490,7 @@ impl From<ForeignItemKind> for ItemKind {
34753490
fn from(foreign_item_kind: ForeignItemKind) -> ItemKind {
34763491
match foreign_item_kind {
34773492
ForeignItemKind::Static(box static_foreign_item) => {
3478-
ItemKind::Static(Box::new(static_foreign_item.into()))
3493+
ItemKind::Static(Box::new(static_foreign_item))
34793494
}
34803495
ForeignItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind),
34813496
ForeignItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind),
@@ -3489,9 +3504,7 @@ impl TryFrom<ItemKind> for ForeignItemKind {
34893504

34903505
fn try_from(item_kind: ItemKind) -> Result<ForeignItemKind, ItemKind> {
34913506
Ok(match item_kind {
3492-
ItemKind::Static(box static_item) => {
3493-
ForeignItemKind::Static(Box::new(static_item.into()))
3494-
}
3507+
ItemKind::Static(box static_item) => ForeignItemKind::Static(Box::new(static_item)),
34953508
ItemKind::Fn(fn_kind) => ForeignItemKind::Fn(fn_kind),
34963509
ItemKind::TyAlias(ty_alias_kind) => ForeignItemKind::TyAlias(ty_alias_kind),
34973510
ItemKind::MacCall(a) => ForeignItemKind::MacCall(a),

compiler/rustc_ast/src/ast_traits.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl HasTokens for StmtKind {
153153
StmtKind::Let(local) => local.tokens.as_ref(),
154154
StmtKind::Item(item) => item.tokens(),
155155
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.tokens(),
156-
StmtKind::Empty => return None,
156+
StmtKind::Empty => None,
157157
StmtKind::MacCall(mac) => mac.tokens.as_ref(),
158158
}
159159
}
@@ -162,7 +162,7 @@ impl HasTokens for StmtKind {
162162
StmtKind::Let(local) => Some(&mut local.tokens),
163163
StmtKind::Item(item) => item.tokens_mut(),
164164
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.tokens_mut(),
165-
StmtKind::Empty => return None,
165+
StmtKind::Empty => None,
166166
StmtKind::MacCall(mac) => Some(&mut mac.tokens),
167167
}
168168
}

compiler/rustc_ast/src/entry.rs

+9-11
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/src/mut_visit.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,7 @@ fn walk_anon_const<T: MutVisitor>(vis: &mut T, AnonConst { id, value }: &mut Ano
13881388
fn walk_inline_asm<T: MutVisitor>(vis: &mut T, asm: &mut InlineAsm) {
13891389
// FIXME: Visit spans inside all this currently ignored stuff.
13901390
let InlineAsm {
1391+
asm_macro: _,
13911392
template: _,
13921393
template_strs: _,
13931394
operands,

compiler/rustc_ast/src/visit.rs

+1
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,7 @@ pub fn walk_anon_const<'a, V: Visitor<'a>>(visitor: &mut V, constant: &'a AnonCo
976976

977977
pub fn walk_inline_asm<'a, V: Visitor<'a>>(visitor: &mut V, asm: &'a InlineAsm) -> V::Result {
978978
let InlineAsm {
979+
asm_macro: _,
979980
template: _,
980981
template_strs: _,
981982
operands,

compiler/rustc_ast_lowering/src/asm.rs

+9-5
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,
@@ -474,8 +472,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
474472
);
475473
let line_spans =
476474
self.arena.alloc_from_iter(asm.line_spans.iter().map(|span| self.lower_span(*span)));
477-
let hir_asm =
478-
hir::InlineAsm { template, template_strs, operands, options: asm.options, line_spans };
475+
let hir_asm = hir::InlineAsm {
476+
asm_macro: asm.asm_macro,
477+
template,
478+
template_strs,
479+
operands,
480+
options: asm.options,
481+
line_spans,
482+
};
479483
self.arena.alloc(hir_asm)
480484
}
481485
}

compiler/rustc_ast_lowering/src/expr.rs

+2-2
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
}
@@ -1837,7 +1837,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18371837
Safety::Default,
18381838
sym::allow,
18391839
sym::unreachable_code,
1840-
self.lower_span(span),
1840+
try_span,
18411841
);
18421842
let attrs: AttrVec = thin_vec![attr];
18431843

0 commit comments

Comments
 (0)