Skip to content

Commit 0c31763

Browse files
committed
Auto merge of rust-lang#130878 - matthiaskrgr:rollup-npprq87, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#129687 (Implement RFC3137 trim-paths sysroot changes - take 2) - rust-lang#130820 (Fix diagnostics for coroutines with () as input.) - rust-lang#130833 (Fix the misleading diagnostic for `let_underscore_drop` on type without `Drop` implementation) - rust-lang#130845 (Utf8Chunks: add link to Utf8Chunk) - rust-lang#130868 (Update FIXME comment in s390x_unknown_linux_*.rs) - rust-lang#130873 (rustc_target: Add powerpc64 atomic-related features) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f2becdf + a4a17a3 commit 0c31763

23 files changed

+215
-107
lines changed

compiler/rustc_lint/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ lint_non_binding_let_multi_suggestion =
531531
consider immediately dropping the value
532532
533533
lint_non_binding_let_on_drop_type =
534-
non-binding let on a type that implements `Drop`
534+
non-binding let on a type that has a destructor
535535
536536
lint_non_binding_let_on_sync_lock = non-binding let on a synchronization lock
537537
.label = this lock is not assigned to a binding and is immediately dropped

compiler/rustc_lint/src/let_underscore.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ declare_lint! {
5151
/// intent.
5252
pub LET_UNDERSCORE_DROP,
5353
Allow,
54-
"non-binding let on a type that implements `Drop`"
54+
"non-binding let on a type that has a destructor"
5555
}
5656

