Skip to content

Commit

Permalink
Auto merge of rust-lang#133500 - GuillaumeGomez:rollup-4vcthwo, r=Gui…
Browse files Browse the repository at this point in the history
…llaumeGomez

Rollup of 13 pull requests

Successful merges:

 - rust-lang#133411 (the emscripten OS no longer exists on non-wasm targets)
 - rust-lang#133419 (Added a doc test for std::path::strip_prefix)
 - rust-lang#133430 (Tweak parameter mismatch explanation to not say `{unknown}`)
 - rust-lang#133443 (Remove dead code stemming from the old effects desugaring (II))
 - rust-lang#133450 (remove "onur-ozkan" from  users_on_vacation)
 - rust-lang#133454 (Update test expectations to accept LLVM 'initializes' attribute)
 - rust-lang#133462 (Use ReadCache for archive reading in bootstrap)
 - rust-lang#133464 (std::thread: avoid leading whitespace in some panic messages)
 - rust-lang#133467 (tests: Add recursive associated type bound regression tests)
 - rust-lang#133470 (Cleanup: delete `//@ pretty-expanded` directive)
 - rust-lang#133473 (tests: Add regression test for recursive enum with Cow and Clone)
 - rust-lang#133481 (Disable `avr-rjmp-offset` on Windows for now)
 - rust-lang#133495 (add test for alias-bound shadowing, rename folder)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Nov 26, 2024
2 parents f2abf82 + 0dba983 commit dff3e7c
Show file tree
Hide file tree
Showing 693 changed files with 233 additions and 773 deletions.
18 changes: 3 additions & 15 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2117,11 +2117,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
hir::ConstArgKind::Anon(ct)
};

self.arena.alloc(hir::ConstArg {
hir_id: self.next_id(),
kind: ct_kind,
is_desugared_from_effects: false,
})
self.arena.alloc(hir::ConstArg { hir_id: self.next_id(), kind: ct_kind })
}

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

return ConstArg {
hir_id: self.next_id(),
kind: hir::ConstArgKind::Path(qpath),
is_desugared_from_effects: false,
};
return ConstArg { hir_id: self.next_id(), kind: hir::ConstArgKind::Path(qpath) };
}

let lowered_anon = self.lower_anon_const_to_anon_const(anon);
ConstArg {
hir_id: self.next_id(),
kind: hir::ConstArgKind::Anon(lowered_anon),
is_desugared_from_effects: false,
}
ConstArg { hir_id: self.next_id(), kind: hir::ConstArgKind::Anon(lowered_anon) }
}

/// See [`hir::ConstArg`] for when to use this function vs
Expand Down
11 changes: 1 addition & 10 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@ pub struct ConstArg<'hir> {
#[stable_hasher(ignore)]
pub hir_id: HirId,
pub kind: ConstArgKind<'hir>,
/// Indicates whether this comes from a `~const` desugaring.
pub is_desugared_from_effects: bool,
}

