Skip to content

Commit dff3e7c

Browse files
committed
Auto merge of #133500 - GuillaumeGomez:rollup-4vcthwo, r=GuillaumeGomez
Rollup of 13 pull requests Successful merges: - #133411 (the emscripten OS no longer exists on non-wasm targets) - #133419 (Added a doc test for std::path::strip_prefix) - #133430 (Tweak parameter mismatch explanation to not say `{unknown}`) - #133443 (Remove dead code stemming from the old effects desugaring (II)) - #133450 (remove "onur-ozkan" from users_on_vacation) - #133454 (Update test expectations to accept LLVM 'initializes' attribute) - #133462 (Use ReadCache for archive reading in bootstrap) - #133464 (std::thread: avoid leading whitespace in some panic messages) - #133467 (tests: Add recursive associated type bound regression tests) - #133470 (Cleanup: delete `//@ pretty-expanded` directive) - #133473 (tests: Add regression test for recursive enum with Cow and Clone) - #133481 (Disable `avr-rjmp-offset` on Windows for now) - #133495 (add test for alias-bound shadowing, rename folder) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f2abf82 + 0dba983 commit dff3e7c

File tree

693 files changed

+233
-773
lines changed

Some content is hidden

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

693 files changed

+233
-773
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+3-15
Original file line numberDiff line numberDiff line change
@@ -2117,11 +2117,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21172117
hir::ConstArgKind::Anon(ct)
21182118
};
21192119

2120-
self.arena.alloc(hir::ConstArg {
2121-
hir_id: self.next_id(),
2122-
kind: ct_kind,
2123-
is_desugared_from_effects: false,
2124-
})
2120+
self.arena.alloc(hir::ConstArg { hir_id: self.next_id(), kind: ct_kind })
21252121
}
21262122

21272123
/// See [`hir::ConstArg`] for when to use this function vs
@@ -2163,19 +2159,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21632159
None,
21642160
);
21652161

2166-
return ConstArg {
2167-
hir_id: self.next_id(),
2168-
kind: hir::ConstArgKind::Path(qpath),
2169-
is_desugared_from_effects: false,
2170-
};
2162+
return ConstArg { hir_id: self.next_id(), kind: hir::ConstArgKind::Path(qpath) };
21712163
}
21722164

21732165
let lowered_anon = self.lower_anon_const_to_anon_const(anon);
2174-
ConstArg {
2175-
hir_id: self.next_id(),
2176-
kind: hir::ConstArgKind::Anon(lowered_anon),
2177-
is_desugared_from_effects: false,
2178-
}
2166+
ConstArg { hir_id: self.next_id(), kind: hir::ConstArgKind::Anon(lowered_anon) }
21792167
}
21802168

21812169
/// See [`hir::ConstArg`] for when to use this function vs

compiler/rustc_hir/src/hir.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,6 @@ pub struct ConstArg<'hir> {
261261
#[stable_hasher(ignore)]
262262
pub hir_id: HirId,
263263
pub kind: ConstArgKind<'hir>,
264-
/// Indicates whether this comes from a `~const` desugaring.
265-
pub is_desugared_from_effects: bool,
266264
}
267265

