Rollup merge of #37442 - estebank:cast-deref-hint, r=jonathandturner
Provide hint when cast needs a dereference For a given code: ``` rust vec![0.0].iter().map(|s| s as i16).collect::<Vec<i16>>(); ``` display: ``` nocode error: casting `&f64` as `i16` is invalid --> file3.rs:2:35 | 2 | vec![0.0].iter().map(|s| s as i16).collect::<Vec<i16>>(); | - ^^^ | | | did you mean `*s`? ``` instead of: ``` nocode error: casting `&f64` as `i16` is invalid --> <anon>:2:30 | 2 | vec![0.0].iter().map(|s| s as i16).collect(); | ^^^^^^^^ | = help: cast through a raw pointer first ``` Fixes #37338.
This commit is contained in:
commit
464cce99f1
2 changed files with 47 additions and 2 deletions
|
|
@ -115,4 +115,9 @@ fn main()
|
|||
let _ = cf as *const Bar;
|
||||
//~^ ERROR casting
|
||||
//~^^ NOTE vtable kinds
|
||||
|
||||
vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>();
|
||||
//~^ ERROR casting `&{float}` as `f32` is invalid
|
||||
//~| NOTE cannot cast `&{float}` as `f32`
|
||||
//~| NOTE did you mean `*s`?
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue