Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 02e6243

Browse files
committedFeb 17, 2024
Remove suspicious auto trait lint
1 parent f311be1 commit 02e6243

22 files changed

+76
-474
lines changed
 

‎compiler/rustc_hir_analysis/src/coherence/orphan.rs

Lines changed: 4 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
//! Orphan checker: every impl either implements a trait defined in this
22
//! crate or pertains to a type defined in this crate.
33
4-
use rustc_data_structures::fx::FxHashSet;
5-
use rustc_errors::{DelayDm, ErrorGuaranteed};
4+
use rustc_errors::ErrorGuaranteed;
65
use rustc_hir as hir;
7-
use rustc_middle::ty::util::CheckRegions;
8-
use rustc_middle::ty::GenericArgs;
9-
use rustc_middle::ty::{
10-
self, AliasKind, ImplPolarity, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
11-
TypeVisitor,
12-
};
13-
use rustc_session::lint;
14-
use rustc_span::def_id::{DefId, LocalDefId};
6+
use rustc_middle::ty::{self, AliasKind, Ty, TyCtxt, TypeVisitableExt};
7+
use rustc_span::def_id::LocalDefId;
158
use rustc_span::Span;
169
use rustc_trait_selection::traits;
17-
use std::ops::ControlFlow;
1810

1911
use crate::errors;
2012

@@ -26,12 +18,7 @@ pub(crate) fn orphan_check_impl(
2618
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap().instantiate_identity();
2719
trait_ref.error_reported()?;
2820

29-
let ret = do_orphan_check_impl(tcx, trait_ref, impl_def_id);
30-
if tcx.trait_is_auto(trait_ref.def_id) {
31-
lint_auto_trait_impl(tcx, trait_ref, impl_def_id);
32-
}
33-
34-
ret
21+
do_orphan_check_impl(tcx, trait_ref, impl_def_id)
3522
}
3623

3724
fn do_orphan_check_impl<'tcx>(
@@ -445,146 +432,3 @@ fn emit_orphan_check_error<'tcx>(
445432
}
446433
})
447434
}
448-
449-
/// Lint impls of auto traits if they are likely to have
450-
/// unsound or surprising effects on auto impls.
451-
fn lint_auto_trait_impl<'tcx>(
452-
tcx: TyCtxt<'tcx>,
453-
trait_ref: ty::TraitRef<'tcx>,
454-
impl_def_id: LocalDefId,
455-
) {
456-
if trait_ref.args.len() != 1 {
457-
tcx.dcx().span_delayed_bug(
458-
tcx.def_span(impl_def_id),
459-
"auto traits cannot have generic parameters",
460-
);
461-
return;
462-
}
463-
let self_ty = trait_ref.self_ty();
464-
let (self_type_did, args) = match self_ty.kind() {
465-
ty::Adt(def, args) => (def.did(), args),
466-
_ => {
467-
// FIXME: should also lint for stuff like `&i32` but
468-
// considering that auto traits are unstable, that
469-
// isn't too important for now as this only affects
470-
// crates using `nightly`, and std.
471-
return;
472-
}
473-
};
474-
475-
// Impls which completely cover a given root type are fine as they
476-
// disable auto impls entirely. So only lint if the args
477-
// are not a permutation of the identity args.
478-
let Err(arg) = tcx.uses_unique_generic_params(args, CheckRegions::No) else {
479-
// ok
480-
return;
481-
};
482-
483-
// Ideally:
484-
//
485-
// - compute the requirements for the auto impl candidate
486-
// - check whether these are implied by the non covering impls
487-
// - if not, emit the lint
488-
//
489-
// What we do here is a bit simpler:
490-
//
491-
// - badly check if an auto impl candidate definitely does not apply
492-
// for the given simplified type
493-
// - if so, do not lint
494-
if fast_reject_auto_impl(tcx, trait_ref.def_id, self_ty) {
495-
// ok
496-
return;
497-
}
498-
499-
tcx.node_span_lint(
500-
lint::builtin::SUSPICIOUS_AUTO_TRAIT_IMPLS,
501-
tcx.local_def_id_to_hir_id(impl_def_id),
502-
tcx.def_span(impl_def_id),
503-
DelayDm(|| {
504-
format!(
505-
"cross-crate traits with a default impl, like `{}`, \
506-
should not be specialized",
507-
tcx.def_path_str(trait_ref.def_id),
508-
)
509-
}),
510-
|lint| {
511-
let item_span = tcx.def_span(self_type_did);
512-
let self_descr = tcx.def_descr(self_type_did);
513-
match arg {
514-
ty::util::NotUniqueParam::DuplicateParam(arg) => {
515-
lint.note(format!("`{arg}` is mentioned multiple times"));
516-
}
517-
ty::util::NotUniqueParam::NotParam(arg) => {
518-
lint.note(format!("`{arg}` is not a generic parameter"));
519-
}
520-
}
521-
lint.span_note(
522-
item_span,
523-
format!(
524-
"try using the same sequence of generic parameters as the {self_descr} definition",
525-
),
526-
);
527-
},
528-
);
529-
}
530-
531-
fn fast_reject_auto_impl<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId, self_ty: Ty<'tcx>) -> bool {
532-
struct DisableAutoTraitVisitor<'tcx> {
533-
tcx: TyCtxt<'tcx>,
534-
trait_def_id: DefId,
535-
self_ty_root: Ty<'tcx>,
536-
seen: FxHashSet<DefId>,
537-
}
538-
539-
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for DisableAutoTraitVisitor<'tcx> {
540-
type BreakTy = ();
541-
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
542-
let tcx = self.tcx;
543-
if ty != self.self_ty_root {
544-
for impl_def_id in tcx.non_blanket_impls_for_ty(self.trait_def_id, ty) {
545-
match tcx.impl_polarity(impl_def_id) {
546-
ImplPolarity::Negative => return ControlFlow::Break(()),
547-
ImplPolarity::Reservation => {}
548-
// FIXME(@lcnr): That's probably not good enough, idk
549-
//
550-
// We might just want to take the rustdoc code and somehow avoid
551-
// explicit impls for `Self`.
552-
ImplPolarity::Positive => return ControlFlow::Continue(()),
553-
}
554-
}
555-
}
556-
557-
match ty.kind() {
558-
ty::Adt(def, args) if def.is_phantom_data() => args.visit_with(self),
559-
ty::Adt(def, args) => {
560-
// @lcnr: This is the only place where cycles can happen. We avoid this
561-
// by only visiting each `DefId` once.
562-
//
563-
// This will be is incorrect in subtle cases, but I don't care :)
564-
if self.seen.insert(def.did()) {
565-
for ty in def.all_fields().map(|field| field.ty(tcx, args)) {
566-
ty.visit_with(self)?;
567-
}
568-
}
569-
570-
ControlFlow::Continue(())
571-
}
572-
_ => ty.super_visit_with(self),
573-
}
574-
}
575-
}
576-
577-
let self_ty_root = match self_ty.kind() {
578-
ty::Adt(def, _) => Ty::new_adt(tcx, *def, GenericArgs::identity_for_item(tcx, def.did())),
579-
_ => unimplemented!("unexpected self ty {:?}", self_ty),
580-
};
581-
582-
self_ty_root
583-
.visit_with(&mut DisableAutoTraitVisitor {
584-
tcx,
585-
self_ty_root,
586-
trait_def_id,
587-
seen: FxHashSet::default(),
588-
})
589-
.is_break()
590-
}

