Auto merge of #42391 - photoszzt:master, r=Manishearth
Better suggestion for unknown method r? @Manishearth fixes #42386
This commit is contained in:
commit
8f66fafebd
@ -176,7 +176,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
if mode == Mode::MethodCall {
|
||||
"method"
|
||||
} else {
|
||||
"associated item"
|
||||
match item_name.as_str().chars().next() {
|
||||
Some(name) => {
|
||||
if name.is_lowercase() {
|
||||
"function or associated item"
|
||||
} else {
|
||||
"associated item"
|
||||
}
|
||||
},
|
||||
None => {
|
||||
""
|
||||
},
|
||||
}
|
||||
},
|
||||
item_name,
|
||||
self.ty_to_string(actual))
|
||||
|
@ -15,6 +15,6 @@ fn main() {
|
||||
let red: color = color::rgb(255, 0, 0);
|
||||
match red {
|
||||
color::rgb(r, g, b) => { println!("rgb"); }
|
||||
color::hsl(h, s, l) => { println!("hsl"); } //~ ERROR no associated
|
||||
color::hsl(h, s, l) => { println!("hsl"); } //~ ERROR no function
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,9 @@ use std::ops::BitXor;
|
||||
fn main() {
|
||||
let x: u8 = BitXor::bitor(0 as u8, 0 as u8);
|
||||
//~^ ERROR must be specified
|
||||
//~| no associated item named
|
||||
//~| no function or associated item named
|
||||
|
||||
let g = BitXor::bitor;
|
||||
//~^ ERROR must be specified
|
||||
//~| no associated item named
|
||||
}
|
||||
//~| no function or associated item named
|
||||
}
|
||||
|
@ -15,5 +15,5 @@ use issue_30123_aux::*;
|
||||
|
||||
fn main() {
|
||||
let ug = Graph::<i32, i32>::new_undirected();
|
||||
//~^ ERROR no associated item named `new_undirected` found for type
|
||||
//~^ ERROR no function or associated item named `new_undirected` found for type
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ impl Dim for Dim3 {
|
||||
|
||||
pub struct Vector<T, D: Dim> {
|
||||
entries: [T; D::dim()]
|
||||
//~^ ERROR no associated item named `dim` found for type `D` in the current scope
|
||||
//~^ ERROR no function or associated item named `dim` found for type `D` in the current scope
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -30,6 +30,6 @@ impl ToString_ for Point {
|
||||
|
||||
fn main() {
|
||||
let p = Point::new(0.0, 0.0);
|
||||
//~^ ERROR no associated item named `new` found for type `Point` in the current scope
|
||||
//~^ ERROR no function or associated item named `new` found for type `Point`
|
||||
println!("{}", p.to_string());
|
||||
}
|
||||
|
@ -13,5 +13,6 @@
|
||||
struct Foo;
|
||||
|
||||
fn main() {
|
||||
Foo::bar(); //~ ERROR no associated item named `bar` found for type `Foo` in the current scope
|
||||
Foo::bar();
|
||||
//~^ ERROR no function or associated item named `bar` found for type `Foo`
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ mod Foo {
|
||||
pub fn f() {}
|
||||
}
|
||||
fn g<Foo>() {
|
||||
Foo::f(); //~ ERROR no associated item named `f`
|
||||
Foo::f(); //~ ERROR no function or associated item named `f`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -86,8 +86,10 @@ fn check_method() {
|
||||
|
||||
// Methods, UFCS
|
||||
// a, b, c are resolved as trait items, their traits need to be in scope
|
||||
S::a(&S); //~ ERROR no associated item named `a` found for type `S` in the current scope
|
||||
S::b(&S); //~ ERROR no associated item named `b` found for type `S` in the current scope
|
||||
S::a(&S);
|
||||
//~^ ERROR no function or associated item named `a` found for type `S`
|
||||
S::b(&S);
|
||||
//~^ ERROR no function or associated item named `b` found for type `S`
|
||||
S::c(&S); // OK
|
||||
// a, b, c are resolved as inherent items, their traits don't need to be in scope
|
||||
C::a(&S); //~ ERROR method `a` is private
|
||||
|
@ -18,13 +18,13 @@ pub trait Bar<X=usize, A=Self> {
|
||||
|
||||
fn main() {
|
||||
let a = Foo::lol();
|
||||
//~^ ERROR no associated item named
|
||||
//~^ ERROR no function or associated item named
|
||||
let b = Foo::<_>::lol();
|
||||
//~^ ERROR no associated item named
|
||||
//~^ ERROR no function or associated item named
|
||||
let c = Bar::lol();
|
||||
//~^ ERROR no associated item named
|
||||
//~^ ERROR no function or associated item named
|
||||
let d = Bar::<usize, _>::lol();
|
||||
//~^ ERROR no associated item named
|
||||
//~^ ERROR no function or associated item named
|
||||
let e = Bar::<usize>::lol();
|
||||
//~^ ERROR must be explicitly specified
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user