5757
declare_lint! {

compiler/rustc_metadata/src/rmeta/decoder.rs

+56-49
Original file line numberDiff line numberDiff line change
@@ -1622,56 +1622,63 @@ impl<'a> CrateMetadataRef<'a> {
16221622
);
16231623

16241624
for virtual_dir in virtual_rust_source_base_dir.iter().flatten() {
1625-
if let Some(real_dir) = &sess.opts.real_rust_source_base_dir {
1626-
if let rustc_span::FileName::Real(old_name) = name {
1627-
if let rustc_span::RealFileName::Remapped { local_path: _, virtual_name } =
1628-
old_name
1629-
{
1630-
if let Ok(rest) = virtual_name.strip_prefix(virtual_dir) {
1631-
let virtual_name = virtual_name.clone();
1632-
1633-
// The std library crates are in
1634-
// `$sysroot/lib/rustlib/src/rust/library`, whereas other crates
1635-
// may be in `$sysroot/lib/rustlib/src/rust/` directly. So we
1636-
// detect crates from the std libs and handle them specially.
1637-
const STD_LIBS: &[&str] = &[
1638-
"core",
1639-
"alloc",
1640-
"std",
1641-
"test",
1642-
"term",
1643-
"unwind",
1644-
"proc_macro",
1645-
"panic_abort",
1646-
"panic_unwind",
1647-
"profiler_builtins",
1648-
"rtstartup",
1649-
"rustc-std-workspace-core",
1650-
"rustc-std-workspace-alloc",
1651-
"rustc-std-workspace-std",
1652-
"backtrace",
1653-
];
1654-
let is_std_lib = STD_LIBS.iter().any(|l| rest.starts_with(l));
1655-
1656-
let new_path = if is_std_lib {
1657-
real_dir.join("library").join(rest)
1658-
} else {
1659-
real_dir.join(rest)
1660-
};
1661-
1662-
debug!(
1663-
"try_to_translate_virtual_to_real: `{}` -> `{}`",
1664-
virtual_name.display(),
1665-
new_path.display(),
1666-
);
1667-
let new_name = rustc_span::RealFileName::Remapped {
1668-
local_path: Some(new_path),
1669-
virtual_name,
1670-
};
1671-
*old_name = new_name;
1672-
}
1625+
if let Some(real_dir) = &sess.opts.real_rust_source_base_dir
1626+
&& let rustc_span::FileName::Real(old_name) = name
1627+
&& let rustc_span::RealFileName::Remapped { local_path: _, virtual_name } =
1628+
old_name
1629+
&& let Ok(rest) = virtual_name.strip_prefix(virtual_dir)
1630+
{
1631+
// The std library crates are in
1632+
// `$sysroot/lib/rustlib/src/rust/library`, whereas other crates
1633+
// may be in `$sysroot/lib/rustlib/src/rust/` directly. So we
1634+
// detect crates from the std libs and handle them specially.
1635+
const STD_LIBS: &[&str] = &[
1636+
"core",
1637+
"alloc",
1638+
"std",
1639+
"test",
1640+
"term",
1641+
"unwind",
1642+
"proc_macro",
1643+
"panic_abort",
1644+
"panic_unwind",
1645+
"profiler_builtins",
1646+
"rtstartup",
1647+
"rustc-std-workspace-core",
1648+
"rustc-std-workspace-alloc",
1649+
"rustc-std-workspace-std",
1650+
"backtrace",
1651+
];
1652+
let is_std_lib = STD_LIBS.iter().any(|l| rest.starts_with(l));
1653+
1654+
let new_path = if is_std_lib {
1655+
real_dir.join("library").join(rest)
1656+
} else {
1657+
real_dir.join(rest)
1658+
};
1659+
1660+
debug!(
1661+
"try_to_translate_virtual_to_real: `{}` -> `{}`",
1662+
virtual_name.display(),
1663+
new_path.display(),
1664+
);
1665+
1666+
// Check if the translated real path is affected by any user-requested
1667+
// remaps via --remap-path-prefix. Apply them if so.
1668+
// Note that this is a special case for imported rust-src paths specified by
1669+
// https://rust-lang.github.io/rfcs/3127-trim-paths.html#handling-sysroot-paths.
1670+
// Other imported paths are not currently remapped (see #66251).
1671+
let (user_remapped, applied) =
1672+
sess.source_map().path_mapping().map_prefix(&new_path);
1673+
let new_name = if applied {
1674+
rustc_span::RealFileName::Remapped {
1675+
local_path: Some(new_path.clone()),
1676+
virtual_name: user_remapped.to_path_buf(),
16731677
}
1674-
}
1678+
} else {
1679+
rustc_span::RealFileName::LocalPath(new_path)
1680+
};
1681+
*old_name = new_name;
16751682
}
16761683
}
16771684
};

compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ pub(crate) fn target() -> Target {
66
base.endian = Endian::Big;
77
// z10 is the oldest CPU supported by LLVM
88
base.cpu = "z10".into();
9-
// FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector
10-
// ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we
11-
// also strip v128 from the data_layout below to match the older LLVM's expectation.
9+
// FIXME: The ABI implementation in abi/call/s390x.rs is for now hard-coded to assume the no-vector
10+
// ABI. Pass the -vector feature string to LLVM to respect this assumption.
1211
base.features = "-vector".into();
1312
base.max_atomic_width = Some(128);
1413
base.min_global_align = Some(16);

compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ pub(crate) fn target() -> Target {
66
base.endian = Endian::Big;
77
// z10 is the oldest CPU supported by LLVM
88
base.cpu = "z10".into();
9-
// FIXME: The ABI implementation in cabi_s390x.rs is for now hard-coded to assume the no-vector
10-
// ABI. Pass the -vector feature string to LLVM to respect this assumption. On LLVM < 16, we
11-
// also strip v128 from the data_layout below to match the older LLVM's expectation.
9+
// FIXME: The ABI implementation in abi/call/s390x.rs is for now hard-coded to assume the no-vector
10+
// ABI. Pass the -vector feature string to LLVM to respect this assumption.
1211
base.features = "-vector".into();
1312
base.max_atomic_width = Some(128);
1413
base.min_global_align = Some(16);

compiler/rustc_target/src/target_features.rs

+2
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,13 @@ const HEXAGON_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
352352
const POWERPC_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
353353
// tidy-alphabetical-start
354354
("altivec", Unstable(sym::powerpc_target_feature), &[]),
355+
("partword-atomics", Unstable(sym::powerpc_target_feature), &[]),
355356
("power10-vector", Unstable(sym::powerpc_target_feature), &["power9-vector"]),
356357
("power8-altivec", Unstable(sym::powerpc_target_feature), &["altivec"]),
357358
("power8-vector", Unstable(sym::powerpc_target_feature), &["vsx", "power8-altivec"]),
358359
("power9-altivec", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
359360
("power9-vector", Unstable(sym::powerpc_target_feature), &["power8-vector", "power9-altivec"]),
361+
("quadword-atomics", Unstable(sym::powerpc_target_feature), &[]),
360362
("vsx", Unstable(sym::powerpc_target_feature), &["altivec"]),
361363
// tidy-alphabetical-end
362364
];

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

+35-37
Original file line numberDiff line numberDiff line change
@@ -2635,49 +2635,47 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
26352635
// This shouldn't be common unless manually implementing one of the
26362636
// traits manually, but don't make it more confusing when it does
26372637
// happen.
2638-
Ok(
2639-
if Some(expected_trait_ref.def_id) != self.tcx.lang_items().coroutine_trait()
2640-
&& not_tupled
2641-
{
2642-
self.report_and_explain_type_error(
2643-
TypeTrace::trait_refs(
2644-
&obligation.cause,
2645-
true,
2646-
expected_trait_ref,
2647-
found_trait_ref,
2648-
),
2649-
ty::error::TypeError::Mismatch,
2650-
)
2651-
} else if found.len() == expected.len() {
2652-
self.report_closure_arg_mismatch(
2653-
span,
2654-
found_span,
2655-
found_trait_ref,
2656-
expected_trait_ref,
2657-
obligation.cause.code(),
2658-
found_node,
2659-
obligation.param_env,
2660-
)
2661-
} else {
2662-
let (closure_span, closure_arg_span, found) = found_did
2663-
.and_then(|did| {
2664-
let node = self.tcx.hir().get_if_local(did)?;
2665-
let (found_span, closure_arg_span, found) =
2666-
self.get_fn_like_arguments(node)?;
2667-
Some((Some(found_span), closure_arg_span, found))
2668-
})
2669-
.unwrap_or((found_span, None, found));
2670-
2671-
self.report_arg_count_mismatch(
2638+
if Some(expected_trait_ref.def_id) != self.tcx.lang_items().coroutine_trait() && not_tupled
2639+
{
2640+
return Ok(self.report_and_explain_type_error(
2641+
TypeTrace::trait_refs(&obligation.cause, true, expected_trait_ref, found_trait_ref),
2642+
ty::error::TypeError::Mismatch,
2643+
));
2644+
}
2645+
if found.len() != expected.len() {
2646+
let (closure_span, closure_arg_span, found) = found_did
2647+
.and_then(|did| {
2648+
let node = self.tcx.hir().get_if_local(did)?;
2649+
let (found_span, closure_arg_span, found) = self.get_fn_like_arguments(node)?;
2650+
Some((Some(found_span), closure_arg_span, found))
2651+
})
2652+
.unwrap_or((found_span, None, found));
2653+
2654+
// If the coroutine take a single () as its argument,
2655+
// the trait argument would found the coroutine take 0 arguments,
2656+
// but get_fn_like_arguments would give 1 argument.
2657+
// This would result in "Expected to take 1 argument, but it takes 1 argument".
2658+
// Check again to avoid this.
2659+
if found.len() != expected.len() {
2660+
return Ok(self.report_arg_count_mismatch(
26722661
span,
26732662
closure_span,
26742663
expected,
26752664
found,
26762665
found_trait_ty.is_closure(),
26772666
closure_arg_span,
2678-
)
2679-
},
2680-
)
2667+
));
2668+
}
2669+
}
2670+
Ok(self.report_closure_arg_mismatch(
2671+
span,
2672+
found_span,
2673+
found_trait_ref,
2674+
expected_trait_ref,
2675+
obligation.cause.code(),
2676+
found_node,
2677+
obligation.param_env,
2678+
))
26812679
}
26822680

26832681
/// Given some node representing a fn-like thing in the HIR map,

library/core/src/str/lossy.rs

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ impl [u8] {
88
/// Creates an iterator over the contiguous valid UTF-8 ranges of this
99
/// slice, and the non-UTF-8 fragments in between.
1010
///
11+
/// See the [`Utf8Chunk`] type for documenation of the items yielded by this iterator.
12+
///
1113
/// # Examples
1214
///
1315
/// This function formats arbitrary but mostly-UTF-8 bytes into Rust source
@@ -148,6 +150,8 @@ impl fmt::Debug for Debug<'_> {
148150
/// If you want a simple conversion from UTF-8 byte slices to string slices,
149151
/// [`from_utf8`] is easier to use.
150152
///
153+
/// See the [`Utf8Chunk`] type for documenation of the items yielded by this iterator.
154+
///
151155
/// [byteslice]: slice
152156
/// [`from_utf8`]: super::from_utf8
153157
///

src/tools/compiletest/src/header.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,7 @@ fn expand_variables(mut value: String, config: &Config) -> String {
11151115
const CWD: &str = "{{cwd}}";
11161116
const SRC_BASE: &str = "{{src-base}}";
11171117
const BUILD_BASE: &str = "{{build-base}}";
1118+
const RUST_SRC_BASE: &str = "{{rust-src-base}}";
11181119
const SYSROOT_BASE: &str = "{{sysroot-base}}";
11191120
const TARGET_LINKER: &str = "{{target-linker}}";
11201121
const TARGET: &str = "{{target}}";
@@ -1144,6 +1145,15 @@ fn expand_variables(mut value: String, config: &Config) -> String {
11441145
value = value.replace(TARGET, &config.target);
11451146
}
11461147

1148+
if value.contains(RUST_SRC_BASE) {
1149+
let src_base = config
1150+
.sysroot_base
1151+
.join("lib/rustlib/src/rust")
1152+
.read_link()
1153+
.expect("lib/rustlib/src/rust in target is a symlink to checkout root");
1154+
value = value.replace(RUST_SRC_BASE, &src_base.to_string_lossy());
1155+
}
1156+
11471157
value
11481158
}
11491159

src/tools/compiletest/src/runtest.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -2294,7 +2294,7 @@ impl<'test> TestCx<'test> {
22942294
}
22952295

22962296
let base_dir = Path::new("/rustc/FAKE_PREFIX");
2297-
// Paths into the libstd/libcore
2297+
// Fake paths into the libstd/libcore
22982298
normalize_path(&base_dir.join("library"), "$SRC_DIR");
22992299
// `ui-fulldeps` tests can show paths to the compiler source when testing macros from
23002300
// `rustc_macros`
@@ -2310,8 +2310,14 @@ impl<'test> TestCx<'test> {
23102310
// eg. /home/user/rust/build
23112311
normalize_path(parent_build_dir, "$BUILD_DIR");
23122312

2313-
// Paths into lib directory.
2314-
normalize_path(&parent_build_dir.parent().unwrap().join("lib"), "$LIB_DIR");
2313+
// Real paths into the libstd/libcore
2314+
let rust_src_dir = &self
2315+
.config
2316+
.sysroot_base
2317+
.join("lib/rustlib/src/rust")
2318+
.read_link()
2319+
.expect("lib/rustlib/src/rust in target is a symlink to checkout root");
2320+
normalize_path(&rust_src_dir.join("library"), "$SRC_DIR_REAL");
23152321

23162322
if json {
23172323
// escaped newlines in json strings should be readable

tests/ui/check-cfg/mix.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ warning: unexpected `cfg` condition value: `zebra`
251251
LL | cfg!(target_feature = "zebra");
252252
| ^^^^^^^^^^^^^^^^^^^^^^^^
253253
|
254-
= note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 239 more
254+
= note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 241 more
255255
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
256256

257257
warning: 27 warnings emitted

0 commit comments

Comments
 (0)