Tweak feature error, add test

This commit is contained in:
Michael Goulet 2022-09-06 17:16:08 +00:00
parent 05812df603
commit 55df9201fe
5 changed files with 52 additions and 9 deletions

View file

@ -62,7 +62,7 @@ LL | async fn bar(&self) {}
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
| ------------------------------- the found opaque type
|
= note: expected associated type `<Self as T>::bar::{opaque#0}`
= note: expected associated type `<Self as T>::bar::{opaque#0}<'_>`
found opaque type `impl Future<Output = ()>`
error[E0308]: mismatched types

View file

@ -3,6 +3,9 @@ error[E0562]: `impl Trait` only allowed in function and inherent method return t
|
LL | fn bar() -> impl Sized;
| ^^^^^^^^^^
|
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
error: aborting due to previous error

View file

@ -0,0 +1,18 @@
// check-pass
#![feature(return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]
trait Foo {
fn f() -> Box<impl Sized>;
}
impl Foo for () {
fn f() -> Box<String> {
Box::new(String::new())
}
}
fn main() {
let x: Box<String> = <() as Foo>::f();
}

View file

@ -162,12 +162,18 @@ error[E0562]: `impl Trait` only allowed in function and inherent method return t
|
LL | fn in_return() -> impl Debug;
| ^^^^^^^^^^
|
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return
--> $DIR/where-allowed.rs:125:34
|
LL | fn in_trait_impl_return() -> impl Debug { () }
| ^^^^^^^^^^
|
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` param
--> $DIR/where-allowed.rs:138:33