Skip to content

Commit cda05b0

Browse files
committed
Merge branch 'master' of https://github.com/rust-lang/rust
2 parents 8a4ff14 + b8c54d6 commit cda05b0

File tree

962 files changed

+10234
-6096
lines changed

Some content is hidden

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

962 files changed

+10234
-6096
lines changed

.git-blame-ignore-revs

+2
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ ec2cc761bc7067712ecc7734502f703fe3b024c8
3131
c682aa162b0d41e21cc6748f4fecfe01efb69d1f
3232
# reformat with updated edition 2024
3333
1fcae03369abb4c2cc180cd5a49e1f4440a81300
34+
# Breaking up of compiletest runtest.rs
35+
60600a6fa403216bfd66e04f948b1822f6450af7

Cargo.lock

+4-17
Original file line numberDiff line numberDiff line change
@@ -2022,9 +2022,9 @@ checksum = "9fa0e2a1fcbe2f6be6c42e342259976206b383122fc152e872795338b5a3f3a7"
20222022

20232023
[[package]]
20242024
name = "libc"
2025-
version = "0.2.171"
2025+
version = "0.2.172"
20262026
source = "registry+https://github.com/rust-lang/crates.io-index"
2027-
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
2027+
checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
20282028

20292029
[[package]]
20302030
name = "libdbus-sys"
@@ -2572,16 +2572,6 @@ version = "0.2.0"
25722572
source = "registry+https://github.com/rust-lang/crates.io-index"
25732573
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
25742574

2575-
[[package]]
2576-
name = "os_pipe"
2577-
version = "1.2.1"
2578-
source = "registry+https://github.com/rust-lang/crates.io-index"
2579-
checksum = "5ffd2b0a5634335b135d5728d84c5e0fd726954b87111f7506a61c502280d982"
2580-
dependencies = [
2581-
"libc",
2582-
"windows-sys 0.59.0",
2583-
]
2584-
25852575
[[package]]
25862576
name = "overload"
25872577
version = "0.1.1"
@@ -3142,7 +3132,6 @@ dependencies = [
31423132
"gimli 0.31.1",
31433133
"libc",
31443134
"object 0.36.7",
3145-
"os_pipe",
31463135
"regex",
31473136
"serde_json",
31483137
"similar",
@@ -3199,14 +3188,12 @@ dependencies = [
31993188

32003189
[[package]]
32013190
name = "rustc-rayon-core"
3202-
version = "0.5.0"
3191+
version = "0.5.1"
32033192
source = "registry+https://github.com/rust-lang/crates.io-index"
3204-
checksum = "67668daaf00e359c126f6dcb40d652d89b458a008c8afa727a42a2d20fca0b7f"
3193+
checksum = "2f42932dcd3bcbe484b38a3ccf79b7906fac41c02d408b5b1bac26da3416efdb"
32053194
dependencies = [
3206-
"crossbeam-channel",
32073195
"crossbeam-deque",
32083196
"crossbeam-utils",
3209-
"num_cpus",
32103197
]
32113198

32123199
[[package]]

bootstrap.example.toml

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
# Note that this has no default value (x.py uses the defaults in `bootstrap.example.toml`).
2020
#profile = <none>
2121

22+
# Inherits configuration values from different configuration files (a.k.a. config extensions).
23+
# Supports absolute paths, and uses the current directory (where the bootstrap was invoked)
24+
# as the base if the given path is not absolute.
25+
#
26+
# The overriding logic follows a right-to-left order. For example, in `include = ["a.toml", "b.toml"]`,
27+
# extension `b.toml` overrides `a.toml`. Also, parent extensions always overrides the inner ones.
28+
#include = []
29+
2230
# Keeps track of major changes made to this configuration.
2331
#
2432
# This value also represents ID of the PR that caused major changes. Meaning,

compiler/rustc_ast/src/attr/mod.rs

+22-11
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ impl MetaItem {
305305
if let [PathSegment { ident, .. }] = self.path.segments[..] { Some(ident) } else { None }
306306
}
307307

308-
pub fn name_or_empty(&self) -> Symbol {
309-
self.ident().unwrap_or_else(Ident::empty).name
308+
pub fn name(&self) -> Option<Symbol> {
309+
self.ident().map(|ident| ident.name)
310310
}
311311

312312
pub fn has_name(&self, name: Symbol) -> bool {
@@ -511,13 +511,14 @@ impl MetaItemInner {
511511
}
512512
}
513513

514-
/// For a single-segment meta item, returns its name; otherwise, returns `None`.
514+
/// For a single-segment meta item, returns its identifier; otherwise, returns `None`.
515515
pub fn ident(&self) -> Option<Ident> {
516516
self.meta_item().and_then(|meta_item| meta_item.ident())
517517
}
518518

519-
pub fn name_or_empty(&self) -> Symbol {
520-
self.ident().unwrap_or_else(Ident::empty).name
519+
/// For a single-segment meta item, returns its name; otherwise, returns `None`.
520+
pub fn name(&self) -> Option<Symbol> {
521+
self.ident().map(|ident| ident.name)
521522
}
522523

523524
/// Returns `true` if this list item is a MetaItem with a name of `name`.
@@ -738,9 +739,9 @@ pub trait AttributeExt: Debug {
738739
fn id(&self) -> AttrId;
739740

740741
/// For a single-segment attribute (i.e., `#[attr]` and not `#[path::atrr]`),
741-
/// return the name of the attribute, else return the empty identifier.
742-
fn name_or_empty(&self) -> Symbol {
743-
self.ident().unwrap_or_else(Ident::empty).name
742+
/// return the name of the attribute; otherwise, returns `None`.
743+
fn name(&self) -> Option<Symbol> {
744+
self.ident().map(|ident| ident.name)
744745
}
745746

746747
/// Get the meta item list, `#[attr(meta item list)]`
@@ -752,7 +753,7 @@ pub trait AttributeExt: Debug {
752753
/// Gets the span of the value literal, as string, when using `#[attr = value]`
753754
fn value_span(&self) -> Option<Span>;
754755

755-
/// For a single-segment attribute, returns its name; otherwise, returns `None`.
756+
/// For a single-segment attribute, returns its ident; otherwise, returns `None`.
756757
fn ident(&self) -> Option<Ident>;
757758

758759
/// Checks whether the path of this attribute matches the name.
@@ -770,6 +771,11 @@ pub trait AttributeExt: Debug {
770771
self.ident().map(|x| x.name == name).unwrap_or(false)
771772
}
772773

774+
#[inline]
775+
fn has_any_name(&self, names: &[Symbol]) -> bool {
776+
names.iter().any(|&name| self.has_name(name))
777+
}
778+
773779
/// get the span of the entire attribute
774780
fn span(&self) -> Span;
775781

@@ -813,8 +819,8 @@ impl Attribute {
813819
AttributeExt::id(self)
814820
}
815821

816-
pub fn name_or_empty(&self) -> Symbol {
817-
AttributeExt::name_or_empty(self)
822+
pub fn name(&self) -> Option<Symbol> {
823+
AttributeExt::name(self)
818824
}
819825

820826
pub fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>> {
@@ -846,6 +852,11 @@ impl Attribute {
846852
AttributeExt::has_name(self, name)
847853
}
848854

855+
#[inline]
856+
pub fn has_any_name(&self, names: &[Symbol]) -> bool {
857+
AttributeExt::has_any_name(self, names)
858+
}
859+
849860
pub fn span(&self) -> Span {
850861
AttributeExt::span(self)
851862
}

compiler/rustc_ast/src/expand/autodiff_attrs.rs

+26-14
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,32 @@ pub enum DiffActivity {
5050
/// with it.
5151
Dual,
5252
/// Forward Mode, Compute derivatives for this input/output and *overwrite* the shadow argument
53+
/// with it. It expects the shadow argument to be `width` times larger than the original
54+
/// input/output.
55+
Dualv,
56+
/// Forward Mode, Compute derivatives for this input/output and *overwrite* the shadow argument
5357
/// with it. Drop the code which updates the original input/output for maximum performance.
5458
DualOnly,
59+
/// Forward Mode, Compute derivatives for this input/output and *overwrite* the shadow argument
60+
/// with it. Drop the code which updates the original input/output for maximum performance.
61+
/// It expects the shadow argument to be `width` times larger than the original input/output.
62+
DualvOnly,
5563
/// Reverse Mode, Compute derivatives for this &T or *T input and *add* it to the shadow argument.
5664
Duplicated,
5765
/// Reverse Mode, Compute derivatives for this &T or *T input and *add* it to the shadow argument.
5866
/// Drop the code which updates the original input for maximum performance.
5967
DuplicatedOnly,
6068
/// All Integers must be Const, but these are used to mark the integer which represents the
6169
/// length of a slice/vec. This is used for safety checks on slices.
62-
FakeActivitySize,
70+
/// The integer (if given) specifies the size of the slice element in bytes.
71+
FakeActivitySize(Option<u32>),
72+
}
73+
74+
impl DiffActivity {
75+
pub fn is_dual_or_const(&self) -> bool {
76+
use DiffActivity::*;
77+
matches!(self, |Dual| DualOnly | Dualv | DualvOnly | Const)
78+
}
6379
}
6480
/// We generate one of these structs for each `#[autodiff(...)]` attribute.
6581
#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
@@ -131,11 +147,7 @@ pub fn valid_ret_activity(mode: DiffMode, activity: DiffActivity) -> bool {
131147
match mode {
132148
DiffMode::Error => false,
133149
DiffMode::Source => false,
134-
DiffMode::Forward => {
135-
activity == DiffActivity::Dual
136-
|| activity == DiffActivity::DualOnly
137-
|| activity == DiffActivity::Const
138-
}
150+
DiffMode::Forward => activity.is_dual_or_const(),
139151
DiffMode::Reverse => {
140152
activity == DiffActivity::Const
141153
|| activity == DiffActivity::Active
@@ -153,10 +165,8 @@ pub fn valid_ret_activity(mode: DiffMode, activity: DiffActivity) -> bool {
153165
pub fn valid_ty_for_activity(ty: &P<Ty>, activity: DiffActivity) -> bool {
154166
use DiffActivity::*;
155167
// It's always allowed to mark something as Const, since we won't compute derivatives wrt. it.
156-
if matches!(activity, Const) {
157-
return true;
158-
}
159-
if matches!(activity, Dual | DualOnly) {
168+
// Dual variants also support all types.
169+
if activity.is_dual_or_const() {
160170
return true;
161171
}
162172
// FIXME(ZuseZ4) We should make this more robust to also
@@ -172,9 +182,7 @@ pub fn valid_input_activity(mode: DiffMode, activity: DiffActivity) -> bool {
172182
return match mode {
173183
DiffMode::Error => false,
174184
DiffMode::Source => false,
175-
DiffMode::Forward => {
176-
matches!(activity, Dual | DualOnly | Const)
177-
}
185+
DiffMode::Forward => activity.is_dual_or_const(),
178186
DiffMode::Reverse => {
179187
matches!(activity, Active | ActiveOnly | Duplicated | DuplicatedOnly | Const)
180188
}
@@ -189,10 +197,12 @@ impl Display for DiffActivity {
189197
DiffActivity::Active => write!(f, "Active"),
190198
DiffActivity::ActiveOnly => write!(f, "ActiveOnly"),
191199
DiffActivity::Dual => write!(f, "Dual"),
200+
DiffActivity::Dualv => write!(f, "Dualv"),
192201
DiffActivity::DualOnly => write!(f, "DualOnly"),
202+
DiffActivity::DualvOnly => write!(f, "DualvOnly"),
193203
DiffActivity::Duplicated => write!(f, "Duplicated"),
194204
DiffActivity::DuplicatedOnly => write!(f, "DuplicatedOnly"),
195-
DiffActivity::FakeActivitySize => write!(f, "FakeActivitySize"),
205+
DiffActivity::FakeActivitySize(s) => write!(f, "FakeActivitySize({:?})", s),
196206
}
197207
}
198208
}
@@ -220,7 +230,9 @@ impl FromStr for DiffActivity {
220230
"ActiveOnly" => Ok(DiffActivity::ActiveOnly),
221231
"Const" => Ok(DiffActivity::Const),
222232
"Dual" => Ok(DiffActivity::Dual),
233+
"Dualv" => Ok(DiffActivity::Dualv),
223234
"DualOnly" => Ok(DiffActivity::DualOnly),
235+
"DualvOnly" => Ok(DiffActivity::DualvOnly),
224236
"Duplicated" => Ok(DiffActivity::Duplicated),
225237
"DuplicatedOnly" => Ok(DiffActivity::DuplicatedOnly),
226238
_ => Err(()),

compiler/rustc_ast_lowering/src/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
13101310
// create a fake body so that the entire rest of the compiler doesn't have to deal with
13111311
// this as a special case.
13121312
return self.lower_fn_body(decl, contract, |this| {
1313-
if attrs.iter().any(|a| a.name_or_empty() == sym::rustc_intrinsic) {
1313+
if attrs.iter().any(|a| a.has_name(sym::rustc_intrinsic)) {
13141314
let span = this.lower_span(span);
13151315
let empty_block = hir::Block {
13161316
hir_id: this.next_id(),

compiler/rustc_ast_lowering/src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1767,21 +1767,21 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17671767
) -> &'hir hir::Lifetime {
17681768
let res = self.resolver.get_lifetime_res(id).unwrap_or(LifetimeRes::Error);
17691769
let res = match res {
1770-
LifetimeRes::Param { param, .. } => hir::LifetimeName::Param(param),
1770+
LifetimeRes::Param { param, .. } => hir::LifetimeKind::Param(param),
17711771
LifetimeRes::Fresh { param, .. } => {
17721772
debug_assert_eq!(ident.name, kw::UnderscoreLifetime);
17731773
let param = self.local_def_id(param);
1774-
hir::LifetimeName::Param(param)
1774+
hir::LifetimeKind::Param(param)
17751775
}
17761776
LifetimeRes::Infer => {
17771777
debug_assert_eq!(ident.name, kw::UnderscoreLifetime);
1778-
hir::LifetimeName::Infer
1778+
hir::LifetimeKind::Infer
17791779
}
17801780
LifetimeRes::Static { .. } => {
17811781
debug_assert!(matches!(ident.name, kw::StaticLifetime | kw::UnderscoreLifetime));
1782-
hir::LifetimeName::Static
1782+
hir::LifetimeKind::Static
17831783
}
1784-
LifetimeRes::Error => hir::LifetimeName::Error,
1784+
LifetimeRes::Error => hir::LifetimeKind::Error,
17851785
LifetimeRes::ElidedAnchor { .. } => {
17861786
panic!("Unexpected `ElidedAnchar` {:?} at {:?}", ident, ident.span);
17871787
}
@@ -2388,7 +2388,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23882388
let r = hir::Lifetime::new(
23892389
self.next_id(),
23902390
Ident::new(kw::UnderscoreLifetime, self.lower_span(span)),
2391-
hir::LifetimeName::ImplicitObjectLifetimeDefault,
2391+
hir::LifetimeKind::ImplicitObjectLifetimeDefault,
23922392
IsAnonInPath::No,
23932393
);
23942394
debug!("elided_dyn_bound: r={:?}", r);

compiler/rustc_ast_passes/messages.ftl

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ ast_passes_extern_types_cannot = `type`s inside `extern` blocks cannot have {$de
7979
.suggestion = remove the {$remove_descr}
8080
.label = `extern` block begins here
8181
82+
ast_passes_extern_without_abi = `extern` declarations without an explicit ABI are disallowed
83+
.suggestion = specify an ABI
84+
.help = prior to Rust 2024, a default ABI was inferred
85+
8286
ast_passes_feature_on_non_nightly = `#![feature]` may not be used on the {$channel} release channel
8387
.suggestion = remove the attribute
8488
.stable_since = the feature `{$name}` has been stable since `{$since}` and no longer requires an attribute to enable

compiler/rustc_ast_passes/src/ast_validation.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ impl<'a> AstValidator<'a> {
347347
sym::forbid,
348348
sym::warn,
349349
];
350-
!arr.contains(&attr.name_or_empty()) && rustc_attr_parsing::is_builtin_attr(*attr)
350+
!attr.has_any_name(&arr) && rustc_attr_parsing::is_builtin_attr(*attr)
351351
})
352352
.for_each(|attr| {
353353
if attr.is_doc_comment() {
@@ -684,7 +684,7 @@ impl<'a> AstValidator<'a> {
684684
self.dcx().emit_err(errors::PatternFnPointer { span });
685685
});
686686
if let Extern::Implicit(extern_span) = bfty.ext {
687-
self.maybe_lint_missing_abi(extern_span, ty.id);
687+
self.handle_missing_abi(extern_span, ty.id);
688688
}
689689
}
690690
TyKind::TraitObject(bounds, ..) => {
@@ -717,10 +717,12 @@ impl<'a> AstValidator<'a> {
717717
}
718718
}
719719

720-
fn maybe_lint_missing_abi(&mut self, span: Span, id: NodeId) {
720+
fn handle_missing_abi(&mut self, span: Span, id: NodeId) {
721721
// FIXME(davidtwco): This is a hack to detect macros which produce spans of the
722722
// call site which do not have a macro backtrace. See #61963.
723-
if self
723+
if span.edition().at_least_edition_future() && self.features.explicit_extern_abis() {
724+
self.dcx().emit_err(errors::MissingAbi { span });
725+
} else if self
724726
.sess
725727
.source_map()
726728
.span_to_snippet(span)
@@ -945,8 +947,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
945947
self.visit_attrs_vis_ident(&item.attrs, &item.vis, ident);
946948
self.check_defaultness(item.span, *defaultness);
947949

948-
let is_intrinsic =
949-
item.attrs.iter().any(|a| a.name_or_empty() == sym::rustc_intrinsic);
950+
let is_intrinsic = item.attrs.iter().any(|a| a.has_name(sym::rustc_intrinsic));
950951
if body.is_none() && !is_intrinsic {
951952
self.dcx().emit_err(errors::FnWithoutBody {
952953
span: item.span,
@@ -996,7 +997,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
996997
}
997998

998999
if abi.is_none() {
999-
self.maybe_lint_missing_abi(*extern_span, item.id);
1000+
self.handle_missing_abi(*extern_span, item.id);
10001001
}
10011002
self.with_in_extern_mod(*safety, |this| {
10021003
visit::walk_item(this, item);
@@ -1370,7 +1371,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13701371
},
13711372
) = fk
13721373
{
1373-
self.maybe_lint_missing_abi(*extern_span, id);
1374+
self.handle_missing_abi(*extern_span, id);
13741375
}
13751376

13761377
// Functions without bodies cannot have patterns.

0 commit comments

Comments
 (0)