Skip to content

Commit 4ecd70d

Browse files
committed
Auto merge of rust-lang#137611 - fmease:rollup-ln673ux, r=fmease
Rollup of 6 pull requests Successful merges: - rust-lang#135480 (Don't require method impls for methods with `Self:Sized` bounds for impls for unsized types) - rust-lang#137360 (Use `as_chunks` in `analyze_source_file_sse2`) - rust-lang#137460 (downgrade bootstrap `cc`) - rust-lang#137515 (Update `compiler-builtins` to 0.1.148) - rust-lang#137522 (use stage 2 on cargo and clippy tests when possible) - rust-lang#137597 (Revert accidental cargo submodule update) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c51b9b6 + fb9ae4c commit 4ecd70d

23 files changed

+222
-43
lines changed

compiler/rustc_codegen_cranelift/patches/0029-stdlib-Disable-f16-and-f128-in-compiler-builtins.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ index 7165c3e48af..968552ad435 100644
1616

1717
[dependencies]
1818
core = { path = "../core", public = true }
19-
-compiler_builtins = { version = "=0.1.147", features = ['rustc-dep-of-std'] }
20-
+compiler_builtins = { version = "=0.1.147", features = ['rustc-dep-of-std', 'no-f16-f128'] }
19+
-compiler_builtins = { version = "=0.1.148", features = ['rustc-dep-of-std'] }
20+
+compiler_builtins = { version = "=0.1.148", features = ['rustc-dep-of-std', 'no-f16-f128'] }
2121

2222
[dev-dependencies]
2323
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }

compiler/rustc_hir_analysis/messages.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,8 @@ hir_analysis_unused_generic_parameter_adt_no_phantom_data_help =
605605
hir_analysis_unused_generic_parameter_ty_alias_help =
606606
consider removing `{$param_name}` or referring to it in the body of the type alias
607607
608+
hir_analysis_useless_impl_item = this item cannot be used as its where bounds are not satisfied for the `Self` type
609+
608610
hir_analysis_value_of_associated_struct_already_specified =
609611
the value of the associated type `{$item_name}` in trait `{$def_path}` is already specified
610612
.label = re-bound here

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,32 @@ fn check_impl_items_against_trait<'tcx>(
992992

993993
let trait_def = tcx.trait_def(trait_ref.def_id);
994994

995+
let infcx = tcx.infer_ctxt().ignoring_regions().build(TypingMode::non_body_analysis());
996+
997+
let ocx = ObligationCtxt::new_with_diagnostics(&infcx);
998+
let cause = ObligationCause::misc(tcx.def_span(impl_id), impl_id);
999+
let param_env = tcx.param_env(impl_id);
1000+
1001+
let self_is_guaranteed_unsized = match tcx
1002+
.struct_tail_raw(
1003+
trait_ref.self_ty(),
1004+
|ty| {
1005+
ocx.structurally_normalize_ty(&cause, param_env, ty).unwrap_or_else(|_| {
1006+
Ty::new_error_with_message(
1007+
tcx,
1008+
tcx.def_span(impl_id),
1009+
"struct tail should be computable",
1010+
)
1011+
})
1012+
},
1013+
|| (),
1014+
)
1015+
.kind()
1016+
{
1017+
ty::Dynamic(_, _, ty::DynKind::Dyn) | ty::Slice(_) | ty::Str => true,
1018+
_ => false,
1019+
};
1020+
9951021
for &impl_item in impl_item_refs {
9961022
let ty_impl_item = tcx.associated_item(impl_item);
9971023
let ty_trait_item = if let Some(trait_item_id) = ty_impl_item.trait_item_def_id {
@@ -1021,6 +1047,15 @@ fn check_impl_items_against_trait<'tcx>(
10211047
}
10221048
}
10231049

1050+
if self_is_guaranteed_unsized && tcx.generics_require_sized_self(ty_trait_item.def_id) {
1051+
tcx.emit_node_span_lint(
1052+
rustc_lint_defs::builtin::DEAD_CODE,
1053+
tcx.local_def_id_to_hir_id(ty_impl_item.def_id.expect_local()),
1054+
tcx.def_span(ty_impl_item.def_id),
1055+
errors::UselessImplItem,
1056+
)
1057+
}
1058+
10241059
check_specialization_validity(
10251060
tcx,
10261061
trait_def,
@@ -1044,7 +1079,11 @@ fn check_impl_items_against_trait<'tcx>(
10441079
.as_ref()
10451080
.is_some_and(|node_item| node_item.item.defaultness(tcx).has_value());
10461081

1047-
if !is_implemented && tcx.defaultness(impl_id).is_final() {
1082+
if !is_implemented
1083+
&& tcx.defaultness(impl_id).is_final()
1084+
// unsized types don't need to implement methods that have `Self: Sized` bounds.
1085+
&& !(self_is_guaranteed_unsized && tcx.generics_require_sized_self(trait_item_id))
1086+
{
10481087
missing_items.push(tcx.associated_item(trait_item_id));
10491088
}
10501089

compiler/rustc_hir_analysis/src/errors.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,10 @@ pub(crate) enum ImplNotMarkedDefault {
908908
},
909909
}
910910

911+
#[derive(LintDiagnostic)]
912+
#[diag(hir_analysis_useless_impl_item)]
913+
pub(crate) struct UselessImplItem;
914+
911915
#[derive(Diagnostic)]
912916
#[diag(hir_analysis_missing_trait_item, code = E0046)]
913917
pub(crate) struct MissingTraitItem {

compiler/rustc_span/src/analyze_source_file.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,18 @@ cfg_match! {
6868

6969
const CHUNK_SIZE: usize = 16;
7070

71-
let src_bytes = src.as_bytes();
72-
73-
let chunk_count = src.len() / CHUNK_SIZE;
71+
let (chunks, tail) = src.as_bytes().as_chunks::<CHUNK_SIZE>();
7472

7573
// This variable keeps track of where we should start decoding a
7674
// chunk. If a multi-byte character spans across chunk boundaries,
7775
// we need to skip that part in the next chunk because we already
7876
// handled it.
7977
let mut intra_chunk_offset = 0;
8078

81-
for chunk_index in 0..chunk_count {
82-
let ptr = src_bytes.as_ptr() as *const __m128i;
79+
for (chunk_index, chunk) in chunks.iter().enumerate() {
8380
// We don't know if the pointer is aligned to 16 bytes, so we
8481
// use `loadu`, which supports unaligned loading.
85-
let chunk = unsafe { _mm_loadu_si128(ptr.add(chunk_index)) };
82+
let chunk = unsafe { _mm_loadu_si128(chunk.as_ptr() as *const __m128i) };
8683

8784
// For character in the chunk, see if its byte value is < 0, which
8885
// indicates that it's part of a UTF-8 char.
@@ -123,7 +120,7 @@ cfg_match! {
123120
}
124121

125122
// There might still be a tail left to analyze
126-
let tail_start = chunk_count * CHUNK_SIZE + intra_chunk_offset;
123+
let tail_start = src.len() - tail.len() + intra_chunk_offset;
127124
if tail_start < src.len() {
128125
analyze_source_file_generic(
129126
&src[tail_start..],

compiler/rustc_span/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#![feature(round_char_boundary)]
3232
#![feature(rustc_attrs)]
3333
#![feature(rustdoc_internals)]
34+
#![feature(slice_as_chunks)]
3435
#![warn(unreachable_pub)]
3536
// tidy-alphabetical-end
3637

library/Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ dependencies = [
6161

6262
[[package]]
6363
name = "compiler_builtins"
64-
version = "0.1.147"
64+
version = "0.1.148"
6565
source = "registry+https://github.com/rust-lang/crates.io-index"
66-
checksum = "7170335a76fbcba350c3ea795c15df3b2c02934e35e502e82c4dd7837d4d0161"
66+
checksum = "26137996631d90d2727b905b480fdcf8c4479fdbce7afd7f8e3796d689b33cc2"
6767
dependencies = [
6868
"cc",
6969
"rustc-std-workspace-core",

library/alloc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ edition = "2021"
1212

1313
[dependencies]
1414
core = { path = "../core", public = true }
15-
compiler_builtins = { version = "=0.1.147", features = ['rustc-dep-of-std'] }
15+
compiler_builtins = { version = "=0.1.148", features = ['rustc-dep-of-std'] }
1616

1717
[dev-dependencies]
1818
rand = { version = "0.9.0", default-features = false, features = ["alloc"] }

library/std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
1818
panic_unwind = { path = "../panic_unwind", optional = true }
1919
panic_abort = { path = "../panic_abort" }
2020
core = { path = "../core", public = true }
21-
compiler_builtins = { version = "=0.1.147" }
21+
compiler_builtins = { version = "=0.1.148" }
2222
unwind = { path = "../unwind" }
2323
hashbrown = { version = "0.15", default-features = false, features = [
2424
'rustc-dep-of-std',

src/bootstrap/Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ dependencies = [
8888

8989
[[package]]
9090
name = "cc"
91-
version = "1.2.0"
91+
version = "1.1.22"
9292
source = "registry+https://github.com/rust-lang/crates.io-index"
93-
checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8"
93+
checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0"
9494
dependencies = [
9595
"shlex",
9696
]

0 commit comments

Comments
 (0)