Auto merge of #74005 - estebank:type-ascription-redux, r=petrochenkov

Clean up errors in typeck and resolve

* Tweak ordering of suggestions
* Do not suggest similarly named enclosing item
* Point at item definition in foreign crates
* Add missing primary label

CC #34255.
This commit is contained in:
bors 2020-08-10 23:50:39 +00:00
commit 3bb5a863c8
26 changed files with 230 additions and 151 deletions

View File

@ -942,6 +942,45 @@ impl<'a> Resolver<'a> {
Some(suggestion) if suggestion.candidate == kw::Underscore => return false,
Some(suggestion) => suggestion,
};
let def_span = suggestion.res.opt_def_id().and_then(|def_id| match def_id.krate {
LOCAL_CRATE => self.opt_span(def_id),
_ => Some(
self.session
.source_map()
.guess_head_span(self.cstore().get_span_untracked(def_id, self.session)),
),
});
if let Some(def_span) = def_span {
if span.overlaps(def_span) {
// Don't suggest typo suggestion for itself like in the followoing:
// error[E0423]: expected function, tuple struct or tuple variant, found struct `X`
// --> $DIR/issue-64792-bad-unicode-ctor.rs:3:14
// |
// LL | struct X {}
// | ----------- `X` defined here
// LL |
// LL | const Y: X = X("ö");
// | -------------^^^^^^- similarly named constant `Y` defined here
// |
// help: use struct literal syntax instead
// |
// LL | const Y: X = X {};
// | ^^^^
// help: a constant with a similar name exists
// |
// LL | const Y: X = Y("ö");
// | ^
return false;
}
err.span_label(
self.session.source_map().guess_head_span(def_span),
&format!(
"similarly named {} `{}` defined here",
suggestion.res.descr(),
suggestion.candidate.as_str(),
),
);
}
let msg = format!(
"{} {} with a similar name exists",
suggestion.res.article(),
@ -953,24 +992,6 @@ impl<'a> Resolver<'a> {
suggestion.candidate.to_string(),
Applicability::MaybeIncorrect,
);
let def_span = suggestion.res.opt_def_id().and_then(|def_id| match def_id.krate {
LOCAL_CRATE => self.opt_span(def_id),
_ => Some(
self.session
.source_map()
.guess_head_span(self.cstore().get_span_untracked(def_id, self.session)),
),
});
if let Some(span) = def_span {
err.span_label(
self.session.source_map().guess_head_span(span),
&format!(
"similarly named {} `{}` defined here",
suggestion.res.descr(),
suggestion.candidate.as_str(),
),
);
}
true
}

View File

