Skip to content

Commit

Permalink
Further deduplicate type ascription errors
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Jul 15, 2020
1 parent 1e105ea commit 06cab8e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 42 deletions.
16 changes: 16 additions & 0 deletions src/librustc_resolve/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,22 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
Applicability::MaybeIncorrect,
);
show_label = false;
if self
.r
.session
.parse_sess
.type_ascription_path_suggestions
.borrow()
.contains(&colon_sp)
{
err.delay_as_bug();
}
self.r
.session
.parse_sess
.type_ascription_path_suggestions
.borrow_mut()
.insert(colon_sp);
}
if let Ok(base_snippet) = base_snippet {
let mut sp = after_colon_sp;
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/type/ascription/issue-54516.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ 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]
}
20 changes: 1 addition & 19 deletions src/test/ui/type/ascription/issue-54516.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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[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
error: aborting due to previous error

Some errors have detailed explanations: E0412, E0423.
For more information about an error, try `rustc --explain E0412`.
2 changes: 0 additions & 2 deletions src/test/ui/type/ascription/issue-60933.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
fn main() {
let u: 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]
}
20 changes: 1 addition & 19 deletions src/test/ui/type/ascription/issue-60933.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,5 @@ LL | let u: usize = std::mem:size_of::<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-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[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
error: aborting due to previous error

Some errors have detailed explanations: E0412, E0423.
For more information about an error, try `rustc --explain E0412`.

0 comments on commit 06cab8e

Please sign in to comment.