Skip to content

Commit 8e8a1d0

Browse files
committed
Merge remote-tracking branch 'origin/master' into catch-unwind-doc-update
2 parents 99706e7 + 9cb1998 commit 8e8a1d0

File tree

1,049 files changed

+23445
-11999
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,049 files changed

+23445
-11999
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Session.vim
1919
*.iml
2020
.vscode
2121
.project
22+
.vim/
23+
.helix/
24+
.zed/
2225
.favorites.json
2326
.settings/
2427
.vs/

Cargo.lock

+18-19
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ dependencies = [
205205

206206
[[package]]
207207
name = "ar_archive_writer"
208-
version = "0.3.0"
208+
version = "0.3.3"
209209
source = "registry+https://github.com/rust-lang/crates.io-index"
210-
checksum = "f8412a2d690663356cba5a2532f3ed55d1e8090743bc6695b88403b27df67733"
210+
checksum = "3f2bcb7cf51decfbbfc7ef476e28b0775b13e5eb1190f8b7df145cd53d4f4374"
211211
dependencies = [
212-
"object 0.35.0",
212+
"object 0.36.2",
213213
]
214214

215215
[[package]]
@@ -564,14 +564,15 @@ dependencies = [
564564
"termize",
565565
"tokio",
566566
"toml 0.7.8",
567-
"ui_test 0.24.0",
567+
"ui_test 0.25.0",
568568
"walkdir",
569569
]
570570

571571
[[package]]
572572
name = "clippy_config"
573573
version = "0.1.82"
574574
dependencies = [
575+
"itertools",
575576
"rustc-semver",
576577
"serde",
577578
"toml 0.7.8",
@@ -1406,8 +1407,11 @@ name = "generate-copyright"
14061407
version = "0.1.0"
14071408
dependencies = [
14081409
"anyhow",
1410+
"cargo_metadata 0.18.1",
1411+
"rinja",
14091412
"serde",
14101413
"serde_json",
1414+
"thiserror",
14111415
]
14121416

14131417
[[package]]
@@ -2282,6 +2286,7 @@ dependencies = [
22822286
"smallvec",
22832287
"tempfile",
22842288
"ui_test 0.21.2",
2289+
"windows-sys 0.52.0",
22852290
]
22862291

22872292
[[package]]
@@ -2453,15 +2458,6 @@ dependencies = [
24532458
"ruzstd 0.5.0",
24542459
]
24552460

2456-
[[package]]
2457-
name = "object"
2458-
version = "0.35.0"
2459-
source = "registry+https://github.com/rust-lang/crates.io-index"
2460-
checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e"
2461-
dependencies = [
2462-
"memchr",
2463-
]
2464-
24652461
[[package]]
24662462
name = "object"
24672463
version = "0.36.2"
@@ -3102,7 +3098,10 @@ version = "0.3.0"
31023098
source = "registry+https://github.com/rust-lang/crates.io-index"
31033099
checksum = "6d3762e3740cdbf2fd2be465cc2c26d643ad17353cc2e0223d211c1b096118bd"
31043100
dependencies = [
3101+
"humansize",
31053102
"itoa",
3103+
"num-traits",
3104+
"percent-encoding",
31063105
"rinja_derive",
31073106
]
31083107

@@ -3156,9 +3155,9 @@ dependencies = [
31563155

31573156
[[package]]
31583157
name = "rustc-build-sysroot"
3159-
version = "0.5.2"
3158+
version = "0.5.3"
31603159
source = "registry+https://github.com/rust-lang/crates.io-index"
3161-
checksum = "fa3ca63cc537c1cb69e4c2c0afc5fda2ccd36ac84c97d5a4ae05e69b1c834afb"
3160+
checksum = "2471f8f296262437d7e848e527b4210b44a96e53a3b4435b890227ce3e6da106"
31623161
dependencies = [
31633162
"anyhow",
31643163
"rustc_version",
@@ -4938,9 +4937,9 @@ dependencies = [
49384937

49394938
[[package]]
49404939
name = "spanned"
4941-
version = "0.2.1"
4940+
version = "0.3.0"
49424941
source = "registry+https://github.com/rust-lang/crates.io-index"
4943-
checksum = "ed14ba8b4b82241bd5daba2c49185d4a0581a0058355fe96537338f002b8605d"
4942+
checksum = "86af297923fbcfd107c20a189a6e9c872160df71a7190ae4a7a6c5dce4b2feb6"
49444943
dependencies = [
49454944
"bstr",
49464945
"color-eyre",
@@ -5564,9 +5563,9 @@ dependencies = [
55645563

55655564
[[package]]
55665565
name = "ui_test"
5567-
version = "0.24.0"
5566+
version = "0.25.0"
55685567
source = "registry+https://github.com/rust-lang/crates.io-index"
5569-
checksum = "bc1c6c78d55482388711c8d417b8e547263046a607512278fed274c54633bbe4"
5568+
checksum = "f7e4f339f62edc873975c47115f9e71c5454ddaa37c1142b42fc0b2672c8dacb"
55705569
dependencies = [
55715570
"annotate-snippets 0.11.4",
55725571
"anyhow",

REUSE.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ SPDX-License-Identifier = "MIT OR Apache-2.0"
163163
path = "src/llvm-project/**"
164164
precedence = "override"
165165
SPDX-FileCopyrightText = [
166-
"2003-2019 by the contributors listed in [CREDITS.TXT](https://github.com/rust-lang/llvm-project/blob/7738295178045041669876bf32b0543ec8319a5c/llvm/CREDITS.TXT)",
166+
"2003-2019 by the contributors listed in CREDITS.TXT (https://github.com/rust-lang/llvm-project/blob/7738295178045041669876bf32b0543ec8319a5c/llvm/CREDITS.TXT)",
167167
"2010 Apple Inc",
168168
"2003-2019 University of Illinois at Urbana-Champaign.",
169169
]

compiler/rustc/src/main.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// We need this feature as it changes `dylib` linking behavior and allows us to link to `rustc_driver`.
2+
#![feature(rustc_private)]
3+
14
// A note about jemalloc: rustc uses jemalloc when built for CI and
25
// distribution. The obvious way to do this is with the `#[global_allocator]`
36
// mechanism. However, for complicated reasons (see

compiler/rustc_ast/src/ast.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,9 @@ impl Pat {
585585
}
586586
// A slice/array pattern `[P]` can be reparsed as `[T]`, an unsized array,
587587
// when `P` can be reparsed as a type `T`.
588-
PatKind::Slice(pats) if pats.len() == 1 => pats[0].to_ty().map(TyKind::Slice)?,
588+
PatKind::Slice(pats) if let [pat] = pats.as_slice() => {
589+
pat.to_ty().map(TyKind::Slice)?
590+
}
589591
// A tuple pattern `(P0, .., Pn)` can be reparsed as `(T0, .., Tn)`
590592
// assuming `T0` to `Tn` are all syntactically valid as types.
591593
PatKind::Tuple(pats) => {
@@ -1187,8 +1189,8 @@ impl Expr {
11871189
/// Does not ensure that the path resolves to a const param, the caller should check this.
11881190
pub fn is_potential_trivial_const_arg(&self) -> bool {
11891191
let this = if let ExprKind::Block(block, None) = &self.kind
1190-
&& block.stmts.len() == 1
1191-
&& let StmtKind::Expr(expr) = &block.stmts[0].kind
1192+
&& let [stmt] = block.stmts.as_slice()
1193+
&& let StmtKind::Expr(expr) = &stmt.kind
11921194
{
11931195
expr
11941196
} else {
@@ -1248,7 +1250,9 @@ impl Expr {
12481250
expr.to_ty().map(|ty| TyKind::Array(ty, expr_len.clone()))?
12491251
}
12501252

1251-
ExprKind::Array(exprs) if exprs.len() == 1 => exprs[0].to_ty().map(TyKind::Slice)?,
1253+
ExprKind::Array(exprs) if let [expr] = exprs.as_slice() => {
1254+
expr.to_ty().map(TyKind::Slice)?
1255+
}
12521256

12531257
ExprKind::Tup(exprs) => {
12541258
let tys = exprs.iter().map(|expr| expr.to_ty()).collect::<Option<ThinVec<_>>>()?;

compiler/rustc_ast_lowering/src/delegation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
275275
// FIXME(fn_delegation): Alternatives for target expression lowering:
276276
// https://github.com/rust-lang/rfcs/pull/3530#issuecomment-2197170600.
277277
fn lower_target_expr(&mut self, block: &Block) -> hir::Expr<'hir> {
278-
if block.stmts.len() == 1
279-
&& let StmtKind::Expr(expr) = &block.stmts[0].kind
278+
if let [stmt] = block.stmts.as_slice()
279+
&& let StmtKind::Expr(expr) = &stmt.kind
280280
{
281281
return self.lower_expr_mut(expr);
282282
}

compiler/rustc_ast_lowering/src/item.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
16681668
}),
16691669
)),
16701670
)),
1671-
// FIXME(effects) we might not need a default.
16721671
default: Some(default_ct),
16731672
is_host_effect: true,
16741673
synthetic: true,

compiler/rustc_ast_pretty/src/pprust/state.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,8 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
502502
if !self.is_beginning_of_line() {
503503
self.word(" ");
504504
}
505-
if cmnt.lines.len() == 1 {
506-
self.word(cmnt.lines[0].clone());
505+
if let [line] = cmnt.lines.as_slice() {
506+
self.word(line.clone());
507507
self.hardbreak()
508508
} else {
509509
self.visual_align();

compiler/rustc_ast_pretty/src/pprust/state/item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,8 @@ impl<'a> State<'a> {
783783
}
784784
if items.is_empty() {
785785
self.word("{}");
786-
} else if items.len() == 1 {
787-
self.print_use_tree(&items[0].0);
786+
} else if let [(item, _)] = items.as_slice() {
787+
self.print_use_tree(item);
788788
} else {
789789
self.cbox(INDENT_UNIT);
790790
self.word("{");

compiler/rustc_attr/src/builtin.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -665,12 +665,12 @@ pub fn eval_condition(
665665
res & eval_condition(mi.meta_item().unwrap(), sess, features, eval)
666666
}),
667667
sym::not => {
668-
if mis.len() != 1 {
668+
let [mi] = mis.as_slice() else {
669669
dcx.emit_err(session_diagnostics::ExpectedOneCfgPattern { span: cfg.span });
670670
return false;
671-
}
671+
};
672672

673-
!eval_condition(mis[0].meta_item().unwrap(), sess, features, eval)
673+
!eval_condition(mi.meta_item().unwrap(), sess, features, eval)
674674
}
675675
sym::target => {
676676
if let Some(features) = features
@@ -1051,10 +1051,10 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
10511051
MetaItemKind::List(nested_items) => {
10521052
if meta_item.has_name(sym::align) {
10531053
recognised = true;
1054-
if nested_items.len() == 1 {
1054+
if let [nested_item] = nested_items.as_slice() {
10551055
sess.dcx().emit_err(
10561056
session_diagnostics::IncorrectReprFormatExpectInteger {
1057-
span: nested_items[0].span(),
1057+
span: nested_item.span(),
10581058
},
10591059
);
10601060
} else {
@@ -1066,10 +1066,10 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
10661066
}
10671067
} else if meta_item.has_name(sym::packed) {
10681068
recognised = true;
1069-
if nested_items.len() == 1 {
1069+
if let [nested_item] = nested_items.as_slice() {
10701070
sess.dcx().emit_err(
10711071
session_diagnostics::IncorrectReprFormatPackedExpectInteger {
1072-
span: nested_items[0].span(),
1072+
span: nested_item.span(),
10731073
},
10741074
);
10751075
} else {

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1124,8 +1124,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
11241124
err.multipart_suggestion(
11251125
"consider moving the expression out of the loop so it is only moved once",
11261126
vec![
1127-
(parent.span, "value".to_string()),
11281127
(span.shrink_to_lo(), format!("let mut value = {value};{indent}")),
1128+
(parent.span, "value".to_string()),
11291129
],
11301130
Applicability::MaybeIncorrect,
11311131
);

compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ impl OutlivesSuggestionBuilder {
206206

207207
// If there is exactly one suggestable constraints, then just suggest it. Otherwise, emit a
208208
// list of diagnostics.
209-
let mut diag = if suggested.len() == 1 {
210-
mbcx.dcx().struct_help(match suggested.last().unwrap() {
209+
let mut diag = if let [constraint] = suggested.as_slice() {
210+
mbcx.dcx().struct_help(match constraint {
211211
SuggestedConstraint::Outlives(a, bs) => {
212212
let bs: SmallVec<[String; 2]> = bs.iter().map(|r| r.to_string()).collect();
213213
format!("add bound `{a}: {}`", bs.join(" + "))

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+20-15
Original file line numberDiff line numberDiff line change
@@ -225,21 +225,26 @@ impl<'tcx> RegionInferenceContext<'tcx> {
225225

226226
// Find something that we can name
227227
let upper_bound = self.approx_universal_upper_bound(vid);
228-
let upper_bound = &self.definitions[upper_bound];
229-
match upper_bound.external_name {
230-
Some(reg) => reg,
231-
None => {
232-
// Nothing exact found, so we pick the first one that we find.
233-
let scc = self.constraint_sccs.scc(vid);
234-
for vid in self.rev_scc_graph.as_ref().unwrap().upper_bounds(scc) {
235-
match self.definitions[vid].external_name {
236-
None => {}
237-
Some(region) if region.is_static() => {}
238-
Some(region) => return region,
239-
}
240-
}
241-
region
242-
}
228+
if let Some(universal_region) = self.definitions[upper_bound].external_name {
229+
return universal_region;
230+
}
231+
232+
// Nothing exact found, so we pick a named upper bound, if there's only one.
233+
// If there's >1 universal region, then we probably are dealing w/ an intersection
234+
// region which cannot be mapped back to a universal.
235+
// FIXME: We could probably compute the LUB if there is one.
236+
let scc = self.constraint_sccs.scc(vid);
237+
let upper_bounds: Vec<_> = self
238+
.rev_scc_graph
239+
.as_ref()
240+
.unwrap()
241+
.upper_bounds(scc)
242+
.filter_map(|vid| self.definitions[vid].external_name)
243+
.filter(|r| !r.is_static())
244+
.collect();
245+
match &upper_bounds[..] {
246+
[universal_region] => *universal_region,
247+
_ => region,
243248
}
244249
}
245250
_ => region,

compiler/rustc_borrowck/src/type_check/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -2330,10 +2330,16 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
23302330
match (cast_ty_from, cast_ty_to) {
23312331
(Some(CastTy::Ptr(src)), Some(CastTy::Ptr(dst))) => {
23322332
let mut normalize = |t| self.normalize(t, location);
2333+
2334+
// N.B. `struct_tail_with_normalize` only "structurally resolves"
2335+
// the type. It is not fully normalized, so we have to normalize it
2336+
// afterwards.
23332337
let src_tail =
23342338
tcx.struct_tail_with_normalize(src.ty, &mut normalize, || ());
2339+
let src_tail = normalize(src_tail);
23352340
let dst_tail =
23362341
tcx.struct_tail_with_normalize(dst.ty, &mut normalize, || ());
2342+
let dst_tail = normalize(dst_tail);
23372343

23382344
// This checks (lifetime part of) vtable validity for pointer casts,
23392345
// which is irrelevant when there are aren't principal traits on both sides (aka only auto traits).

compiler/rustc_builtin_macros/src/asm.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -745,10 +745,9 @@ fn expand_preparsed_asm(
745745
unused_operands.push((args.operands[idx].1, msg));
746746
}
747747
}
748-
match unused_operands.len() {
749-
0 => {}
750-
1 => {
751-
let (sp, msg) = unused_operands.into_iter().next().unwrap();
748+
match unused_operands[..] {
749+
[] => {}
750+
[(sp, msg)] => {
752751
ecx.dcx()
753752
.struct_span_err(sp, msg)
754753
.with_span_label(sp, msg)

0 commit comments

Comments
 (0)