1
Fork 0

Call type_of for opaque types later in compilation

This ensures that various wf checks have already been done before we
typeck item bodies.
This commit is contained in:
Matthew Jasper 2020-09-26 17:56:03 +01:00
parent ef83742b2b
commit 3a81adeca2
32 changed files with 361 additions and 425 deletions

View file

@ -385,6 +385,7 @@ pub(super) fn check_opaque<'tcx>(
origin: &hir::OpaqueTyOrigin, origin: &hir::OpaqueTyOrigin,
) { ) {
check_opaque_for_inheriting_lifetimes(tcx, def_id, span); check_opaque_for_inheriting_lifetimes(tcx, def_id, span);
tcx.ensure().type_of(def_id);
check_opaque_for_cycles(tcx, def_id, substs, span, origin); check_opaque_for_cycles(tcx, def_id, substs, span, origin);
} }

View file

@ -693,8 +693,14 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) {
// Desugared from `impl Trait`, so visited by the function's return type. // Desugared from `impl Trait`, so visited by the function's return type.
hir::ItemKind::OpaqueTy(hir::OpaqueTy { impl_trait_fn: Some(_), .. }) => {} hir::ItemKind::OpaqueTy(hir::OpaqueTy { impl_trait_fn: Some(_), .. }) => {}
hir::ItemKind::OpaqueTy(..) // Don't call `type_of` on opaque types, since that depends on type
| hir::ItemKind::TyAlias(..) // checking function bodies. `check_item_type` ensures that it's called
// instead.
hir::ItemKind::OpaqueTy(..) => {
tcx.ensure().generics_of(def_id);
tcx.ensure().predicates_of(def_id);
}
hir::ItemKind::TyAlias(..)
| hir::ItemKind::Static(..) | hir::ItemKind::Static(..)
| hir::ItemKind::Const(..) | hir::ItemKind::Const(..)
| hir::ItemKind::Fn(..) => { | hir::ItemKind::Fn(..) => {

View file

@ -360,7 +360,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorReported> {
// this ensures that later parts of type checking can assume that items // this ensures that later parts of type checking can assume that items
// have valid types and not error // have valid types and not error
// FIXME(matthewjasper) We shouldn't need to do this. // FIXME(matthewjasper) We shouldn't need to use `track_errors`.
tcx.sess.track_errors(|| { tcx.sess.track_errors(|| {
tcx.sess.time("type_collecting", || { tcx.sess.time("type_collecting", || {
for &module in tcx.hir().krate().modules.keys() { for &module in tcx.hir().krate().modules.keys() {

View file

@ -60,11 +60,8 @@ fn FW3<T>() where T: Iterator<Item: 'static, Item: 'static> {}
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> { iter::empty() } fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> { iter::empty() }
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> { iter::empty() } fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> { iter::empty() }
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> { iter::empty() } fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> { iter::empty() }
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {} fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {}
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
fn FAPIT2(_: impl Iterator<Item: Copy, Item: Copy>) {} fn FAPIT2(_: impl Iterator<Item: Copy, Item: Copy>) {}
@ -107,28 +104,16 @@ type TAW3<T> where T: Iterator<Item: 'static, Item: 'static> = T;
type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy; type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy;
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
//~| ERROR could not find defining uses
type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy; type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy;
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
//~| ERROR could not find defining uses
type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy; type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy;
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
//~| ERROR could not find defining uses
type ETAI4 = impl Iterator<Item: Copy, Item: Send>; type ETAI4 = impl Iterator<Item: Copy, Item: Send>;
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
//~| ERROR could not find defining uses
//~| ERROR could not find defining uses
//~| ERROR could not find defining uses
type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; type ETAI5 = impl Iterator<Item: Copy, Item: Copy>;
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
//~| ERROR could not find defining uses
//~| ERROR could not find defining uses
//~| ERROR could not find defining uses
type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; type ETAI6 = impl Iterator<Item: 'static, Item: 'static>;
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
//~| ERROR could not find defining uses
//~| ERROR could not find defining uses
//~| ERROR could not find defining uses
trait TRI1<T: Iterator<Item: Copy, Item: Send>> {} trait TRI1<T: Iterator<Item: Copy, Item: Send>> {}
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
@ -166,15 +151,9 @@ trait TRA3 { type A: Iterator<Item: 'static, Item: 'static>; }
type TADyn1 = dyn Iterator<Item: Copy, Item: Send>; type TADyn1 = dyn Iterator<Item: Copy, Item: Send>;
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
//~| ERROR could not find defining uses
//~| ERROR could not find defining uses
type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>; type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>;
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
//~| ERROR could not find defining uses
//~| ERROR could not find defining uses
type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>; type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>;
//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719]
//~| ERROR could not find defining uses
//~| ERROR could not find defining uses
fn main() {} fn main() {}

View file

@ -200,7 +200,7 @@ LL | fn FW3<T>() where T: Iterator<Item: 'static, Item: 'static> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:68:40 --> $DIR/duplicate.rs:65:40
| |
LL | fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {} LL | fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -208,7 +208,7 @@ LL | fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:70:40 --> $DIR/duplicate.rs:67:40
| |
LL | fn FAPIT2(_: impl Iterator<Item: Copy, Item: Copy>) {} LL | fn FAPIT2(_: impl Iterator<Item: Copy, Item: Copy>) {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -216,7 +216,7 @@ LL | fn FAPIT2(_: impl Iterator<Item: Copy, Item: Copy>) {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:72:43 --> $DIR/duplicate.rs:69:43
| |
LL | fn FAPIT3(_: impl Iterator<Item: 'static, Item: 'static>) {} LL | fn FAPIT3(_: impl Iterator<Item: 'static, Item: 'static>) {}
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -224,7 +224,7 @@ LL | fn FAPIT3(_: impl Iterator<Item: 'static, Item: 'static>) {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:75:39 --> $DIR/duplicate.rs:72:39
| |
LL | const CIT1: impl Iterator<Item: Copy, Item: Send> = iter::empty(); LL | const CIT1: impl Iterator<Item: Copy, Item: Send> = iter::empty();
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -232,7 +232,7 @@ LL | const CIT1: impl Iterator<Item: Copy, Item: Send> = iter::empty();
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:77:39 --> $DIR/duplicate.rs:74:39
| |
LL | const CIT2: impl Iterator<Item: Copy, Item: Copy> = iter::empty(); LL | const CIT2: impl Iterator<Item: Copy, Item: Copy> = iter::empty();
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -240,7 +240,7 @@ LL | const CIT2: impl Iterator<Item: Copy, Item: Copy> = iter::empty();
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:79:42 --> $DIR/duplicate.rs:76:42
| |
LL | const CIT3: impl Iterator<Item: 'static, Item: 'static> = iter::empty(); LL | const CIT3: impl Iterator<Item: 'static, Item: 'static> = iter::empty();
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -248,7 +248,7 @@ LL | const CIT3: impl Iterator<Item: 'static, Item: 'static> = iter::empty();
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:81:40 --> $DIR/duplicate.rs:78:40
| |
LL | static SIT1: impl Iterator<Item: Copy, Item: Send> = iter::empty(); LL | static SIT1: impl Iterator<Item: Copy, Item: Send> = iter::empty();
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -256,7 +256,7 @@ LL | static SIT1: impl Iterator<Item: Copy, Item: Send> = iter::empty();
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:83:40 --> $DIR/duplicate.rs:80:40
| |
LL | static SIT2: impl Iterator<Item: Copy, Item: Copy> = iter::empty(); LL | static SIT2: impl Iterator<Item: Copy, Item: Copy> = iter::empty();
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -264,7 +264,7 @@ LL | static SIT2: impl Iterator<Item: Copy, Item: Copy> = iter::empty();
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:85:43 --> $DIR/duplicate.rs:82:43
| |
LL | static SIT3: impl Iterator<Item: 'static, Item: 'static> = iter::empty(); LL | static SIT3: impl Iterator<Item: 'static, Item: 'static> = iter::empty();
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -272,7 +272,7 @@ LL | static SIT3: impl Iterator<Item: 'static, Item: 'static> = iter::empty();
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:88:46 --> $DIR/duplicate.rs:85:46
| |
LL | fn lit1() { let _: impl Iterator<Item: Copy, Item: Send> = iter::empty(); } LL | fn lit1() { let _: impl Iterator<Item: Copy, Item: Send> = iter::empty(); }
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -280,7 +280,7 @@ LL | fn lit1() { let _: impl Iterator<Item: Copy, Item: Send> = iter::empty(); }
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:90:46 --> $DIR/duplicate.rs:87:46
| |
LL | fn lit2() { let _: impl Iterator<Item: Copy, Item: Copy> = iter::empty(); } LL | fn lit2() { let _: impl Iterator<Item: Copy, Item: Copy> = iter::empty(); }
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -288,7 +288,7 @@ LL | fn lit2() { let _: impl Iterator<Item: Copy, Item: Copy> = iter::empty(); }
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:92:49 --> $DIR/duplicate.rs:89:49
| |
LL | fn lit3() { let _: impl Iterator<Item: 'static, Item: 'static> = iter::empty(); } LL | fn lit3() { let _: impl Iterator<Item: 'static, Item: 'static> = iter::empty(); }
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -296,7 +296,7 @@ LL | fn lit3() { let _: impl Iterator<Item: 'static, Item: 'static> = iter::empt
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:95:35 --> $DIR/duplicate.rs:92:35
| |
LL | type TAI1<T: Iterator<Item: Copy, Item: Send>> = T; LL | type TAI1<T: Iterator<Item: Copy, Item: Send>> = T;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -304,7 +304,7 @@ LL | type TAI1<T: Iterator<Item: Copy, Item: Send>> = T;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:97:35 --> $DIR/duplicate.rs:94:35
| |
LL | type TAI2<T: Iterator<Item: Copy, Item: Copy>> = T; LL | type TAI2<T: Iterator<Item: Copy, Item: Copy>> = T;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -312,7 +312,7 @@ LL | type TAI2<T: Iterator<Item: Copy, Item: Copy>> = T;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:99:38 --> $DIR/duplicate.rs:96:38
| |
LL | type TAI3<T: Iterator<Item: 'static, Item: 'static>> = T; LL | type TAI3<T: Iterator<Item: 'static, Item: 'static>> = T;
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -320,7 +320,7 @@ LL | type TAI3<T: Iterator<Item: 'static, Item: 'static>> = T;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:101:44 --> $DIR/duplicate.rs:98:44
| |
LL | type TAW1<T> where T: Iterator<Item: Copy, Item: Send> = T; LL | type TAW1<T> where T: Iterator<Item: Copy, Item: Send> = T;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -328,7 +328,7 @@ LL | type TAW1<T> where T: Iterator<Item: Copy, Item: Send> = T;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:103:44 --> $DIR/duplicate.rs:100:44
| |
LL | type TAW2<T> where T: Iterator<Item: Copy, Item: Copy> = T; LL | type TAW2<T> where T: Iterator<Item: Copy, Item: Copy> = T;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -336,7 +336,7 @@ LL | type TAW2<T> where T: Iterator<Item: Copy, Item: Copy> = T;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:105:47 --> $DIR/duplicate.rs:102:47
| |
LL | type TAW3<T> where T: Iterator<Item: 'static, Item: 'static> = T; LL | type TAW3<T> where T: Iterator<Item: 'static, Item: 'static> = T;
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -344,7 +344,7 @@ LL | type TAW3<T> where T: Iterator<Item: 'static, Item: 'static> = T;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:108:36 --> $DIR/duplicate.rs:105:36
| |
LL | type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy; LL | type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -352,99 +352,39 @@ LL | type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:62:42 --> $DIR/duplicate.rs:107:36
|
LL | fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> { iter::empty() }
| ---------- ^^^^^^^^^^ re-bound here
| |
| `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:64:42
|
LL | fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> { iter::empty() }
| ---------- ^^^^^^^^^^ re-bound here
| |
| `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:66:45
|
LL | fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> { iter::empty() }
| ------------- ^^^^^^^^^^^^^ re-bound here
| |
| `Item` bound here first
error: could not find defining uses
--> $DIR/duplicate.rs:108:51
|
LL | type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy;
| ^^^^^^^^^
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:111:36
| |
LL | type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy; LL | type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
| | | |
| `Item` bound here first | `Item` bound here first
error: could not find defining uses
--> $DIR/duplicate.rs:111:51
|
LL | type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy;
| ^^^^^^^^^
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:114:39 --> $DIR/duplicate.rs:109:39
| |
LL | type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy; LL | type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy;
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
| | | |
| `Item` bound here first | `Item` bound here first
error: could not find defining uses
--> $DIR/duplicate.rs:114:57
|
LL | type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy;
| ^^^^^^^^^
error: could not find defining uses
--> $DIR/duplicate.rs:117:14
|
LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:117:40 --> $DIR/duplicate.rs:111:40
| |
LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>; LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
| | | |
| `Item` bound here first | `Item` bound here first
error: could not find defining uses
--> $DIR/duplicate.rs:122:14
|
LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:122:40 --> $DIR/duplicate.rs:113:40
| |
LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
| | | |
| `Item` bound here first | `Item` bound here first
error: could not find defining uses
--> $DIR/duplicate.rs:127:14
|
LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:127:43 --> $DIR/duplicate.rs:115:43
| |
LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>;
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -452,7 +392,7 @@ LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:133:36 --> $DIR/duplicate.rs:118:36
| |
LL | trait TRI1<T: Iterator<Item: Copy, Item: Send>> {} LL | trait TRI1<T: Iterator<Item: Copy, Item: Send>> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -460,7 +400,7 @@ LL | trait TRI1<T: Iterator<Item: Copy, Item: Send>> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:135:36 --> $DIR/duplicate.rs:120:36
| |
LL | trait TRI2<T: Iterator<Item: Copy, Item: Copy>> {} LL | trait TRI2<T: Iterator<Item: Copy, Item: Copy>> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -468,7 +408,7 @@ LL | trait TRI2<T: Iterator<Item: Copy, Item: Copy>> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:137:39 --> $DIR/duplicate.rs:122:39
| |
LL | trait TRI3<T: Iterator<Item: 'static, Item: 'static>> {} LL | trait TRI3<T: Iterator<Item: 'static, Item: 'static>> {}
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -476,7 +416,7 @@ LL | trait TRI3<T: Iterator<Item: 'static, Item: 'static>> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:139:34 --> $DIR/duplicate.rs:124:34
| |
LL | trait TRS1: Iterator<Item: Copy, Item: Send> {} LL | trait TRS1: Iterator<Item: Copy, Item: Send> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -484,7 +424,7 @@ LL | trait TRS1: Iterator<Item: Copy, Item: Send> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:141:34 --> $DIR/duplicate.rs:126:34
| |
LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {} LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -492,7 +432,7 @@ LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:143:37 --> $DIR/duplicate.rs:128:37
| |
LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {} LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {}
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -500,7 +440,7 @@ LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:145:45 --> $DIR/duplicate.rs:130:45
| |
LL | trait TRW1<T> where T: Iterator<Item: Copy, Item: Send> {} LL | trait TRW1<T> where T: Iterator<Item: Copy, Item: Send> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -508,7 +448,7 @@ LL | trait TRW1<T> where T: Iterator<Item: Copy, Item: Send> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:147:45 --> $DIR/duplicate.rs:132:45
| |
LL | trait TRW2<T> where T: Iterator<Item: Copy, Item: Copy> {} LL | trait TRW2<T> where T: Iterator<Item: Copy, Item: Copy> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -516,7 +456,7 @@ LL | trait TRW2<T> where T: Iterator<Item: Copy, Item: Copy> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:149:48 --> $DIR/duplicate.rs:134:48
| |
LL | trait TRW3<T> where T: Iterator<Item: 'static, Item: 'static> {} LL | trait TRW3<T> where T: Iterator<Item: 'static, Item: 'static> {}
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -524,7 +464,7 @@ LL | trait TRW3<T> where T: Iterator<Item: 'static, Item: 'static> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:151:46 --> $DIR/duplicate.rs:136:46
| |
LL | trait TRSW1 where Self: Iterator<Item: Copy, Item: Send> {} LL | trait TRSW1 where Self: Iterator<Item: Copy, Item: Send> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -532,7 +472,7 @@ LL | trait TRSW1 where Self: Iterator<Item: Copy, Item: Send> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:151:46 --> $DIR/duplicate.rs:136:46
| |
LL | trait TRSW1 where Self: Iterator<Item: Copy, Item: Send> {} LL | trait TRSW1 where Self: Iterator<Item: Copy, Item: Send> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -540,7 +480,7 @@ LL | trait TRSW1 where Self: Iterator<Item: Copy, Item: Send> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:154:46 --> $DIR/duplicate.rs:139:46
| |
LL | trait TRSW2 where Self: Iterator<Item: Copy, Item: Copy> {} LL | trait TRSW2 where Self: Iterator<Item: Copy, Item: Copy> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -548,7 +488,7 @@ LL | trait TRSW2 where Self: Iterator<Item: Copy, Item: Copy> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:154:46 --> $DIR/duplicate.rs:139:46
| |
LL | trait TRSW2 where Self: Iterator<Item: Copy, Item: Copy> {} LL | trait TRSW2 where Self: Iterator<Item: Copy, Item: Copy> {}
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -556,7 +496,7 @@ LL | trait TRSW2 where Self: Iterator<Item: Copy, Item: Copy> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:157:49 --> $DIR/duplicate.rs:142:49
| |
LL | trait TRSW3 where Self: Iterator<Item: 'static, Item: 'static> {} LL | trait TRSW3 where Self: Iterator<Item: 'static, Item: 'static> {}
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -564,7 +504,7 @@ LL | trait TRSW3 where Self: Iterator<Item: 'static, Item: 'static> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:157:49 --> $DIR/duplicate.rs:142:49
| |
LL | trait TRSW3 where Self: Iterator<Item: 'static, Item: 'static> {} LL | trait TRSW3 where Self: Iterator<Item: 'static, Item: 'static> {}
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -572,7 +512,7 @@ LL | trait TRSW3 where Self: Iterator<Item: 'static, Item: 'static> {}
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:160:43 --> $DIR/duplicate.rs:145:43
| |
LL | trait TRA1 { type A: Iterator<Item: Copy, Item: Send>; } LL | trait TRA1 { type A: Iterator<Item: Copy, Item: Send>; }
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -580,7 +520,7 @@ LL | trait TRA1 { type A: Iterator<Item: Copy, Item: Send>; }
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:162:43 --> $DIR/duplicate.rs:147:43
| |
LL | trait TRA2 { type A: Iterator<Item: Copy, Item: Copy>; } LL | trait TRA2 { type A: Iterator<Item: Copy, Item: Copy>; }
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -588,7 +528,7 @@ LL | trait TRA2 { type A: Iterator<Item: Copy, Item: Copy>; }
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:164:46 --> $DIR/duplicate.rs:149:46
| |
LL | trait TRA3 { type A: Iterator<Item: 'static, Item: 'static>; } LL | trait TRA3 { type A: Iterator<Item: 'static, Item: 'static>; }
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
@ -596,7 +536,7 @@ LL | trait TRA3 { type A: Iterator<Item: 'static, Item: 'static>; }
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:167:40 --> $DIR/duplicate.rs:152:40
| |
LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>; LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -604,7 +544,7 @@ LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:171:44 --> $DIR/duplicate.rs:154:44
| |
LL | type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>; LL | type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>;
| ---------- ^^^^^^^^^^ re-bound here | ---------- ^^^^^^^^^^ re-bound here
@ -612,85 +552,13 @@ LL | type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>;
| `Item` bound here first | `Item` bound here first
error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified
--> $DIR/duplicate.rs:175:43 --> $DIR/duplicate.rs:156:43
| |
LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>; LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>;
| ------------- ^^^^^^^^^^^^^ re-bound here | ------------- ^^^^^^^^^^^^^ re-bound here
| | | |
| `Item` bound here first | `Item` bound here first
error: could not find defining uses error: aborting due to 69 previous errors; 1 warning emitted
--> $DIR/duplicate.rs:117:28
|
LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>;
| ^^^^^^^^^^
error: could not find defining uses
--> $DIR/duplicate.rs:117:40
|
LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>;
| ^^^^^^^^^^
error: could not find defining uses
--> $DIR/duplicate.rs:122:28
|
LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>;
| ^^^^^^^^^^
error: could not find defining uses
--> $DIR/duplicate.rs:122:40
|
LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>;
| ^^^^^^^^^^
error: could not find defining uses
--> $DIR/duplicate.rs:127:28
|
LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>;
| ^^^^^^^^^^^^^
error: could not find defining uses
--> $DIR/duplicate.rs:127:43
|
LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>;
| ^^^^^^^^^^^^^
error: could not find defining uses
--> $DIR/duplicate.rs:167:28
|
LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>;
| ^^^^^^^^^^
error: could not find defining uses
--> $DIR/duplicate.rs:167:40
|
LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>;
| ^^^^^^^^^^
error: could not find defining uses
--> $DIR/duplicate.rs:171:32
|
LL | type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>;
| ^^^^^^^^^^
error: could not find defining uses
--> $DIR/duplicate.rs:171:44
|
LL | type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>;
| ^^^^^^^^^^
error: could not find defining uses
--> $DIR/duplicate.rs:175:28
|
LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>;
| ^^^^^^^^^^^^^
error: could not find defining uses
--> $DIR/duplicate.rs:175:43
|
LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>;
| ^^^^^^^^^^^^^
error: aborting due to 90 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0719`. For more information about this error, try `rustc --explain E0719`.

View file

@ -3,32 +3,27 @@
struct S1 { f: dyn Iterator<Item: Copy> } struct S1 { f: dyn Iterator<Item: Copy> }
//~^ ERROR associated type bounds are not allowed within structs, enums, or unions //~^ ERROR associated type bounds are not allowed within structs, enums, or unions
//~| ERROR could not find defining uses
struct S2 { f: Box<dyn Iterator<Item: Copy>> } struct S2 { f: Box<dyn Iterator<Item: Copy>> }
//~^ ERROR associated type bounds are not allowed within structs, enums, or unions //~^ ERROR associated type bounds are not allowed within structs, enums, or unions
//~| ERROR could not find defining uses
struct S3 { f: dyn Iterator<Item: 'static> } struct S3 { f: dyn Iterator<Item: 'static> }
//~^ ERROR associated type bounds are not allowed within structs, enums, or unions //~^ ERROR associated type bounds are not allowed within structs, enums, or unions
//~| ERROR could not find defining uses
enum E1 { V(dyn Iterator<Item: Copy>) } enum E1 { V(dyn Iterator<Item: Copy>) }
//~^ ERROR associated type bounds are not allowed within structs, enums, or unions //~^ ERROR associated type bounds are not allowed within structs, enums, or unions
//~| ERROR could not find defining uses //~| ERROR the size for values of type `(dyn Iterator<Item = impl Copy> + 'static)`
enum E2 { V(Box<dyn Iterator<Item: Copy>>) } enum E2 { V(Box<dyn Iterator<Item: Copy>>) }
//~^ ERROR associated type bounds are not allowed within structs, enums, or unions //~^ ERROR associated type bounds are not allowed within structs, enums, or unions
//~| ERROR could not find defining uses
enum E3 { V(dyn Iterator<Item: 'static>) } enum E3 { V(dyn Iterator<Item: 'static>) }
//~^ ERROR associated type bounds are not allowed within structs, enums, or unions //~^ ERROR associated type bounds are not allowed within structs, enums, or unions
//~| ERROR could not find defining uses //~| ERROR the size for values of type `(dyn Iterator<Item = impl Sized> + 'static)`
union U1 { f: dyn Iterator<Item: Copy> } union U1 { f: dyn Iterator<Item: Copy> }
//~^ ERROR associated type bounds are not allowed within structs, enums, or unions //~^ ERROR associated type bounds are not allowed within structs, enums, or unions
//~| ERROR could not find defining uses //~| ERROR the size for values of type `(dyn Iterator<Item = impl Copy> + 'static)`
union U2 { f: Box<dyn Iterator<Item: Copy>> } union U2 { f: Box<dyn Iterator<Item: Copy>> }
//~^ ERROR associated type bounds are not allowed within structs, enums, or unions //~^ ERROR associated type bounds are not allowed within structs, enums, or unions
//~| ERROR could not find defining uses
union U3 { f: dyn Iterator<Item: 'static> } union U3 { f: dyn Iterator<Item: 'static> }
//~^ ERROR associated type bounds are not allowed within structs, enums, or unions //~^ ERROR associated type bounds are not allowed within structs, enums, or unions
//~| ERROR could not find defining uses //~| ERROR the size for values of type `(dyn Iterator<Item = impl Sized> + 'static)`
fn main() {} fn main() {}

View file

@ -5,106 +5,125 @@ LL | struct S1 { f: dyn Iterator<Item: Copy> }
| ^^^^^^^^^^ | ^^^^^^^^^^
error: associated type bounds are not allowed within structs, enums, or unions error: associated type bounds are not allowed within structs, enums, or unions
--> $DIR/inside-adt.rs:7:33 --> $DIR/inside-adt.rs:6:33
| |
LL | struct S2 { f: Box<dyn Iterator<Item: Copy>> } LL | struct S2 { f: Box<dyn Iterator<Item: Copy>> }
| ^^^^^^^^^^ | ^^^^^^^^^^
error: associated type bounds are not allowed within structs, enums, or unions error: associated type bounds are not allowed within structs, enums, or unions
--> $DIR/inside-adt.rs:10:29 --> $DIR/inside-adt.rs:8:29
| |
LL | struct S3 { f: dyn Iterator<Item: 'static> } LL | struct S3 { f: dyn Iterator<Item: 'static> }
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: associated type bounds are not allowed within structs, enums, or unions error: associated type bounds are not allowed within structs, enums, or unions
--> $DIR/inside-adt.rs:14:26 --> $DIR/inside-adt.rs:11:26
| |
LL | enum E1 { V(dyn Iterator<Item: Copy>) } LL | enum E1 { V(dyn Iterator<Item: Copy>) }
| ^^^^^^^^^^ | ^^^^^^^^^^
error: associated type bounds are not allowed within structs, enums, or unions error: associated type bounds are not allowed within structs, enums, or unions
--> $DIR/inside-adt.rs:17:30 --> $DIR/inside-adt.rs:14:30
| |
LL | enum E2 { V(Box<dyn Iterator<Item: Copy>>) } LL | enum E2 { V(Box<dyn Iterator<Item: Copy>>) }
| ^^^^^^^^^^ | ^^^^^^^^^^
error: associated type bounds are not allowed within structs, enums, or unions error: associated type bounds are not allowed within structs, enums, or unions
--> $DIR/inside-adt.rs:20:26 --> $DIR/inside-adt.rs:16:26
| |
LL | enum E3 { V(dyn Iterator<Item: 'static>) } LL | enum E3 { V(dyn Iterator<Item: 'static>) }
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: associated type bounds are not allowed within structs, enums, or unions error: associated type bounds are not allowed within structs, enums, or unions
--> $DIR/inside-adt.rs:24:28 --> $DIR/inside-adt.rs:20:28
| |
LL | union U1 { f: dyn Iterator<Item: Copy> } LL | union U1 { f: dyn Iterator<Item: Copy> }
| ^^^^^^^^^^ | ^^^^^^^^^^
error: associated type bounds are not allowed within structs, enums, or unions error: associated type bounds are not allowed within structs, enums, or unions
--> $DIR/inside-adt.rs:27:32 --> $DIR/inside-adt.rs:23:32
| |
LL | union U2 { f: Box<dyn Iterator<Item: Copy>> } LL | union U2 { f: Box<dyn Iterator<Item: Copy>> }
| ^^^^^^^^^^ | ^^^^^^^^^^
error: associated type bounds are not allowed within structs, enums, or unions error: associated type bounds are not allowed within structs, enums, or unions
--> $DIR/inside-adt.rs:30:28 --> $DIR/inside-adt.rs:25:28
| |
LL | union U3 { f: dyn Iterator<Item: 'static> } LL | union U3 { f: dyn Iterator<Item: 'static> }
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
error: could not find defining uses error[E0277]: the size for values of type `(dyn Iterator<Item = impl Copy> + 'static)` cannot be known at compilation time
--> $DIR/inside-adt.rs:4:29 --> $DIR/inside-adt.rs:11:13
|
LL | struct S1 { f: dyn Iterator<Item: Copy> }
| ^^^^^^^^^^
error: could not find defining uses
--> $DIR/inside-adt.rs:7:33
|
LL | struct S2 { f: Box<dyn Iterator<Item: Copy>> }
| ^^^^^^^^^^
error: could not find defining uses
--> $DIR/inside-adt.rs:10:29
|
LL | struct S3 { f: dyn Iterator<Item: 'static> }
| ^^^^^^^^^^^^^
error: could not find defining uses
--> $DIR/inside-adt.rs:14:26
| |
LL | enum E1 { V(dyn Iterator<Item: Copy>) } LL | enum E1 { V(dyn Iterator<Item: Copy>) }
| ^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
error: could not find defining uses
--> $DIR/inside-adt.rs:17:30
| |
LL | enum E2 { V(Box<dyn Iterator<Item: Copy>>) } = help: the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Copy> + 'static)`
| ^^^^^^^^^^ = note: no field of an enum variant may have a dynamically sized type
= help: change the field's type to have a statically known size
help: borrowed types always have a statically known size
|
LL | enum E1 { V(&dyn Iterator<Item: Copy>) }
| ^
help: the `Box` type always has a statically known size and allocates its contents in the heap
|
LL | enum E1 { V(Box<dyn Iterator<Item: Copy>>) }
| ^^^^ ^
error: could not find defining uses error[E0277]: the size for values of type `(dyn Iterator<Item = impl Sized> + 'static)` cannot be known at compilation time
--> $DIR/inside-adt.rs:20:26 --> $DIR/inside-adt.rs:16:13
| |
LL | enum E3 { V(dyn Iterator<Item: 'static>) } LL | enum E3 { V(dyn Iterator<Item: 'static>) }
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Sized> + 'static)`
= note: no field of an enum variant may have a dynamically sized type
= help: change the field's type to have a statically known size
help: borrowed types always have a statically known size
|
LL | enum E3 { V(&dyn Iterator<Item: 'static>) }
| ^
help: the `Box` type always has a statically known size and allocates its contents in the heap
|
LL | enum E3 { V(Box<dyn Iterator<Item: 'static>>) }
| ^^^^ ^
error: could not find defining uses error[E0277]: the size for values of type `(dyn Iterator<Item = impl Copy> + 'static)` cannot be known at compilation time
--> $DIR/inside-adt.rs:24:28 --> $DIR/inside-adt.rs:20:15
| |
LL | union U1 { f: dyn Iterator<Item: Copy> } LL | union U1 { f: dyn Iterator<Item: Copy> }
| ^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
error: could not find defining uses
--> $DIR/inside-adt.rs:27:32
| |
LL | union U2 { f: Box<dyn Iterator<Item: Copy>> } = help: the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Copy> + 'static)`
| ^^^^^^^^^^ = note: no field of a union may have a dynamically sized type
= help: change the field's type to have a statically known size
help: borrowed types always have a statically known size
|
LL | union U1 { f: &dyn Iterator<Item: Copy> }
| ^
help: the `Box` type always has a statically known size and allocates its contents in the heap
|
LL | union U1 { f: Box<dyn Iterator<Item: Copy>> }
| ^^^^ ^
error: could not find defining uses error[E0277]: the size for values of type `(dyn Iterator<Item = impl Sized> + 'static)` cannot be known at compilation time
--> $DIR/inside-adt.rs:30:28 --> $DIR/inside-adt.rs:25:15
| |
LL | union U3 { f: dyn Iterator<Item: 'static> } LL | union U3 { f: dyn Iterator<Item: 'static> }
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `(dyn Iterator<Item = impl Sized> + 'static)`
= note: no field of a union may have a dynamically sized type
= help: change the field's type to have a statically known size
help: borrowed types always have a statically known size
|
LL | union U3 { f: &dyn Iterator<Item: 'static> }
| ^
help: the `Box` type always has a statically known size and allocates its contents in the heap
|
LL | union U3 { f: Box<dyn Iterator<Item: 'static>> }
| ^^^^ ^
error: aborting due to 18 previous errors error: aborting due to 13 previous errors
For more information about this error, try `rustc --explain E0277`.

View file

@ -5,7 +5,7 @@
async fn copy() -> Result<()> //~ ERROR wrong number of type arguments async fn copy() -> Result<()> //~ ERROR wrong number of type arguments
{ {
Ok(()) Ok(())
//~^ type annotations needed //~^ ERROR type annotations needed
} }
fn main() { } fn main() { }

View file

@ -1,8 +1,7 @@
// ignore-tidy-linelength // ignore-tidy-linelength
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]
pub trait Bar pub trait Bar {
{
type E: Copy; type E: Copy;
fn foo<T>() -> Self::E; fn foo<T>() -> Self::E;
@ -15,6 +14,7 @@ impl<S: Default> Bar for S {
fn foo<T: Default>() -> Self::E { fn foo<T: Default>() -> Self::E {
//~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias //~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
//~| ERROR impl has stricter requirements than trait
(S::default(), T::default()) (S::default(), T::default())
} }
} }

View file

@ -1,5 +1,14 @@
error[E0276]: impl has stricter requirements than trait
--> $DIR/issue-55872-1.rs:15:5
|
LL | fn foo<T>() -> Self::E;
| ----------------------- definition of `foo` from trait
...
LL | fn foo<T: Default>() -> Self::E {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: Default`
error[E0277]: the trait bound `S: Copy` is not satisfied in `(S, T)` error[E0277]: the trait bound `S: Copy` is not satisfied in `(S, T)`
--> $DIR/issue-55872-1.rs:12:14 --> $DIR/issue-55872-1.rs:11:14
| |
LL | type E = impl Copy; LL | type E = impl Copy;
| ^^^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `S` | ^^^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `S`
@ -12,7 +21,7 @@ LL | impl<S: Default + Copy> Bar for S {
| ^^^^^^ | ^^^^^^
error[E0277]: the trait bound `T: Copy` is not satisfied in `(S, T)` error[E0277]: the trait bound `T: Copy` is not satisfied in `(S, T)`
--> $DIR/issue-55872-1.rs:12:14 --> $DIR/issue-55872-1.rs:11:14
| |
LL | type E = impl Copy; LL | type E = impl Copy;
| ^^^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `T` | ^^^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `T`
@ -25,15 +34,17 @@ LL | fn foo<T: Default + Copy>() -> Self::E {
| ^^^^^^ | ^^^^^^
error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
--> $DIR/issue-55872-1.rs:16:37 --> $DIR/issue-55872-1.rs:15:37
| |
LL | fn foo<T: Default>() -> Self::E { LL | fn foo<T: Default>() -> Self::E {
| _____________________________________^ | _____________________________________^
LL | | LL | |
LL | |
LL | | (S::default(), T::default()) LL | | (S::default(), T::default())
LL | | } LL | | }
| |_____^ | |_____^
error: aborting due to 3 previous errors error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0277`. Some errors have detailed explanations: E0276, E0277.
For more information about an error, try `rustc --explain E0276`.

View file

@ -56,10 +56,12 @@ fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() }
fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() }
//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
//~| ERROR nested `impl Trait` is not allowed //~| ERROR nested `impl Trait` is not allowed
//~| ERROR cannot resolve opaque type
// Disallowed // Disallowed
fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() } fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() }
//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types
//~| ERROR cannot resolve opaque type
// Disallowed // Disallowed
fn in_Fn_parameter_in_generics<F: Fn(impl Debug)> (_: F) { panic!() } fn in_Fn_parameter_in_generics<F: Fn(impl Debug)> (_: F) { panic!() }

View file

@ -17,7 +17,7 @@ LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic
| outer `impl Trait` | outer `impl Trait`
error[E0658]: `impl Trait` in type aliases is unstable error[E0658]: `impl Trait` in type aliases is unstable
--> $DIR/where-allowed.rs:119:16 --> $DIR/where-allowed.rs:121:16
| |
LL | type Out = impl Debug; LL | type Out = impl Debug;
| ^^^^^^^^^^ | ^^^^^^^^^^
@ -26,7 +26,7 @@ LL | type Out = impl Debug;
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
error[E0658]: `impl Trait` in type aliases is unstable error[E0658]: `impl Trait` in type aliases is unstable
--> $DIR/where-allowed.rs:155:23 --> $DIR/where-allowed.rs:157:23
| |
LL | type InTypeAlias<R> = impl Debug; LL | type InTypeAlias<R> = impl Debug;
| ^^^^^^^^^^ | ^^^^^^^^^^
@ -35,7 +35,7 @@ LL | type InTypeAlias<R> = impl Debug;
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
error[E0658]: `impl Trait` in type aliases is unstable error[E0658]: `impl Trait` in type aliases is unstable
--> $DIR/where-allowed.rs:159:39 --> $DIR/where-allowed.rs:161:39
| |
LL | type InReturnInTypeAlias<R> = fn() -> impl Debug; LL | type InReturnInTypeAlias<R> = fn() -> impl Debug;
| ^^^^^^^^^^ | ^^^^^^^^^^
@ -110,139 +110,139 @@ LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:61:59 --> $DIR/where-allowed.rs:62:59
| |
LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() } LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() }
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:65:38 --> $DIR/where-allowed.rs:67:38
| |
LL | fn in_Fn_parameter_in_generics<F: Fn(impl Debug)> (_: F) { panic!() } LL | fn in_Fn_parameter_in_generics<F: Fn(impl Debug)> (_: F) { panic!() }
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:69:40 --> $DIR/where-allowed.rs:71:40
| |
LL | fn in_Fn_return_in_generics<F: Fn() -> impl Debug> (_: F) { panic!() } LL | fn in_Fn_return_in_generics<F: Fn() -> impl Debug> (_: F) { panic!() }
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:82:32 --> $DIR/where-allowed.rs:84:32
| |
LL | struct InBraceStructField { x: impl Debug } LL | struct InBraceStructField { x: impl Debug }
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:86:41 --> $DIR/where-allowed.rs:88:41
| |
LL | struct InAdtInBraceStructField { x: Vec<impl Debug> } LL | struct InAdtInBraceStructField { x: Vec<impl Debug> }
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:90:27 --> $DIR/where-allowed.rs:92:27
| |
LL | struct InTupleStructField(impl Debug); LL | struct InTupleStructField(impl Debug);
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:95:25 --> $DIR/where-allowed.rs:97:25
| |
LL | InBraceVariant { x: impl Debug }, LL | InBraceVariant { x: impl Debug },
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:97:20 --> $DIR/where-allowed.rs:99:20
| |
LL | InTupleVariant(impl Debug), LL | InTupleVariant(impl Debug),
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:108:23 --> $DIR/where-allowed.rs:110:23
| |
LL | fn in_return() -> impl Debug; LL | fn in_return() -> impl Debug;
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:126:34 --> $DIR/where-allowed.rs:128:34
| |
LL | fn in_trait_impl_return() -> impl Debug { () } LL | fn in_trait_impl_return() -> impl Debug { () }
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:139:33 --> $DIR/where-allowed.rs:141:33
| |
LL | fn in_foreign_parameters(_: impl Debug); LL | fn in_foreign_parameters(_: impl Debug);
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:142:31 --> $DIR/where-allowed.rs:144:31
| |
LL | fn in_foreign_return() -> impl Debug; LL | fn in_foreign_return() -> impl Debug;
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:159:39 --> $DIR/where-allowed.rs:161:39
| |
LL | type InReturnInTypeAlias<R> = fn() -> impl Debug; LL | type InReturnInTypeAlias<R> = fn() -> impl Debug;
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:164:16 --> $DIR/where-allowed.rs:166:16
| |
LL | impl PartialEq<impl Debug> for () { LL | impl PartialEq<impl Debug> for () {
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:169:24 --> $DIR/where-allowed.rs:171:24
| |
LL | impl PartialEq<()> for impl Debug { LL | impl PartialEq<()> for impl Debug {
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:174:6 --> $DIR/where-allowed.rs:176:6
| |
LL | impl impl Debug { LL | impl impl Debug {
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:180:24 --> $DIR/where-allowed.rs:182:24
| |
LL | impl InInherentImplAdt<impl Debug> { LL | impl InInherentImplAdt<impl Debug> {
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:186:11 --> $DIR/where-allowed.rs:188:11
| |
LL | where impl Debug: Debug LL | where impl Debug: Debug
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:193:15 --> $DIR/where-allowed.rs:195:15
| |
LL | where Vec<impl Debug>: Debug LL | where Vec<impl Debug>: Debug
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:200:24 --> $DIR/where-allowed.rs:202:24
| |
LL | where T: PartialEq<impl Debug> LL | where T: PartialEq<impl Debug>
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:207:17 --> $DIR/where-allowed.rs:209:17
| |
LL | where T: Fn(impl Debug) LL | where T: Fn(impl Debug)
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:214:22 --> $DIR/where-allowed.rs:216:22
| |
LL | where T: Fn() -> impl Debug LL | where T: Fn() -> impl Debug
| ^^^^^^^^^^ | ^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:220:29 --> $DIR/where-allowed.rs:222:29
| |
LL | let _in_local_variable: impl Fn() = || {}; LL | let _in_local_variable: impl Fn() = || {};
| ^^^^^^^^^ | ^^^^^^^^^
@ -250,24 +250,44 @@ LL | let _in_local_variable: impl Fn() = || {};
= help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> $DIR/where-allowed.rs:222:46 --> $DIR/where-allowed.rs:224:46
| |
LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; LL | let _in_return_in_local_variable = || -> impl Fn() { || {} };
| ^^^^^^^^^ | ^^^^^^^^^
error[E0720]: cannot resolve opaque type
--> $DIR/where-allowed.rs:56:49
|
LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() }
| ^^^^^^^^^^^^^^^^^^^ -------- this returned value is of `!` type
| |
| cannot resolve opaque type
|
= help: this error will resolve once the item's body returns a concrete type
error[E0720]: cannot resolve opaque type
--> $DIR/where-allowed.rs:62:46
|
LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() }
| ^^^^^^^^^^^^^^^^^^^^^^^ -------- this returned value is of `!` type
| |
| cannot resolve opaque type
|
= help: this error will resolve once the item's body returns a concrete type
error: could not find defining uses error: could not find defining uses
--> $DIR/where-allowed.rs:119:16 --> $DIR/where-allowed.rs:121:16
| |
LL | type Out = impl Debug; LL | type Out = impl Debug;
| ^^^^^^^^^^ | ^^^^^^^^^^
error: could not find defining uses error: could not find defining uses
--> $DIR/where-allowed.rs:155:23 --> $DIR/where-allowed.rs:157:23
| |
LL | type InTypeAlias<R> = impl Debug; LL | type InTypeAlias<R> = impl Debug;
| ^^^^^^^^^^ | ^^^^^^^^^^
error: aborting due to 42 previous errors error: aborting due to 44 previous errors
Some errors have detailed explanations: E0562, E0658, E0666. Some errors have detailed explanations: E0562, E0658, E0666, E0720.
For more information about an error, try `rustc --explain E0562`. For more information about an error, try `rustc --explain E0562`.

View file

@ -1,19 +1,18 @@
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]
fn main() { fn main() {}
}
trait TraitWithAssoc { trait TraitWithAssoc {
type Assoc; type Assoc;
} }
type Foo<V> = impl Trait<V>; type Foo<V> = impl Trait<V>;
//~^ ERROR the trait bound `T: TraitWithAssoc` is not satisfied
trait Trait<U> {} trait Trait<U> {}
impl<W> Trait<W> for () {} impl<W> Trait<W> for () {}
fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> { fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> {
//~^ ERROR non-defining opaque type use in defining scope
() ()
} }

View file

@ -1,14 +1,14 @@
error[E0277]: the trait bound `T: TraitWithAssoc` is not satisfied error: non-defining opaque type use in defining scope
--> $DIR/bound_reduction2.rs:10:15 --> $DIR/bound_reduction2.rs:15:46
|
LL | fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> {
| ^^^^^^^^^^^^^
|
note: used non-generic type `<T as TraitWithAssoc>::Assoc` for generic parameter
--> $DIR/bound_reduction2.rs:9:10
| |
LL | type Foo<V> = impl Trait<V>; LL | type Foo<V> = impl Trait<V>;
| ^^^^^^^^^^^^^ the trait `TraitWithAssoc` is not implemented for `T` | ^
|
help: consider further restricting this bound
|
LL | fn foo_desugared<T: TraitWithAssoc + TraitWithAssoc>(_: T) -> Foo<T::Assoc> {
| ^^^^^^^^^^^^^^^^
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.

View file

@ -9,4 +9,5 @@ mod boo {
fn bomp() -> boo::Boo { fn bomp() -> boo::Boo {
"" ""
//~^ mismatched types
} }

View file

@ -4,5 +4,20 @@ error: could not find defining uses
LL | pub type Boo = impl ::std::fmt::Debug; LL | pub type Boo = impl ::std::fmt::Debug;
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error error[E0308]: mismatched types
--> $DIR/declared_but_not_defined_in_scope.rs:11:5
|
LL | pub type Boo = impl ::std::fmt::Debug;
| ---------------------- the expected opaque type
...
LL | fn bomp() -> boo::Boo {
| -------- expected `impl Debug` because of return type
LL | ""
| ^^ expected opaque type, found `&str`
|
= note: expected opaque type `impl Debug`
found reference `&'static str`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -8,10 +8,10 @@ fn main() {}
type Two<T, U> = impl Debug; type Two<T, U> = impl Debug;
fn one<T: Debug>(t: T) -> Two<T, T> { fn one<T: Debug>(t: T) -> Two<T, T> {
//~^ ERROR non-defining opaque type use in defining scope
t t
} }
fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> { fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> {
//~^ ERROR concrete type differs from previous defining opaque type use
t t
} }

View file

@ -1,14 +1,14 @@
error: concrete type differs from previous defining opaque type use error: non-defining opaque type use in defining scope
--> $DIR/generic_duplicate_param_use2.rs:14:1 --> $DIR/generic_duplicate_param_use2.rs:10:27
|
LL | fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `U`, got `T`
|
note: previous use here
--> $DIR/generic_duplicate_param_use2.rs:10:1
| |
LL | fn one<T: Debug>(t: T) -> Two<T, T> { LL | fn one<T: Debug>(t: T) -> Two<T, T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^
|
note: type used multiple times
--> $DIR/generic_duplicate_param_use2.rs:8:10
|
LL | type Two<T, U> = impl Debug;
| ^ ^
error: aborting due to previous error error: aborting due to previous error

View file

@ -8,11 +8,11 @@ fn main() {}
type Two<T, U> = impl Debug; type Two<T, U> = impl Debug;
fn one<T: Debug>(t: T) -> Two<T, T> { fn one<T: Debug>(t: T) -> Two<T, T> {
//~^ ERROR non-defining opaque type use in defining scope
t t
} }
fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> { fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> {
//~^ ERROR concrete type differs from previous defining opaque type use
t t
} }

View file

@ -1,14 +1,14 @@
error: concrete type differs from previous defining opaque type use error: non-defining opaque type use in defining scope
--> $DIR/generic_duplicate_param_use3.rs:14:1 --> $DIR/generic_duplicate_param_use3.rs:10:27
|
LL | fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `U`, got `T`
|
note: previous use here
--> $DIR/generic_duplicate_param_use3.rs:10:1
| |
LL | fn one<T: Debug>(t: T) -> Two<T, T> { LL | fn one<T: Debug>(t: T) -> Two<T, T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^
|
note: type used multiple times
--> $DIR/generic_duplicate_param_use3.rs:8:10
|
LL | type Two<T, U> = impl Debug;
| ^ ^
error: aborting due to previous error error: aborting due to previous error

View file

@ -3,10 +3,11 @@
fn main() {} fn main() {}
trait Trait {} trait Trait {}
type Underconstrained<T: Trait> = impl 'static; //~ ERROR the trait bound `T: Trait` type Underconstrained<T: Trait> = impl 'static;
//~^ ERROR: at least one trait must be specified //~^ ERROR: at least one trait must be specified
// no `Trait` bound // no `Trait` bound
fn underconstrain<T>(_: T) -> Underconstrained<T> { fn underconstrain<T>(_: T) -> Underconstrained<T> {
//~^ ERROR the trait bound `T: Trait`
unimplemented!() unimplemented!()
} }

View file

@ -5,12 +5,14 @@ LL | type Underconstrained<T: Trait> = impl 'static;
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error[E0277]: the trait bound `T: Trait` is not satisfied error[E0277]: the trait bound `T: Trait` is not satisfied
--> $DIR/generic_underconstrained.rs:6:35 --> $DIR/generic_underconstrained.rs:10:31
| |
LL | type Underconstrained<T: Trait> = impl 'static; LL | type Underconstrained<T: Trait> = impl 'static;
| ^^^^^^^^^^^^ the trait `Trait` is not implemented for `T` | ----- required by this bound in `Underconstrained`
...
LL | fn underconstrain<T>(_: T) -> Underconstrained<T> {
| ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T`
| |
= note: the return type of a function must have a statically known size
help: consider restricting type parameter `T` help: consider restricting type parameter `T`
| |
LL | fn underconstrain<T: Trait>(_: T) -> Underconstrained<T> { LL | fn underconstrain<T: Trait>(_: T) -> Underconstrained<T> {

View file

@ -3,19 +3,19 @@
fn main() {} fn main() {}
type Underconstrained<T: std::fmt::Debug> = impl 'static; type Underconstrained<T: std::fmt::Debug> = impl 'static;
//~^ ERROR `U` doesn't implement `Debug` //~^ ERROR: at least one trait must be specified
//~^^ ERROR: at least one trait must be specified
// not a defining use, because it doesn't define *all* possible generics // not a defining use, because it doesn't define *all* possible generics
fn underconstrained<U>(_: U) -> Underconstrained<U> { fn underconstrained<U>(_: U) -> Underconstrained<U> {
//~^ ERROR `U` doesn't implement `Debug`
5u32 5u32
} }
type Underconstrained2<T: std::fmt::Debug> = impl 'static; type Underconstrained2<T: std::fmt::Debug> = impl 'static;
//~^ ERROR `V` doesn't implement `Debug` //~^ ERROR: at least one trait must be specified
//~^^ ERROR: at least one trait must be specified
// not a defining use, because it doesn't define *all* possible generics // not a defining use, because it doesn't define *all* possible generics
fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> { fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
//~^ ERROR `V` doesn't implement `Debug`
5u32 5u32
} }

View file

@ -11,30 +11,28 @@ LL | type Underconstrained2<T: std::fmt::Debug> = impl 'static;
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
error[E0277]: `U` doesn't implement `Debug` error[E0277]: `U` doesn't implement `Debug`
--> $DIR/generic_underconstrained2.rs:5:45 --> $DIR/generic_underconstrained2.rs:9:33
| |
LL | type Underconstrained<T: std::fmt::Debug> = impl 'static; LL | type Underconstrained<T: std::fmt::Debug> = impl 'static;
| ^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug` | --------------- required by this bound in `Underconstrained`
... ...
LL | 5u32 LL | fn underconstrained<U>(_: U) -> Underconstrained<U> {
| ---- this returned value is of type `u32` | ^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug`
| |
= note: the return type of a function must have a statically known size
help: consider restricting type parameter `U` help: consider restricting type parameter `U`
| |
LL | fn underconstrained<U: Debug>(_: U) -> Underconstrained<U> { LL | fn underconstrained<U: Debug>(_: U) -> Underconstrained<U> {
| ^^^^^^^ | ^^^^^^^
error[E0277]: `V` doesn't implement `Debug` error[E0277]: `V` doesn't implement `Debug`
--> $DIR/generic_underconstrained2.rs:14:46 --> $DIR/generic_underconstrained2.rs:18:43
| |
LL | type Underconstrained2<T: std::fmt::Debug> = impl 'static; LL | type Underconstrained2<T: std::fmt::Debug> = impl 'static;
| ^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug` | --------------- required by this bound in `Underconstrained2`
... ...
LL | 5u32 LL | fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
| ---- this returned value is of type `u32` | ^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug`
| |
= note: the return type of a function must have a statically known size
help: consider restricting type parameter `V` help: consider restricting type parameter `V`
| |
LL | fn underconstrained2<U, V: Debug>(_: U, _: V) -> Underconstrained2<V> { LL | fn underconstrained2<U, V: Debug>(_: U, _: V) -> Underconstrained2<V> {

View file

@ -9,10 +9,9 @@ trait X {
} }
impl<T> X for () { impl<T> X for () {
//~^ ERROR the type parameter `T` is not constrained
type I = impl Sized; type I = impl Sized;
//~^ ERROR could not find defining uses
fn f() -> Self::I {} fn f() -> Self::I {}
//~^ ERROR type annotations needed
} }
fn main() {} fn main() {}

View file

@ -1,15 +1,9 @@
error[E0282]: type annotations needed error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
--> $DIR/impl-with-unconstrained-param.rs:14:23 --> $DIR/impl-with-unconstrained-param.rs:11:6
| |
LL | fn f() -> Self::I {} LL | impl<T> X for () {
| ^^ cannot infer type for type parameter `T` | ^ unconstrained type parameter
error: could not find defining uses error: aborting due to previous error
--> $DIR/impl-with-unconstrained-param.rs:12:14
|
LL | type I = impl Sized;
| ^^^^^^^^^^
error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0207`.
For more information about this error, try `rustc --explain E0282`.

View file

@ -22,6 +22,6 @@ impl Foo for X {
} }
} }
trait Baz<A, B> = Fn(&A) -> &B; trait Baz<A: ?Sized, B: ?Sized> = Fn(&A) -> &B;
fn main() {} fn main() {}

View file

@ -7,6 +7,7 @@ fn main() {}
type Two<T, U> = impl Debug; type Two<T, U> = impl Debug;
fn two<T: Debug>(t: T) -> Two<T, u32> { fn two<T: Debug>(t: T) -> Two<T, u32> {
//~^ ERROR non-defining opaque type use in defining scope
(t, 4i8) (t, 4i8)
} }
@ -24,9 +25,7 @@ impl Bar for u32 {
const FOO: i32 = 42; const FOO: i32 = 42;
} }
// this should work! But it requires `two` and `three` not to be defining uses, fn four<T: Debug, U: Bar>(t: T) -> Two<T, U> {
// just restricting uses
fn four<T: Debug, U: Bar>(t: T) -> Two<T, U> { //~ concrete type differs from previous
(t, <U as Bar>::FOO) (t, <U as Bar>::FOO)
} }

View file

@ -1,14 +1,14 @@
error: concrete type differs from previous defining opaque type use error: non-defining opaque type use in defining scope
--> $DIR/not_a_defining_use.rs:29:1 --> $DIR/not_a_defining_use.rs:9:27
|
LL | fn four<T: Debug, U: Bar>(t: T) -> Two<T, U> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(T, i8)`, got `(T, <U as Bar>::Blub)`
|
note: previous use here
--> $DIR/not_a_defining_use.rs:9:1
| |
LL | fn two<T: Debug>(t: T) -> Two<T, u32> { LL | fn two<T: Debug>(t: T) -> Two<T, u32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^
|
note: used non-generic type `u32` for generic parameter
--> $DIR/not_a_defining_use.rs:7:13
|
LL | type Two<T, U> = impl Debug;
| ^
error: aborting due to previous error error: aborting due to previous error

View file

@ -0,0 +1,18 @@
// regression test for #74018
#![feature(type_alias_impl_trait)]
trait Trait {
type Associated;
fn into(self) -> Self::Associated;
}
impl<'a, I: Iterator<Item = i32>> Trait for (i32, I) {
//~^ ERROR the lifetime parameter `'a` is not constrained
type Associated = (i32, impl Iterator<Item = i32>);
fn into(self) -> Self::Associated {
(0_i32, [0_i32].iter().copied())
}
}
fn main() {}

View file

@ -0,0 +1,9 @@
error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
--> $DIR/type-alias-impl-trait-unconstrained-lifetime.rs:10:6
|
LL | impl<'a, I: Iterator<Item = i32>> Trait for (i32, I) {
| ^^ unconstrained lifetime parameter
error: aborting due to previous error
For more information about this error, try `rustc --explain E0207`.

View file

@ -405,15 +405,10 @@ LL | type X = Box<_>;
| ^ not allowed in type signatures | ^ not allowed in type signatures
error[E0121]: the type placeholder `_` is not allowed within types on item signatures error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:43:27 --> $DIR/typeck_type_placeholder_item.rs:182:21
| |
LL | fn test10(&self, _x : _) { } LL | type Y = impl Trait<_>;
| ^ not allowed in type signatures | ^ not allowed in type signatures
|
help: use type parameters instead
|
LL | fn test10<T>(&self, _x : T) { }
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:140:31 --> $DIR/typeck_type_placeholder_item.rs:140:31
@ -485,45 +480,6 @@ help: use type parameters instead
LL | fn assoc_fn_test3<T>() -> T; LL | fn assoc_fn_test3<T>() -> T;
| ^^^ ^ | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:61:37
|
LL | fn clone_from(&mut self, other: _) { *self = Test9; }
| ^ not allowed in type signatures
|
help: use type parameters instead
|
LL | fn clone_from<T>(&mut self, other: T) { *self = Test9; }
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:110:34
|
LL | fn fn_test10(&self, _x : _) { }
| ^ not allowed in type signatures
|
help: use type parameters instead
|
LL | fn fn_test10<T>(&self, _x : T) { }
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:118:41
|
LL | fn clone_from(&mut self, other: _) { *self = FnTest9; }
| ^ not allowed in type signatures
|
help: use type parameters instead
|
LL | fn clone_from<T>(&mut self, other: T) { *self = FnTest9; }
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:182:21
|
LL | type Y = impl Trait<_>;
| ^ not allowed in type signatures
error[E0121]: the type placeholder `_` is not allowed within types on item signatures error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:190:14 --> $DIR/typeck_type_placeholder_item.rs:190:14
| |
@ -560,6 +516,17 @@ LL | fn test9(&self) -> _ { () }
| not allowed in type signatures | not allowed in type signatures
| help: replace with the correct return type: `()` | help: replace with the correct return type: `()`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:43:27
|
LL | fn test10(&self, _x : _) { }
| ^ not allowed in type signatures
|
help: use type parameters instead
|
LL | fn test10<T>(&self, _x : T) { }
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:58:24 --> $DIR/typeck_type_placeholder_item.rs:58:24
| |
@ -569,6 +536,17 @@ LL | fn clone(&self) -> _ { Test9 }
| not allowed in type signatures | not allowed in type signatures
| help: replace with the correct return type: `Test9` | help: replace with the correct return type: `Test9`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:61:37
|
LL | fn clone_from(&mut self, other: _) { *self = Test9; }
| ^ not allowed in type signatures
|
help: use type parameters instead
|
LL | fn clone_from<T>(&mut self, other: T) { *self = Test9; }
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:107:31 --> $DIR/typeck_type_placeholder_item.rs:107:31
| |
@ -578,6 +556,17 @@ LL | fn fn_test9(&self) -> _ { () }
| not allowed in type signatures | not allowed in type signatures
| help: replace with the correct return type: `()` | help: replace with the correct return type: `()`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:110:34
|
LL | fn fn_test10(&self, _x : _) { }
| ^ not allowed in type signatures
|
help: use type parameters instead
|
LL | fn fn_test10<T>(&self, _x : T) { }
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:115:28 --> $DIR/typeck_type_placeholder_item.rs:115:28
| |
@ -587,6 +576,17 @@ LL | fn clone(&self) -> _ { FnTest9 }
| not allowed in type signatures | not allowed in type signatures
| help: replace with the correct return type: `FnTest9` | help: replace with the correct return type: `FnTest9`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:118:41
|
LL | fn clone_from(&mut self, other: _) { *self = FnTest9; }
| ^ not allowed in type signatures
|
help: use type parameters instead
|
LL | fn clone_from<T>(&mut self, other: T) { *self = FnTest9; }
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:201:14 --> $DIR/typeck_type_placeholder_item.rs:201:14
| |