From 6c73adf3240261315446582cb57de079bf2b87f9 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 28 Oct 2020 00:41:40 +0000 Subject: [PATCH 1/2] Adjust turbofish help message for const generics --- .../rustc_parse/src/parser/diagnostics.rs | 9 +++---- ...st-missing-braces-without-turbofish.stderr | 24 +++++++++---------- src/test/ui/did_you_mean/issue-40396.stderr | 14 +++++------ .../require-parens-for-chained-comparison.rs | 6 ++--- ...quire-parens-for-chained-comparison.stderr | 6 ++--- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 52cbba9d2bf..debe6a5c12c 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -20,7 +20,8 @@ use rustc_span::{MultiSpan, Span, SpanSnippetError, DUMMY_SP}; 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. pub(super) fn dummy_arg(ident: Ident) -> Param { @@ -659,7 +660,7 @@ impl<'a> Parser<'a> { Ok(_) => { e.span_suggestion_verbose( binop.span.shrink_to_lo(), - "use `::<...>` instead of `<...>` to specify type arguments", + TURBOFISH_SUGGESTION_STR, "::".to_string(), Applicability::MaybeIncorrect, ); @@ -814,7 +815,7 @@ impl<'a> Parser<'a> { let suggest = |err: &mut DiagnosticBuilder<'_>| { err.span_suggestion_verbose( op.span.shrink_to_lo(), - TURBOFISH, + TURBOFISH_SUGGESTION_STR, "::".to_string(), Applicability::MaybeIncorrect, ); @@ -888,7 +889,7 @@ impl<'a> Parser<'a> { { // All we know is that this is `foo < bar >` and *nothing* else. Try to // 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"); } diff --git a/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces-without-turbofish.stderr b/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces-without-turbofish.stderr index 103a295fced..13742238a20 100644 --- a/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces-without-turbofish.stderr +++ b/src/test/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces-without-turbofish.stderr @@ -4,7 +4,7 @@ error: comparison operators cannot be chained LL | foo(); | ^ ^ | -help: use `::<...>` instead of `<...>` to specify type arguments +help: use `::<...>` instead of `<...>` to specify type or const arguments | LL | foo::(); | ^^ @@ -15,7 +15,7 @@ error: comparison operators cannot be chained LL | foo(); | ^ ^ | -help: use `::<...>` instead of `<...>` to specify type arguments +help: use `::<...>` instead of `<...>` to specify type or const arguments | LL | foo::(); | ^^ @@ -26,7 +26,7 @@ error: comparison operators cannot be chained 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>(); | ^^ @@ -37,7 +37,7 @@ error: comparison operators cannot be chained LL | foo(); | ^ ^ | -help: use `::<...>` instead of `<...>` to specify type arguments +help: use `::<...>` instead of `<...>` to specify type or const arguments | LL | foo::(); | ^^ @@ -48,7 +48,7 @@ error: comparison operators cannot be chained LL | foo(); | ^ ^ | -help: use `::<...>` instead of `<...>` to specify type arguments +help: use `::<...>` instead of `<...>` to specify type or const arguments | LL | foo::(); | ^^ @@ -59,7 +59,7 @@ error: comparison operators cannot be chained 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>(); | ^^ @@ -70,7 +70,7 @@ error: comparison operators cannot be chained LL | foo()>(); | ^ ^ | -help: use `::<...>` instead of `<...>` to specify type arguments +help: use `::<...>` instead of `<...>` to specify type or const arguments | LL | foo::()>(); | ^^ @@ -87,7 +87,7 @@ error: comparison operators cannot be chained LL | foo()>(); | ^ ^ | -help: use `::<...>` instead of `<...>` to specify type arguments +help: use `::<...>` instead of `<...>` to specify type or const arguments | LL | foo::()>(); | ^^ @@ -98,7 +98,7 @@ error: comparison operators cannot be chained LL | foo() + BAR>(); | ^ ^ | -help: use `::<...>` instead of `<...>` to specify type arguments +help: use `::<...>` instead of `<...>` to specify type or const arguments | LL | foo::() + BAR>(); | ^^ @@ -109,7 +109,7 @@ error: comparison operators cannot be chained LL | foo() - BAR>(); | ^ ^ | -help: use `::<...>` instead of `<...>` to specify type arguments +help: use `::<...>` instead of `<...>` to specify type or const arguments | LL | foo::() - BAR>(); | ^^ @@ -120,7 +120,7 @@ error: comparison operators cannot be chained LL | foo()>(); | ^ ^ | -help: use `::<...>` instead of `<...>` to specify type arguments +help: use `::<...>` instead of `<...>` to specify type or const arguments | LL | foo::()>(); | ^^ @@ -131,7 +131,7 @@ error: comparison operators cannot be chained LL | foo()>(); | ^ ^ | -help: use `::<...>` instead of `<...>` to specify type arguments +help: use `::<...>` instead of `<...>` to specify type or const arguments | LL | foo::()>(); | ^^ diff --git a/src/test/ui/did_you_mean/issue-40396.stderr b/src/test/ui/did_you_mean/issue-40396.stderr index 184bcf0c74b..2c2978d2bff 100644 --- a/src/test/ui/did_you_mean/issue-40396.stderr +++ b/src/test/ui/did_you_mean/issue-40396.stderr @@ -4,7 +4,7 @@ error: comparison operators cannot be chained LL | (0..13).collect>(); | ^ ^ | -help: use `::<...>` instead of `<...>` to specify type arguments +help: use `::<...>` instead of `<...>` to specify type or const arguments | LL | (0..13).collect::>(); | ^^ @@ -15,7 +15,7 @@ error: comparison operators cannot be chained LL | Vec::new(); | ^ ^ | -help: use `::<...>` instead of `<...>` to specify type arguments +help: use `::<...>` instead of `<...>` to specify type or const arguments | LL | Vec::::new(); | ^^ @@ -26,7 +26,7 @@ error: comparison operators cannot be chained LL | (0..13).collect(); | ^ ^ | -help: use `::<...>` instead of `<...>` to specify type arguments +help: use `::<...>` instead of `<...>` to specify type or const arguments | LL | (0..13).collect::(); | ^^ @@ -37,7 +37,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,` LL | let x = std::collections::HashMap::new(); | ^ 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::::new(); | ^^ @@ -48,7 +48,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found LL | std::collections::HashMap::new() | ^ 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::::new() | ^^ @@ -59,7 +59,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found LL | std::collections::HashMap::new(); | ^ 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::::new(); | ^^ @@ -70,7 +70,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found LL | std::collections::HashMap::new(1, 2); | ^ 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::::new(1, 2); | ^^ diff --git a/src/test/ui/parser/require-parens-for-chained-comparison.rs b/src/test/ui/parser/require-parens-for-chained-comparison.rs index 4e97904ed6d..e3ce6cd39bc 100644 --- a/src/test/ui/parser/require-parens-for-chained-comparison.rs +++ b/src/test/ui/parser/require-parens-for-chained-comparison.rs @@ -12,15 +12,15 @@ fn main() { f(); //~^ 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, Option>>(1, 2); //~^ 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; let _ = identity; //~^ 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 } diff --git a/src/test/ui/parser/require-parens-for-chained-comparison.stderr b/src/test/ui/parser/require-parens-for-chained-comparison.stderr index 7001aa8e8a1..afb964c17e2 100644 --- a/src/test/ui/parser/require-parens-for-chained-comparison.stderr +++ b/src/test/ui/parser/require-parens-for-chained-comparison.stderr @@ -26,7 +26,7 @@ error: comparison operators cannot be chained LL | f(); | ^ ^ | -help: use `::<...>` instead of `<...>` to specify type arguments +help: use `::<...>` instead of `<...>` to specify type or const arguments | LL | f::(); | ^^ @@ -37,7 +37,7 @@ error: comparison operators cannot be chained LL | f, Option>>(1, 2); | ^ ^ | -help: use `::<...>` instead of `<...>` to specify type arguments +help: use `::<...>` instead of `<...>` to specify type or const arguments | LL | f::, Option>>(1, 2); | ^^ @@ -48,7 +48,7 @@ error: comparison operators cannot be chained LL | let _ = identity; | ^ ^ | - = 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 error: aborting due to 5 previous errors From a6d01da7165d904d83407c385282803b9cb71dbb Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 28 Oct 2020 00:46:53 +0000 Subject: [PATCH 2/2] Remove irrelevant FIXME --- compiler/rustc_infer/src/infer/mod.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index ff7bbf0562f..acded5351f8 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -678,8 +678,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn unsolved_variables(&self) -> Vec> { let mut inner = self.inner.borrow_mut(); - // FIXME(const_generics): should there be an equivalent function for const variables? - let mut vars: Vec> = inner .type_variables() .unsolved_variables()