Add regression test for ICE with undefined type in async fn

This commit is contained in:
ThanhNguyxn 2026-01-22 18:28:54 +07:00
parent 44e34e1ac6
commit 565b772fa5
2 changed files with 35 additions and 0 deletions

View file

@ -0,0 +1,16 @@
//! Regression test for <https://github.com/rust-lang/rust/issues/138225>
pub struct A {
name: NestedOption<Option<String>>,
//~^ ERROR cannot find type `NestedOption` in this scope
}
impl A {
pub async fn func1() -> &'static A {
//~^ ERROR `async fn` is not permitted in Rust 2015
static RES: A = A { name: None };
&RES
}
}
fn main() {}

View file

@ -0,0 +1,19 @@
error[E0670]: `async fn` is not permitted in Rust 2015
--> $DIR/gvn-opt-138225.rs:9:9
|
LL | pub async fn func1() -> &'static A {
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
= help: pass `--edition 2024` to `rustc`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0425]: cannot find type `NestedOption` in this scope
--> $DIR/gvn-opt-138225.rs:4:11
|
LL | name: NestedOption<Option<String>>,
| ^^^^^^^^^^^^ not found in this scope
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0425, E0670.
For more information about an error, try `rustc --explain E0425`.