Skip to content

Commit 06cab8e

Browse files
committed
Further deduplicate type ascription errors
1 parent 1e105ea commit 06cab8e

File tree

5 files changed

+18
-42
lines changed

5 files changed

+18
-42
lines changed

src/librustc_resolve/late/diagnostics.rs

+16
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,22 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
936936
Applicability::MaybeIncorrect,
937937
);
938938
show_label = false;
939+
if self
940+
.r
941+
.session
942+
.parse_sess
943+
.type_ascription_path_suggestions
944+
.borrow()
945+
.contains(&colon_sp)
946+
{
947+
err.delay_as_bug();
948+
}
949+
self.r
950+
.session
951+
.parse_sess
952+
.type_ascription_path_suggestions
953+
.borrow_mut()
954+
.insert(colon_sp);
939955
}
940956
if let Ok(base_snippet) = base_snippet {
941957
let mut sp = after_colon_sp;

src/test/ui/type/ascription/issue-54516.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ use std::collections::BTreeMap;
33
fn main() {
44
println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
55
//~^ ERROR casts cannot be followed by a function call
6-
//~| ERROR expected value, found module `std::mem` [E0423]
7-
//~| ERROR cannot find type `size_of` in this scope [E0412]
86
}

src/test/ui/type/ascription/issue-54516.stderr

+1-19
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,5 @@ LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
88
|
99
= note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
1010

11-
error[E0423]: expected value, found module `std::mem`
12-
--> $DIR/issue-54516.rs:4:20
13-
|
14-
LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
15-
| ^^^^^^^^- help: maybe you meant to write a path separator here: `::`
16-
| |
17-
| not a value
18-
19-
error[E0412]: cannot find type `size_of` in this scope
20-
--> $DIR/issue-54516.rs:4:29
21-
|
22-
LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
23-
| -^^^^^^^ not found in this scope
24-
| |
25-
| help: maybe you meant to write a path separator here: `::`
26-
27-
error: aborting due to 3 previous errors
11+
error: aborting due to previous error
2812

29-
Some errors have detailed explanations: E0412, E0423.
30-
For more information about an error, try `rustc --explain E0412`.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
fn main() {
22
let u: usize = std::mem:size_of::<u32>();
33
//~^ ERROR casts cannot be followed by a function call
4-
//~| ERROR expected value, found module `std::mem` [E0423]
5-
//~| ERROR cannot find type `size_of` in this scope [E0412]
64
}

src/test/ui/type/ascription/issue-60933.stderr

+1-19
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,5 @@ LL | let u: usize = std::mem:size_of::<u32>();
88
|
99
= note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
1010

11-
error[E0423]: expected value, found module `std::mem`
12-
--> $DIR/issue-60933.rs:2:20
13-
|
14-
LL | let u: usize = std::mem:size_of::<u32>();
15-
| ^^^^^^^^- help: maybe you meant to write a path separator here: `::`
16-
| |
17-
| not a value
18-
19-
error[E0412]: cannot find type `size_of` in this scope
20-
--> $DIR/issue-60933.rs:2:29
21-
|
22-
LL | let u: usize = std::mem:size_of::<u32>();
23-
| -^^^^^^^ not found in this scope
24-
| |
25-
| help: maybe you meant to write a path separator here: `::`
26-
27-
error: aborting due to 3 previous errors
11+
error: aborting due to previous error
2812

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

0 commit comments

Comments
 (0)