add tests for ICE in mir building with captured value of unresolved type, None in compiler/rustc_mir_build/src/build/expr/as_place.rs #110453

Fixes #110453
This commit is contained in:
Matthias Krüger 2024-03-24 10:49:16 +01:00
parent 56ea366763
commit e800b99347
4 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,18 @@
// ICE in mir building with captured value of unresolved type
// None in compiler/rustc_mir_build/src/build/expr/as_place.rs
// issue: rust-lang/rust#110453
//@ edition:2021
#![crate_type="lib"]
pub struct B;
pub fn a() -> B { B }
mod handlers {
pub struct C(B);
//~^ ERROR cannot find type `B` in this scope
pub fn c() -> impl Fn() -> C {
let a1 = ();
|| C((crate::a(), a1).into())
}
}

View File

@ -0,0 +1,14 @@
error[E0412]: cannot find type `B` in this scope
--> $DIR/mir-build-2021-closure-capture-ice-110453-1.rs:12:18
|
LL | pub struct C(B);
| ^ not found in this scope
|
help: consider importing this struct
|
LL + use crate::B;
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0412`.

View File

@ -0,0 +1,11 @@
// ICE in mir building with captured value of unresolved type
// None in compiler/rustc_mir_build/src/build/expr/as_place.rs
// issue: rust-lang/rust#110453
//@ edition:2021
#![crate_type="lib"]
pub fn dup(f: impl Fn(i32) -> i32) -> impl Fn(as_str) -> i32 {
//~^ ERROR cannot find type `as_str` in this scope
move |a| f(a * 2)
}

View File

@ -0,0 +1,9 @@
error[E0412]: cannot find type `as_str` in this scope
--> $DIR/mir-build-2021-closure-capture-ice-110453-2.rs:8:47
|
LL | pub fn dup(f: impl Fn(i32) -> i32) -> impl Fn(as_str) -> i32 {
| ^^^^^^ not found in this scope
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0412`.