2455: Add BuiltinShadowMode r=flodiebold a=edwin0cheng

This PR try to fix #1905 by introduce an `BuiltinShadowMode` in name resolving functions. 

cc @flodiebold 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
This commit is contained in:
bors[bot] 2019-12-01 11:13:25 +00:00 committed by GitHub
commit ec164fbb68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 139 additions and 32 deletions

View file

@ -3693,6 +3693,42 @@ fn main() {
assert_eq!(t, "Foo");
}
#[test]
fn not_shadowing_primitive_by_module() {
let t = type_at(
r#"
//- /str.rs
fn foo() {}
//- /main.rs
mod str;
fn foo() -> &'static str { "" }
fn main() {
foo()<|>;
}"#,
);
assert_eq!(t, "&str");
}
#[test]
fn not_shadowing_module_by_primitive() {
let t = type_at(
r#"
//- /str.rs
fn foo() -> u32 {0}
//- /main.rs
mod str;
fn foo() -> &'static str { "" }
fn main() {
str::foo()<|>;
}"#,
);
assert_eq!(t, "u32");
}
#[test]
fn deref_trait() {
let t = type_at(