Skip to content

Commit b4a2a55

Browse files
Rollup merge of #78460 - varkor:turbofish-string-generic, r=lcnr
Adjust turbofish help message for const generics Types are no longer special. (This message arguably only makes sense with `min_const_generics` or more, but we'll be there soon.) r? @lcnr
2 parents d354dff + a6d01da commit b4a2a55

File tree

6 files changed

+30
-31
lines changed

6 files changed

+30
-31
lines changed

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
678678

679679
pub fn unsolved_variables(&self) -> Vec<Ty<'tcx>> {
680680
let mut inner = self.inner.borrow_mut();
681-
// FIXME(const_generics): should there be an equivalent function for const variables?
682-
683681
let mut vars: Vec<Ty<'_>> = inner
684682
.type_variables()
685683
.unsolved_variables()

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ use rustc_span::{MultiSpan, Span, SpanSnippetError, DUMMY_SP};
2020

2121
use tracing::{debug, trace};
2222

23-
const TURBOFISH: &str = "use `::<...>` instead of `<...>` to specify type arguments";
23+
const TURBOFISH_SUGGESTION_STR: &str =
24+
"use `::<...>` instead of `<...>` to specify type or const arguments";
2425

2526
/// Creates a placeholder argument.
2627
pub(super) fn dummy_arg(ident: Ident) -> Param {
@@ -659,7 +660,7 @@ impl<'a> Parser<'a> {
659660
Ok(_) => {
660661
e.span_suggestion_verbose(
661662
binop.span.shrink_to_lo(),
662-
"use `::<...>` instead of `<...>` to specify type arguments",
663+
TURBOFISH_SUGGESTION_STR,
663664
"::".to_string(),
664665
Applicability::MaybeIncorrect,
665666
);
@@ -814,7 +815,7 @@ impl<'a> Parser<'a> {
814815
let suggest = |err: &mut DiagnosticBuilder<'_>| {
815816
err.span_suggestion_verbose(
816817
op.span.shrink_to_lo(),
817-
TURBOFISH,
818+
TURBOFISH_SUGGESTION_STR,
818819
"::".to_string(),
819820
Applicability::MaybeIncorrect,
820821
);
@@ -888,7 +889,7 @@ impl<'a> Parser<'a> {
888889
{
889890
// All we know is that this is `foo < bar >` and *nothing* else. Try to
890891
// be helpful, but don't attempt to recover.
891-
err.help(TURBOFISH);
892+
err.help(TURBOFISH_SUGGESTION_STR);
892893
err.help("or use `(...)` if you meant to specify fn arguments");
893894
}
894895

src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces-without-turbofish.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: comparison operators cannot be chained
44
LL | foo<BAR + 3>();
55
| ^ ^
66
|
7-
help: use `::<...>` instead of `<...>` to specify type arguments
7+
help: use `::<...>` instead of `<...>` to specify type or const arguments
88
|
99
LL | foo::<BAR + 3>();
1010
| ^^
@@ -15,7 +15,7 @@ error: comparison operators cannot be chained
1515
LL | foo<BAR + BAR>();
1616
| ^ ^
1717
|
18-
help: use `::<...>` instead of `<...>` to specify type arguments
18+
help: use `::<...>` instead of `<...>` to specify type or const arguments
1919
|
2020
LL | foo::<BAR + BAR>();
2121
| ^^
@@ -26,7 +26,7 @@ error: comparison operators cannot be chained
2626
LL | foo<3 + 3>();
2727
| ^ ^
2828
|
29-
help: use `::<...>` instead of `<...>` to specify type arguments
29+
help: use `::<...>` instead of `<...>` to specify type or const arguments
3030
|
3131
LL | foo::<3 + 3>();
3232
| ^^
@@ -37,7 +37,7 @@ error: comparison operators cannot be chained
3737
LL | foo<BAR - 3>();
3838
| ^ ^
3939
|
40-
help: use `::<...>` instead of `<...>` to specify type arguments
40+
help: use `::<...>` instead of `<...>` to specify type or const arguments
4141
|
4242
LL | foo::<BAR - 3>();
4343
| ^^
@@ -48,7 +48,7 @@ error: comparison operators cannot be chained
4848
LL | foo<BAR - BAR>();
4949
| ^ ^
5050
|
51-
help: use `::<...>` instead of `<...>` to specify type arguments
51+
help: use `::<...>` instead of `<...>` to specify type or const arguments
5252
|
5353
LL | foo::<BAR - BAR>();
5454
| ^^
@@ -59,7 +59,7 @@ error: comparison operators cannot be chained
5959
LL | foo<100 - BAR>();
6060
| ^ ^
6161
|
62-
help: use `::<...>` instead of `<...>` to specify type arguments
62+
help: use `::<...>` instead of `<...>` to specify type or const arguments
6363
|
6464
LL | foo::<100 - BAR>();
6565
| ^^
@@ -70,7 +70,7 @@ error: comparison operators cannot be chained
7070
LL | foo<bar<i32>()>();
7171
| ^ ^
7272
|
73-
help: use `::<...>` instead of `<...>` to specify type arguments
73+
help: use `::<...>` instead of `<...>` to specify type or const arguments
7474
|
7575
LL | foo::<bar<i32>()>();
7676
| ^^
@@ -87,7 +87,7 @@ error: comparison operators cannot be chained
8787
LL | foo<bar::<i32>()>();
8888
| ^ ^
8989
|
90-
help: use `::<...>` instead of `<...>` to specify type arguments
90+
help: use `::<...>` instead of `<...>` to specify type or const arguments
9191
|
9292
LL | foo::<bar::<i32>()>();
9393
| ^^
@@ -98,7 +98,7 @@ error: comparison operators cannot be chained
9898
LL | foo<bar::<i32>() + BAR>();
9999
| ^ ^
100100
|
101-
help: use `::<...>` instead of `<...>` to specify type arguments
101+
help: use `::<...>` instead of `<...>` to specify type or const arguments
102102
|
103103
LL | foo::<bar::<i32>() + BAR>();
104104
| ^^
@@ -109,7 +109,7 @@ error: comparison operators cannot be chained
109109
LL | foo<bar::<i32>() - BAR>();
110110
| ^ ^
111111
|
112-
help: use `::<...>` instead of `<...>` to specify type arguments
112+
help: use `::<...>` instead of `<...>` to specify type or const arguments
113113
|
114114
LL | foo::<bar::<i32>() - BAR>();
115115
| ^^
@@ -120,7 +120,7 @@ error: comparison operators cannot be chained
120120
LL | foo<BAR - bar::<i32>()>();
121121
| ^ ^
122122
|
123-
help: use `::<...>` instead of `<...>` to specify type arguments
123+
help: use `::<...>` instead of `<...>` to specify type or const arguments
124124
|
125125
LL | foo::<BAR - bar::<i32>()>();
126126
| ^^
@@ -131,7 +131,7 @@ error: comparison operators cannot be chained
131131
LL | foo<BAR - bar::<i32>()>();
132132
| ^ ^
133133
|
134-
help: use `::<...>` instead of `<...>` to specify type arguments
134+
help: use `::<...>` instead of `<...>` to specify type or const arguments
135135
|
136136
LL | foo::<BAR - bar::<i32>()>();
137137
| ^^

src/test/ui/did_you_mean/issue-40396.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: comparison operators cannot be chained
44
LL | (0..13).collect<Vec<i32>>();
55
| ^ ^
66
|
7-
help: use `::<...>` instead of `<...>` to specify type arguments
7+
help: use `::<...>` instead of `<...>` to specify type or const arguments
88
|
99
LL | (0..13).collect::<Vec<i32>>();
1010
| ^^
@@ -15,7 +15,7 @@ error: comparison operators cannot be chained
1515
LL | Vec<i32>::new();
1616
| ^ ^
1717
|
18-
help: use `::<...>` instead of `<...>` to specify type arguments
18+
help: use `::<...>` instead of `<...>` to specify type or const arguments
1919
|
2020
LL | Vec::<i32>::new();
2121
| ^^
@@ -26,7 +26,7 @@ error: comparison operators cannot be chained
2626
LL | (0..13).collect<Vec<i32>();
2727
| ^ ^
2828
|
29-
help: use `::<...>` instead of `<...>` to specify type arguments
29+
help: use `::<...>` instead of `<...>` to specify type or const arguments
3030
|
3131
LL | (0..13).collect::<Vec<i32>();
3232
| ^^
@@ -37,7 +37,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
3737
LL | let x = std::collections::HashMap<i128, i128>::new();
3838
| ^ expected one of 7 possible tokens
3939
|
40-
help: use `::<...>` instead of `<...>` to specify type arguments
40+
help: use `::<...>` instead of `<...>` to specify type or const arguments
4141
|
4242
LL | let x = std::collections::HashMap::<i128, i128>::new();
4343
| ^^
@@ -48,7 +48,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found
4848
LL | std::collections::HashMap<i128, i128>::new()
4949
| ^ expected one of 8 possible tokens
5050
|
51-
help: use `::<...>` instead of `<...>` to specify type arguments
51+
help: use `::<...>` instead of `<...>` to specify type or const arguments
5252
|
5353
LL | std::collections::HashMap::<i128, i128>::new()
5454
| ^^
@@ -59,7 +59,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found
5959
LL | std::collections::HashMap<i128, i128>::new();
6060
| ^ expected one of 8 possible tokens
6161
|
62-
help: use `::<...>` instead of `<...>` to specify type arguments
62+
help: use `::<...>` instead of `<...>` to specify type or const arguments
6363
|
6464
LL | std::collections::HashMap::<i128, i128>::new();
6565
| ^^
@@ -70,7 +70,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found
7070
LL | std::collections::HashMap<i128, i128>::new(1, 2);
7171
| ^ expected one of 8 possible tokens
7272
|
73-
help: use `::<...>` instead of `<...>` to specify type arguments
73+
help: use `::<...>` instead of `<...>` to specify type or const arguments
7474
|
7575
LL | std::collections::HashMap::<i128, i128>::new(1, 2);
7676
| ^^

src/test/ui/parser/require-parens-for-chained-comparison.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ fn main() {
1212

1313
f<X>();
1414
//~^ ERROR comparison operators cannot be chained
15-
//~| HELP use `::<...>` instead of `<...>` to specify type arguments
15+
//~| HELP use `::<...>` instead of `<...>` to specify type or const arguments
1616

1717
f<Result<Option<X>, Option<Option<X>>>(1, 2);
1818
//~^ ERROR comparison operators cannot be chained
19-
//~| HELP use `::<...>` instead of `<...>` to specify type arguments
19+
//~| HELP use `::<...>` instead of `<...>` to specify type or const arguments
2020

2121
use std::convert::identity;
2222
let _ = identity<u8>;
2323
//~^ ERROR comparison operators cannot be chained
24-
//~| HELP use `::<...>` instead of `<...>` to specify type arguments
24+
//~| HELP use `::<...>` instead of `<...>` to specify type or const arguments
2525
//~| HELP or use `(...)` if you meant to specify fn arguments
2626
}

src/test/ui/parser/require-parens-for-chained-comparison.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ error: comparison operators cannot be chained
2626
LL | f<X>();
2727
| ^ ^
2828
|
29-
help: use `::<...>` instead of `<...>` to specify type arguments
29+
help: use `::<...>` instead of `<...>` to specify type or const arguments
3030
|
3131
LL | f::<X>();
3232
| ^^
@@ -37,7 +37,7 @@ error: comparison operators cannot be chained
3737
LL | f<Result<Option<X>, Option<Option<X>>>(1, 2);
3838
| ^ ^
3939
|
40-
help: use `::<...>` instead of `<...>` to specify type arguments
40+
help: use `::<...>` instead of `<...>` to specify type or const arguments
4141
|
4242
LL | f::<Result<Option<X>, Option<Option<X>>>(1, 2);
4343
| ^^
@@ -48,7 +48,7 @@ error: comparison operators cannot be chained
4848
LL | let _ = identity<u8>;
4949
| ^ ^
5050
|
51-
= help: use `::<...>` instead of `<...>` to specify type arguments
51+
= help: use `::<...>` instead of `<...>` to specify type or const arguments
5252
= help: or use `(...)` if you meant to specify fn arguments
5353

5454
error: aborting due to 5 previous errors

0 commit comments

Comments
 (0)