Do array unsizing for method receivers

It turns out rustc actually only unsizes array method receivers, so we don't
need to do any trait solving for this (at least for now).

Fixes #2670.
This commit is contained in:
Florian Diebold 2020-02-29 22:01:36 +01:00
parent 5e78036e6c
commit e313efb992
2 changed files with 37 additions and 2 deletions

View file

@ -838,6 +838,24 @@ fn test() { (&S).foo()<|>; }
assert_eq!(t, "u128");
}
#[test]
fn method_resolution_unsize_array() {
let t = type_at(
r#"
//- /main.rs
#[lang = "slice"]
impl<T> [T] {
fn len(&self) -> usize { loop {} }
}
fn test() {
let a = [1, 2, 3];
a.len()<|>;
}
"#,
);
assert_eq!(t, "usize");
}
#[test]
fn method_resolution_trait_from_prelude() {
let (db, pos) = TestDB::with_position(