Skip to content

Commit

Permalink
Bless test fallout (duplicate diagnostics)
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Mar 20, 2024
1 parent aa39dbb commit ce5f8c9
Show file tree
Hide file tree
Showing 54 changed files with 571 additions and 128 deletions.
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/future_not_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
}
let ret_ty = return_ty(cx, cx.tcx.local_def_id_to_hir_id(fn_def_id).expect_owner());
if let ty::Alias(ty::Opaque, AliasTy { def_id, args, .. }) = *ret_ty.kind() {
let preds = cx.tcx.explicit_item_bounds(def_id);
let preds = cx.tcx.explicit_item_super_predicates(def_id);
let mut is_future = false;
for (p, _span) in preds.iter_instantiated_copied(cx.tcx, args) {
if let Some(trait_pred) = p.as_trait_clause() {
Expand Down
8 changes: 4 additions & 4 deletions src/tools/clippy/clippy_utils/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
return false;
}

for (predicate, _span) in cx.tcx.explicit_item_bounds(def_id).instantiate_identity_iter_copied() {
for (predicate, _span) in cx.tcx.explicit_item_super_predicates(def_id).instantiate_identity_iter_copied() {
match predicate.kind().skip_binder() {
// For `impl Trait<U>`, it will register a predicate of `T: Trait<U>`, so we go through
// and check substitutions to find `U`.
Expand Down Expand Up @@ -328,7 +328,7 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
},
ty::Tuple(args) => args.iter().any(|ty| is_must_use_ty(cx, ty)),
ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => {
for (predicate, _) in cx.tcx.explicit_item_bounds(def_id).skip_binder() {
for (predicate, _) in cx.tcx.explicit_item_super_predicates(def_id).skip_binder() {
if let ty::ClauseKind::Trait(trait_predicate) = predicate.kind().skip_binder() {
if cx.tcx.has_attr(trait_predicate.trait_ref.def_id, sym::must_use) {
return true;
Expand Down Expand Up @@ -729,7 +729,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => sig_from_bounds(
cx,
ty,
cx.tcx.item_bounds(def_id).iter_instantiated(cx.tcx, args),
cx.tcx.item_super_predicates(def_id).iter_instantiated(cx.tcx, args),
cx.tcx.opt_parent(def_id),
),
ty::FnPtr(sig) => Some(ExprFnSig::Sig(sig, None)),
Expand Down Expand Up @@ -807,7 +807,7 @@ fn sig_for_projection<'tcx>(cx: &LateContext<'tcx>, ty: AliasTy<'tcx>) -> Option

for (pred, _) in cx
.tcx
.explicit_item_bounds(ty.def_id)
.explicit_item_super_predicates(ty.def_id)
.iter_instantiated_copied(cx.tcx, ty.args)
{
match pred.kind().skip_binder() {
Expand Down
1 change: 1 addition & 0 deletions tests/rustdoc-ui/invalid_associated_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
trait T {
type A: S<C<X = 0i32> = 34>;
//~^ ERROR associated type bindings are not allowed here
//~| ERROR associated type bindings are not allowed here
}

trait S {
Expand Down
10 changes: 9 additions & 1 deletion tests/rustdoc-ui/invalid_associated_const.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ error[E0229]: associated type bindings are not allowed here
LL | type A: S<C<X = 0i32> = 34>;
| ^^^^^^^^ associated type not allowed here

error: aborting due to 1 previous error
error[E0229]: associated type bindings are not allowed here
--> $DIR/invalid_associated_const.rs:4:17
|
LL | type A: S<C<X = 0i32> = 34>;
| ^^^^^^^^ associated type not allowed here
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0229`.
1 change: 1 addition & 0 deletions tests/rustdoc-ui/issue-102467.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
trait T {
type A: S<C<X = 0i32> = 34>;
//~^ ERROR associated type bindings are not allowed here
//~| ERROR associated type bindings are not allowed here
}

trait S {
Expand Down
10 changes: 9 additions & 1 deletion tests/rustdoc-ui/issue-102467.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ error[E0229]: associated type bindings are not allowed here
LL | type A: S<C<X = 0i32> = 34>;
| ^^^^^^^^ associated type not allowed here

error: aborting due to 1 previous error
error[E0229]: associated type bindings are not allowed here
--> $DIR/issue-102467.rs:7:17
|
LL | type A: S<C<X = 0i32> = 34>;
| ^^^^^^^^ associated type not allowed here
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0229`.
1 change: 1 addition & 0 deletions tests/rustdoc-ui/issues/issue-96287.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub trait TraitWithAssoc {

pub type Foo<V> = impl Trait<V::Assoc>;
//~^ ERROR
//~| ERROR

pub trait Trait<U> {}

Expand Down
14 changes: 13 additions & 1 deletion tests/rustdoc-ui/issues/issue-96287.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ help: consider restricting type parameter `V`
LL | pub type Foo<V: TraitWithAssoc> = impl Trait<V::Assoc>;
| ++++++++++++++++

error: aborting due to 1 previous error
error[E0220]: associated type `Assoc` not found for `V`
--> $DIR/issue-96287.rs:7:33
|
LL | pub type Foo<V> = impl Trait<V::Assoc>;
| ^^^^^ there is an associated type `Assoc` in the trait `TraitWithAssoc`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: consider restricting type parameter `V`
|
LL | pub type Foo<V: TraitWithAssoc> = impl Trait<V::Assoc>;
| ++++++++++++++++

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0220`.
14 changes: 14 additions & 0 deletions tests/ui/associated-consts/assoc-const-eq-param-in-ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,19 @@ fn take2<P: Project<SELF = {}>>(_: P) {}

trait Iface<'r> {
//~^ NOTE the lifetime parameter `'r` is defined here
//~| NOTE the lifetime parameter `'r` is defined here
type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
//~^ ERROR the type of the associated constant `K` must not depend on generic parameters
//~| ERROR the type of the associated constant `K` must not depend on generic parameters
//~| NOTE its type must not depend on the lifetime parameter `'r`
//~| NOTE `K` has type `&'r [Self; Q]`
//~| ERROR the type of the associated constant `K` must not depend on `Self`
//~| NOTE its type must not depend on `Self`
//~| NOTE `K` has type `&'r [Self; Q]`
//~| ERROR the type of the associated constant `K` must not depend on generic parameters
//~| NOTE its type must not depend on the const parameter `Q`
//~| NOTE the const parameter `Q` is defined here
//~| NOTE `K` has type `&'r [Self; Q]`
//~| NOTE its type must not depend on the lifetime parameter `'r`
//~| NOTE `K` has type `&'r [Self; Q]`
//~| ERROR the type of the associated constant `K` must not depend on `Self`
Expand All @@ -48,6 +59,9 @@ trait Iface<'r> {
//~| NOTE its type must not depend on the const parameter `Q`
//~| NOTE the const parameter `Q` is defined here
//~| NOTE `K` has type `&'r [Self; Q]`
//~| NOTE duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
//~| NOTE duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
//~| NOTE duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
where
Self: Sized + 'r;
}
Expand Down
42 changes: 37 additions & 5 deletions tests/ui/associated-consts/assoc-const-eq-param-in-ty.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,26 @@ LL | fn take2<P: Project<SELF = {}>>(_: P) {}
= note: `SELF` has type `P`

error: the type of the associated constant `K` must not depend on generic parameters
--> $DIR/assoc-const-eq-param-in-ty.rs:40:52
--> $DIR/assoc-const-eq-param-in-ty.rs:41:52
|
LL | trait Iface<'r> {
| -- the lifetime parameter `'r` is defined here
LL |
...
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
| ^ its type must not depend on the lifetime parameter `'r`
|
= note: `K` has type `&'r [Self; Q]`

error: the type of the associated constant `K` must not depend on `Self`
--> $DIR/assoc-const-eq-param-in-ty.rs:40:52
--> $DIR/assoc-const-eq-param-in-ty.rs:41:52
|
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
| ^ its type must not depend on `Self`
|
= note: `K` has type `&'r [Self; Q]`

error: the type of the associated constant `K` must not depend on generic parameters
--> $DIR/assoc-const-eq-param-in-ty.rs:40:52
--> $DIR/assoc-const-eq-param-in-ty.rs:41:52
|
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
| - ^ its type must not depend on the const parameter `Q`
Expand All @@ -72,5 +72,37 @@ LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
|
= note: `K` has type `&'r [Self; Q]`

error: aborting due to 8 previous errors
error: the type of the associated constant `K` must not depend on generic parameters
--> $DIR/assoc-const-eq-param-in-ty.rs:41:52
|
LL | trait Iface<'r> {
| -- the lifetime parameter `'r` is defined here
...
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
| ^ its type must not depend on the lifetime parameter `'r`
|
= note: `K` has type `&'r [Self; Q]`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: the type of the associated constant `K` must not depend on `Self`
--> $DIR/assoc-const-eq-param-in-ty.rs:41:52
|
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
| ^ its type must not depend on `Self`
|
= note: `K` has type `&'r [Self; Q]`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: the type of the associated constant `K` must not depend on generic parameters
--> $DIR/assoc-const-eq-param-in-ty.rs:41:52
|
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = { loop {} }>
| - ^ its type must not depend on the const parameter `Q`
| |
| the const parameter `Q` is defined here
|
= note: `K` has type `&'r [Self; Q]`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 11 previous errors

1 change: 1 addition & 0 deletions tests/ui/associated-consts/issue-102335-const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
trait T {
type A: S<C<X = 0i32> = 34>;
//~^ ERROR associated type bindings are not allowed here
//~| ERROR associated type bindings are not allowed here
}

trait S {
Expand Down
10 changes: 9 additions & 1 deletion tests/ui/associated-consts/issue-102335-const.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ error[E0229]: associated type bindings are not allowed here
LL | type A: S<C<X = 0i32> = 34>;
| ^^^^^^^^ associated type not allowed here

error: aborting due to 1 previous error
error[E0229]: associated type bindings are not allowed here
--> $DIR/issue-102335-const.rs:4:17
|
LL | type A: S<C<X = 0i32> = 34>;
| ^^^^^^^^ associated type not allowed here
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0229`.
6 changes: 4 additions & 2 deletions tests/ui/associated-inherent-types/issue-109299-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ impl Lexer<i32> {
type Cursor = ();
}

type X = impl for<T> Fn() -> Lexer<T>::Cursor; //~ ERROR associated type `Cursor` not found for `Lexer<T>` in the current scope
//~^ ERROR: unconstrained opaque type
type X = impl for<T> Fn() -> Lexer<T>::Cursor;
//~^ ERROR associated type `Cursor` not found for `Lexer<T>` in the current scope
//~| ERROR associated type `Cursor` not found for `Lexer<T>` in the current scope
//~| ERROR: unconstrained opaque type

fn main() {}
15 changes: 14 additions & 1 deletion tests/ui/associated-inherent-types/issue-109299-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ LL | type X = impl for<T> Fn() -> Lexer<T>::Cursor;
= note: the associated type was found for
- `Lexer<i32>`

error[E0220]: associated type `Cursor` not found for `Lexer<T>` in the current scope
--> $DIR/issue-109299-1.rs:10:40
|
LL | struct Lexer<T>(T);
| --------------- associated item `Cursor` not found for this struct
...
LL | type X = impl for<T> Fn() -> Lexer<T>::Cursor;
| ^^^^^^ associated item not found in `Lexer<T>`
|
= note: the associated type was found for
- `Lexer<i32>`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: unconstrained opaque type
--> $DIR/issue-109299-1.rs:10:10
|
Expand All @@ -18,6 +31,6 @@ LL | type X = impl for<T> Fn() -> Lexer<T>::Cursor;
|
= note: `X` must be used in combination with a concrete type within the same module

error: aborting due to 2 previous errors
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0220`.
9 changes: 9 additions & 0 deletions tests/ui/associated-type-bounds/duplicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,19 @@ where

fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> {
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
iter::empty()
//~^ ERROR type annotations needed
}
fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> {
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
iter::empty()
//~^ ERROR type annotations needed
}
fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> {
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
iter::empty()
//~^ ERROR type annotations needed
}
Expand Down Expand Up @@ -182,10 +185,13 @@ type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy;
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
type ETAI4 = impl Iterator<Item: Copy, Item: Send>;
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
type ETAI5 = impl Iterator<Item: Copy, Item: Copy>;
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
type ETAI6 = impl Iterator<Item: 'static, Item: 'static>;
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]

trait TRI1<T: Iterator<Item: Copy, Item: Send>> {}
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
Expand Down Expand Up @@ -250,14 +256,17 @@ where
trait TRA1 {
type A: Iterator<Item: Copy, Item: Send>;
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
}
trait TRA2 {
type A: Iterator<Item: Copy, Item: Copy>;
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
}
trait TRA3 {
type A: Iterator<Item: 'static, Item: 'static>;
//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719]
}

fn main() {}
Loading

0 comments on commit ce5f8c9

Please sign in to comment.