Skip to content

Commit aff365f

Browse files
committed
Add regression test for issue 281
Without #![feature(impl_trait_in_bindings)]: error[E0562]: `impl Trait` is not allowed in paths --> tests/test.rs:1680:42 | 1680 | async fn method(&self) -> Result<impl AsRef<str> + Send + Sync, Self::Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the type of variable bindings --> tests/test.rs:1680:42 | 1680 | async fn method(&self) -> Result<impl AsRef<str> + Send + Sync, Self::Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `impl Trait` is only allowed in arguments and return types of functions and methods = note: see issue #63065 <rust-lang/rust#63065> for more information = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable = note: this compiler was built on 2025-01-02; consider upgrading it if it is out of date With #![feature(impl_trait_in_bindings)]: error[E0562]: `impl Trait` is not allowed in paths --> tests/test.rs:1680:42 | 1680 | async fn method(&self) -> Result<impl AsRef<str> + Send + Sync, Self::Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `impl Trait` is only allowed in arguments and return types of functions and methods
1 parent 7d8519d commit aff365f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/test.rs

+21
Original file line numberDiff line numberDiff line change
@@ -1661,3 +1661,24 @@ pub mod issue277 {
16611661

16621662
fn g(_: &mut &()) {}
16631663
}
1664+
1665+
// https://github.com/dtolnay/async-trait/issues/281
1666+
pub mod issue281 {
1667+
use async_trait::async_trait;
1668+
1669+
#[async_trait]
1670+
pub trait Trait {
1671+
type Error;
1672+
async fn method(&self) -> Result<impl AsRef<str> + Send + Sync, Self::Error>;
1673+
}
1674+
1675+
pub struct T;
1676+
1677+
#[async_trait]
1678+
impl Trait for T {
1679+
type Error = ();
1680+
async fn method(&self) -> Result<impl AsRef<str> + Send + Sync, Self::Error> {
1681+
Ok("Hello World")
1682+
}
1683+
}
1684+
}

0 commit comments

Comments
 (0)