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
This commit is contained in:
Yuki Okushi 2020-10-29 12:08:50 +09:00 committed by GitHub
commit a7a0538802
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 31 deletions

View file

@ -678,8 +678,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
pub fn unsolved_variables(&self) -> Vec<Ty<'tcx>> { pub fn unsolved_variables(&self) -> Vec<Ty<'tcx>> {
let mut inner = self.inner.borrow_mut(); let mut inner = self.inner.borrow_mut();
// FIXME(const_generics): should there be an equivalent function for const variables?
let mut vars: Vec<Ty<'_>> = inner let mut vars: Vec<Ty<'_>> = inner
.type_variables() .type_variables()
.unsolved_variables() .unsolved_variables()

View file

@ -20,7 +20,8 @@ use rustc_span::{MultiSpan, Span, SpanSnippetError, DUMMY_SP};
use tracing::{debug, trace}; use tracing::{debug, trace};
const TURBOFISH: &str = "use `::<...>` instead of `<...>` to specify type arguments"; const TURBOFISH_SUGGESTION_STR: &str =
"use `::<...>` instead of `<...>` to specify type or const arguments";
/// Creates a placeholder argument. /// Creates a placeholder argument.
pub(super) fn dummy_arg(ident: Ident) -> Param { pub(super) fn dummy_arg(ident: Ident) -> Param {
@ -659,7 +660,7 @@ impl<'a> Parser<'a> {
Ok(_) => { Ok(_) => {
e.span_suggestion_verbose( e.span_suggestion_verbose(
binop.span.shrink_to_lo(), binop.span.shrink_to_lo(),
"use `::<...>` instead of `<...>` to specify type arguments", TURBOFISH_SUGGESTION_STR,
"::".to_string(), "::".to_string(),
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
@ -814,7 +815,7 @@ impl<'a> Parser<'a> {
let suggest = |err: &mut DiagnosticBuilder<'_>| { let suggest = |err: &mut DiagnosticBuilder<'_>| {
err.span_suggestion_verbose( err.span_suggestion_verbose(
op.span.shrink_to_lo(), op.span.shrink_to_lo(),
TURBOFISH, TURBOFISH_SUGGESTION_STR,
"::".to_string(), "::".to_string(),
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
@ -888,7 +889,7 @@ impl<'a> Parser<'a> {
{ {
// All we know is that this is `foo < bar >` and *nothing* else. Try to // All we know is that this is `foo < bar >` and *nothing* else. Try to
// be helpful, but don't attempt to recover. // be helpful, but don't attempt to recover.
err.help(TURBOFISH); err.help(TURBOFISH_SUGGESTION_STR);
err.help("or use `(...)` if you meant to specify fn arguments"); err.help("or use `(...)` if you meant to specify fn arguments");
} }

View file

@ -4,7 +4,7 @@ error: comparison operators cannot be chained
LL | foo<BAR + 3>(); LL | foo<BAR + 3>();
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | foo::<BAR + 3>(); LL | foo::<BAR + 3>();
| ^^ | ^^
@ -15,7 +15,7 @@ error: comparison operators cannot be chained
LL | foo<BAR + BAR>(); LL | foo<BAR + BAR>();
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | foo::<BAR + BAR>(); LL | foo::<BAR + BAR>();
| ^^ | ^^
@ -26,7 +26,7 @@ error: comparison operators cannot be chained
LL | foo<3 + 3>(); LL | foo<3 + 3>();
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | foo::<3 + 3>(); LL | foo::<3 + 3>();
| ^^ | ^^
@ -37,7 +37,7 @@ error: comparison operators cannot be chained
LL | foo<BAR - 3>(); LL | foo<BAR - 3>();
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | foo::<BAR - 3>(); LL | foo::<BAR - 3>();
| ^^ | ^^
@ -48,7 +48,7 @@ error: comparison operators cannot be chained
LL | foo<BAR - BAR>(); LL | foo<BAR - BAR>();
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | foo::<BAR - BAR>(); LL | foo::<BAR - BAR>();
| ^^ | ^^
@ -59,7 +59,7 @@ error: comparison operators cannot be chained
LL | foo<100 - BAR>(); LL | foo<100 - BAR>();
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | foo::<100 - BAR>(); LL | foo::<100 - BAR>();
| ^^ | ^^
@ -70,7 +70,7 @@ error: comparison operators cannot be chained
LL | foo<bar<i32>()>(); LL | foo<bar<i32>()>();
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | foo::<bar<i32>()>(); LL | foo::<bar<i32>()>();
| ^^ | ^^
@ -87,7 +87,7 @@ error: comparison operators cannot be chained
LL | foo<bar::<i32>()>(); LL | foo<bar::<i32>()>();
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | foo::<bar::<i32>()>(); LL | foo::<bar::<i32>()>();
| ^^ | ^^
@ -98,7 +98,7 @@ error: comparison operators cannot be chained
LL | foo<bar::<i32>() + BAR>(); LL | foo<bar::<i32>() + BAR>();
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | foo::<bar::<i32>() + BAR>(); LL | foo::<bar::<i32>() + BAR>();
| ^^ | ^^
@ -109,7 +109,7 @@ error: comparison operators cannot be chained
LL | foo<bar::<i32>() - BAR>(); LL | foo<bar::<i32>() - BAR>();
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | foo::<bar::<i32>() - BAR>(); LL | foo::<bar::<i32>() - BAR>();
| ^^ | ^^
@ -120,7 +120,7 @@ error: comparison operators cannot be chained
LL | foo<BAR - bar::<i32>()>(); LL | foo<BAR - bar::<i32>()>();
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | foo::<BAR - bar::<i32>()>(); LL | foo::<BAR - bar::<i32>()>();
| ^^ | ^^
@ -131,7 +131,7 @@ error: comparison operators cannot be chained
LL | foo<BAR - bar::<i32>()>(); LL | foo<BAR - bar::<i32>()>();
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | foo::<BAR - bar::<i32>()>(); LL | foo::<BAR - bar::<i32>()>();
| ^^ | ^^

View file

@ -4,7 +4,7 @@ error: comparison operators cannot be chained
LL | (0..13).collect<Vec<i32>>(); LL | (0..13).collect<Vec<i32>>();
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | (0..13).collect::<Vec<i32>>(); LL | (0..13).collect::<Vec<i32>>();
| ^^ | ^^
@ -15,7 +15,7 @@ error: comparison operators cannot be chained
LL | Vec<i32>::new(); LL | Vec<i32>::new();
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | Vec::<i32>::new(); LL | Vec::<i32>::new();
| ^^ | ^^
@ -26,7 +26,7 @@ error: comparison operators cannot be chained
LL | (0..13).collect<Vec<i32>(); LL | (0..13).collect<Vec<i32>();
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | (0..13).collect::<Vec<i32>(); LL | (0..13).collect::<Vec<i32>();
| ^^ | ^^
@ -37,7 +37,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
LL | let x = std::collections::HashMap<i128, i128>::new(); LL | let x = std::collections::HashMap<i128, i128>::new();
| ^ expected one of 7 possible tokens | ^ expected one of 7 possible tokens
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | let x = std::collections::HashMap::<i128, i128>::new(); LL | let x = std::collections::HashMap::<i128, i128>::new();
| ^^ | ^^
@ -48,7 +48,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found
LL | std::collections::HashMap<i128, i128>::new() LL | std::collections::HashMap<i128, i128>::new()
| ^ expected one of 8 possible tokens | ^ expected one of 8 possible tokens
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | std::collections::HashMap::<i128, i128>::new() LL | std::collections::HashMap::<i128, i128>::new()
| ^^ | ^^
@ -59,7 +59,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found
LL | std::collections::HashMap<i128, i128>::new(); LL | std::collections::HashMap<i128, i128>::new();
| ^ expected one of 8 possible tokens | ^ expected one of 8 possible tokens
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | std::collections::HashMap::<i128, i128>::new(); LL | std::collections::HashMap::<i128, i128>::new();
| ^^ | ^^
@ -70,7 +70,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found
LL | std::collections::HashMap<i128, i128>::new(1, 2); LL | std::collections::HashMap<i128, i128>::new(1, 2);
| ^ expected one of 8 possible tokens | ^ expected one of 8 possible tokens
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | std::collections::HashMap::<i128, i128>::new(1, 2); LL | std::collections::HashMap::<i128, i128>::new(1, 2);
| ^^ | ^^

View file

@ -12,15 +12,15 @@ fn main() {
f<X>(); f<X>();
//~^ ERROR comparison operators cannot be chained //~^ ERROR comparison operators cannot be chained
//~| HELP use `::<...>` instead of `<...>` to specify type arguments //~| HELP use `::<...>` instead of `<...>` to specify type or const arguments
f<Result<Option<X>, Option<Option<X>>>(1, 2); f<Result<Option<X>, Option<Option<X>>>(1, 2);
//~^ ERROR comparison operators cannot be chained //~^ ERROR comparison operators cannot be chained
//~| HELP use `::<...>` instead of `<...>` to specify type arguments //~| HELP use `::<...>` instead of `<...>` to specify type or const arguments
use std::convert::identity; use std::convert::identity;
let _ = identity<u8>; let _ = identity<u8>;
//~^ ERROR comparison operators cannot be chained //~^ ERROR comparison operators cannot be chained
//~| HELP use `::<...>` instead of `<...>` to specify type arguments //~| HELP use `::<...>` instead of `<...>` to specify type or const arguments
//~| HELP or use `(...)` if you meant to specify fn arguments //~| HELP or use `(...)` if you meant to specify fn arguments
} }

View file

@ -26,7 +26,7 @@ error: comparison operators cannot be chained
LL | f<X>(); LL | f<X>();
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | f::<X>(); LL | f::<X>();
| ^^ | ^^
@ -37,7 +37,7 @@ error: comparison operators cannot be chained
LL | f<Result<Option<X>, Option<Option<X>>>(1, 2); LL | f<Result<Option<X>, Option<Option<X>>>(1, 2);
| ^ ^ | ^ ^
| |
help: use `::<...>` instead of `<...>` to specify type arguments help: use `::<...>` instead of `<...>` to specify type or const arguments
| |
LL | f::<Result<Option<X>, Option<Option<X>>>(1, 2); LL | f::<Result<Option<X>, Option<Option<X>>>(1, 2);
| ^^ | ^^
@ -48,7 +48,7 @@ error: comparison operators cannot be chained
LL | let _ = identity<u8>; LL | let _ = identity<u8>;
| ^ ^ | ^ ^
| |
= help: use `::<...>` instead of `<...>` to specify type arguments = help: use `::<...>` instead of `<...>` to specify type or const arguments
= help: or use `(...)` if you meant to specify fn arguments = help: or use `(...)` if you meant to specify fn arguments
error: aborting due to 5 previous errors error: aborting due to 5 previous errors