impl<'hir> ConstArg<'hir> {
Expand Down Expand Up @@ -462,14 +460,7 @@ impl<'hir> GenericArgs<'hir> {
/// This function returns the number of type and const generic params.
/// It should only be used for diagnostics.
pub fn num_generic_params(&self) -> usize {
self.args
.iter()
.filter(|arg| match arg {
GenericArg::Lifetime(_)
| GenericArg::Const(ConstArg { is_desugared_from_effects: true, .. }) => false,
_ => true,
})
.count()
self.args.iter().filter(|arg| !matches!(arg, GenericArg::Lifetime(_))).count()
}

/// The span encompassing the arguments and constraints[^1] inside the surrounding brackets.
Expand Down
53 changes: 30 additions & 23 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2347,9 +2347,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

let check_for_matched_generics = || {
if matched_inputs.iter().any(|x| x.is_some())
&& params_with_generics.iter().any(|x| x.0.is_some())
&& params_with_generics.iter().any(|x| x.1.is_some())
{
for (idx, (generic, _)) in params_with_generics.iter().enumerate() {
for &(idx, generic, _) in &params_with_generics {
// Param has to have a generic and be matched to be relevant
if matched_inputs[idx.into()].is_none() {
continue;
Expand All @@ -2362,7 +2362,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
for unmatching_idx in idx + 1..params_with_generics.len() {
if matched_inputs[unmatching_idx.into()].is_none()
&& let Some(unmatched_idx_param_generic) =
params_with_generics[unmatching_idx].0
params_with_generics[unmatching_idx].1
&& unmatched_idx_param_generic.name.ident()
== generic.name.ident()
{
Expand All @@ -2377,8 +2377,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

let check_for_matched_generics = check_for_matched_generics();

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

let other_params_matched: Vec<(usize, &hir::Param<'_>)> = params_with_generics
.iter()
.enumerate()
.filter(|(other_idx, (other_generic_param, _))| {
.filter(|(other_idx, other_generic_param, _)| {
if *other_idx == idx {
return false;
}
Expand All @@ -2410,18 +2409,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
other_generic_param.name.ident() == generic_param.name.ident()
})
.map(|(other_idx, (_, other_param))| (other_idx, *other_param))
.map(|&(other_idx, _, other_param)| (other_idx, other_param))
.collect();

if !other_params_matched.is_empty() {
let other_param_matched_names: Vec<String> = other_params_matched
.iter()
.map(|(_, other_param)| {
.map(|(idx, other_param)| {
if let hir::PatKind::Binding(_, _, ident, _) = other_param.pat.kind
{
format!("`{ident}`")
} else {
"{unknown}".to_string()
format!("parameter #{}", idx + 1)
}
})
.collect();
Expand Down Expand Up @@ -2478,18 +2477,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{
let param_idents_matching: Vec<String> = params_with_generics
.iter()
.filter(|(generic, _)| {
.filter(|(_, generic, _)| {
if let Some(generic) = generic {
generic.name.ident() == generic_param.name.ident()
} else {
false
}
})
.map(|(_, param)| {
.map(|(idx, _, param)| {
if let hir::PatKind::Binding(_, _, ident, _) = param.pat.kind {
format!("`{ident}`")
} else {
"{unknown}".to_string()
format!("parameter #{}", idx + 1)
}
})
.collect();
Expand All @@ -2498,8 +2497,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
spans.push_span_label(
generic_param.span,
format!(
"{} all reference this parameter {}",
"{} {} reference this parameter `{}`",
display_list_with_comma_and(&param_idents_matching),
if param_idents_matching.len() == 2 { "both" } else { "all" },
generic_param.name.ident().name,
),
);
Expand Down Expand Up @@ -2580,7 +2580,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

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

let mut idxs_matched: Vec<usize> = vec![];
for (other_idx, (_, _)) in params_with_generics.iter().enumerate().filter(
|(other_idx, (other_generic_param, _))| {
if *other_idx == idx {
for &(other_idx, _, _) in
params_with_generics.iter().filter(|&&(other_idx, other_generic_param, _)| {
if other_idx == idx {
return false;
}
let Some(other_generic_param) = other_generic_param else {
return false;
};
if matched_inputs[(*other_idx).into()].is_some() {
if matched_inputs[other_idx.into()].is_some() {
return false;
}
other_generic_param.name.ident() == generic_param.name.ident()
},
) {
})
{
idxs_matched.push(other_idx);
}

Expand Down Expand Up @@ -2642,7 +2642,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self,
def_id: DefId,
is_method: bool,
) -> Option<Vec<(Option<&hir::GenericParam<'_>>, &hir::Param<'_>)>> {
) -> Option<Vec<(usize, Option<&hir::GenericParam<'_>>, &hir::Param<'_>)>> {
let fn_node = self.tcx.hir().get_if_local(def_id)?;
let fn_decl = fn_node.fn_decl()?;

Expand Down Expand Up @@ -2685,7 +2685,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

debug_assert_eq!(params.len(), generic_params.len());
Some(generic_params.into_iter().zip(params).collect())
Some(
generic_params
.into_iter()
.zip(params)
.enumerate()
.map(|(a, (b, c))| (a, b, c))
.collect(),
)
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ fn attempt_load_dylib(path: &Path) -> Result<libloading::Library, libloading::Er
// the expected format is lib<name>.a(libname.so) for the actual
// dynamic library
let library_name = path.file_stem().expect("expect a library name");
let mut archive_member = OsString::from("a(");
let mut archive_member = std::ffi::OsString::from("a(");
archive_member.push(library_name);
archive_member.push(".so)");
let new_path = path.with_extension(archive_member);
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_target/src/spec/tests/tests_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ impl Target {
if self.is_like_msvc {
assert!(self.is_like_windows);
}
if self.os == "emscripten" {
assert!(self.is_like_wasm);
}

// Check that default linker flavor is compatible with some other key properties.
assert_eq!(self.is_like_osx, matches!(self.linker_flavor, LinkerFlavor::Darwin(..)));
Expand Down Expand Up @@ -137,7 +140,7 @@ impl Target {
assert!(self.dynamic_linking);
}
// Apparently PIC was slow on wasm at some point, see comments in wasm_base.rs
if self.dynamic_linking && !(self.is_like_wasm && self.os != "emscripten") {
if self.dynamic_linking && !self.is_like_wasm {
assert_eq!(self.relocation_model, RelocModel::Pic);
}
if self.position_independent_executables {
Expand Down
1 change: 1 addition & 0 deletions library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2504,6 +2504,7 @@ impl Path {
/// assert_eq!(path.strip_prefix("/test/haha/foo.txt/"), Ok(Path::new("")));
///
/// assert!(path.strip_prefix("test").is_err());
/// assert!(path.strip_prefix("/te").is_err());
/// assert!(path.strip_prefix("/haha").is_err());
///
/// let prefix = PathBuf::from("/test/");
Expand Down
14 changes: 7 additions & 7 deletions library/std/src/thread/current.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,17 @@ fn init_current(current: *mut ()) -> Thread {
// a particular API should be entirely allocation-free, feel free to open
// an issue on the Rust repository, we'll see what we can do.
rtabort!(
"\n
Attempted to access thread-local data while allocating said data.\n
Do not access functions that allocate in the global allocator!\n
This is a bug in the global allocator.\n
"
"\n\
Attempted to access thread-local data while allocating said data.\n\
Do not access functions that allocate in the global allocator!\n\
This is a bug in the global allocator.\n\
"
)
} else {
debug_assert_eq!(current, DESTROYED);
panic!(
"use of std::thread::current() is not possible after the thread's
local data has been destroyed"
"use of std::thread::current() is not possible after the thread's \
local data has been destroyed"
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fd-lock = "4.0"
home = "0.5"
ignore = "0.4"
libc = "0.2"
object = { version = "0.36.3", default-features = false, features = ["archive", "coff", "read_core", "unaligned"] }
object = { version = "0.36.3", default-features = false, features = ["archive", "coff", "read_core", "std", "unaligned"] }
opener = "0.5"
semver = "1.0"
serde = "1.0"
Expand Down
14 changes: 7 additions & 7 deletions src/bootstrap/src/utils/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ pub fn is_dylib(path: &Path) -> bool {
}

fn is_aix_shared_archive(path: &Path) -> bool {
// FIXME(#133268): reading the entire file as &[u8] into memory seems excessive
// look into either mmap it or use the ReadCache
let data = match fs::read(path) {
Ok(data) => data,
let file = match fs::File::open(path) {
Ok(file) => file,
Err(_) => return false,
};
let file = match ArchiveFile::parse(&*data) {
Ok(file) => file,
let reader = object::ReadCache::new(file);
let archive = match ArchiveFile::parse(&reader) {
Ok(result) => result,
Err(_) => return false,
};

file.members()
archive
.members()
.filter_map(Result::ok)
.any(|entry| String::from_utf8_lossy(entry.name()).contains(".so"))
}
Expand Down
8 changes: 0 additions & 8 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2516,14 +2516,6 @@ fn clean_generic_args<'tcx>(
}
hir::GenericArg::Lifetime(_) => GenericArg::Lifetime(Lifetime::elided()),
hir::GenericArg::Type(ty) => GenericArg::Type(clean_ty(ty, cx)),
// Checking for `is_desugared_from_effects` on the `AnonConst` not only accounts for the case
// where the argument is `host` but for all possible cases (e.g., `true`, `false`).
hir::GenericArg::Const(hir::ConstArg {
is_desugared_from_effects: true,
..
}) => {
return None;
}
hir::GenericArg::Const(ct) => GenericArg::Const(Box::new(clean_const(ct, cx))),
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
})
Expand Down
1 change: 0 additions & 1 deletion src/tools/compiletest/src/directive-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"only-x86_64-unknown-linux-gnu",
"pp-exact",
"pretty-compare-only",
"pretty-expanded",
"pretty-mode",
"reference",
"regex-error-pattern",
Expand Down
5 changes: 0 additions & 5 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ pub struct TestProps {
// a proc-macro and needs `#![crate_type = "proc-macro"]`. This ensures
// that the aux file is compiled as a `proc-macro` and not as a `dylib`.
pub no_prefer_dynamic: bool,
// Run -Zunpretty expanded when running pretty printing tests
pub pretty_expanded: bool,
// Which pretty mode are we testing with, default to 'normal'
pub pretty_mode: String,
// Only compare pretty output and don't try compiling
Expand Down Expand Up @@ -218,7 +216,6 @@ mod directives {
pub const DONT_CHECK_COMPILER_STDOUT: &'static str = "dont-check-compiler-stdout";
pub const DONT_CHECK_COMPILER_STDERR: &'static str = "dont-check-compiler-stderr";
pub const NO_PREFER_DYNAMIC: &'static str = "no-prefer-dynamic";
pub const PRETTY_EXPANDED: &'static str = "pretty-expanded";
pub const PRETTY_MODE: &'static str = "pretty-mode";
pub const PRETTY_COMPARE_ONLY: &'static str = "pretty-compare-only";
pub const AUX_BIN: &'static str = "aux-bin";
Expand Down Expand Up @@ -278,7 +275,6 @@ impl TestProps {
dont_check_compiler_stderr: false,
compare_output_lines_by_subset: false,
no_prefer_dynamic: false,
pretty_expanded: false,
pretty_mode: "normal".to_string(),
pretty_compare_only: false,
forbid_output: vec![],
Expand Down Expand Up @@ -425,7 +421,6 @@ impl TestProps {
&mut self.dont_check_compiler_stderr,
);
config.set_name_directive(ln, NO_PREFER_DYNAMIC, &mut self.no_prefer_dynamic);
config.set_name_directive(ln, PRETTY_EXPANDED, &mut self.pretty_expanded);

if let Some(m) = config.parse_name_value_directive(ln, PRETTY_MODE) {
self.pretty_mode = m;
Expand Down
16 changes: 0 additions & 16 deletions src/tools/compiletest/src/runtest/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,5 @@ impl TestCx<'_> {
if !proc_res.status.success() {
self.fatal_proc_rec("pretty-printed source does not typecheck", &proc_res);
}

if !self.props.pretty_expanded {
return;
}

// additionally, run `-Zunpretty=expanded` and try to build it.
let proc_res = self.print_source(ReadFrom::Path, "expanded");
if !proc_res.status.success() {
self.fatal_proc_rec("pretty-printing (expanded) failed", &proc_res);
}

let ProcRes { stdout: expanded_src, .. } = proc_res;
let proc_res = self.typecheck_source(expanded_src);
if !proc_res.status.success() {
self.fatal_proc_rec("pretty-printed source (expanded) does not typecheck", &proc_res);
}
}
}
Loading

0 comments on commit dff3e7c

Please sign in to comment.