mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
Rollup merge of #52507 - estebank:infer-type, r=nikomatsakis
Reword when `_` couldn't be inferred r? @nikomatsakis
This commit is contained in:
commit
82cdbf1d3a
@ -97,7 +97,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
let name = self.extract_type_name(&ty);
|
||||
|
||||
let mut err_span = span;
|
||||
let mut labels = vec![(span, format!("cannot infer type for `{}`", name))];
|
||||
let mut labels = vec![(
|
||||
span,
|
||||
if &name == "_" {
|
||||
"cannot infer type".to_string()
|
||||
} else {
|
||||
format!("cannot infer type for `{}`", name)
|
||||
},
|
||||
)];
|
||||
|
||||
let mut local_visitor = FindLocalByTypeVisitor {
|
||||
infcx: &self,
|
||||
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed
|
||||
LL | let x = "hello".chars().rev().collect(); //~ ERROR E0282
|
||||
| ^
|
||||
| |
|
||||
| cannot infer type for `_`
|
||||
| cannot infer type
|
||||
| consider giving `x` a type
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed
|
||||
LL | let &v = new();
|
||||
| -^
|
||||
| ||
|
||||
| |cannot infer type for `_`
|
||||
| |cannot infer type
|
||||
| consider giving the pattern a type
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed
|
||||
LL | let &v = new();
|
||||
| -^
|
||||
| ||
|
||||
| |cannot infer type for `_`
|
||||
| |cannot infer type
|
||||
| consider giving the pattern a type
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed
|
||||
LL | / { return () }
|
||||
LL | | //~^ ERROR type annotations needed [E0282]
|
||||
LL | | ()
|
||||
| |______^ cannot infer type for `_`
|
||||
| |______^ cannot infer type
|
||||
|
|
||||
= note: type must be known at this point
|
||||
|
||||
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed
|
||||
LL | let x; //~ ERROR type annotations needed
|
||||
| ^
|
||||
| |
|
||||
| cannot infer type for `_`
|
||||
| cannot infer type
|
||||
| consider giving `x` a type
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed
|
||||
LL | for (ref i,) in [].iter() {
|
||||
| --------- the element type for this iterator is not specified
|
||||
LL | i.clone();
|
||||
| ^^^^^ cannot infer type for `_`
|
||||
| ^^^^^ cannot infer type
|
||||
|
|
||||
= note: type must be known at this point
|
||||
|
||||
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed
|
||||
LL | let x = panic!();
|
||||
| - consider giving `x` a type
|
||||
LL | x.clone(); //~ ERROR type annotations needed
|
||||
| ^ cannot infer type for `_`
|
||||
| ^ cannot infer type
|
||||
|
|
||||
= note: type must be known at this point
|
||||
|
||||
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed
|
||||
--> $DIR/issue-23041.rs:16:22
|
||||
|
|
||||
LL | b.downcast_ref::<fn(_)->_>(); //~ ERROR E0282
|
||||
| ^^^^^^^^ cannot infer type for `_`
|
||||
| ^^^^^^^^ cannot infer type
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed
|
||||
--> $DIR/issue-24013.rs:15:20
|
||||
|
|
||||
LL | unsafe {swap::<&mut _>(transmute(&a), transmute(&b))};
|
||||
| ^^^^^^ cannot infer type for `_`
|
||||
| ^^^^^^ cannot infer type
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -15,7 +15,7 @@ fn main() {
|
||||
//~^ NOTE the element type for this iterator is not specified
|
||||
*tile = 0;
|
||||
//~^ ERROR type annotations needed
|
||||
//~| NOTE cannot infer type for `_`
|
||||
//~| NOTE cannot infer type
|
||||
//~| NOTE type must be known at this point
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ LL | for tile in row {
|
||||
| --- the element type for this iterator is not specified
|
||||
LL | //~^ NOTE the element type for this iterator is not specified
|
||||
LL | *tile = 0;
|
||||
| ^^^^^ cannot infer type for `_`
|
||||
| ^^^^^ cannot infer type
|
||||
|
|
||||
= note: type must be known at this point
|
||||
|
||||
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed
|
||||
--> $DIR/issue-7813.rs:12:13
|
||||
|
|
||||
LL | let v = &[]; //~ ERROR type annotations needed
|
||||
| - ^^^ cannot infer type for `_`
|
||||
| - ^^^ cannot infer type
|
||||
| |
|
||||
| consider giving `v` a type
|
||||
|
||||
|
@ -13,7 +13,7 @@ error[E0282]: type annotations needed
|
||||
|
|
||||
LL | / data.iter() //~ ERROR 22:5: 23:20: type annotations needed
|
||||
LL | | .sum::<_>()
|
||||
| |___________________^ cannot infer type for `_`
|
||||
| |___________________^ cannot infer type
|
||||
|
|
||||
= note: type must be known at this point
|
||||
|
||||
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed
|
||||
LL | let mut x = Default::default();
|
||||
| ----- consider giving `x` a type
|
||||
LL | x.0;
|
||||
| ^ cannot infer type for `_`
|
||||
| ^ cannot infer type
|
||||
|
|
||||
= note: type must be known at this point
|
||||
|
||||
@ -14,7 +14,7 @@ error[E0282]: type annotations needed
|
||||
LL | let mut x = Default::default();
|
||||
| ----- consider giving `x` a type
|
||||
LL | x[0];
|
||||
| ^ cannot infer type for `_`
|
||||
| ^ cannot infer type
|
||||
|
|
||||
= note: type must be known at this point
|
||||
|
||||
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed
|
||||
--> $DIR/cannot_infer_local_or_array.rs:12:13
|
||||
|
|
||||
LL | let x = []; //~ ERROR type annotations needed
|
||||
| - ^^ cannot infer type for `_`
|
||||
| - ^^ cannot infer type
|
||||
| |
|
||||
| consider giving `x` a type
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user