diff options
| author | bors <bors@rust-lang.org> | 2022-03-31 02:53:34 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-03-31 02:53:34 +0000 |
| commit | edbed409aaed33aa949e7044fbf39c366b0af92b (patch) | |
| tree | d1ed4a643e93252169db662d9780889a7150432f | |
| parent | 7bccde19767082c7865a12902fa614ed4f8fed73 (diff) | |
| parent | f81aea969d02c91faa824fc5798cfd9579b17ddd (diff) | |
| download | rust-edbed409aaed33aa949e7044fbf39c366b0af92b.tar.gz rust-edbed409aaed33aa949e7044fbf39c366b0af92b.zip | |
Auto merge of #95464 - lcnr:backport-94925, r=Dylan-DPC
[beta] backport #94925 backports #94925 looks like that PR might have slipped through :thinking: 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`
| -rw-r--r-- | compiler/rustc_typeck/src/coherence/orphan.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/auto-traits/suspicious-impls-lint.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/auto-traits/suspicious-impls-lint.stderr | 17 |
3 files changed, 27 insertions, 12 deletions
diff --git a/compiler/rustc_typeck/src/coherence/orphan.rs b/compiler/rustc_typeck/src/coherence/orphan.rs index dfa4120784a..20f42b16b14 100644 --- a/compiler/rustc_typeck/src/coherence/orphan.rs +++ b/compiler/rustc_typeck/src/coherence/orphan.rs @@ -300,17 +300,11 @@ impl<'tcx> TypeVisitor<'tcx> for AreUniqueParamsVisitor { _ => ControlFlow::Break(NotUniqueParam::NotParam(t.into())), } } - fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> { - match *r { - ty::ReEarlyBound(p) => { - if self.seen.insert(p.index) { - ControlFlow::CONTINUE - } else { - ControlFlow::Break(NotUniqueParam::DuplicateParam(r.into())) - } - } - _ => ControlFlow::Break(NotUniqueParam::NotParam(r.into())), - } + fn visit_region(&mut self, _: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> { + // We don't drop candidates during candidate assembly because of region + // constraints, so the behavior for impls only constrained by regions + // will not change. + ControlFlow::CONTINUE } fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> { match c.val() { diff --git a/src/test/ui/auto-traits/suspicious-impls-lint.rs b/src/test/ui/auto-traits/suspicious-impls-lint.rs index 1574a7e02e9..7712e84f4a2 100644 --- a/src/test/ui/auto-traits/suspicious-impls-lint.rs +++ b/src/test/ui/auto-traits/suspicious-impls-lint.rs @@ -41,4 +41,10 @@ unsafe impl<T> Send for WithPhantomDataSend<*const T, i8> {} //~^ ERROR //~| WARNING this will change its meaning +pub struct WithLifetime<'a, T>(&'a (), T); +unsafe impl<T> Send for WithLifetime<'static, T> {} // ok +unsafe impl<T> Sync for WithLifetime<'static, Vec<T>> {} +//~^ ERROR +//~| WARNING this will change its meaning + fn main() {} diff --git a/src/test/ui/auto-traits/suspicious-impls-lint.stderr b/src/test/ui/auto-traits/suspicious-impls-lint.stderr index 084bfef49c0..e299e5369fe 100644 --- a/src/test/ui/auto-traits/suspicious-impls-lint.stderr +++ b/src/test/ui/auto-traits/suspicious-impls-lint.stderr @@ -63,5 +63,20 @@ LL | pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `*const T` is not a generic parameter -error: aborting due to 4 previous errors +error: cross-crate traits with a default impl, like `Sync`, should not be specialized + --> $DIR/suspicious-impls-lint.rs:46:1 + | +LL | unsafe impl<T> Sync for WithLifetime<'static, Vec<T>> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this will change its meaning in a future release! + = note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367> +note: try using the same sequence of generic parameters as the struct definition + --> $DIR/suspicious-impls-lint.rs:44:1 + | +LL | pub struct WithLifetime<'a, T>(&'a (), T); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: `Vec<T>` is not a generic parameter + +error: aborting due to 5 previous errors |
