Skip to content

Commit cb1b6c9

Browse files
authored
Rollup merge of rust-lang#62817 - estebank:variant-sp, r=matthewjasper
Tweak span for variant not found error
2 parents b704be5 + 2641bed commit cb1b6c9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/librustc_typeck/astconv.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
16501650
Applicability::MaybeIncorrect,
16511651
);
16521652
} else {
1653-
err.span_label(span, format!("variant not found in `{}`", qself_ty));
1653+
err.span_label(
1654+
assoc_ident.span,
1655+
format!("variant not found in `{}`", qself_ty),
1656+
);
16541657
}
16551658

16561659
if let Some(sp) = tcx.hir().span_if_local(adt_def.did) {

src/test/ui/suggestions/suggest-variants.stderr

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ LL | enum Shape {
2323
| ---------- variant `Rombus` not found here
2424
...
2525
LL | println!("My shape is {:?}", Shape::Rombus{ size: 5});
26-
| -------^^^^^^
27-
| |
28-
| variant not found in `Shape`
26+
| ^^^^^^ variant not found in `Shape`
2927

3028
error[E0599]: no variant or associated item named `Squareee` found for type `Shape` in the current scope
3129
--> $DIR/suggest-variants.rs:15:12

0 commit comments

Comments
 (0)