about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAndy Russell <arussell123@gmail.com>2018-06-02 16:23:26 -0400
committerAndy Russell <arussell123@gmail.com>2018-06-02 16:58:49 -0400
commit9eb70c3cf5c36b71db409ec845dddb7b7da5d587 (patch)
tree36eec05548d5746feaf46c7eeb41cf70cf5c9cfc /src
parent4ecf12bf0eb8386626ccdb5f721a7183ccc4eba6 (diff)
downloadrust-9eb70c3cf5c36b71db409ec845dddb7b7da5d587.tar.gz
rust-9eb70c3cf5c36b71db409ec845dddb7b7da5d587.zip
use type name in E0599 enum variant suggestion
Also, rename the variable from "type_str" to "item_kind" to avoid
the ambiguity that caused this bug.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_typeck/check/method/suggest.rs12
-rw-r--r--src/test/ui/issue-23217.stderr2
-rw-r--r--src/test/ui/issue-28971.stderr2
3 files changed, 8 insertions, 8 deletions
diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs
index 6031984350b..86cd8d0fb2c 100644
--- a/src/librustc_typeck/check/method/suggest.rs
+++ b/src/librustc_typeck/check/method/suggest.rs
@@ -195,7 +195,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                 let ty_string = self.ty_to_string(actual);
                 let is_method = mode == Mode::MethodCall;
                 let mut suggestion = None;
-                let type_str = if is_method {
+                let item_kind = if is_method {
                     "method"
                 } else if actual.is_enum() {
                     if let TyAdt(ref adt_def, _) = actual.sty {
@@ -235,7 +235,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                             span,
                             E0689,
                             "can't call {} `{}` on ambiguous numeric type `{}`",
-                            type_str,
+                            item_kind,
                             item_name,
                             ty_string
                         );
@@ -284,12 +284,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                             span,
                             E0599,
                             "no {} named `{}` found for type `{}` in the current scope",
-                            type_str,
+                            item_kind,
                             item_name,
                             ty_string
                         );
                         if let Some(suggestion) = suggestion {
-                            err.note(&format!("did you mean `{}::{}`?", type_str, suggestion));
+                            err.note(&format!("did you mean `{}::{}`?", ty_string, suggestion));
                         }
                         err
                     }
@@ -301,7 +301,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                     if let Some(full_sp) = tcx.hir.span_if_local(def.did) {
                         let def_sp = tcx.sess.codemap().def_span(full_sp);
                         err.span_label(def_sp, format!("{} `{}` not found {}",
-                                                       type_str,
+                                                       item_kind,
                                                        item_name,
                                                        if def.is_enum() && !is_method {
                                                            "here"
@@ -355,7 +355,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                         }
                     }
                 } else {
-                    err.span_label(span, format!("{} not found in `{}`", type_str, ty_string));
+                    err.span_label(span, format!("{} not found in `{}`", item_kind, ty_string));
                 }
 
                 if self.is_fn_ty(&rcvr_ty, span) {
diff --git a/src/test/ui/issue-23217.stderr b/src/test/ui/issue-23217.stderr
index d542a10e9b6..d87f239bca6 100644
--- a/src/test/ui/issue-23217.stderr
+++ b/src/test/ui/issue-23217.stderr
@@ -6,7 +6,7 @@ LL | pub enum SomeEnum {
 LL |     B = SomeEnum::A,
    |         ^^^^^^^^^^^ variant not found in `SomeEnum`
    |
-   = note: did you mean `variant::B`?
+   = note: did you mean `SomeEnum::B`?
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issue-28971.stderr b/src/test/ui/issue-28971.stderr
index df114351ff5..c04e21f7c58 100644
--- a/src/test/ui/issue-28971.stderr
+++ b/src/test/ui/issue-28971.stderr
@@ -7,7 +7,7 @@ LL | enum Foo {
 LL |             Foo::Baz(..) => (),
    |             ^^^^^^^^^^^^ variant not found in `Foo`
    |
-   = note: did you mean `variant::Bar`?
+   = note: did you mean `Foo::Bar`?
 
 error: aborting due to previous error