diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-07-20 16:17:19 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-20 16:17:19 +0530 |
| commit | eecfdfb8a12367cb292a85b6a30981eb35a56379 (patch) | |
| tree | 5450ed5b247533c39a063456dbc71de8e2156f78 /src | |
| parent | 3c3c5da9adfdf308b5189b8034c07e0dc5492a54 (diff) | |
| parent | 64dc377a103c0d377b3e60e08d29f69fcf7ba2c5 (diff) | |
| download | rust-eecfdfb8a12367cb292a85b6a30981eb35a56379.tar.gz rust-eecfdfb8a12367cb292a85b6a30981eb35a56379.zip | |
Rollup merge of #99383 - ouz-a:issue_57961, r=oli-obk
Formalize defining_use_anchor This tackles issue #57961 Introduces new enum called `DefiningAnchor` that replaces `Option<LocalDefId>` of `defining_use_anchor`. Now every use of it is explicit and exhaustively matched, catching errors like one in the linked issue. This is not a perfect fix but it's a step in the right direction. r? `@oli-obk`
Diffstat (limited to 'src')
10 files changed, 108 insertions, 35 deletions
diff --git a/src/test/ui/impl-trait/issues/issue-99348-impl-compatibility.rs b/src/test/ui/impl-trait/issues/issue-99348-impl-compatibility.rs index d29a82f76a7..b05579f2166 100644 --- a/src/test/ui/impl-trait/issues/issue-99348-impl-compatibility.rs +++ b/src/test/ui/impl-trait/issues/issue-99348-impl-compatibility.rs @@ -6,7 +6,7 @@ type Tait = impl Sized; impl Foo for Concrete { type Item = Concrete; - //~^ mismatched types + //~^ type mismatch resolving } impl Bar for Concrete { diff --git a/src/test/ui/impl-trait/issues/issue-99348-impl-compatibility.stderr b/src/test/ui/impl-trait/issues/issue-99348-impl-compatibility.stderr index a25f0cd8761..f0dceb1b11a 100644 --- a/src/test/ui/impl-trait/issues/issue-99348-impl-compatibility.stderr +++ b/src/test/ui/impl-trait/issues/issue-99348-impl-compatibility.stderr @@ -1,15 +1,25 @@ -error[E0308]: mismatched types +error[E0271]: type mismatch resolving `<Concrete as Bar>::Other == Concrete` --> $DIR/issue-99348-impl-compatibility.rs:8:17 | LL | type Tait = impl Sized; - | ---------- the expected opaque type + | ---------- the found opaque type ... LL | type Item = Concrete; - | ^^^^^^^^ types differ + | ^^^^^^^^ type mismatch resolving `<Concrete as Bar>::Other == Concrete` | - = note: expected opaque type `Tait` - found struct `Concrete` +note: expected this to be `Concrete` + --> $DIR/issue-99348-impl-compatibility.rs:13:18 + | +LL | type Other = Tait; + | ^^^^ + = note: expected struct `Concrete` + found opaque type `Tait` +note: required by a bound in `Foo::Item` + --> $DIR/issue-99348-impl-compatibility.rs:17:20 + | +LL | type Item: Bar<Other = Self>; + | ^^^^^^^^^^^^ required by this bound in `Foo::Item` error: aborting due to previous error -For more information about this error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/parser/fn-header-semantic-fail.rs b/src/test/ui/parser/fn-header-semantic-fail.rs index c2954868f78..8ff14fb1f30 100644 --- a/src/test/ui/parser/fn-header-semantic-fail.rs +++ b/src/test/ui/parser/fn-header-semantic-fail.rs @@ -27,7 +27,7 @@ fn main() { struct Y; impl X for Y { async fn ft1() {} //~ ERROR functions in traits cannot be declared `async` - //~^ ERROR impl has stricter requirements than trait + //~^ ERROR has an incompatible type for trait unsafe fn ft2() {} // OK. const fn ft3() {} //~ ERROR functions in traits cannot be declared const extern "C" fn ft4() {} @@ -36,7 +36,7 @@ fn main() { //~| ERROR functions in traits cannot be declared const //~| ERROR functions cannot be both `const` and `async` //~| ERROR cycle detected - //~| ERROR impl has stricter requirements than trait + //~| ERROR has an incompatible type for trait } impl Y { diff --git a/src/test/ui/parser/fn-header-semantic-fail.stderr b/src/test/ui/parser/fn-header-semantic-fail.stderr index 75d27c614e2..bc51ba8b8c5 100644 --- a/src/test/ui/parser/fn-header-semantic-fail.stderr +++ b/src/test/ui/parser/fn-header-semantic-fail.stderr @@ -216,23 +216,41 @@ LL | | } LL | | } | |_^ -error[E0276]: impl has stricter requirements than trait - --> $DIR/fn-header-semantic-fail.rs:29:9 +error[E0053]: method `ft1` has an incompatible type for trait + --> $DIR/fn-header-semantic-fail.rs:29:24 | -LL | async fn ft1(); - | --------------- definition of `ft1` from trait -... LL | async fn ft1() {} - | ^^^^^^^^^^^^^^ impl has extra requirement `(): Future` + | ^ + | | + | checked the `Output` of this `async fn`, found opaque type + | expected `()`, found opaque type + | + = note: while checking the return type of the `async fn` +note: type in trait + --> $DIR/fn-header-semantic-fail.rs:17:23 + | +LL | async fn ft1(); + | ^ + = note: expected fn pointer `fn()` + found fn pointer `fn() -> impl Future<Output = ()>` -error[E0276]: impl has stricter requirements than trait - --> $DIR/fn-header-semantic-fail.rs:34:9 +error[E0053]: method `ft5` has an incompatible type for trait + --> $DIR/fn-header-semantic-fail.rs:34:48 | -LL | const async unsafe extern "C" fn ft5(); - | --------------------------------------- definition of `ft5` from trait -... LL | const async unsafe extern "C" fn ft5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `(): Future` + | ^ + | | + | checked the `Output` of this `async fn`, found opaque type + | expected `()`, found opaque type + | + = note: while checking the return type of the `async fn` +note: type in trait + --> $DIR/fn-header-semantic-fail.rs:21:47 + | +LL | const async unsafe extern "C" fn ft5(); + | ^ + = note: expected fn pointer `unsafe extern "C" fn()` + found fn pointer `unsafe extern "C" fn() -> impl Future<Output = ()>` error[E0391]: cycle detected when computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 28:17>::ft5::{opaque#0}` --> $DIR/fn-header-semantic-fail.rs:34:48 @@ -308,5 +326,5 @@ LL | | } error: aborting due to 23 previous errors -Some errors have detailed explanations: E0276, E0379, E0391, E0706. -For more information about an error, try `rustc --explain E0276`. +Some errors have detailed explanations: E0053, E0379, E0391, E0706. +For more information about an error, try `rustc --explain E0053`. diff --git a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs index 6facc467f7a..aaf0f7eaef0 100644 --- a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs +++ b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs @@ -14,7 +14,7 @@ trait B { impl B for A { async fn associated(); //~ ERROR without body //~^ ERROR cannot be declared `async` - //~| ERROR impl has stricter requirements than trait + //~| ERROR has an incompatible type for trait } fn main() {} diff --git a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr index c144060a859..d3214458eac 100644 --- a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr +++ b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr @@ -44,16 +44,25 @@ LL | async fn associated(); = note: `async` trait functions are not currently supported = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait -error[E0276]: impl has stricter requirements than trait - --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:5 +error[E0053]: method `associated` has an incompatible type for trait + --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:26 | LL | async fn associated(); - | ---------------------- definition of `associated` from trait -... + | ^ + | | + | checked the `Output` of this `async fn`, found opaque type + | expected `()`, found opaque type + | + = note: while checking the return type of the `async fn` +note: type in trait + --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:11:26 + | LL | async fn associated(); - | ^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `(): Future` + | ^ + = note: expected fn pointer `fn()` + found fn pointer `fn() -> impl Future<Output = ()>` error: aborting due to 6 previous errors -Some errors have detailed explanations: E0276, E0706. -For more information about an error, try `rustc --explain E0276`. +Some errors have detailed explanations: E0053, E0706. +For more information about an error, try `rustc --explain E0053`. diff --git a/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs b/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs index 377ce85e8b2..4a11bb5020e 100644 --- a/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs +++ b/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs @@ -3,7 +3,7 @@ type Foo = impl Fn() -> Foo; fn foo() -> Foo { -//~^ ERROR: overflow evaluating the requirement `fn() -> Foo {foo}: Sized` +//~^ ERROR: overflow evaluating the requirement foo } diff --git a/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr b/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr index d20b1cc6d85..00c682b2193 100644 --- a/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr @@ -1,10 +1,8 @@ -error[E0275]: overflow evaluating the requirement `fn() -> Foo {foo}: Sized` +error[E0275]: overflow evaluating the requirement `<fn() -> Foo {foo} as FnOnce<()>>::Output == fn() -> Foo {foo}` --> $DIR/issue-53398-cyclic-types.rs:5:13 | LL | fn foo() -> Foo { | ^^^ - | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_53398_cyclic_types`) error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/issue-57961.rs b/src/test/ui/type-alias-impl-trait/issue-57961.rs new file mode 100644 index 00000000000..472886c9caa --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-57961.rs @@ -0,0 +1,18 @@ +#![feature(type_alias_impl_trait)] + +type X = impl Sized; + +trait Foo { + type Bar: Iterator<Item = X>; +} + +impl Foo for () { + type Bar = std::vec::IntoIter<u32>; + //~^ ERROR type mismatch resolving `<std::vec::IntoIter<u32> as Iterator>::Item == X +} + +fn incoherent() { + let f: X = 22_i32; +} + +fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/issue-57961.stderr b/src/test/ui/type-alias-impl-trait/issue-57961.stderr new file mode 100644 index 00000000000..ed4caf6ce68 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-57961.stderr @@ -0,0 +1,20 @@ +error[E0271]: type mismatch resolving `<std::vec::IntoIter<u32> as Iterator>::Item == X` + --> $DIR/issue-57961.rs:10:16 + | +LL | type X = impl Sized; + | ---------- the expected opaque type +... +LL | type Bar = std::vec::IntoIter<u32>; + | ^^^^^^^^^^^^^^^^^^^^^^^ expected opaque type, found `u32` + | + = note: expected opaque type `X` + found type `u32` +note: required by a bound in `Foo::Bar` + --> $DIR/issue-57961.rs:6:24 + | +LL | type Bar: Iterator<Item = X>; + | ^^^^^^^^ required by this bound in `Foo::Bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`. |