@ -12,7 +12,7 @@ use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}
use rustc_hir as hir;
use rustc_hir::def::Namespace::{self, *};
use rustc_hir::def::{self, CtorKind, DefKind};
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX};
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
use rustc_hir::PrimTy;
use rustc_session::config::nightly_options;
use rustc_span::hygiene::MacroKind;
@ -88,6 +88,18 @@ fn import_candidate_to_enum_paths(suggestion: &ImportSuggestion) -> (String, Str
}
impl<'a> LateResolutionVisitor<'a, '_, '_> {
fn def_span(&self, def_id: DefId) -> Option<Span> {
match def_id.krate {
LOCAL_CRATE => self.r.opt_span(def_id),
_ => Some(
self.r
.session
.source_map()
.guess_head_span(self.r.cstore().get_span_untracked(def_id, self.r.session)),
),
}
}
/// Handles error reporting for `smart_resolve_path_fragment` function.
/// Creates base error and amends it with one short label and possibly some longer helps/notes.
pub(crate) fn smart_resolve_report_errors(
@ -339,8 +351,6 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
// Try Levenshtein algorithm.
let typo_sugg = self.lookup_typo_candidate(path, ns, is_expected, span);
let levenshtein_worked = self.r.add_typo_suggestion(&mut err, typo_sugg, ident_span);
// Try context-dependent help if relaxed lookup didn't work.
if let Some(res) = res {
if self.smart_resolve_context_dependent_help(
@ -351,14 +361,18 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
&path_str,
&fallback_label,
) {
// We do this to avoid losing a secondary span when we override the main error span.
self.r.add_typo_suggestion(&mut err, typo_sugg, ident_span);
return (err, candidates);
}
}
// Fallback label.
if !levenshtein_worked {
if !self.type_ascription_suggestion(&mut err, base_span)
&& !self.r.add_typo_suggestion(&mut err, typo_sugg, ident_span)
{
// Fallback label.
err.span_label(base_span, fallback_label);
self.type_ascription_suggestion(&mut err, base_span);
match self.diagnostic_metadata.current_let_binding {
Some((pat_sp, Some(ty_sp), None)) if ty_sp.contains(base_span) && could_be_expr => {
err.span_suggestion_short(
@ -518,6 +532,7 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
}),
) if followed_by_brace => {
if let Some(sp) = closing_brace {
err.span_label(span, fallback_label);
err.multipart_suggestion(
"surround the struct literal with parentheses",
vec![
@ -550,7 +565,7 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
}
_ => span,
};
if let Some(span) = self.r.opt_span(def_id) {
if let Some(span) = self.def_span(def_id) {
err.span_label(span, &format!("`{}` defined here", path_str));
}
let (tail, descr, applicability) = match source {
@ -581,12 +596,15 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
applicability,
);
}
_ => {}
_ => {
err.span_label(span, fallback_label);
}
}
};
match (res, source) {
(Res::Def(DefKind::Macro(MacroKind::Bang), _), _) => {
err.span_label(span, fallback_label);
err.span_suggestion_verbose(
span.shrink_to_hi(),
"use `!` to invoke the macro",
@ -602,7 +620,7 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
if nightly_options::is_nightly_build() {
let msg = "you might have meant to use `#![feature(trait_alias)]` instead of a \
`type` alias";
if let Some(span) = self.r.opt_span(def_id) {
if let Some(span) = self.def_span(def_id) {
err.span_help(span, msg);
} else {
err.help(msg);
@ -680,7 +698,7 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
bad_struct_syntax_suggestion(def_id);
}
(Res::Def(DefKind::Ctor(_, CtorKind::Fn), def_id), _) if ns == ValueNS => {
if let Some(span) = self.r.opt_span(def_id) {
if let Some(span) = self.def_span(def_id) {
err.span_label(span, &format!("`{}` defined here", path_str));
}
err.span_label(span, format!("did you mean `{}( /* fields */ )`?", path_str));
@ -869,7 +887,7 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
start.to(sm.next_point(start))
}
fn type_ascription_suggestion(&self, err: &mut DiagnosticBuilder<'_>, base_span: Span) {
fn type_ascription_suggestion(&self, err: &mut DiagnosticBuilder<'_>, base_span: Span) -> bool {
let sm = self.r.session.source_map();
let base_snippet = sm.span_to_snippet(base_span);
if let Some(&sp) = self.diagnostic_metadata.current_type_ascription.last() {
@ -939,9 +957,11 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
"expecting a type here because of type ascription",
);
}
return show_label;
}
}
}
false
}
fn find_module(&mut self, def_id: DefId) -> Option<(Module<'a>, ImportSuggestion)> {

View File

@ -2,10 +2,7 @@ error[E0573]: expected type, found const parameter `C`
--> $DIR/struct-with-invalid-const-param.rs:4:23
|
LL | struct S<const C: u8>(C);
| ----------------------^--
| | |
| | help: a struct with a similar name exists: `S`
| similarly named struct `S` defined here
| ^ not a type
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/struct-with-invalid-const-param.rs:1:12

View File

@ -12,14 +12,14 @@ LL | let e1 = Empty1;
LL | pub struct XEmpty2;
| ------------------- similarly named unit struct `XEmpty2` defined here
|
help: a unit struct with a similar name exists
|
LL | let e1 = XEmpty2;
| ^^^^^^^
help: use struct literal syntax instead
|
LL | let e1 = Empty1 {};
| ^^^^^^^^^
help: a unit struct with a similar name exists
|
LL | let e1 = XEmpty2;
| ^^^^^^^
error[E0423]: expected function, tuple struct or tuple variant, found struct `Empty1`
--> $DIR/empty-struct-braces-expr.rs:16:14
@ -29,15 +29,20 @@ LL | struct Empty1 {}
...
LL | let e1 = Empty1();
| ^^^^^^^^
|
::: $DIR/auxiliary/empty-struct.rs:2:1
|
help: a unit struct with a similar name exists
LL | pub struct XEmpty2;
| ------------------- similarly named unit struct `XEmpty2` defined here
|
LL | let e1 = XEmpty2();
| ^^^^^^^
help: use struct literal syntax instead
|
LL | let e1 = Empty1 {};
| ^^^^^^^^^
help: a unit struct with a similar name exists
|
LL | let e1 = XEmpty2();
| ^^^^^^^
error[E0423]: expected value, found struct variant `E::Empty3`
--> $DIR/empty-struct-braces-expr.rs:18:14
@ -63,34 +68,43 @@ error[E0423]: expected value, found struct `XEmpty1`
LL | let xe1 = XEmpty1;
| ^^^^^^^
|
::: $DIR/auxiliary/empty-struct.rs:2:1
::: $DIR/auxiliary/empty-struct.rs:1:1
|
LL | pub struct XEmpty1 {}
| ------------------ `XEmpty1` defined here
LL | pub struct XEmpty2;
| ------------------- similarly named unit struct `XEmpty2` defined here
|
help: a unit struct with a similar name exists
|
LL | let xe1 = XEmpty2;
| ^^^^^^^
help: use struct literal syntax instead
|
LL | let xe1 = XEmpty1 {};
| ^^^^^^^^^^
help: a unit struct with a similar name exists
|
LL | let xe1 = XEmpty2;
| ^^^^^^^
error[E0423]: expected function, tuple struct or tuple variant, found struct `XEmpty1`
--> $DIR/empty-struct-braces-expr.rs:23:15
|
LL | let xe1 = XEmpty1();
| ^^^^^^^^^
|
::: $DIR/auxiliary/empty-struct.rs:1:1
|
help: a unit struct with a similar name exists
LL | pub struct XEmpty1 {}
| ------------------ `XEmpty1` defined here
LL | pub struct XEmpty2;
| ------------------- similarly named unit struct `XEmpty2` defined here
|
LL | let xe1 = XEmpty2();
| ^^^^^^^
help: use struct literal syntax instead
|
LL | let xe1 = XEmpty1 {};
| ^^^^^^^^^^
help: a unit struct with a similar name exists
|
LL | let xe1 = XEmpty2();
| ^^^^^^^
error[E0599]: no variant or associated item named `Empty3` found for enum `empty_struct::XE` in the current scope
--> $DIR/empty-struct-braces-expr.rs:25:19

View File

@ -13,19 +13,21 @@ error[E0532]: expected unit struct, unit variant or constant, found struct varia
LL | XE::XEmpty3 => ()
| ^^^^^^^^^^^
|
::: $DIR/auxiliary/empty-struct.rs:7:5
::: $DIR/auxiliary/empty-struct.rs:6:5
|
LL | XEmpty3 {},
| ------- `XE::XEmpty3` defined here
LL | XEmpty4,
| ------- similarly named unit variant `XEmpty4` defined here
|
help: a unit variant with a similar name exists
|
LL | XE::XEmpty4 => ()
| ^^^^^^^
help: use struct pattern syntax instead
|
LL | XE::XEmpty3 { /* fields */ } => ()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: a unit variant with a similar name exists
|
LL | XE::XEmpty4 => ()
| ^^^^^^^
error: aborting due to 2 previous errors

View File

@ -6,30 +6,43 @@ LL | struct Empty1 {}
...
LL | Empty1() => ()
| ^^^^^^^^
|
::: $DIR/auxiliary/empty-struct.rs:3:1
|
help: a tuple struct with a similar name exists
LL | pub struct XEmpty6();
| --------------------- similarly named tuple struct `XEmpty6` defined here
|
LL | XEmpty6() => ()
| ^^^^^^^
help: use struct pattern syntax instead
|
LL | Empty1 {} => ()
| ^^^^^^^^^
help: a tuple struct with a similar name exists
|
LL | XEmpty6() => ()
| ^^^^^^^
error[E0532]: expected tuple struct or tuple variant, found struct `XEmpty1`
--> $DIR/empty-struct-braces-pat-2.rs:18:9
|
LL | XEmpty1() => ()
| ^^^^^^^^^
|
::: $DIR/auxiliary/empty-struct.rs:1:1
|
help: a tuple struct with a similar name exists
LL | pub struct XEmpty1 {}
| ------------------ `XEmpty1` defined here
LL | pub struct XEmpty2;
LL | pub struct XEmpty6();
| --------------------- similarly named tuple struct `XEmpty6` defined here
|
LL | XEmpty6() => ()
| ^^^^^^^
help: use struct pattern syntax instead
|
LL | XEmpty1 {} => ()
| ^^^^^^^^^^
help: a tuple struct with a similar name exists
|
LL | XEmpty6() => ()
| ^^^^^^^
error[E0532]: expected tuple struct or tuple variant, found struct `Empty1`
--> $DIR/empty-struct-braces-pat-2.rs:21:9
@ -39,30 +52,43 @@ LL | struct Empty1 {}
...
LL | Empty1(..) => ()
| ^^^^^^^^^^
|
::: $DIR/auxiliary/empty-struct.rs:3:1
|
help: a tuple struct with a similar name exists
LL | pub struct XEmpty6();
| --------------------- similarly named tuple struct `XEmpty6` defined here
|
LL | XEmpty6(..) => ()
| ^^^^^^^
help: use struct pattern syntax instead
|
LL | Empty1 {} => ()
| ^^^^^^^^^
help: a tuple struct with a similar name exists
|
LL | XEmpty6(..) => ()
| ^^^^^^^
error[E0532]: expected tuple struct or tuple variant, found struct `XEmpty1`
--> $DIR/empty-struct-braces-pat-2.rs:24:9
|
LL | XEmpty1(..) => ()
| ^^^^^^^^^^^
|
::: $DIR/auxiliary/empty-struct.rs:1:1
|
help: a tuple struct with a similar name exists
LL | pub struct XEmpty1 {}
| ------------------ `XEmpty1` defined here
LL | pub struct XEmpty2;
LL | pub struct XEmpty6();
| --------------------- similarly named tuple struct `XEmpty6` defined here
|
LL | XEmpty6(..) => ()
| ^^^^^^^
help: use struct pattern syntax instead
|
LL | XEmpty1 {} => ()
| ^^^^^^^^^^
help: a tuple struct with a similar name exists
|
LL | XEmpty6(..) => ()
| ^^^^^^^
error: aborting due to 4 previous errors

View File

@ -12,15 +12,23 @@ error[E0532]: expected tuple struct or tuple variant, found struct variant `XE::
|
LL | XE::XEmpty3() => ()
| ^^^^^^^^^^^^^
|
::: $DIR/auxiliary/empty-struct.rs:6:5
|
help: a tuple variant with a similar name exists
LL | XEmpty3 {},
| ------- `XE::XEmpty3` defined here
LL | XEmpty4,
LL | XEmpty5(),
| --------- similarly named tuple variant `XEmpty5` defined here
|
LL | XE::XEmpty5() => ()
| ^^^^^^^
help: use struct pattern syntax instead
|
LL | XE::XEmpty3 { /* fields */ } => ()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: a tuple variant with a similar name exists
|
LL | XE::XEmpty5() => ()
| ^^^^^^^
error[E0532]: expected tuple struct or tuple variant, found struct variant `E::Empty3`
--> $DIR/empty-struct-braces-pat-3.rs:25:9
@ -36,15 +44,23 @@ error[E0532]: expected tuple struct or tuple variant, found struct variant `XE::
|
LL | XE::XEmpty3(..) => ()
| ^^^^^^^^^^^^^^^
|
::: $DIR/auxiliary/empty-struct.rs:6:5
|
help: a tuple variant with a similar name exists
LL | XEmpty3 {},
| ------- `XE::XEmpty3` defined here
LL | XEmpty4,
LL | XEmpty5(),
| --------- similarly named tuple variant `XEmpty5` defined here
|
LL | XE::XEmpty5(..) => ()
| ^^^^^^^
help: use struct pattern syntax instead
|
LL | XE::XEmpty3 { /* fields */ } => ()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: a tuple variant with a similar name exists
|
LL | XE::XEmpty5(..) => ()
| ^^^^^^^
error: aborting due to 4 previous errors

View File

@ -38,6 +38,8 @@ LL | XE::XEmpty5 => (),
|
LL | XEmpty4,
| ------- similarly named unit variant `XEmpty4` defined here
LL | XEmpty5(),
| --------- `XE::XEmpty5` defined here
error: aborting due to 4 previous errors

View File

@ -34,21 +34,24 @@ LL | struct Foo { a: bool };
LL |
LL | let f = Foo();
| ^^^^^
...
LL | fn foo() {
| -------- similarly named function `foo` defined here
|
help: a function with a similar name exists
|
LL | let f = foo();
| ^^^
help: use struct literal syntax instead
|
LL | let f = Foo { a: val };
| ^^^^^^^^^^^^^^
help: a function with a similar name exists
|
LL | let f = foo();
| ^^^
error[E0423]: expected value, found struct `T`
--> $DIR/E0423.rs:14:8
|
LL | if T {} == T {} { println!("Ok"); }
| ^
| ^ not a value
|
help: surround the struct literal with parentheses
|

View File

@ -8,7 +8,7 @@ error[E0423]: expected value, found macro `semitransparent`
--> $DIR/rustc-macro-transparency.rs:29:5
|
LL | semitransparent;
| ^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^ not a value
|
help: use `!` to invoke the macro
|
@ -19,7 +19,7 @@ error[E0423]: expected value, found macro `opaque`
--> $DIR/rustc-macro-transparency.rs:30:5
|
LL | opaque;
| ^^^^^^
| ^^^^^^ not a value
|
help: use `!` to invoke the macro
|

View File

@ -1,10 +1,8 @@
error[E0425]: cannot find function `g` in this scope
--> $DIR/issue-31845.rs:7:12
|
LL | fn h() {
| ------ similarly named function `h` defined here
LL | g();
| ^ help: a function with a similar name exists: `h`
| ^ not found in this scope
error: aborting due to previous error

View File

@ -5,16 +5,7 @@ LL | struct X {}
| ----------- `X` defined here
LL |
LL | const Y: X = X("ö");
| ^^^^^^
|
help: a constant with a similar name exists
|
LL | const Y: X = Y("ö");
| ^
help: use struct literal syntax instead
|
LL | const Y: X = X {};
| ^^^^
| ^^^^^^ help: use struct literal syntax instead: `X {}`
error: aborting due to previous error

View File

@ -53,14 +53,14 @@ LL | TV(),
LL | check(m7::V);
| ^^^^^
|
help: a tuple variant with a similar name exists
|
LL | check(m7::TV);
| ^^
help: use struct literal syntax instead
|
LL | check(m7::V {});
| ^^^^^^^^
help: a tuple variant with a similar name exists
|
LL | check(m7::TV);
| ^^
help: consider importing one of these items instead
|
LL | use m8::V;
@ -74,19 +74,21 @@ error[E0423]: expected value, found struct variant `xm7::V`
LL | check(xm7::V);
| ^^^^^^
|
::: $DIR/auxiliary/namespace-mix.rs:7:9
::: $DIR/auxiliary/namespace-mix.rs:6:9
|
LL | V {},
| - `xm7::V` defined here
LL | TV(),
| ---- similarly named tuple variant `TV` defined here
|
help: a tuple variant with a similar name exists
|
LL | check(xm7::TV);
| ^^
help: use struct literal syntax instead
|
LL | check(xm7::V { /* fields */ });
| ^^^^^^^^^^^^^^^^^^^^^^^
help: a tuple variant with a similar name exists
|
LL | check(xm7::TV);
| ^^
help: consider importing one of these items instead
|
LL | use m8::V;

View File

@ -1,10 +1,8 @@
error[E0423]: expected function, tuple struct or tuple variant, found struct `S`
--> $DIR/legacy-ctor-visibility.rs:9:13
|
LL | fn f() {
| ------ similarly named function `f` defined here
LL | S(10);
| ^ help: a function with a similar name exists: `f`
| ^
error: aborting due to previous error

View File

@ -44,12 +44,8 @@ error[E0412]: cannot find type `Y` in this scope
--> $DIR/attributes-on-modules-fail.rs:10:14
|
LL | type A = Y;
| ---------^- similarly named type alias `A` defined here
| ^ not found in this scope
|
help: a type alias with a similar name exists
|
LL | type A = A;
| ^
help: consider importing this struct
|
LL | use Y;
@ -59,12 +55,8 @@ error[E0412]: cannot find type `X` in this scope
--> $DIR/attributes-on-modules-fail.rs:14:10
|
LL | type A = X;
| ---------^- similarly named type alias `A` defined here
| ^ not found in this scope
|
help: a type alias with a similar name exists
|
LL | type A = A;
| ^
help: consider importing this struct
|
LL | use m::X;

View File

@ -12,6 +12,11 @@ error[E0423]: expected value, found struct variant `issue_19452_aux::Homura::Mad
|
LL | let homura = issue_19452_aux::Homura::Madoka;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `issue_19452_aux::Homura::Madoka { /* fields */ }`
|
::: $DIR/auxiliary/issue-19452-aux.rs:2:5
|
LL | Madoka { age: u32 }
| ------ `issue_19452_aux::Homura::Madoka` defined here
error: aborting due to 2 previous errors

View File

@ -7,14 +7,14 @@ LL | struct Handle {}
LL | handle: Handle
| ^^^^^^
|
help: a local variable with a similar name exists
|
LL | handle: handle
| ^^^^^^
help: use struct literal syntax instead
|
LL | handle: Handle {}
| ^^^^^^^^^
help: a local variable with a similar name exists
|
LL | handle: handle
| ^^^^^^
error: aborting due to previous error

View File

@ -16,16 +16,9 @@ LL | m::Z::Unit;
error[E0423]: expected value, found enum `Z`
--> $DIR/privacy-enum-ctor.rs:25:9
|
LL | fn f() {
| ------ similarly named function `f` defined here
...
LL | Z;
| ^
|
help: a function with a similar name exists
|
LL | f;
| ^
help: try using one of the enum's variants
|
LL | m::Z::Fn;
@ -55,10 +48,6 @@ LL | fn f() {
LL | let _: E = m::E;
| ^^^^
|
help: a function with a similar name exists
|
LL | let _: E = m::f;
| ^
help: try using one of the enum's variants
|
LL | let _: E = E::Fn;
@ -67,6 +56,10 @@ LL | let _: E = E::Struct;
| ^^^^^^^^^
LL | let _: E = E::Unit;
| ^^^^^^^
help: a function with a similar name exists
|
LL | let _: E = m::f;
| ^
help: consider importing one of these items instead
|
LL | use std::f32::consts::E;

View File

@ -2,7 +2,7 @@ error[E0423]: expected function, found macro `assert`
--> $DIR/resolve-hint-macro.rs:2:5
|
LL | assert(true);
| ^^^^^^
| ^^^^^^ not a function
|
help: use `!` to invoke the macro
|

View File

@ -31,14 +31,14 @@ LL | pub const I: i32 = 1;
LL | a::b.J
| ^^^^
|
help: a constant with a similar name exists
|
LL | a::I.J
| ^
help: use the path separator to refer to an item
|
LL | a::b::J
|
help: a constant with a similar name exists
|
LL | a::I.J
| ^
error[E0423]: expected value, found module `a`
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:37:5
@ -68,14 +68,14 @@ LL | pub const I: i32 = 1;
LL | a::b.f()
| ^^^^
|
help: a constant with a similar name exists
|
LL | a::I.f()
| ^
help: use the path separator to refer to an item
|
LL | a::b::f()
| ^^^^^^^
help: a constant with a similar name exists
|
LL | a::I.f()
| ^
error[E0423]: expected value, found module `a::b`
--> $DIR/suggest-path-instead-of-mod-dot-item.rs:50:5

View File

@ -46,7 +46,7 @@ error[E0423]: expected value, found struct variant `E::V`
--> $DIR/struct-literal-variant-in-if.rs:10:13
|
LL | if x == E::V { field } {}
| ^^^^
| ^^^^ not a value
|
help: surround the struct literal with parentheses
|

View File

@ -9,14 +9,14 @@ LL | B { a: usize },
LL | let _: E = E::B;
| ^^^^
|
help: a tuple variant with a similar name exists
|
LL | let _: E = E::A;
| ^
help: use struct literal syntax instead
|
LL | let _: E = E::B { a: val };
| ^^^^^^^^^^^^^^^
help: a tuple variant with a similar name exists
|
LL | let _: E = E::A;
| ^
error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:29:20

View File

@ -11,7 +11,7 @@ error[E0574]: expected struct, variant or union type, found macro `try`
--> $DIR/try-block-in-edition2015.rs:4:33
|
LL | let try_result: Option<_> = try {
| ^^^
| ^^^ not a struct, variant or union type
|
= note: if you want the `try` keyword, you need to be in the 2018 edition
help: use `!` to invoke the macro

View File

@ -4,10 +4,7 @@ error[E0573]: expected type, found function `f`
LL | f() :
| - help: maybe you meant to write `;` here
LL | f();
| ^^^
| |
| not a type
| expecting a type here because of type ascription
| ^^^ expecting a type here because of type ascription
error: aborting due to previous error

View File

@ -2,10 +2,7 @@ error[E0412]: cannot find type `B` in this scope
--> $DIR/ui-testing-optout.rs:4:10
|
4 | type A = B;
| ---------^-
| | |
| | help: a type alias with a similar name exists: `A`
| similarly named type alias `A` defined here
| ^ not found in this scope
error[E0412]: cannot find type `D` in this scope
--> $DIR/ui-testing-optout.rs:7:10

View File

@ -3,6 +3,11 @@ error[E0423]: expected value, found struct `xcrate_unit_struct::StructWithFields
|
LL | let _ = xcrate_unit_struct::StructWithFields;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `xcrate_unit_struct::StructWithFields { foo: val }`
|
::: $DIR/auxiliary/xcrate_unit_struct.rs:20:1
|
LL | pub struct StructWithFields {
| --------------------------- `xcrate_unit_struct::StructWithFields` defined here
error: aborting due to previous error