Skip to content

Commit a3964c2

Browse files
committed
reword some path errors
1 parent f6ce33d commit a3964c2

File tree

7 files changed

+27
-19
lines changed

7 files changed

+27
-19
lines changed

compiler/rustc_resolve/src/ident.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,16 +1590,24 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15901590
module,
15911591
|| {
15921592
let name_str = if name == kw::PathRoot {
1593-
"crate root".to_string()
1593+
"the crate root".to_string()
15941594
} else {
15951595
format!("`{name}`")
15961596
};
1597-
let label = if segment_idx == 1 && path[0].ident.name == kw::PathRoot {
1598-
format!("global paths cannot start with {name_str}")
1597+
let (message, label) = if segment_idx == 1
1598+
&& path[0].ident.name == kw::PathRoot
1599+
{
1600+
(
1601+
format!("global paths cannot start with {name_str}"),
1602+
"cannot start with this".to_string(),
1603+
)
15991604
} else {
1600-
format!("{name_str} in paths can only be used in start position")
1605+
(
1606+
format!("{name_str} in paths can only be used in start position"),
1607+
"can only be used in path start position".to_string(),
1608+
)
16011609
};
1602-
(label.clone(), label, None)
1610+
(message, label, None)
16031611
},
16041612
);
16051613
}

tests/ui/delegation/bad-resolve.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ error[E0433]: `crate` in paths can only be used in start position
9191
--> $DIR/bad-resolve.rs:44:29
9292
|
9393
LL | reuse prefix::{self, super, crate};
94-
| ^^^^^ `crate` in paths can only be used in start position
94+
| ^^^^^ can only be used in path start position
9595

9696
error: aborting due to 12 previous errors
9797

tests/ui/dollar-crate/dollar-crate-is-keyword-2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ macro_rules! m {
55
use a::$crate; //~ ERROR: unresolved import `a::$crate`
66
//~^ NOTE: no `$crate` in `a`
77
use a::$crate::b; //~ ERROR: `$crate` in paths can only be used in start position
8-
//~^ NOTE: `$crate` in paths can only be used in start position
8+
//~^ NOTE: can only be used in path start position
99
type A = a::$crate; //~ ERROR: `$crate` in paths can only be used in start position
10-
//~^ NOTE: `$crate` in paths can only be used in start position
10+
//~^ NOTE: can only be used in path start position
1111
}
1212
}
1313

tests/ui/dollar-crate/dollar-crate-is-keyword-2.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0433]: `$crate` in paths can only be used in start position
22
--> $DIR/dollar-crate-is-keyword-2.rs:7:16
33
|
44
LL | use a::$crate::b;
5-
| ^^^^^^ `$crate` in paths can only be used in start position
5+
| ^^^^^^ can only be used in path start position
66
...
77
LL | m!();
88
| ---- in this macro invocation
@@ -24,7 +24,7 @@ error[E0433]: `$crate` in paths can only be used in start position
2424
--> $DIR/dollar-crate-is-keyword-2.rs:9:21
2525
|
2626
LL | type A = a::$crate;
27-
| ^^^^^^ `$crate` in paths can only be used in start position
27+
| ^^^^^^ can only be used in path start position
2828
...
2929
LL | m!();
3030
| ---- in this macro invocation

tests/ui/imports/absolute-paths-in-nested-use-groups.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
error[E0433]: crate root in paths can only be used in start position
1+
error[E0433]: the crate root in paths can only be used in start position
22
--> $DIR/absolute-paths-in-nested-use-groups.rs:6:5
33
|
44
LL | ::bar,
5-
| ^ crate root in paths can only be used in start position
5+
| ^ can only be used in path start position
66

77
error[E0433]: `super` in paths can only be used in start position
88
--> $DIR/absolute-paths-in-nested-use-groups.rs:8:5
99
|
1010
LL | super::bar,
11-
| ^^^^^ `super` in paths can only be used in start position
11+
| ^^^^^ can only be used in path start position
1212

1313
error[E0433]: `self` in paths can only be used in start position
1414
--> $DIR/absolute-paths-in-nested-use-groups.rs:10:5
1515
|
1616
LL | self::bar,
17-
| ^^^^ `self` in paths can only be used in start position
17+
| ^^^^ can only be used in path start position
1818

1919
error: aborting due to 3 previous errors
2020

tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ error[E0433]: `crate` in paths can only be used in start position
22
--> $DIR/crate-path-non-absolute.rs:5:22
33
|
44
LL | let s = ::m::crate::S;
5-
| ^^^^^ `crate` in paths can only be used in start position
5+
| ^^^^^ can only be used in path start position
66

77
error[E0433]: global paths cannot start with `crate`
88
--> $DIR/crate-path-non-absolute.rs:6:20
99
|
1010
LL | let s1 = ::crate::S;
11-
| ^^^^^ global paths cannot start with `crate`
11+
| ^^^^^ cannot start with this
1212

1313
error: aborting due to 2 previous errors
1414

tests/ui/use/use-super-global-path.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ error[E0433]: global paths cannot start with `super`
22
--> $DIR/use-super-global-path.rs:7:11
33
|
44
LL | use ::super::{S, Z};
5-
| ^^^^^ global paths cannot start with `super`
5+
| ^^^^^ cannot start with this
66

77
error[E0433]: global paths cannot start with `super`
88
--> $DIR/use-super-global-path.rs:7:11
99
|
1010
LL | use ::super::{S, Z};
11-
| ^^^^^ global paths cannot start with `super`
11+
| ^^^^^ cannot start with this
1212
|
1313
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
1414

1515
error[E0433]: global paths cannot start with `super`
1616
--> $DIR/use-super-global-path.rs:12:15
1717
|
1818
LL | use ::super::main;
19-
| ^^^^^ global paths cannot start with `super`
19+
| ^^^^^ cannot start with this
2020

2121
error: aborting due to 3 previous errors
2222

0 commit comments

Comments
 (0)