Remove opaque type obligation and just register opaque types as they are encountered.
This also registers obligations for the hidden type immediately.
This commit is contained in:
parent
86e1860495
commit
1163aa7e72
60 changed files with 290 additions and 311 deletions
|
|
@ -306,7 +306,6 @@ impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
|
|||
| ty::PredicateKind::ObjectSafe(..)
|
||||
| ty::PredicateKind::ClosureKind(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::OpaqueType(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => panic!("not user writable"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ async fn suggest_await_in_async_fn_return() {
|
|||
dummy()
|
||||
//~^ ERROR mismatched types [E0308]
|
||||
//~| HELP consider `await`ing on the `Future`
|
||||
//~| HELP consider using a semicolon here
|
||||
//~| SUGGESTION .await
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,9 +33,13 @@ help: consider `await`ing on the `Future`
|
|||
|
|
||||
LL | dummy().await
|
||||
| ++++++
|
||||
help: consider using a semicolon here
|
||||
|
|
||||
LL | dummy();
|
||||
| +
|
||||
|
||||
error[E0308]: `if` and `else` have incompatible types
|
||||
--> $DIR/suggest-missing-await.rs:34:9
|
||||
--> $DIR/suggest-missing-await.rs:35:9
|
||||
|
|
||||
LL | let _x = if true {
|
||||
| ______________-
|
||||
|
|
@ -49,20 +53,15 @@ LL | |
|
|||
LL | | };
|
||||
| |_____- `if` and `else` have incompatible types
|
||||
|
|
||||
note: while checking the return type of the `async fn`
|
||||
--> $DIR/suggest-missing-await.rs:18:18
|
||||
|
|
||||
LL | async fn dummy() {}
|
||||
| ^ checked the `Output` of this `async fn`, expected opaque type
|
||||
= note: expected opaque type `impl Future<Output = ()>`
|
||||
found unit type `()`
|
||||
= note: expected type `impl Future<Output = ()>`
|
||||
found unit type `()`
|
||||
help: consider `await`ing on the `Future`
|
||||
|
|
||||
LL | dummy().await
|
||||
| ++++++
|
||||
|
||||
error[E0308]: `match` arms have incompatible types
|
||||
--> $DIR/suggest-missing-await.rs:44:14
|
||||
--> $DIR/suggest-missing-await.rs:45:14
|
||||
|
|
||||
LL | let _x = match 0usize {
|
||||
| ______________-
|
||||
|
|
@ -90,7 +89,7 @@ LL ~ 1 => dummy().await,
|
|||
|
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/suggest-missing-await.rs:52:9
|
||||
--> $DIR/suggest-missing-await.rs:53:9
|
||||
|
|
||||
LL | let _x = match dummy() {
|
||||
| ------- this expression has type `impl Future<Output = ()>`
|
||||
|
|
@ -110,7 +109,7 @@ LL | let _x = match dummy().await {
|
|||
| ++++++
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/suggest-missing-await.rs:66:9
|
||||
--> $DIR/suggest-missing-await.rs:67:9
|
||||
|
|
||||
LL | match dummy_result() {
|
||||
| -------------- this expression has type `impl Future<Output = Result<(), ()>>`
|
||||
|
|
@ -119,7 +118,7 @@ LL | Ok(_) => {}
|
|||
| ^^^^^ expected opaque type, found enum `Result`
|
||||
|
|
||||
note: while checking the return type of the `async fn`
|
||||
--> $DIR/suggest-missing-await.rs:56:28
|
||||
--> $DIR/suggest-missing-await.rs:57:28
|
||||
|
|
||||
LL | async fn dummy_result() -> Result<(), ()> {
|
||||
| ^^^^^^^^^^^^^^ checked the `Output` of this `async fn`, expected opaque type
|
||||
|
|
@ -131,7 +130,7 @@ LL | match dummy_result().await {
|
|||
| ++++++
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/suggest-missing-await.rs:68:9
|
||||
--> $DIR/suggest-missing-await.rs:69:9
|
||||
|
|
||||
LL | match dummy_result() {
|
||||
| -------------- this expression has type `impl Future<Output = Result<(), ()>>`
|
||||
|
|
@ -140,7 +139,7 @@ LL | Err(_) => {}
|
|||
| ^^^^^^ expected opaque type, found enum `Result`
|
||||
|
|
||||
note: while checking the return type of the `async fn`
|
||||
--> $DIR/suggest-missing-await.rs:56:28
|
||||
--> $DIR/suggest-missing-await.rs:57:28
|
||||
|
|
||||
LL | async fn dummy_result() -> Result<(), ()> {
|
||||
| ^^^^^^^^^^^^^^ checked the `Output` of this `async fn`, expected opaque type
|
||||
|
|
|
|||
|
|
@ -18,5 +18,5 @@ fn main() {
|
|||
// this is an `*mut fmt::Debug` in practice
|
||||
let mut b_raw = Box::into_raw(b);
|
||||
// ... and they should not be mixable
|
||||
b_raw = f_raw as *mut _; //~ ERROR mismatched types
|
||||
b_raw = f_raw as *mut _; //~ ERROR is invalid
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,11 @@
|
|||
error[E0308]: mismatched types
|
||||
error[E0606]: casting `*mut impl Debug + ?Sized` as `*mut impl Debug + ?Sized` is invalid
|
||||
--> $DIR/casts-differing-anon.rs:21:13
|
||||
|
|
||||
LL | fn foo() -> Box<impl fmt::Debug+?Sized> {
|
||||
| ---------------------- the found opaque type
|
||||
...
|
||||
LL | fn bar() -> Box<impl fmt::Debug+?Sized> {
|
||||
| ---------------------- the expected opaque type
|
||||
...
|
||||
LL | b_raw = f_raw as *mut _;
|
||||
| ^^^^^ expected opaque type, found a different opaque type
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: expected opaque type `impl Debug + ?Sized` (opaque type at <$DIR/casts-differing-anon.rs:7:17>)
|
||||
found opaque type `impl Debug + ?Sized` (opaque type at <$DIR/casts-differing-anon.rs:3:17>)
|
||||
= note: distinct uses of `impl Trait` result in different opaque types
|
||||
= note: vtable kinds may not match
|
||||
|
||||
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 E0606`.
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
fn will_ice(something: &u32) -> impl Iterator<Item = &u32> {
|
||||
//~^ ERROR `()` is not an iterator
|
||||
//~| ERROR `()` is not an iterator
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,18 @@ LL | fn will_ice(something: &u32) -> impl Iterator<Item = &u32> {
|
|||
|
|
||||
= help: the trait `Iterator` is not implemented for `()`
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0277]: `()` is not an iterator
|
||||
--> $DIR/conservative_impl_trait.rs:3:60
|
||||
|
|
||||
LL | fn will_ice(something: &u32) -> impl Iterator<Item = &u32> {
|
||||
| ____________________________________________________________^
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_^ `()` is not an iterator
|
||||
|
|
||||
= help: the trait `Iterator` is not implemented for `()`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
|||
19
src/test/ui/impl-trait/autoderef.rs
Normal file
19
src/test/ui/impl-trait/autoderef.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// check-pass
|
||||
|
||||
use std::path::Path;
|
||||
use std::ffi::OsStr;
|
||||
use std::ops::Deref;
|
||||
|
||||
fn frob(path: &str) -> impl Deref<Target = Path> + '_ {
|
||||
OsStr::new(path).as_ref()
|
||||
}
|
||||
|
||||
fn open_parent<'path>(_path: &'path Path) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let old_path = frob("hello");
|
||||
|
||||
open_parent(&old_path);
|
||||
}
|
||||
|
|
@ -42,4 +42,4 @@ fn muh3() -> Result<(), impl std::fmt::Debug> {
|
|||
Err(From::from("foo")) //~ ERROR the trait bound `impl Debug: From<&str>` is not satisfied
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@ LL | fn hide<T: Foo>(x: T) -> impl Foo {
|
|||
| -------- the found opaque type
|
||||
...
|
||||
LL | let _: u32 = hide(0_u32);
|
||||
| ^^^^^^^^^^^ expected `u32`, found opaque type
|
||||
| --- ^^^^^^^^^^^ expected `u32`, found opaque type
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected type `u32`
|
||||
found opaque type `impl Foo`
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ fn ham() -> Foo {
|
|||
fn oof() -> impl std::fmt::Debug {
|
||||
let mut bar = ham();
|
||||
let func = bar.next().unwrap();
|
||||
return func(&"oof"); //~^^^ ERROR opaque type's hidden type cannot be another opaque type
|
||||
return func(&"oof"); //~ ERROR opaque type's hidden type cannot be another opaque type
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -13,15 +13,10 @@ LL | Some(Box::new(quux))
|
|||
found enum `Option<Box<for<'r> fn(&'r (dyn ToString + 'r)) -> FooRet {quux}>>`
|
||||
|
||||
error: opaque type's hidden type cannot be another opaque type from the same scope
|
||||
--> $DIR/issue-70877.rs:28:34
|
||||
--> $DIR/issue-70877.rs:31:12
|
||||
|
|
||||
LL | fn oof() -> impl std::fmt::Debug {
|
||||
| __________________________________^
|
||||
LL | | let mut bar = ham();
|
||||
LL | | let func = bar.next().unwrap();
|
||||
LL | | return func(&"oof");
|
||||
LL | | }
|
||||
| |_^ one of the two opaque types used here has to be outside its defining scope
|
||||
LL | return func(&"oof");
|
||||
| ^^^^^^^^^^^^ one of the two opaque types used here has to be outside its defining scope
|
||||
|
|
||||
note: opaque type whose hidden type is being assigned
|
||||
--> $DIR/issue-70877.rs:28:13
|
||||
|
|
|
|||
|
|
@ -26,4 +26,4 @@ fn run<F>(f: F)
|
|||
|
||||
fn main() {
|
||||
run(|_| {});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,4 +27,4 @@ pub fn direct() -> Result<(), impl Debug> {
|
|||
Err(Target)
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ mod b {
|
|||
|
||||
impl PartialEq<(Foo, i32)> for Bar {
|
||||
fn eq(&self, _other: &(Bar, i32)) -> bool {
|
||||
//~^ ERROR impl has stricter requirements than trait
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,5 +14,12 @@ LL | type Foo = impl PartialEq<(Foo, i32)>;
|
|||
|
|
||||
= note: `Foo` must be used in combination with a concrete type within the same module
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0276]: impl has stricter requirements than trait
|
||||
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:23:9
|
||||
|
|
||||
LL | fn eq(&self, _other: &(Bar, i32)) -> bool {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `b::Bar: PartialEq<(b::Bar, i32)>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0276`.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
type A = impl Foo;
|
||||
type A = impl Foo; //~ ERROR unconstrained opaque type
|
||||
type B = impl Foo;
|
||||
|
||||
trait Foo {}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,11 @@
|
|||
error: unconstrained opaque type
|
||||
--> $DIR/two_tait_defining_each_other2.rs:3:10
|
||||
|
|
||||
LL | type A = impl Foo;
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: `A` must be used in combination with a concrete type within the same module
|
||||
|
||||
error: opaque type's hidden type cannot be another opaque type from the same scope
|
||||
--> $DIR/two_tait_defining_each_other2.rs:9:5
|
||||
|
|
||||
|
|
@ -15,5 +23,5 @@ note: opaque type being used as hidden type
|
|||
LL | type A = impl Foo;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ {
|
||||
//~^ ERROR `u32` is not a future
|
||||
//~| ERROR `u32` is not a future
|
||||
*x
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0425]: cannot find value `u` in this scope
|
||||
--> $DIR/issues-71798.rs:7:24
|
||||
--> $DIR/issues-71798.rs:8:24
|
||||
|
|
||||
LL | let _ = test_ref & u;
|
||||
| ^ not found in this scope
|
||||
|
|
@ -13,7 +13,21 @@ LL | fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ {
|
|||
= help: the trait `Future` is not implemented for `u32`
|
||||
= note: u32 must be a future or must implement `IntoFuture` to be awaited
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0277]: `u32` is not a future
|
||||
--> $DIR/issues-71798.rs:1:69
|
||||
|
|
||||
LL | fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ {
|
||||
| _____________________________________________________________________^
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | *x
|
||||
LL | | }
|
||||
| |_^ `u32` is not a future
|
||||
|
|
||||
= help: the trait `Future` is not implemented for `u32`
|
||||
= note: u32 must be a future or must implement `IntoFuture` to be awaited
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0425.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
|
|
|
|||
|
|
@ -27,6 +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
|
||||
unsafe fn ft2() {} // OK.
|
||||
const fn ft3() {} //~ ERROR functions in traits cannot be declared const
|
||||
extern "C" fn ft4() {}
|
||||
|
|
@ -35,6 +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
|
||||
}
|
||||
|
||||
impl Y {
|
||||
|
|
|
|||
|
|
@ -62,19 +62,19 @@ LL | async fn ft1() {}
|
|||
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
|
||||
|
||||
error[E0379]: functions in traits cannot be declared const
|
||||
--> $DIR/fn-header-semantic-fail.rs:31:9
|
||||
--> $DIR/fn-header-semantic-fail.rs:32:9
|
||||
|
|
||||
LL | const fn ft3() {}
|
||||
| ^^^^^ functions in traits cannot be const
|
||||
|
||||
error[E0379]: functions in traits cannot be declared const
|
||||
--> $DIR/fn-header-semantic-fail.rs:33:9
|
||||
--> $DIR/fn-header-semantic-fail.rs:34:9
|
||||
|
|
||||
LL | const async unsafe extern "C" fn ft5() {}
|
||||
| ^^^^^ functions in traits cannot be const
|
||||
|
||||
error[E0706]: functions in traits cannot be declared `async`
|
||||
--> $DIR/fn-header-semantic-fail.rs:33:9
|
||||
--> $DIR/fn-header-semantic-fail.rs:34:9
|
||||
|
|
||||
LL | const async unsafe extern "C" fn ft5() {}
|
||||
| ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -85,7 +85,7 @@ LL | const async unsafe extern "C" fn ft5() {}
|
|||
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
|
||||
|
||||
error: functions cannot be both `const` and `async`
|
||||
--> $DIR/fn-header-semantic-fail.rs:33:9
|
||||
--> $DIR/fn-header-semantic-fail.rs:34:9
|
||||
|
|
||||
LL | const async unsafe extern "C" fn ft5() {}
|
||||
| ^^^^^-^^^^^------------------------------
|
||||
|
|
@ -94,7 +94,7 @@ LL | const async unsafe extern "C" fn ft5() {}
|
|||
| `const` because of this
|
||||
|
||||
error: functions cannot be both `const` and `async`
|
||||
--> $DIR/fn-header-semantic-fail.rs:45:9
|
||||
--> $DIR/fn-header-semantic-fail.rs:47:9
|
||||
|
|
||||
LL | const async unsafe extern "C" fn fi5() {}
|
||||
| ^^^^^-^^^^^------------------------------
|
||||
|
|
@ -103,7 +103,7 @@ LL | const async unsafe extern "C" fn fi5() {}
|
|||
| `const` because of this
|
||||
|
||||
error: functions in `extern` blocks cannot have qualifiers
|
||||
--> $DIR/fn-header-semantic-fail.rs:51:18
|
||||
--> $DIR/fn-header-semantic-fail.rs:53:18
|
||||
|
|
||||
LL | extern "C" {
|
||||
| ---------- in this `extern` block
|
||||
|
|
@ -116,7 +116,7 @@ LL | fn fe1();
|
|||
| ~~
|
||||
|
||||
error: functions in `extern` blocks cannot have qualifiers
|
||||
--> $DIR/fn-header-semantic-fail.rs:52:19
|
||||
--> $DIR/fn-header-semantic-fail.rs:54:19
|
||||
|
|
||||
LL | extern "C" {
|
||||
| ---------- in this `extern` block
|
||||
|
|
@ -130,7 +130,7 @@ LL | fn fe2();
|
|||
| ~~
|
||||
|
||||
error: functions in `extern` blocks cannot have qualifiers
|
||||
--> $DIR/fn-header-semantic-fail.rs:53:18
|
||||
--> $DIR/fn-header-semantic-fail.rs:55:18
|
||||
|
|
||||
LL | extern "C" {
|
||||
| ---------- in this `extern` block
|
||||
|
|
@ -144,7 +144,7 @@ LL | fn fe3();
|
|||
| ~~
|
||||
|
||||
error: functions in `extern` blocks cannot have qualifiers
|
||||
--> $DIR/fn-header-semantic-fail.rs:54:23
|
||||
--> $DIR/fn-header-semantic-fail.rs:56:23
|
||||
|
|
||||
LL | extern "C" {
|
||||
| ---------- in this `extern` block
|
||||
|
|
@ -158,7 +158,7 @@ LL | fn fe4();
|
|||
| ~~
|
||||
|
||||
error: functions in `extern` blocks cannot have qualifiers
|
||||
--> $DIR/fn-header-semantic-fail.rs:55:42
|
||||
--> $DIR/fn-header-semantic-fail.rs:57:42
|
||||
|
|
||||
LL | extern "C" {
|
||||
| ---------- in this `extern` block
|
||||
|
|
@ -172,7 +172,7 @@ LL | fn fe5();
|
|||
| ~~
|
||||
|
||||
error: functions cannot be both `const` and `async`
|
||||
--> $DIR/fn-header-semantic-fail.rs:55:9
|
||||
--> $DIR/fn-header-semantic-fail.rs:57:9
|
||||
|
|
||||
LL | const async unsafe extern "C" fn fe5();
|
||||
| ^^^^^-^^^^^----------------------------
|
||||
|
|
@ -216,30 +216,48 @@ LL | | }
|
|||
LL | | }
|
||||
| |_^
|
||||
|
||||
error[E0391]: cycle detected when computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 38:6>::ft5::{opaque#0}`
|
||||
--> $DIR/fn-header-semantic-fail.rs:33:48
|
||||
error[E0276]: impl has stricter requirements than trait
|
||||
--> $DIR/fn-header-semantic-fail.rs:29:9
|
||||
|
|
||||
LL | async fn ft1();
|
||||
| --------------- definition of `ft1` from trait
|
||||
...
|
||||
LL | async fn ft1() {}
|
||||
| ^^^^^^^^^^^^^^ impl has extra requirement `(): Future`
|
||||
|
||||
error[E0276]: impl has stricter requirements than trait
|
||||
--> $DIR/fn-header-semantic-fail.rs:34:9
|
||||
|
|
||||
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`
|
||||
|
||||
error[E0391]: cycle detected when computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 40:6>::ft5::{opaque#0}`
|
||||
--> $DIR/fn-header-semantic-fail.rs:34:48
|
||||
|
|
||||
LL | const async unsafe extern "C" fn ft5() {}
|
||||
| ^
|
||||
|
|
||||
note: ...which requires borrow-checking `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 38:6>::ft5`...
|
||||
--> $DIR/fn-header-semantic-fail.rs:33:9
|
||||
note: ...which requires borrow-checking `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 40:6>::ft5`...
|
||||
--> $DIR/fn-header-semantic-fail.rs:34:9
|
||||
|
|
||||
LL | const async unsafe extern "C" fn ft5() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires processing `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 38:6>::ft5`...
|
||||
--> $DIR/fn-header-semantic-fail.rs:33:9
|
||||
note: ...which requires processing `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 40:6>::ft5`...
|
||||
--> $DIR/fn-header-semantic-fail.rs:34:9
|
||||
|
|
||||
LL | const async unsafe extern "C" fn ft5() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires const checking `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 38:6>::ft5`...
|
||||
--> $DIR/fn-header-semantic-fail.rs:33:9
|
||||
note: ...which requires const checking `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 40:6>::ft5`...
|
||||
--> $DIR/fn-header-semantic-fail.rs:34:9
|
||||
|
|
||||
LL | const async unsafe extern "C" fn ft5() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: ...which requires computing whether `impl core::future::future::Future<Output = ()>` is freeze...
|
||||
= note: ...which requires evaluating trait selection obligation `impl core::future::future::Future<Output = ()>: core::marker::Freeze`...
|
||||
= note: ...which again requires computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 38:6>::ft5::{opaque#0}`, completing the cycle
|
||||
= note: ...which again requires computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 40:6>::ft5::{opaque#0}`, completing the cycle
|
||||
note: cycle used when checking item types in top-level module
|
||||
--> $DIR/fn-header-semantic-fail.rs:5:1
|
||||
|
|
||||
|
|
@ -252,30 +270,30 @@ LL | | }
|
|||
LL | | }
|
||||
| |_^
|
||||
|
||||
error[E0391]: cycle detected when computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 48:6>::fi5::{opaque#0}`
|
||||
--> $DIR/fn-header-semantic-fail.rs:45:48
|
||||
error[E0391]: cycle detected when computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:42:5: 50:6>::fi5::{opaque#0}`
|
||||
--> $DIR/fn-header-semantic-fail.rs:47:48
|
||||
|
|
||||
LL | const async unsafe extern "C" fn fi5() {}
|
||||
| ^
|
||||
|
|
||||
note: ...which requires borrow-checking `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 48:6>::fi5`...
|
||||
--> $DIR/fn-header-semantic-fail.rs:45:9
|
||||
note: ...which requires borrow-checking `main::<impl at $DIR/fn-header-semantic-fail.rs:42:5: 50:6>::fi5`...
|
||||
--> $DIR/fn-header-semantic-fail.rs:47:9
|
||||
|
|
||||
LL | const async unsafe extern "C" fn fi5() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires processing `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 48:6>::fi5`...
|
||||
--> $DIR/fn-header-semantic-fail.rs:45:9
|
||||
note: ...which requires processing `main::<impl at $DIR/fn-header-semantic-fail.rs:42:5: 50:6>::fi5`...
|
||||
--> $DIR/fn-header-semantic-fail.rs:47:9
|
||||
|
|
||||
LL | const async unsafe extern "C" fn fi5() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires const checking `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 48:6>::fi5`...
|
||||
--> $DIR/fn-header-semantic-fail.rs:45:9
|
||||
note: ...which requires const checking `main::<impl at $DIR/fn-header-semantic-fail.rs:42:5: 50:6>::fi5`...
|
||||
--> $DIR/fn-header-semantic-fail.rs:47:9
|
||||
|
|
||||
LL | const async unsafe extern "C" fn fi5() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: ...which requires computing whether `impl core::future::future::Future<Output = ()>` is freeze...
|
||||
= note: ...which requires evaluating trait selection obligation `impl core::future::future::Future<Output = ()>: core::marker::Freeze`...
|
||||
= note: ...which again requires computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 48:6>::fi5::{opaque#0}`, completing the cycle
|
||||
= note: ...which again requires computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:42:5: 50:6>::fi5::{opaque#0}`, completing the cycle
|
||||
note: cycle used when checking item types in top-level module
|
||||
--> $DIR/fn-header-semantic-fail.rs:5:1
|
||||
|
|
||||
|
|
@ -288,7 +306,7 @@ LL | | }
|
|||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to 21 previous errors
|
||||
error: aborting due to 23 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0379, E0391, E0706.
|
||||
For more information about an error, try `rustc --explain E0379`.
|
||||
Some errors have detailed explanations: E0276, E0379, E0391, E0706.
|
||||
For more information about an error, try `rustc --explain E0276`.
|
||||
|
|
|
|||
|
|
@ -14,6 +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
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,16 @@ 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: aborting due to 5 previous errors
|
||||
error[E0276]: impl has stricter requirements than trait
|
||||
--> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:5
|
||||
|
|
||||
LL | async fn associated();
|
||||
| ---------------------- definition of `associated` from trait
|
||||
...
|
||||
LL | async fn associated();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `(): Future`
|
||||
|
||||
For more information about this error, try `rustc --explain E0706`.
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0276, E0706.
|
||||
For more information about an error, try `rustc --explain E0276`.
|
||||
|
|
|
|||
|
|
@ -16,9 +16,6 @@ fn extra_semicolon() {
|
|||
async fn async_dummy() {} //~ NOTE checked the `Output` of this `async fn`, found opaque type
|
||||
//~| NOTE while checking the return type of the `async fn`
|
||||
//~| NOTE in this expansion of desugaring of `async` block or function
|
||||
//~| NOTE while checking the return type of the `async fn`
|
||||
//~| NOTE in this expansion of desugaring of `async` block or function
|
||||
//~| NOTE checked the `Output` of this `async fn`, expected opaque type
|
||||
async fn async_dummy2() {} //~ NOTE checked the `Output` of this `async fn`, found opaque type
|
||||
//~| NOTE checked the `Output` of this `async fn`, found opaque type
|
||||
//~| NOTE while checking the return type of the `async fn`
|
||||
|
|
@ -34,7 +31,7 @@ async fn async_extra_semicolon_same() {
|
|||
}
|
||||
false => async_dummy(), //~ ERROR `match` arms have incompatible types
|
||||
//~^ NOTE expected `()`, found opaque type
|
||||
//~| NOTE expected unit type `()`
|
||||
//~| NOTE expected type `()`
|
||||
//~| HELP consider `await`ing on the `Future`
|
||||
};
|
||||
}
|
||||
|
|
@ -47,7 +44,7 @@ async fn async_extra_semicolon_different() {
|
|||
}
|
||||
false => async_dummy2(), //~ ERROR `match` arms have incompatible types
|
||||
//~^ NOTE expected `()`, found opaque type
|
||||
//~| NOTE expected unit type `()`
|
||||
//~| NOTE expected type `()`
|
||||
//~| HELP consider `await`ing on the `Future`
|
||||
};
|
||||
}
|
||||
|
|
@ -58,7 +55,7 @@ async fn async_different_futures() {
|
|||
//~| HELP consider `await`ing on both `Future`s
|
||||
false => async_dummy2(), //~ ERROR `match` arms have incompatible types
|
||||
//~^ NOTE expected opaque type, found a different opaque type
|
||||
//~| NOTE expected opaque type `impl Future<Output = ()>`
|
||||
//~| NOTE expected type `impl Future<Output = ()>`
|
||||
//~| NOTE distinct uses of `impl Trait` result in different opaque types
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0308]: `match` arms have incompatible types
|
||||
--> $DIR/match-prev-arm-needing-semi.rs:35:18
|
||||
--> $DIR/match-prev-arm-needing-semi.rs:32:18
|
||||
|
|
||||
LL | let _ = match true {
|
||||
| _____________-
|
||||
|
|
@ -20,8 +20,8 @@ note: while checking the return type of the `async fn`
|
|||
|
|
||||
LL | async fn async_dummy() {}
|
||||
| ^ checked the `Output` of this `async fn`, found opaque type
|
||||
= note: expected unit type `()`
|
||||
found opaque type `impl Future<Output = ()>`
|
||||
= note: expected type `()`
|
||||
found opaque type `impl Future<Output = ()>`
|
||||
help: consider `await`ing on the `Future`
|
||||
|
|
||||
LL | false => async_dummy().await,
|
||||
|
|
@ -33,7 +33,7 @@ LL + async_dummy()
|
|||
|
|
||||
|
||||
error[E0308]: `match` arms have incompatible types
|
||||
--> $DIR/match-prev-arm-needing-semi.rs:48:18
|
||||
--> $DIR/match-prev-arm-needing-semi.rs:45:18
|
||||
|
|
||||
LL | let _ = match true {
|
||||
| _____________-
|
||||
|
|
@ -50,12 +50,12 @@ LL | | };
|
|||
| |_____- `match` arms have incompatible types
|
||||
|
|
||||
note: while checking the return type of the `async fn`
|
||||
--> $DIR/match-prev-arm-needing-semi.rs:22:25
|
||||
--> $DIR/match-prev-arm-needing-semi.rs:19:25
|
||||
|
|
||||
LL | async fn async_dummy2() {}
|
||||
| ^ checked the `Output` of this `async fn`, found opaque type
|
||||
= note: expected unit type `()`
|
||||
found opaque type `impl Future<Output = ()>`
|
||||
= note: expected type `()`
|
||||
found opaque type `impl Future<Output = ()>`
|
||||
help: consider `await`ing on the `Future`
|
||||
|
|
||||
LL | false => async_dummy2().await,
|
||||
|
|
@ -69,7 +69,7 @@ LL ~ false => Box::new(async_dummy2()),
|
|||
|
|
||||
|
||||
error[E0308]: `match` arms have incompatible types
|
||||
--> $DIR/match-prev-arm-needing-semi.rs:59:18
|
||||
--> $DIR/match-prev-arm-needing-semi.rs:56:18
|
||||
|
|
||||
LL | let _ = match true {
|
||||
| _____________-
|
||||
|
|
@ -84,17 +84,12 @@ LL | | };
|
|||
| |_____- `match` arms have incompatible types
|
||||
|
|
||||
note: while checking the return type of the `async fn`
|
||||
--> $DIR/match-prev-arm-needing-semi.rs:16:24
|
||||
|
|
||||
LL | async fn async_dummy() {}
|
||||
| ^ checked the `Output` of this `async fn`, expected opaque type
|
||||
note: while checking the return type of the `async fn`
|
||||
--> $DIR/match-prev-arm-needing-semi.rs:22:25
|
||||
--> $DIR/match-prev-arm-needing-semi.rs:19:25
|
||||
|
|
||||
LL | async fn async_dummy2() {}
|
||||
| ^ checked the `Output` of this `async fn`, found opaque type
|
||||
= note: expected opaque type `impl Future<Output = ()>` (opaque type at <$DIR/match-prev-arm-needing-semi.rs:16:24>)
|
||||
found opaque type `impl Future<Output = ()>` (opaque type at <$DIR/match-prev-arm-needing-semi.rs:22:25>)
|
||||
= note: expected type `impl Future<Output = ()>` (opaque type at <$DIR/match-prev-arm-needing-semi.rs:16:24>)
|
||||
found opaque type `impl Future<Output = ()>` (opaque type at <$DIR/match-prev-arm-needing-semi.rs:19:25>)
|
||||
= note: distinct uses of `impl Trait` result in different opaque types
|
||||
help: consider `await`ing on both `Future`s
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
error[E0308]: `if` and `else` have incompatible types
|
||||
--> $DIR/opaque-type-error.rs:20:9
|
||||
|
|
||||
LL | fn thing_one() -> impl Future<Output = Result<(), ()>> {
|
||||
| ------------------------------------ the expected opaque type
|
||||
...
|
||||
LL | fn thing_two() -> impl Future<Output = Result<(), ()>> {
|
||||
| ------------------------------------ the found opaque type
|
||||
...
|
||||
|
|
@ -16,8 +13,8 @@ LL | | thing_two()
|
|||
LL | | }.await
|
||||
| |_____- `if` and `else` have incompatible types
|
||||
|
|
||||
= note: expected opaque type `impl Future<Output = Result<(), ()>>` (opaque type at <$DIR/opaque-type-error.rs:8:19>)
|
||||
found opaque type `impl Future<Output = Result<(), ()>>` (opaque type at <$DIR/opaque-type-error.rs:12:19>)
|
||||
= note: expected type `impl Future<Output = Result<(), ()>>` (opaque type at <$DIR/opaque-type-error.rs:8:19>)
|
||||
found opaque type `impl Future<Output = Result<(), ()>>` (opaque type at <$DIR/opaque-type-error.rs:12:19>)
|
||||
= note: distinct uses of `impl Trait` result in different opaque types
|
||||
help: consider `await`ing on both `Future`s
|
||||
|
|
||||
|
|
|
|||
|
|
@ -12,11 +12,13 @@ error[E0308]: mismatched types
|
|||
LL | pub type Boo = impl ::std::fmt::Debug;
|
||||
| ---------------------- the expected opaque type
|
||||
...
|
||||
LL | fn bomp() -> boo::Boo {
|
||||
| -------- expected `Boo` because of return type
|
||||
LL | ""
|
||||
| ^^ expected opaque type, found `&str`
|
||||
|
|
||||
= note: expected opaque type `Boo`
|
||||
found reference `&str`
|
||||
found reference `&'static str`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ LL | pub type Boo = impl ::std::fmt::Debug;
|
|||
| ---------------------- the found opaque type
|
||||
...
|
||||
LL | let _: &str = bomp();
|
||||
| ^^^^^^ expected `&str`, found opaque type
|
||||
| ---- ^^^^^^ expected `&str`, found opaque type
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected reference `&str`
|
||||
found opaque type `Boo`
|
||||
|
|
@ -16,11 +18,13 @@ error[E0308]: mismatched types
|
|||
LL | pub type Boo = impl ::std::fmt::Debug;
|
||||
| ---------------------- the expected opaque type
|
||||
...
|
||||
LL | fn bomp() -> boo::Boo {
|
||||
| -------- expected `Boo` because of return type
|
||||
LL | ""
|
||||
| ^^ expected opaque type, found `&str`
|
||||
|
|
||||
= note: expected opaque type `Boo`
|
||||
found reference `&str`
|
||||
found reference `&'static str`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ pub fn is_min_const_fn<'a, 'tcx>(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, msrv:
|
|||
| ty::PredicateKind::ConstEvaluatable(..)
|
||||
| ty::PredicateKind::ConstEquate(..)
|
||||
| ty::PredicateKind::Trait(..)
|
||||
| ty::PredicateKind::OpaqueType(..)
|
||||
| ty::PredicateKind::TypeWellFormedFromEnv(..) => continue,
|
||||
ty::PredicateKind::ObjectSafe(_) => panic!("object safe predicate on function: {:#?}", predicate),
|
||||
ty::PredicateKind::ClosureKind(..) => panic!("closure kind predicate on function: {:#?}", predicate),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue