mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Add more tests
This commit is contained in:
parent
a00fa0c06f
commit
3c5734712a
@ -2437,3 +2437,28 @@ fn infer_inner_type() {
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infer_nested_inner_type() {
|
||||
check_infer(
|
||||
r#"
|
||||
fn foo() {
|
||||
{
|
||||
let s = S { field: 0 };
|
||||
let f = s.field;
|
||||
}
|
||||
struct S { field: u32 }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
9..109 '{ ...32 } }': ()
|
||||
15..79 '{ ... }': ()
|
||||
29..30 's': S
|
||||
33..47 'S { field: 0 }': S
|
||||
44..45 '0': u32
|
||||
61..62 'f': u32
|
||||
65..66 's': S
|
||||
65..72 's.field': u32
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
@ -3151,3 +3151,54 @@ fn test() {
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inner_use() {
|
||||
check_types(
|
||||
r#"
|
||||
mod m {
|
||||
pub trait Tr {
|
||||
fn method(&self) -> u8 { 0 }
|
||||
}
|
||||
|
||||
impl Tr for () {}
|
||||
}
|
||||
|
||||
fn f() {
|
||||
use m::Tr;
|
||||
|
||||
().method();
|
||||
//^^^^^^^^^^^ u8
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inner_use_in_block() {
|
||||
check_types(
|
||||
r#"
|
||||
mod m {
|
||||
pub trait Tr {
|
||||
fn method(&self) -> u8 { 0 }
|
||||
}
|
||||
|
||||
impl Tr for () {}
|
||||
}
|
||||
|
||||
fn f() {
|
||||
{
|
||||
use m::Tr;
|
||||
|
||||
().method();
|
||||
//^^^^^^^^^^^ u8
|
||||
}
|
||||
|
||||
{
|
||||
().method();
|
||||
//^^^^^^^^^^^ {unknown}
|
||||
}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user