‎compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ declare_lint_pass! {
9090
SOFT_UNSTABLE,
9191
STABLE_FEATURES,
9292
STATIC_MUT_REF,
93-
SUSPICIOUS_AUTO_TRAIT_IMPLS,
9493
TEST_UNSTABLE_LINT,
9594
TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
9695
TRIVIAL_CASTS,
@@ -4032,40 +4031,6 @@ declare_lint! {
40324031
"duplicated attribute"
40334032
}
40344033

4035-
declare_lint! {
4036-
/// The `suspicious_auto_trait_impls` lint checks for potentially incorrect
4037-
/// implementations of auto traits.
4038-
///
4039-
/// ### Example
4040-
///
4041-
/// ```rust
4042-
/// struct Foo<T>(T);
4043-
///
4044-
/// unsafe impl<T> Send for Foo<*const T> {}
4045-
/// ```
4046-
///
4047-
/// {{produces}}
4048-
///
4049-
/// ### Explanation
4050-
///
4051-
/// A type can implement auto traits, e.g. `Send`, `Sync` and `Unpin`,
4052-
/// in two different ways: either by writing an explicit impl or if
4053-
/// all fields of the type implement that auto trait.
4054-
///
4055-
/// The compiler disables the automatic implementation if an explicit one
4056-
/// exists for given type constructor. The exact rules governing this
4057-
/// were previously unsound, quite subtle, and have been recently modified.
4058-
/// This change caused the automatic implementation to be disabled in more
4059-
/// cases, potentially breaking some code.
4060-
pub SUSPICIOUS_AUTO_TRAIT_IMPLS,
4061-
Warn,
4062-
"the rules governing auto traits have recently changed resulting in potential breakage",
4063-
@future_incompatible = FutureIncompatibleInfo {
4064-
reason: FutureIncompatibilityReason::FutureReleaseSemanticsChange,
4065-
reference: "issue #93367 <https://github.com/rust-lang/rust/issues/93367>",
4066-
};
4067-
}
4068-
40694034
declare_lint! {
40704035
/// The `deprecated_where_clause_location` lint detects when a where clause in front of the equals
40714036
/// in an associated type.

‎src/tools/clippy/tests/ui/non_send_fields_in_send_ty.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![warn(clippy::non_send_fields_in_send_ty)]
2-
#![allow(suspicious_auto_trait_impls)]
32
#![feature(extern_types)]
43

54
use std::cell::UnsafeCell;

‎src/tools/clippy/tests/ui/non_send_fields_in_send_ty.stderr

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: some fields in `RingBuffer<T>` are not safe to be sent to another thread
2-
--> $DIR/non_send_fields_in_send_ty.rs:17:1
2+
--> $DIR/non_send_fields_in_send_ty.rs:16:1
33
|
44
LL | unsafe impl<T> Send for RingBuffer<T> {}
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
note: it is not safe to send field `data` to another thread
8-
--> $DIR/non_send_fields_in_send_ty.rs:12:5
8+
--> $DIR/non_send_fields_in_send_ty.rs:11:5
99
|
1010
LL | data: Vec<UnsafeCell<T>>,
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -14,155 +14,155 @@ LL | data: Vec<UnsafeCell<T>>,
1414
= help: to override `-D warnings` add `#[allow(clippy::non_send_fields_in_send_ty)]`
1515

1616
error: some fields in `MvccRwLock<T>` are not safe to be sent to another thread
17-
--> $DIR/non_send_fields_in_send_ty.rs:26:1
17+
--> $DIR/non_send_fields_in_send_ty.rs:25:1
1818
|
1919
LL | unsafe impl<T> Send for MvccRwLock<T> {}
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2121
|
2222
note: it is not safe to send field `lock` to another thread
23-
--> $DIR/non_send_fields_in_send_ty.rs:23:5
23+
--> $DIR/non_send_fields_in_send_ty.rs:22:5
2424
|
2525
LL | lock: Mutex<Box<T>>,
2626
| ^^^^^^^^^^^^^^^^^^^
2727
= help: add bounds on type parameter `T` that satisfy `Mutex<Box<T>>: Send`
2828

2929
error: some fields in `ArcGuard<RC, T>` are not safe to be sent to another thread
30-
--> $DIR/non_send_fields_in_send_ty.rs:35:1
30+
--> $DIR/non_send_fields_in_send_ty.rs:34:1
3131
|
3232
LL | unsafe impl<RC, T: Send> Send for ArcGuard<RC, T> {}
3333
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3434
|
3535
note: it is not safe to send field `head` to another thread
36-
--> $DIR/non_send_fields_in_send_ty.rs:32:5
36+
--> $DIR/non_send_fields_in_send_ty.rs:31:5
3737
|
3838
LL | head: Arc<RC>,
3939
| ^^^^^^^^^^^^^
4040
= help: add bounds on type parameter `RC` that satisfy `Arc<RC>: Send`
4141

4242
error: some fields in `DeviceHandle<T>` are not safe to be sent to another thread
43-
--> $DIR/non_send_fields_in_send_ty.rs:52:1
43+
--> $DIR/non_send_fields_in_send_ty.rs:51:1
4444
|
4545
LL | unsafe impl<T: UsbContext> Send for DeviceHandle<T> {}
4646
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4747
|
4848
note: it is not safe to send field `context` to another thread
49-
--> $DIR/non_send_fields_in_send_ty.rs:48:5
49+
--> $DIR/non_send_fields_in_send_ty.rs:47:5
5050
|
5151
LL | context: T,
5252
| ^^^^^^^^^^
5353
= help: add `T: Send` bound in `Send` impl
5454

5555
error: some fields in `NoGeneric` are not safe to be sent to another thread
56-
--> $DIR/non_send_fields_in_send_ty.rs:60:1
56+
--> $DIR/non_send_fields_in_send_ty.rs:59:1
5757
|
5858
LL | unsafe impl Send for NoGeneric {}
5959
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6060
|
6161
note: it is not safe to send field `rc_is_not_send` to another thread
62-
--> $DIR/non_send_fields_in_send_ty.rs:57:5
62+
--> $DIR/non_send_fields_in_send_ty.rs:56:5
6363
|
6464
LL | rc_is_not_send: Rc<String>,
6565
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
6666
= help: use a thread-safe type that implements `Send`
6767

6868
error: some fields in `MultiField<T>` are not safe to be sent to another thread
69-
--> $DIR/non_send_fields_in_send_ty.rs:69:1
69+
--> $DIR/non_send_fields_in_send_ty.rs:68:1
7070
|
7171
LL | unsafe impl<T> Send for MultiField<T> {}
7272
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7373
|
7474
note: it is not safe to send field `field1` to another thread
75-
--> $DIR/non_send_fields_in_send_ty.rs:64:5
75+
--> $DIR/non_send_fields_in_send_ty.rs:63:5
7676
|
7777
LL | field1: T,
7878
| ^^^^^^^^^
7979
= help: add `T: Send` bound in `Send` impl
8080
note: it is not safe to send field `field2` to another thread
81-
--> $DIR/non_send_fields_in_send_ty.rs:65:5
81+
--> $DIR/non_send_fields_in_send_ty.rs:64:5
8282
|
8383
LL | field2: T,
8484
| ^^^^^^^^^
8585
= help: add `T: Send` bound in `Send` impl
8686
note: it is not safe to send field `field3` to another thread
87-
--> $DIR/non_send_fields_in_send_ty.rs:66:5
87+
--> $DIR/non_send_fields_in_send_ty.rs:65:5
8888
|
8989
LL | field3: T,
9090
| ^^^^^^^^^
9191
= help: add `T: Send` bound in `Send` impl
9292

9393
error: some fields in `MyOption<T>` are not safe to be sent to another thread
94-
--> $DIR/non_send_fields_in_send_ty.rs:77:1
94+
--> $DIR/non_send_fields_in_send_ty.rs:76:1
9595
|
9696
LL | unsafe impl<T> Send for MyOption<T> {}
9797
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9898
|
9999
note: it is not safe to send field `0` to another thread
100-
--> $DIR/non_send_fields_in_send_ty.rs:73:12
100+
--> $DIR/non_send_fields_in_send_ty.rs:72:12
101101
|
102102
LL | MySome(T),
103103
| ^
104104
= help: add `T: Send` bound in `Send` impl
105105

106106
error: some fields in `MultiParam<A, B>` are not safe to be sent to another thread
107-
--> $DIR/non_send_fields_in_send_ty.rs:90:1
107+
--> $DIR/non_send_fields_in_send_ty.rs:89:1
108108
|
109109
LL | unsafe impl<A, B> Send for MultiParam<A, B> {}
110110
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
111111
|
112112
note: it is not safe to send field `vec` to another thread
113-
--> $DIR/non_send_fields_in_send_ty.rs:87:5
113+
--> $DIR/non_send_fields_in_send_ty.rs:86:5
114114
|
115115
LL | vec: Vec<(A, B)>,
116116
| ^^^^^^^^^^^^^^^^
117117
= help: add bounds on type parameters `A, B` that satisfy `Vec<(A, B)>: Send`
118118

119119
error: some fields in `HeuristicTest` are not safe to be sent to another thread
120-
--> $DIR/non_send_fields_in_send_ty.rs:109:1
120+
--> $DIR/non_send_fields_in_send_ty.rs:108:1
121121
|
122122
LL | unsafe impl Send for HeuristicTest {}
123123
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
124124
|
125125
note: it is not safe to send field `field4` to another thread
126-
--> $DIR/non_send_fields_in_send_ty.rs:104:5
126+
--> $DIR/non_send_fields_in_send_ty.rs:103:5
127127
|
128128
LL | field4: (*const NonSend, Rc<u8>),
129129
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
130130
= help: use a thread-safe type that implements `Send`
131131

132132
error: some fields in `AttrTest3<T>` are not safe to be sent to another thread
133-
--> $DIR/non_send_fields_in_send_ty.rs:129:1
133+
--> $DIR/non_send_fields_in_send_ty.rs:128:1
134134
|
135135
LL | unsafe impl<T> Send for AttrTest3<T> {}
136136
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
137137
|
138138
note: it is not safe to send field `0` to another thread
139-
--> $DIR/non_send_fields_in_send_ty.rs:124:11
139+
--> $DIR/non_send_fields_in_send_ty.rs:123:11
140140
|
141141
LL | Enum2(T),
142142
| ^
143143
= help: add `T: Send` bound in `Send` impl
144144

145145
error: some fields in `Complex<P, u32>` are not safe to be sent to another thread
146-
--> $DIR/non_send_fields_in_send_ty.rs:138:1
146+
--> $DIR/non_send_fields_in_send_ty.rs:137:1
147147
|
148148
LL | unsafe impl<P> Send for Complex<P, u32> {}
149149
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
150150
|
151151
note: it is not safe to send field `field1` to another thread
152-
--> $DIR/non_send_fields_in_send_ty.rs:134:5
152+
--> $DIR/non_send_fields_in_send_ty.rs:133:5
153153
|
154154
LL | field1: A,
155155
| ^^^^^^^^^
156156
= help: add `P: Send` bound in `Send` impl
157157

158158
error: some fields in `Complex<Q, MutexGuard<'static, bool>>` are not safe to be sent to another thread
159-
--> $DIR/non_send_fields_in_send_ty.rs:142:1
159+
--> $DIR/non_send_fields_in_send_ty.rs:141:1
160160
|
161161
LL | unsafe impl<Q: Send> Send for Complex<Q, MutexGuard<'static, bool>> {}
162162
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
163163
|
164164
note: it is not safe to send field `field2` to another thread
165-
--> $DIR/non_send_fields_in_send_ty.rs:135:5
165+
--> $DIR/non_send_fields_in_send_ty.rs:134:5
166166
|
167167
LL | field2: B,
168168
| ^^^^^^^^^

‎src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,6 @@ pub const DEFAULT_LINTS: &[Lint] = &[
502502
label: "stable_features",
503503
description: r##"stable features found in `#[feature]` directive"##,
504504
},
505-
Lint {
506-
label: "suspicious_auto_trait_impls",
507-
description: r##"the rules governing auto traits have recently changed resulting in potential breakage"##,
508-
},
509505
Lint {
510506
label: "suspicious_double_ref_op",
511507
description: r##"suspicious call of trait method on `&&T`"##,
@@ -778,7 +774,6 @@ pub const DEFAULT_LINT_GROUPS: &[LintGroup] = &[
778774
"repr_transparent_external_private_fields",
779775
"semicolon_in_expressions_from_macros",
780776
"soft_unstable",
781-
"suspicious_auto_trait_impls",
782777
"uninhabited_static",
783778
"unstable_name_collisions",
784779
"unstable_syntax_pre_expansion",

‎tests/ui/auto-traits/issue-117789.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![deny(suspicious_auto_trait_impls)]
2-
31
auto trait Trait<P> {} //~ ERROR auto traits cannot have generic parameters
42
//~^ ERROR auto traits are experimental and possibly buggy
53
impl<P> Trait<P> for () {}

‎tests/ui/auto-traits/issue-117789.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0567]: auto traits cannot have generic parameters
2-
--> $DIR/issue-117789.rs:3:17
2+
--> $DIR/issue-117789.rs:1:17
33
|
44
LL | auto trait Trait<P> {}
55
| -----^^^ help: remove the parameters
66
| |
77
| auto trait cannot have generic parameters
88

99
error[E0658]: auto traits are experimental and possibly buggy
10-
--> $DIR/issue-117789.rs:3:1
10+
--> $DIR/issue-117789.rs:1:1
1111
|
1212
LL | auto trait Trait<P> {}
1313
| ^^^^^^^^^^^^^^^^^^^^^^

‎tests/ui/auto-traits/issue-83857-ub.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(suspicious_auto_trait_impls)]
21
// Tests that we don't incorrectly allow overlap between a builtin auto trait
32
// impl and a user written one. See #83857 for more details
43

‎tests/ui/auto-traits/issue-83857-ub.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
error[E0277]: `Foo<T, U>` cannot be sent between threads safely
2-
--> $DIR/issue-83857-ub.rs:22:38
2+
--> $DIR/issue-83857-ub.rs:21:38
33
|
44
LL | fn generic<T, U>(v: Foo<T, U>, f: fn(<Foo<T, U> as WithAssoc>::Output) -> i32) {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo<T, U>` cannot be sent between threads safely
66
|
77
= help: the trait `Send` is not implemented for `Foo<T, U>`, which is required by `Foo<T, U>: WithAssoc`
88
note: required for `Foo<T, U>` to implement `WithAssoc`
9-
--> $DIR/issue-83857-ub.rs:15:15
9+
--> $DIR/issue-83857-ub.rs:14:15
1010
|
1111
LL | impl<T: Send> WithAssoc for T {
1212
| ---- ^^^^^^^^^ ^
@@ -18,7 +18,7 @@ LL | fn generic<T, U>(v: Foo<T, U>, f: fn(<Foo<T, U> as WithAssoc>::Output) -> i
1818
| +++++++++++++++++++++
1919

2020
error[E0277]: `Foo<T, U>` cannot be sent between threads safely
21-
--> $DIR/issue-83857-ub.rs:22:80
21+
--> $DIR/issue-83857-ub.rs:21:80
2222
|
2323
LL | fn generic<T, U>(v: Foo<T, U>, f: fn(<Foo<T, U> as WithAssoc>::Output) -> i32) {
2424
| ________________________________________________________________________________^
@@ -31,7 +31,7 @@ LL | | }
3131
|
3232
= help: the trait `Send` is not implemented for `Foo<T, U>`, which is required by `Foo<T, U>: WithAssoc`
3333
note: required for `Foo<T, U>` to implement `WithAssoc`
34-
--> $DIR/issue-83857-ub.rs:15:15
34+
--> $DIR/issue-83857-ub.rs:14:15
3535
|
3636
LL | impl<T: Send> WithAssoc for T {
3737
| ---- ^^^^^^^^^ ^
@@ -43,7 +43,7 @@ LL | fn generic<T, U>(v: Foo<T, U>, f: fn(<Foo<T, U> as WithAssoc>::Output) -> i
4343
| +++++++++++++++++++++
4444

4545
error[E0277]: `Foo<T, U>` cannot be sent between threads safely
46-
--> $DIR/issue-83857-ub.rs:25:11
46+
--> $DIR/issue-83857-ub.rs:24:11
4747
|
4848
LL | f(foo(v));
4949
| --- ^ `Foo<T, U>` cannot be sent between threads safely
@@ -52,7 +52,7 @@ LL | f(foo(v));
5252
|
5353
= help: the trait `Send` is not implemented for `Foo<T, U>`
5454
note: required by a bound in `foo`
55-
--> $DIR/issue-83857-ub.rs:29:11
55+
--> $DIR/issue-83857-ub.rs:28:11
5656
|
5757
LL | fn foo<T: Send>(x: T) -> <T as WithAssoc>::Output {
5858
| ^^^^ required by this bound in `foo`
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(suspicious_auto_trait_impls)]
1+
//@ check-pass
22

33
use std::marker::PhantomData;
44

@@ -7,8 +7,6 @@ unsafe impl<T: Send> Send for MayImplementSendOk<T> {} // ok
77

88
struct MayImplementSendErr<T>(T);
99
unsafe impl<T: Send> Send for MayImplementSendErr<&T> {}
10-
//~^ ERROR
11-
//~| WARNING this will change its meaning
1210

1311
struct ContainsNonSendDirect<T>(*const T);
1412
unsafe impl<T: Send> Send for ContainsNonSendDirect<&T> {} // ok
@@ -19,8 +17,6 @@ unsafe impl<T: Send> Send for ContainsIndirectNonSend<&T> {} // ok
1917

2018
struct ContainsVec<T>(Vec<T>);
2119
unsafe impl Send for ContainsVec<i32> {}
22-
//~^ ERROR
23-
//~| WARNING this will change its meaning
2420

2521
struct TwoParams<T, U>(T, U);
2622
unsafe impl<T: Send, U: Send> Send for TwoParams<T, U> {} // ok
@@ -30,21 +26,15 @@ unsafe impl<T: Send, U: Send> Send for TwoParamsFlipped<U, T> {} // ok
3026

3127
struct TwoParamsSame<T, U>(T, U);
3228
unsafe impl<T: Send> Send for TwoParamsSame<T, T> {}
33-
//~^ ERROR
34-
//~| WARNING this will change its meaning
3529

3630
pub struct WithPhantomDataNonSend<T, U>(PhantomData<*const T>, U);
3731
unsafe impl<T> Send for WithPhantomDataNonSend<T, i8> {} // ok
3832

3933
pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U);
4034
unsafe impl<T> Send for WithPhantomDataSend<*const T, i8> {}
41-
//~^ ERROR
42-
//~| WARNING this will change its meaning
4335

4436
pub struct WithLifetime<'a, T>(&'a (), T);
4537
unsafe impl<T> Send for WithLifetime<'static, T> {} // ok
4638
unsafe impl<T> Sync for WithLifetime<'static, Vec<T>> {}
47-
//~^ ERROR
48-
//~| WARNING this will change its meaning
4939

5040
fn main() {}

‎tests/ui/auto-traits/suspicious-impls-lint.stderr

Lines changed: 0 additions & 82 deletions
This file was deleted.
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1+
//@ check-pass
2+
13
#![feature(negative_impls)]
2-
#![deny(suspicious_auto_trait_impls)]
34

45
use std::marker::PhantomData;
56

67
struct ContainsVec<T>(Vec<T>);
78
impl !Send for ContainsVec<u32> {}
8-
//~^ ERROR
9-
//~| WARNING this will change its meaning
109

1110
pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U);
1211
impl<T> !Send for WithPhantomDataSend<*const T, u8> {}
13-
//~^ ERROR
14-
//~| WARNING this will change its meaning
1512

1613
pub struct WithLifetime<'a, T>(&'a (), T);
1714
impl<T> !Sync for WithLifetime<'static, Option<T>> {}
18-
//~^ ERROR
19-
//~| WARNING this will change its meaning
2015

2116
fn main() {}

‎tests/ui/auto-traits/suspicious-negative-impls-lint.stderr

Lines changed: 0 additions & 52 deletions
This file was deleted.

‎tests/ui/coherence/coherence-conflicting-negative-trait-impl.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@ impl<T: MyTrait> !Send for TestType<T> {} //~ ERROR found both positive and nega
1313
unsafe impl<T: 'static> Send for TestType<T> {} //~ ERROR conflicting implementations
1414

1515
impl !Send for TestType<i32> {}
16-
//~^ WARNING
17-
//~| WARNING this will change its meaning
1816

1917
fn main() {}

‎tests/ui/coherence/coherence-conflicting-negative-trait-impl.stderr

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,7 @@ LL | unsafe impl<T: MyTrait + 'static> Send for TestType<T> {}
1616
LL | unsafe impl<T: 'static> Send for TestType<T> {}
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>`
1818

19-
warning: cross-crate traits with a default impl, like `Send`, should not be specialized
20-
--> $DIR/coherence-conflicting-negative-trait-impl.rs:15:1
21-
|
22-
LL | impl !Send for TestType<i32> {}
23-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24-
|
25-
= warning: this will change its meaning in a future release!
26-
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
27-
= note: `i32` is not a generic parameter
28-
note: try using the same sequence of generic parameters as the struct definition
29-
--> $DIR/coherence-conflicting-negative-trait-impl.rs:7:1
30-
|
31-
LL | struct TestType<T>(::std::marker::PhantomData<T>);
32-
| ^^^^^^^^^^^^^^^^^^
33-
= note: `#[warn(suspicious_auto_trait_impls)]` on by default
34-
35-
error: aborting due to 2 previous errors; 1 warning emitted
19+
error: aborting due to 2 previous errors
3620

3721
Some errors have detailed explanations: E0119, E0751.
3822
For more information about an error, try `rustc --explain E0119`.

‎tests/ui/coherence/coherence-orphan.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,16 @@ use lib::TheTrait;
77

88
struct TheType;
99

10-
impl TheTrait<usize> for isize { }
10+
impl TheTrait<usize> for isize {}
1111
//~^ ERROR E0117
1212
//~| ERROR not all trait items implemented
1313

14-
impl TheTrait<TheType> for isize { }
14+
impl TheTrait<TheType> for isize {}
1515
//~^ ERROR not all trait items implemented
1616

17-
impl TheTrait<isize> for TheType { }
17+
impl TheTrait<isize> for TheType {}
1818
//~^ ERROR not all trait items implemented
1919

20-
impl !Send for Vec<isize> { } //~ ERROR E0117
21-
//~^ WARNING
22-
//~| WARNING this will change its meaning
20+
impl !Send for Vec<isize> {} //~ ERROR E0117
2321

24-
fn main() { }
22+
fn main() {}
Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error[E0117]: only traits defined in the current crate can be implemented for primitive types
22
--> $DIR/coherence-orphan.rs:10:1
33
|
4-
LL | impl TheTrait<usize> for isize { }
4+
LL | impl TheTrait<usize> for isize {}
55
| ^^^^^---------------^^^^^-----
66
| | | |
77
| | | `isize` is not defined in the current crate
@@ -13,52 +13,39 @@ LL | impl TheTrait<usize> for isize { }
1313
error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
1414
--> $DIR/coherence-orphan.rs:20:1
1515
|
16-
LL | impl !Send for Vec<isize> { }
16+
LL | impl !Send for Vec<isize> {}
1717
| ^^^^^^^^^^^^^^^----------
1818
| | |
1919
| | `Vec` is not defined in the current crate
2020
| impl doesn't use only types from inside the current crate
2121
|
2222
= note: define and implement a trait or new type instead
2323

24-
warning: cross-crate traits with a default impl, like `Send`, should not be specialized
25-
--> $DIR/coherence-orphan.rs:20:1
26-
|
27-
LL | impl !Send for Vec<isize> { }
28-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
29-
|
30-
= warning: this will change its meaning in a future release!
31-
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
32-
= note: `isize` is not a generic parameter
33-
note: try using the same sequence of generic parameters as the struct definition
34-
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
35-
= note: `#[warn(suspicious_auto_trait_impls)]` on by default
36-
3724
error[E0046]: not all trait items implemented, missing: `the_fn`
3825
--> $DIR/coherence-orphan.rs:10:1
3926
|
40-
LL | impl TheTrait<usize> for isize { }
27+
LL | impl TheTrait<usize> for isize {}
4128
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `the_fn` in implementation
4229
|
4330
= help: implement the missing item: `fn the_fn(&self) { todo!() }`
4431

4532
error[E0046]: not all trait items implemented, missing: `the_fn`
4633
--> $DIR/coherence-orphan.rs:14:1
4734
|
48-
LL | impl TheTrait<TheType> for isize { }
35+
LL | impl TheTrait<TheType> for isize {}
4936
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `the_fn` in implementation
5037
|
5138
= help: implement the missing item: `fn the_fn(&self) { todo!() }`
5239

5340
error[E0046]: not all trait items implemented, missing: `the_fn`
5441
--> $DIR/coherence-orphan.rs:17:1
5542
|
56-
LL | impl TheTrait<isize> for TheType { }
43+
LL | impl TheTrait<isize> for TheType {}
5744
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `the_fn` in implementation
5845
|
5946
= help: implement the missing item: `fn the_fn(&self) { todo!() }`
6047

61-
error: aborting due to 5 previous errors; 1 warning emitted
48+
error: aborting due to 5 previous errors
6249

6350
Some errors have detailed explanations: E0046, E0117.
6451
For more information about an error, try `rustc --explain E0046`.

‎tests/ui/coherence/coherence-overlap-negative-impls.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ struct Test;
1515

1616
trait Fold<F> {}
1717

18-
impl<T, F> Fold<F> for Cons<T> // 0
18+
impl<T, F> Fold<F> for Cons<T>
19+
// 0
1920
where
2021
T: Fold<Nil>,
21-
{}
22+
{
23+
}
2224

23-
impl<T, F> Fold<F> for Cons<T> // 1
25+
impl<T, F> Fold<F> for Cons<T>
26+
// 1
2427
where
2528
T: Fold<F>,
2629
private::Is<T>: private::NotNil,
27-
{}
30+
{
31+
}
2832

2933
impl<F> Fold<F> for Test {} // 2
3034

@@ -34,7 +38,6 @@ mod private {
3438
pub struct Is<T>(T);
3539
pub auto trait NotNil {}
3640

37-
#[allow(suspicious_auto_trait_impls)]
3841
impl !NotNil for Is<Nil> {}
3942
}
4043

‎tests/ui/issues/issue-106755.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,5 @@ impl<T: MyTrait> !Send for TestType<T> {} //~ ERROR found both positive and nega
1515
unsafe impl<T: 'static> Send for TestType<T> {} //~ ERROR conflicting implementations
1616

1717
impl !Send for TestType<i32> {}
18-
//~^ WARNING
19-
//~| WARNING this will change its meaning
2018

2119
fn main() {}

‎tests/ui/issues/issue-106755.stderr

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,7 @@ LL | unsafe impl<T: MyTrait + 'static> Send for TestType<T> {}
1616
LL | unsafe impl<T: 'static> Send for TestType<T> {}
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>`
1818

19-
warning: cross-crate traits with a default impl, like `Send`, should not be specialized
20-
--> $DIR/issue-106755.rs:17:1
21-
|
22-
LL | impl !Send for TestType<i32> {}
23-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24-
|
25-
= warning: this will change its meaning in a future release!
26-
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
27-
= note: `i32` is not a generic parameter
28-
note: try using the same sequence of generic parameters as the struct definition
29-
--> $DIR/issue-106755.rs:9:1
30-
|
31-
LL | struct TestType<T>(::std::marker::PhantomData<T>);
32-
| ^^^^^^^^^^^^^^^^^^
33-
= note: `#[warn(suspicious_auto_trait_impls)]` on by default
34-
35-
error: aborting due to 2 previous errors; 1 warning emitted
19+
error: aborting due to 2 previous errors
3620

3721
Some errors have detailed explanations: E0119, E0751.
3822
For more information about an error, try `rustc --explain E0119`.
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ aux-build:tdticc_coherence_lib.rs
2-
#![allow(suspicious_auto_trait_impls)]
32

43
// Test that we do not consider associated types to be sendable without
54
// some applicable trait bound (and we don't ICE).
@@ -11,15 +10,15 @@ extern crate tdticc_coherence_lib as lib;
1110
use lib::DefaultedTrait;
1211

1312
struct A;
14-
impl DefaultedTrait for (A,) { } //~ ERROR E0117
13+
impl DefaultedTrait for (A,) {} //~ ERROR E0117
1514

1615
struct B;
17-
impl !DefaultedTrait for (B,) { } //~ ERROR E0117
16+
impl !DefaultedTrait for (B,) {} //~ ERROR E0117
1817

1918
struct C;
2019
struct D<T>(T);
21-
impl DefaultedTrait for Box<C> { } //~ ERROR E0321
22-
impl DefaultedTrait for lib::Something<C> { } //~ ERROR E0117
23-
impl DefaultedTrait for D<C> { } // OK
20+
impl DefaultedTrait for Box<C> {} //~ ERROR E0321
21+
impl DefaultedTrait for lib::Something<C> {} //~ ERROR E0117
22+
impl DefaultedTrait for D<C> {} // OK
2423

25-
fn main() { }
24+
fn main() {}

‎tests/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
2-
--> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:14:1
2+
--> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:13:1
33
|
4-
LL | impl DefaultedTrait for (A,) { }
4+
LL | impl DefaultedTrait for (A,) {}
55
| ^^^^^^^^^^^^^^^^^^^^^^^^----
66
| | |
77
| | this is not defined in the current crate because tuples are always foreign
@@ -10,9 +10,9 @@ LL | impl DefaultedTrait for (A,) { }
1010
= note: define and implement a trait or new type instead
1111

1212
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
13-
--> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:17:1
13+
--> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:16:1
1414
|
15-
LL | impl !DefaultedTrait for (B,) { }
15+
LL | impl !DefaultedTrait for (B,) {}
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^----
1717
| | |
1818
| | this is not defined in the current crate because tuples are always foreign
@@ -21,15 +21,15 @@ LL | impl !DefaultedTrait for (B,) { }
2121
= note: define and implement a trait or new type instead
2222

2323
error[E0321]: cross-crate traits with a default impl, like `DefaultedTrait`, can only be implemented for a struct/enum type defined in the current crate
24-
--> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:21:1
24+
--> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:20:1
2525
|
26-
LL | impl DefaultedTrait for Box<C> { }
26+
LL | impl DefaultedTrait for Box<C> {}
2727
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait for type in another crate
2828

2929
error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
30-
--> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:22:1
30+
--> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:21:1
3131
|
32-
LL | impl DefaultedTrait for lib::Something<C> { }
32+
LL | impl DefaultedTrait for lib::Something<C> {}
3333
| ^^^^^^^^^^^^^^^^^^^^^^^^-----------------
3434
| | |
3535
| | `Something` is not defined in the current crate

0 commit comments

Comments
 (0)
Please sign in to comment.