268266
impl<'hir> ConstArg<'hir> {
@@ -462,14 +460,7 @@ impl<'hir> GenericArgs<'hir> {
462460
/// This function returns the number of type and const generic params.
463461
/// It should only be used for diagnostics.
464462
pub fn num_generic_params(&self) -> usize {
465-
self.args
466-
.iter()
467-
.filter(|arg| match arg {
468-
GenericArg::Lifetime(_)
469-
| GenericArg::Const(ConstArg { is_desugared_from_effects: true, .. }) => false,
470-
_ => true,
471-
})
472-
.count()
463+
self.args.iter().filter(|arg| !matches!(arg, GenericArg::Lifetime(_))).count()
473464
}
474465

475466
/// The span encompassing the arguments and constraints[^1] inside the surrounding brackets.

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+30-23
Original file line numberDiff line numberDiff line change
@@ -2347,9 +2347,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
23472347

23482348
let check_for_matched_generics = || {
23492349
if matched_inputs.iter().any(|x| x.is_some())
2350-
&& params_with_generics.iter().any(|x| x.0.is_some())
2350+
&& params_with_generics.iter().any(|x| x.1.is_some())
23512351
{
2352-
for (idx, (generic, _)) in params_with_generics.iter().enumerate() {
2352+
for &(idx, generic, _) in &params_with_generics {
23532353
// Param has to have a generic and be matched to be relevant
23542354
if matched_inputs[idx.into()].is_none() {
23552355
continue;
@@ -2362,7 +2362,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
23622362
for unmatching_idx in idx + 1..params_with_generics.len() {
23632363
if matched_inputs[unmatching_idx.into()].is_none()
23642364
&& let Some(unmatched_idx_param_generic) =
2365-
params_with_generics[unmatching_idx].0
2365+
params_with_generics[unmatching_idx].1
23662366
&& unmatched_idx_param_generic.name.ident()
23672367
== generic.name.ident()
23682368
{
@@ -2377,8 +2377,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
23772377

23782378
let check_for_matched_generics = check_for_matched_generics();
23792379

2380-
for (idx, (generic_param, param)) in
2381-
params_with_generics.iter().enumerate().filter(|(idx, _)| {
2380+
for &(idx, generic_param, param) in
2381+
params_with_generics.iter().filter(|&(idx, _, _)| {
23822382
check_for_matched_generics
23832383
|| expected_idx.is_none_or(|expected_idx| expected_idx == *idx)
23842384
})
@@ -2390,8 +2390,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
23902390

23912391
let other_params_matched: Vec<(usize, &hir::Param<'_>)> = params_with_generics
23922392
.iter()
2393-
.enumerate()
2394-
.filter(|(other_idx, (other_generic_param, _))| {
2393+
.filter(|(other_idx, other_generic_param, _)| {
23952394
if *other_idx == idx {
23962395
return false;
23972396
}
@@ -2410,18 +2409,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24102409
}
24112410
other_generic_param.name.ident() == generic_param.name.ident()
24122411
})
2413-
.map(|(other_idx, (_, other_param))| (other_idx, *other_param))
2412+
.map(|&(other_idx, _, other_param)| (other_idx, other_param))
24142413
.collect();
24152414

24162415
if !other_params_matched.is_empty() {
24172416
let other_param_matched_names: Vec<String> = other_params_matched
24182417
.iter()
2419-
.map(|(_, other_param)| {
2418+
.map(|(idx, other_param)| {
24202419
if let hir::PatKind::Binding(_, _, ident, _) = other_param.pat.kind
24212420
{
24222421
format!("`{ident}`")
24232422
} else {
2424-
"{unknown}".to_string()
2423+
format!("parameter #{}", idx + 1)
24252424
}
24262425
})
24272426
.collect();
@@ -2478,18 +2477,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24782477
{
24792478
let param_idents_matching: Vec<String> = params_with_generics
24802479
.iter()
2481-
.filter(|(generic, _)| {
2480+
.filter(|(_, generic, _)| {
24822481
if let Some(generic) = generic {
24832482
generic.name.ident() == generic_param.name.ident()
24842483
} else {
24852484
false
24862485
}
24872486
})
2488-
.map(|(_, param)| {
2487+
.map(|(idx, _, param)| {
24892488
if let hir::PatKind::Binding(_, _, ident, _) = param.pat.kind {
24902489
format!("`{ident}`")
24912490
} else {
2492-
"{unknown}".to_string()
2491+
format!("parameter #{}", idx + 1)
24932492
}
24942493
})
24952494
.collect();
@@ -2498,8 +2497,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24982497
spans.push_span_label(
24992498
generic_param.span,
25002499
format!(
2501-
"{} all reference this parameter {}",
2500+
"{} {} reference this parameter `{}`",
25022501
display_list_with_comma_and(&param_idents_matching),
2502+
if param_idents_matching.len() == 2 { "both" } else { "all" },
25032503
generic_param.name.ident().name,
25042504
),
25052505
);
@@ -2580,7 +2580,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
25802580

25812581
if let Some(params_with_generics) = self.get_hir_params_with_generics(def_id, is_method) {
25822582
debug_assert_eq!(params_with_generics.len(), matched_inputs.len());
2583-
for (idx, (generic_param, _)) in params_with_generics.iter().enumerate() {
2583+
for &(idx, generic_param, _) in &params_with_generics {
25842584
if matched_inputs[idx.into()].is_none() {
25852585
continue;
25862586
}
@@ -2594,20 +2594,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
25942594
};
25952595

25962596
let mut idxs_matched: Vec<usize> = vec![];
2597-
for (other_idx, (_, _)) in params_with_generics.iter().enumerate().filter(
2598-
|(other_idx, (other_generic_param, _))| {
2599-
if *other_idx == idx {
2597+
for &(other_idx, _, _) in
2598+
params_with_generics.iter().filter(|&&(other_idx, other_generic_param, _)| {
2599+
if other_idx == idx {
26002600
return false;
26012601
}
26022602
let Some(other_generic_param) = other_generic_param else {
26032603
return false;
26042604
};
2605-
if matched_inputs[(*other_idx).into()].is_some() {
2605+
if matched_inputs[other_idx.into()].is_some() {
26062606
return false;
26072607
}
26082608
other_generic_param.name.ident() == generic_param.name.ident()
2609-
},
2610-
) {
2609+
})
2610+
{
26112611
idxs_matched.push(other_idx);
26122612
}
26132613

@@ -2642,7 +2642,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26422642
&self,
26432643
def_id: DefId,
26442644
is_method: bool,
2645-
) -> Option<Vec<(Option<&hir::GenericParam<'_>>, &hir::Param<'_>)>> {
2645+
) -> Option<Vec<(usize, Option<&hir::GenericParam<'_>>, &hir::Param<'_>)>> {
26462646
let fn_node = self.tcx.hir().get_if_local(def_id)?;
26472647
let fn_decl = fn_node.fn_decl()?;
26482648

@@ -2685,7 +2685,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26852685
}
26862686

26872687
debug_assert_eq!(params.len(), generic_params.len());
2688-
Some(generic_params.into_iter().zip(params).collect())
2688+
Some(
2689+
generic_params
2690+
.into_iter()
2691+
.zip(params)
2692+
.enumerate()
2693+
.map(|(a, (b, c))| (a, b, c))
2694+
.collect(),
2695+
)
26892696
}
26902697
}
26912698

compiler/rustc_metadata/src/creader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ fn attempt_load_dylib(path: &Path) -> Result<libloading::Library, libloading::Er
11721172
// the expected format is lib<name>.a(libname.so) for the actual
11731173
// dynamic library
11741174
let library_name = path.file_stem().expect("expect a library name");
1175-
let mut archive_member = OsString::from("a(");
1175+
let mut archive_member = std::ffi::OsString::from("a(");
11761176
archive_member.push(library_name);
11771177
archive_member.push(".so)");
11781178
let new_path = path.with_extension(archive_member);

compiler/rustc_target/src/spec/tests/tests_impl.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ impl Target {
1919
if self.is_like_msvc {
2020
assert!(self.is_like_windows);
2121
}
22+
if self.os == "emscripten" {
23+
assert!(self.is_like_wasm);
24+
}
2225

2326
// Check that default linker flavor is compatible with some other key properties.
2427
assert_eq!(self.is_like_osx, matches!(self.linker_flavor, LinkerFlavor::Darwin(..)));
@@ -137,7 +140,7 @@ impl Target {
137140
assert!(self.dynamic_linking);
138141
}
139142
// Apparently PIC was slow on wasm at some point, see comments in wasm_base.rs
140-
if self.dynamic_linking && !(self.is_like_wasm && self.os != "emscripten") {
143+
if self.dynamic_linking && !self.is_like_wasm {
141144
assert_eq!(self.relocation_model, RelocModel::Pic);
142145
}
143146
if self.position_independent_executables {

library/std/src/path.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2504,6 +2504,7 @@ impl Path {
25042504
/// assert_eq!(path.strip_prefix("/test/haha/foo.txt/"), Ok(Path::new("")));
25052505
///
25062506
/// assert!(path.strip_prefix("test").is_err());
2507+
/// assert!(path.strip_prefix("/te").is_err());
25072508
/// assert!(path.strip_prefix("/haha").is_err());
25082509
///
25092510
/// let prefix = PathBuf::from("/test/");

library/std/src/thread/current.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -243,17 +243,17 @@ fn init_current(current: *mut ()) -> Thread {
243243
// a particular API should be entirely allocation-free, feel free to open
244244
// an issue on the Rust repository, we'll see what we can do.
245245
rtabort!(
246-
"\n
247-
Attempted to access thread-local data while allocating said data.\n
248-
Do not access functions that allocate in the global allocator!\n
249-
This is a bug in the global allocator.\n
250-
"
246+
"\n\
247+
Attempted to access thread-local data while allocating said data.\n\
248+
Do not access functions that allocate in the global allocator!\n\
249+
This is a bug in the global allocator.\n\
250+
"
251251
)
252252
} else {
253253
debug_assert_eq!(current, DESTROYED);
254254
panic!(
255-
"use of std::thread::current() is not possible after the thread's
256-
local data has been destroyed"
255+
"use of std::thread::current() is not possible after the thread's \
256+
local data has been destroyed"
257257
)
258258
}
259259
}

src/bootstrap/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fd-lock = "4.0"
4747
home = "0.5"
4848
ignore = "0.4"
4949
libc = "0.2"
50-
object = { version = "0.36.3", default-features = false, features = ["archive", "coff", "read_core", "unaligned"] }
50+
object = { version = "0.36.3", default-features = false, features = ["archive", "coff", "read_core", "std", "unaligned"] }
5151
opener = "0.5"
5252
semver = "1.0"
5353
serde = "1.0"

src/bootstrap/src/utils/helpers.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,18 @@ pub fn is_dylib(path: &Path) -> bool {
6161
}
6262

6363
fn is_aix_shared_archive(path: &Path) -> bool {
64-
// FIXME(#133268): reading the entire file as &[u8] into memory seems excessive
65-
// look into either mmap it or use the ReadCache
66-
let data = match fs::read(path) {
67-
Ok(data) => data,
64+
let file = match fs::File::open(path) {
65+
Ok(file) => file,
6866
Err(_) => return false,
6967
};
70-
let file = match ArchiveFile::parse(&*data) {
71-
Ok(file) => file,
68+
let reader = object::ReadCache::new(file);
69+
let archive = match ArchiveFile::parse(&reader) {
70+
Ok(result) => result,
7271
Err(_) => return false,
7372
};
7473

75-
file.members()
74+
archive
75+
.members()
7676
.filter_map(Result::ok)
7777
.any(|entry| String::from_utf8_lossy(entry.name()).contains(".so"))
7878
}

src/librustdoc/clean/mod.rs

-8
Original file line numberDiff line numberDiff line change
@@ -2516,14 +2516,6 @@ fn clean_generic_args<'tcx>(
25162516
}
25172517
hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
25182518
hir::GenericArg::Type(ty) => GenericArg::Type(clean_ty(ty, cx)),
2519-
// Checking for `is_desugared_from_effects` on the `AnonConst` not only accounts for the case
2520-
// where the argument is `host` but for all possible cases (e.g., `true`, `false`).
2521-
hir::GenericArg::Const(hir::ConstArg {
2522-
is_desugared_from_effects: true,
2523-
..
2524-
}) => {
2525-
return None;
2526-
}
25272519
hir::GenericArg::Const(ct) => GenericArg::Const(Box::new(clean_const(ct, cx))),
25282520
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
25292521
})

src/tools/compiletest/src/directive-list.rs

-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
214214
"only-x86_64-unknown-linux-gnu",
215215
"pp-exact",
216216
"pretty-compare-only",
217-
"pretty-expanded",
218217
"pretty-mode",
219218
"reference",
220219
"regex-error-pattern",

src/tools/compiletest/src/header.rs

-5
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ pub struct TestProps {
124124
// a proc-macro and needs `#![crate_type = "proc-macro"]`. This ensures
125125
// that the aux file is compiled as a `proc-macro` and not as a `dylib`.
126126
pub no_prefer_dynamic: bool,
127-
// Run -Zunpretty expanded when running pretty printing tests
128-
pub pretty_expanded: bool,
129127
// Which pretty mode are we testing with, default to 'normal'
130128
pub pretty_mode: String,
131129
// Only compare pretty output and don't try compiling
@@ -218,7 +216,6 @@ mod directives {
218216
pub const DONT_CHECK_COMPILER_STDOUT: &'static str = "dont-check-compiler-stdout";
219217
pub const DONT_CHECK_COMPILER_STDERR: &'static str = "dont-check-compiler-stderr";
220218
pub const NO_PREFER_DYNAMIC: &'static str = "no-prefer-dynamic";
221-
pub const PRETTY_EXPANDED: &'static str = "pretty-expanded";
222219
pub const PRETTY_MODE: &'static str = "pretty-mode";
223220
pub const PRETTY_COMPARE_ONLY: &'static str = "pretty-compare-only";
224221
pub const AUX_BIN: &'static str = "aux-bin";
@@ -278,7 +275,6 @@ impl TestProps {
278275
dont_check_compiler_stderr: false,
279276
compare_output_lines_by_subset: false,
280277
no_prefer_dynamic: false,
281-
pretty_expanded: false,
282278
pretty_mode: "normal".to_string(),
283279
pretty_compare_only: false,
284280
forbid_output: vec![],
@@ -425,7 +421,6 @@ impl TestProps {
425421
&mut self.dont_check_compiler_stderr,
426422
);
427423
config.set_name_directive(ln, NO_PREFER_DYNAMIC, &mut self.no_prefer_dynamic);
428-
config.set_name_directive(ln, PRETTY_EXPANDED, &mut self.pretty_expanded);
429424

430425
if let Some(m) = config.parse_name_value_directive(ln, PRETTY_MODE) {
431426
self.pretty_mode = m;

src/tools/compiletest/src/runtest/pretty.rs

-16
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,5 @@ impl TestCx<'_> {
8484
if !proc_res.status.success() {
8585
self.fatal_proc_rec("pretty-printed source does not typecheck", &proc_res);
8686
}
87-
88-
if !self.props.pretty_expanded {
89-
return;
90-
}
91-
92-
// additionally, run `-Zunpretty=expanded` and try to build it.
93-
let proc_res = self.print_source(ReadFrom::Path, "expanded");
94-
if !proc_res.status.success() {
95-
self.fatal_proc_rec("pretty-printing (expanded) failed", &proc_res);
96-
}
97-
98-
let ProcRes { stdout: expanded_src, .. } = proc_res;
99-
let proc_res = self.typecheck_source(expanded_src);
100-
if !proc_res.status.success() {
101-
self.fatal_proc_rec("pretty-printed source (expanded) does not typecheck", &proc_res);
102-
}
10387
}
10488
}

0 commit comments

Comments
 (0)