Rollup merge of #35080 - jonathandturner:fix_numeric_expected_found, r=nikomatsakis
Rename _ to {integer} and {float} for unknown numeric types
This PR renames _ to {integer} or {float} for unknown numeric types, to help people parse error messages that have numeric types that haven't been nailed down.
Example:
```rust
fn main() {
let x: String = 4;
}
```
Before:
```
error[E0308]: mismatched types
--> quicktest.rs:2:21
|
2 | let x: String = 4;
| ^ expected struct `std::string::String`, found integral variable
|
= note: expected type `std::string::String`
= note: found type `_`
error: aborting due to previous error
```
after:
```
error[E0308]: mismatched types
--> quicktest.rs:2:21
|
2 | let x: String = 4;
| ^ expected struct `std::string::String`, found integral variable
|
= note: expected type `std::string::String`
= note: found type `{integer}`
error: aborting due to previous error
```
```
This commit is contained in:
commit
26e22b8e2e
35 changed files with 43 additions and 41 deletions
|
|
@ -974,7 +974,9 @@ impl fmt::Display for ty::InferTy {
|
|||
ty::TyVar(ref vid) if print_var_ids => write!(f, "{:?}", vid),
|
||||
ty::IntVar(ref vid) if print_var_ids => write!(f, "{:?}", vid),
|
||||
ty::FloatVar(ref vid) if print_var_ids => write!(f, "{:?}", vid),
|
||||
ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) => write!(f, "_"),
|
||||
ty::TyVar(_) => write!(f, "_"),
|
||||
ty::IntVar(_) => write!(f, "{}", "{integer}"),
|
||||
ty::FloatVar(_) => write!(f, "{}", "{float}"),
|
||||
ty::FreshTy(v) => write!(f, "FreshTy({})", v),
|
||||
ty::FreshIntTy(v) => write!(f, "FreshIntTy({})", v),
|
||||
ty::FreshFloatTy(v) => write!(f, "FreshFloatTy({})", v)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue