Auto merge of #74210 - estebank:type-ascriptomatic, r=petrochenkov

Deduplicate `::` -> `:` typo errors

Deduplicate errors caused by the same type ascription typo, including
ones suggested during parsing that would get reported again during
resolve. Fix #70382.
This commit is contained in:
bors 2020-08-02 12:20:09 +00:00
commit fd4d151aed
28 changed files with 212 additions and 181 deletions

View file

@ -0,0 +1,6 @@
// run-rustfix
struct X {}
fn main() {
let _ = vec![X {}]; //…
//~^ ERROR expected value, found struct `X`
}

View file

@ -1,5 +1,6 @@
// run-rustfix
struct X {}
fn main() {
vec![X]; //…
let _ = vec![X]; //…
//~^ ERROR expected value, found struct `X`
}

View file

@ -1,11 +1,11 @@
error[E0423]: expected value, found struct `X`
--> $DIR/issue-61226.rs:3:10
--> $DIR/issue-61226.rs:4:18
|
LL | struct X {}
| ----------- `X` defined here
LL | fn main() {
LL | vec![X]; //…
| ^ help: use struct literal syntax instead: `X {}`
LL | let _ = vec![X]; //…
| ^ help: use struct literal syntax instead: `X {}`
error: aborting due to previous error

View file

@ -0,0 +1,5 @@
// run-rustfix
fn main() {
let _ = Box::new("foo".to_string());
//~^ ERROR expected type, found
}

View file

@ -1,4 +1,5 @@
// run-rustfix
fn main() {
Box:new("foo".to_string())
let _ = Box:new("foo".to_string());
//~^ ERROR expected type, found
}

View file

@ -1,10 +1,10 @@
error: expected type, found `"foo"`
--> $DIR/type-ascription-instead-of-method.rs:2:13
--> $DIR/type-ascription-instead-of-method.rs:3:21
|
LL | Box:new("foo".to_string())
| - ^^^^^ expected type
| |
| help: maybe write a path separator here: `::`
LL | let _ = Box:new("foo".to_string());
| - ^^^^^ expected type
| |
| help: maybe write a path separator here: `::`
|
= note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`

View file

@ -0,0 +1,6 @@
// run-rustfix
fn main() -> Result<(), ()> {
let _ = vec![Ok(2)].into_iter().collect::<Result<Vec<_>,_>>()?;
//~^ ERROR expected `::`, found `(`
Ok(())
}

View file

@ -1,5 +1,6 @@
// run-rustfix
fn main() -> Result<(), ()> {
vec![Ok(2)].into_iter().collect:<Result<Vec<_>,_>>()?;
let _ = vec![Ok(2)].into_iter().collect:<Result<Vec<_>,_>>()?;
//~^ ERROR expected `::`, found `(`
Ok(())
}

View file

@ -1,10 +1,10 @@
error: expected `::`, found `(`
--> $DIR/type-ascription-instead-of-path-2.rs:2:55
--> $DIR/type-ascription-instead-of-path-2.rs:3:63
|
LL | vec![Ok(2)].into_iter().collect:<Result<Vec<_>,_>>()?;
| - ^ expected `::`
| |
| help: maybe write a path separator here: `::`
LL | let _ = vec![Ok(2)].into_iter().collect:<Result<Vec<_>,_>>()?;
| - ^ expected `::`
| |
| help: maybe write a path separator here: `::`
|
= note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`

View file

@ -0,0 +1,5 @@
// run-rustfix
fn main() {
let _ = Option::Some("");
//~^ ERROR expected type, found
}

View file

@ -1,3 +1,4 @@
// run-rustfix
fn main() {
let _ = Option:Some("");
//~^ ERROR expected type, found

View file

@ -1,5 +1,5 @@
error: expected type, found `""`
--> $DIR/type-ascription-instead-of-variant.rs:2:25
--> $DIR/type-ascription-instead-of-variant.rs:3:25
|
LL | let _ = Option:Some("");
| - ^^ expected type

View file

@ -0,0 +1,4 @@
// run-rustfix
fn main() {
let _ = Option::Some(vec![0, 1]); //~ ERROR expected type, found
}

View file

@ -1,7 +1,4 @@
// run-rustfix
fn main() {
let _ = Option:Some(vec![0, 1]); //~ ERROR expected type, found
//~^ ERROR expected value, found enum `Option`
//~| ERROR expected type, found variant `Some`
}
// This case isn't currently being handled gracefully due to the macro invocation.

View file

@ -1,5 +1,5 @@
error: expected type, found reserved keyword `box`
--> $DIR/issue-47666.rs:2:25
--> $DIR/issue-47666.rs:3:25
|
LL | let _ = Option:Some(vec![0, 1]);
| - ^^^^^^^^^^
@ -12,35 +12,5 @@ LL | let _ = Option:Some(vec![0, 1]);
= note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0423]: expected value, found enum `Option`
--> $DIR/issue-47666.rs:2:13
|
LL | let _ = Option:Some(vec![0, 1]);
| ^^^^^^
|
help: try using one of the enum's variants
|
LL | let _ = std::option::Option::None:Some(vec![0, 1]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL | let _ = std::option::Option::Some:Some(vec![0, 1]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
error[E0573]: expected type, found variant `Some`
--> $DIR/issue-47666.rs:2:20
|
LL | let _ = Option:Some(vec![0, 1]);
| ^^^^^^^^^^^^^^^^ not a type
|
help: try using the variant's enum
|
LL | let _ = Option:std::option::Option;
| ^^^^^^^^^^^^^^^^^^^
help: maybe you meant to write a path separator here
|
LL | let _ = Option::Some(vec![0, 1]);
| ^^
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0423, E0573.
For more information about an error, try `rustc --explain E0423`.

View file

@ -0,0 +1,7 @@
// run-rustfix
use std::collections::BTreeMap;
fn main() {
println!("{}", std::mem::size_of::<BTreeMap<u32, u32>>());
//~^ ERROR casts cannot be followed by a function call
}

View file

@ -1,8 +1,7 @@
// run-rustfix
use std::collections::BTreeMap;
fn main() {
println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
//~^ ERROR casts cannot be followed by a function call
//~| ERROR expected value, found module `std::mem` [E0423]
//~| ERROR cannot find type `size_of` in this scope [E0412]
}

View file

@ -1,5 +1,5 @@
error: casts cannot be followed by a function call
--> $DIR/issue-54516.rs:4:20
--> $DIR/issue-54516.rs:5:20
|
LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
| ^^^^^^^^-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -8,23 +8,5 @@ LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
|
= note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
error[E0423]: expected value, found module `std::mem`
--> $DIR/issue-54516.rs:4:20
|
LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
| ^^^^^^^^- help: maybe you meant to write a path separator here: `::`
| |
| not a value
error: aborting due to previous error
error[E0412]: cannot find type `size_of` in this scope
--> $DIR/issue-54516.rs:4:29
|
LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
| -^^^^^^^ not found in this scope
| |
| help: maybe you meant to write a path separator here: `::`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0412, E0423.
For more information about an error, try `rustc --explain E0412`.

View file

@ -0,0 +1,5 @@
// run-rustfix
fn main() {
let _: usize = std::mem::size_of::<u32>();
//~^ ERROR casts cannot be followed by a function call
}

View file

@ -1,6 +1,5 @@
// run-rustfix
fn main() {
let u: usize = std::mem:size_of::<u32>();
let _: usize = std::mem:size_of::<u32>();
//~^ ERROR casts cannot be followed by a function call
//~| ERROR expected value, found module `std::mem` [E0423]
//~| ERROR cannot find type `size_of` in this scope [E0412]
}

View file

@ -1,30 +1,12 @@
error: casts cannot be followed by a function call
--> $DIR/issue-60933.rs:2:20
--> $DIR/issue-60933.rs:3:20
|
LL | let u: usize = std::mem:size_of::<u32>();
LL | let _: usize = std::mem:size_of::<u32>();
| ^^^^^^^^-^^^^^^^^^^^^^^
| |
| help: maybe write a path separator here: `::`
|
= note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
error[E0423]: expected value, found module `std::mem`
--> $DIR/issue-60933.rs:2:20
|
LL | let u: usize = std::mem:size_of::<u32>();
| ^^^^^^^^- help: maybe you meant to write a path separator here: `::`
| |
| not a value
error: aborting due to previous error
error[E0412]: cannot find type `size_of` in this scope
--> $DIR/issue-60933.rs:2:29
|
LL | let u: usize = std::mem:size_of::<u32>();
| -^^^^^^^ not found in this scope
| |
| help: maybe you meant to write a path separator here: `::`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0412, E0423.
For more information about an error, try `rustc --explain E0412`.

View file

@ -0,0 +1,9 @@
// run-rustfix
#![feature(type_ascription)]
fn main() {
f() ;
f(); //~ ERROR expected type, found function
}
fn f() {}

View file

@ -1,3 +1,4 @@
// run-rustfix
#![feature(type_ascription)]
fn main() {

View file

@ -1,8 +1,8 @@
error[E0573]: expected type, found function `f`
--> $DIR/type-ascription-with-fn-call.rs:5:5
--> $DIR/type-ascription-with-fn-call.rs:6:5
|
LL | f() :
| - help: did you mean to use `;` here instead?
| - help: maybe you meant to write `;` here
LL | f();
| ^^^
| |