Skip to content

Commit edbed40

Browse files
committed
Auto merge of #95464 - lcnr:backport-94925, r=Dylan-DPC
[beta] backport #94925 backports #94925 looks like that PR might have slipped through 🤔 does it help if there's an open issue to track that in the future, or are there other things I can do to make this less likely in the future? r? `@Mark-Simulacrum`
2 parents 7bccde1 + f81aea9 commit edbed40

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

Diff for: compiler/rustc_typeck/src/coherence/orphan.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -300,17 +300,11 @@ impl<'tcx> TypeVisitor<'tcx> for AreUniqueParamsVisitor {
300300
_ => ControlFlow::Break(NotUniqueParam::NotParam(t.into())),
301301
}
302302
}
303-
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
304-
match *r {
305-
ty::ReEarlyBound(p) => {
306-
if self.seen.insert(p.index) {
307-
ControlFlow::CONTINUE
308-
} else {
309-
ControlFlow::Break(NotUniqueParam::DuplicateParam(r.into()))
310-
}
311-
}
312-
_ => ControlFlow::Break(NotUniqueParam::NotParam(r.into())),
313-
}
303+
fn visit_region(&mut self, _: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
304+
// We don't drop candidates during candidate assembly because of region
305+
// constraints, so the behavior for impls only constrained by regions
306+
// will not change.
307+
ControlFlow::CONTINUE
314308
}
315309
fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
316310
match c.val() {

Diff for: src/test/ui/auto-traits/suspicious-impls-lint.rs

+6
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,10 @@ unsafe impl<T> Send for WithPhantomDataSend<*const T, i8> {}
4141
//~^ ERROR
4242
//~| WARNING this will change its meaning
4343

44+
pub struct WithLifetime<'a, T>(&'a (), T);
45+
unsafe impl<T> Send for WithLifetime<'static, T> {} // ok
46+
unsafe impl<T> Sync for WithLifetime<'static, Vec<T>> {}
47+
//~^ ERROR
48+
//~| WARNING this will change its meaning
49+
4450
fn main() {}

Diff for: src/test/ui/auto-traits/suspicious-impls-lint.stderr

+16-1
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,20 @@ LL | pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U);
6363
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6464
= note: `*const T` is not a generic parameter
6565

66-
error: aborting due to 4 previous errors
66+
error: cross-crate traits with a default impl, like `Sync`, should not be specialized
67+
--> $DIR/suspicious-impls-lint.rs:46:1
68+
|
69+
LL | unsafe impl<T> Sync for WithLifetime<'static, Vec<T>> {}
70+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
71+
|
72+
= warning: this will change its meaning in a future release!
73+
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
74+
note: try using the same sequence of generic parameters as the struct definition
75+
--> $DIR/suspicious-impls-lint.rs:44:1
76+
|
77+
LL | pub struct WithLifetime<'a, T>(&'a (), T);
78+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
79+
= note: `Vec<T>` is not a generic parameter
80+
81+
error: aborting due to 5 previous errors
6782

0 commit comments

Comments
 (0)