Skip to content

Commit 9eb70c3

Browse files
committed
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.
1 parent 4ecf12b commit 9eb70c3

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Diff for: src/librustc_typeck/check/method/suggest.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
195195
let ty_string = self.ty_to_string(actual);
196196
let is_method = mode == Mode::MethodCall;
197197
let mut suggestion = None;
198-
let type_str = if is_method {
198+
let item_kind = if is_method {
199199
"method"
200200
} else if actual.is_enum() {
201201
if let TyAdt(ref adt_def, _) = actual.sty {
@@ -235,7 +235,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
235235
span,
236236
E0689,
237237
"can't call {} `{}` on ambiguous numeric type `{}`",
238-
type_str,
238+
item_kind,
239239
item_name,
240240
ty_string
241241
);
@@ -284,12 +284,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
284284
span,
285285
E0599,
286286
"no {} named `{}` found for type `{}` in the current scope",
287-
type_str,
287+
item_kind,
288288
item_name,
289289
ty_string
290290
);
291291
if let Some(suggestion) = suggestion {
292-
err.note(&format!("did you mean `{}::{}`?", type_str, suggestion));
292+
err.note(&format!("did you mean `{}::{}`?", ty_string, suggestion));
293293
}
294294
err
295295
}
@@ -301,7 +301,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
301301
if let Some(full_sp) = tcx.hir.span_if_local(def.did) {
302302
let def_sp = tcx.sess.codemap().def_span(full_sp);
303303
err.span_label(def_sp, format!("{} `{}` not found {}",
304-
type_str,
304+
item_kind,
305305
item_name,
306306
if def.is_enum() && !is_method {
307307
"here"
@@ -355,7 +355,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
355355
}
356356
}
357357
} else {
358-
err.span_label(span, format!("{} not found in `{}`", type_str, ty_string));
358+
err.span_label(span, format!("{} not found in `{}`", item_kind, ty_string));
359359
}
360360

361361
if self.is_fn_ty(&rcvr_ty, span) {

Diff for: src/test/ui/issue-23217.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | pub enum SomeEnum {
66
LL | B = SomeEnum::A,
77
| ^^^^^^^^^^^ variant not found in `SomeEnum`
88
|
9-
= note: did you mean `variant::B`?
9+
= note: did you mean `SomeEnum::B`?
1010

1111
error: aborting due to previous error
1212

Diff for: src/test/ui/issue-28971.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | enum Foo {
77
LL | Foo::Baz(..) => (),
88
| ^^^^^^^^^^^^ variant not found in `Foo`
99
|
10-
= note: did you mean `variant::Bar`?
10+
= note: did you mean `Foo::Bar`?
1111

1212
error: aborting due to previous error
1313

0 commit comments

Comments
 (0)