Skip to content

Commit 0541b4e

Browse files
committed
use named_span in case of tuple variant
1 parent 3d1b679 commit 0541b4e

File tree

14 files changed

+26
-31
lines changed

14 files changed

+26
-31
lines changed

compiler/rustc_middle/src/hir/map/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1012,12 +1012,7 @@ impl<'hir> Map<'hir> {
10121012
ItemKind::Use(path, _) => path.span,
10131013
_ => named_span(item.span, item.ident, item.kind.generics()),
10141014
},
1015-
Node::Variant(variant) => match variant.data {
1016-
VariantData::Struct(..) | VariantData::Unit(..) => {
1017-
named_span(variant.span, variant.ident, None)
1018-
}
1019-
VariantData::Tuple(..) => variant.span,
1020-
},
1015+
Node::Variant(variant) => named_span(variant.span, variant.ident, None),
10211016
Node::ImplItem(item) => named_span(item.span, item.ident, Some(item.generics)),
10221017
Node::ForeignItem(item) => match item.kind {
10231018
ForeignItemKind::Fn(decl, _, _) => until_within(item.span, decl.output.span()),

compiler/rustc_trait_selection/src/traits/specialize/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ fn report_negative_positive_conflict(
341341
positive_impl_def_id: DefId,
342342
sg: &mut specialization_graph::Graph,
343343
) {
344-
let impl_span = tcx.span_of_impl(local_impl_def_id.to_def_id()).unwrap();
344+
let impl_span = tcx.def_span(local_impl_def_id);
345345

346346
let mut err = struct_span_err!(
347347
tcx.sess,

src/test/ui/empty/empty-struct-braces-pat-3.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ LL | XEmpty3 {},
1919
| ------- `XE::XEmpty3` defined here
2020
LL | XEmpty4,
2121
LL | XEmpty5(),
22-
| --------- similarly named tuple variant `XEmpty5` defined here
22+
| ------- similarly named tuple variant `XEmpty5` defined here
2323
|
2424
help: use struct pattern syntax instead
2525
|
@@ -51,7 +51,7 @@ LL | XEmpty3 {},
5151
| ------- `XE::XEmpty3` defined here
5252
LL | XEmpty4,
5353
LL | XEmpty5(),
54-
| --------- similarly named tuple variant `XEmpty5` defined here
54+
| ------- similarly named tuple variant `XEmpty5` defined here
5555
|
5656
help: use struct pattern syntax instead
5757
|

src/test/ui/empty/empty-struct-tuple-pat.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ LL | XE::XEmpty5 => (),
3636
LL | XEmpty4,
3737
| ------- similarly named unit variant `XEmpty4` defined here
3838
LL | XEmpty5(),
39-
| --------- `XE::XEmpty5` defined here
39+
| ------- `XE::XEmpty5` defined here
4040
|
4141
help: use the tuple variant pattern syntax instead
4242
|

src/test/ui/empty/empty-struct-unit-pat.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ LL | XE::XEmpty4() => (),
108108
LL | XEmpty4,
109109
| ------- `XE::XEmpty4` defined here
110110
LL | XEmpty5(),
111-
| --------- similarly named tuple variant `XEmpty5` defined here
111+
| ------- similarly named tuple variant `XEmpty5` defined here
112112
|
113113
help: use this syntax instead
114114
|
@@ -139,7 +139,7 @@ LL | XE::XEmpty4(..) => (),
139139
LL | XEmpty4,
140140
| ------- `XE::XEmpty4` defined here
141141
LL | XEmpty5(),
142-
| --------- similarly named tuple variant `XEmpty5` defined here
142+
| ------- similarly named tuple variant `XEmpty5` defined here
143143
|
144144
help: use this syntax instead
145145
|

src/test/ui/mismatched_types/issue-47706.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ error[E0593]: function is expected to take 0 arguments, but it takes 1 argument
1919
--> $DIR/issue-47706.rs:27:9
2020
|
2121
LL | Bar(i32),
22-
| -------- takes 1 argument
22+
| --- takes 1 argument
2323
...
2424
LL | foo(Qux::Bar);
2525
| --- ^^^^^^^^ expected function that takes 0 arguments

src/test/ui/namespace/namespace-mix.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ LL | check(xm7::V);
9494
LL | V {},
9595
| - `xm7::V` defined here
9696
LL | TV(),
97-
| ---- similarly named tuple variant `TV` defined here
97+
| -- similarly named tuple variant `TV` defined here
9898
|
9999
help: use struct literal syntax instead
100100
|

src/test/ui/pattern/pat-tuple-field-count-cross.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ LL | E1::Z0() => {}
6060
::: $DIR/auxiliary/declarations-for-tuple-field-count-errors.rs:11:15
6161
|
6262
LL | pub enum E1 { Z0, Z1(), S(u8, u8, u8) }
63-
| -- ---- similarly named tuple variant `Z1` defined here
63+
| -- -- similarly named tuple variant `Z1` defined here
6464
| |
6565
| `E1::Z0` defined here
6666
|
@@ -82,7 +82,7 @@ LL | E1::Z0(x) => {}
8282
::: $DIR/auxiliary/declarations-for-tuple-field-count-errors.rs:11:15
8383
|
8484
LL | pub enum E1 { Z0, Z1(), S(u8, u8, u8) }
85-
| -- ---- similarly named tuple variant `Z1` defined here
85+
| -- -- similarly named tuple variant `Z1` defined here
8686
| |
8787
| `E1::Z0` defined here
8888
|
@@ -104,7 +104,7 @@ LL | E1::Z1 => {}
104104
::: $DIR/auxiliary/declarations-for-tuple-field-count-errors.rs:11:19
105105
|
106106
LL | pub enum E1 { Z0, Z1(), S(u8, u8, u8) }
107-
| -- ---- `E1::Z1` defined here
107+
| -- -- `E1::Z1` defined here
108108
| |
109109
| similarly named unit variant `Z0` defined here
110110
|
@@ -295,7 +295,7 @@ LL | E1::Z1(x) => {}
295295
::: $DIR/auxiliary/declarations-for-tuple-field-count-errors.rs:11:19
296296
|
297297
LL | pub enum E1 { Z0, Z1(), S(u8, u8, u8) }
298-
| ---- tuple variant has 0 fields
298+
| -- tuple variant has 0 fields
299299

300300
error[E0023]: this pattern has 0 fields, but the corresponding tuple variant has 3 fields
301301
--> $DIR/pat-tuple-field-count-cross.rs:39:9

src/test/ui/pattern/pat-tuple-overfield.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ error[E0023]: this pattern has 1 field, but the corresponding tuple variant has
289289
--> $DIR/pat-tuple-overfield.rs:71:16
290290
|
291291
LL | Z1(),
292-
| ---- tuple variant has 0 fields
292+
| -- tuple variant has 0 fields
293293
...
294294
LL | E1::Z1(_) => {}
295295
| ^ expected 0 fields, found 1
@@ -298,7 +298,7 @@ error[E0023]: this pattern has 2 fields, but the corresponding tuple variant has
298298
--> $DIR/pat-tuple-overfield.rs:72:16
299299
|
300300
LL | Z1(),
301-
| ---- tuple variant has 0 fields
301+
| -- tuple variant has 0 fields
302302
...
303303
LL | E1::Z1(_, _) => {}
304304
| ^ ^ expected 0 fields, found 2

src/test/ui/proc-macro/parent-source-spans.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ LL | one!("hello", "world");
148148
::: $SRC_DIR/core/src/result.rs:LL:COL
149149
|
150150
LL | Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
151-
| --------------------------------------------------- similarly named tuple variant `Ok` defined here
151+
| -- similarly named tuple variant `Ok` defined here
152152
|
153153
= note: this error originates in the macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info)
154154

@@ -164,7 +164,7 @@ LL | two!("yay", "rust");
164164
::: $SRC_DIR/core/src/result.rs:LL:COL
165165
|
166166
LL | Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
167-
| --------------------------------------------------- similarly named tuple variant `Ok` defined here
167+
| -- similarly named tuple variant `Ok` defined here
168168
|
169169
= note: this error originates in the macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info)
170170

@@ -180,7 +180,7 @@ LL | three!("hip", "hop");
180180
::: $SRC_DIR/core/src/result.rs:LL:COL
181181
|
182182
LL | Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
183-
| --------------------------------------------------- similarly named tuple variant `Ok` defined here
183+
| -- similarly named tuple variant `Ok` defined here
184184
|
185185
= note: this error originates in the macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info)
186186

src/test/ui/repr/repr-transparent.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ error[E0731]: transparent enum needs exactly one variant, but has 2
5858
LL | enum MultipleVariants {
5959
| ^^^^^^^^^^^^^^^^^^^^^ needs exactly one variant, but has 2
6060
LL | Foo(String),
61-
| -----------
61+
| ---
6262
LL | Bar,
6363
| --- too many variants in `MultipleVariants`
6464

src/test/ui/resolve/privacy-enum-ctor.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ error[E0308]: mismatched types
318318
--> $DIR/privacy-enum-ctor.rs:27:20
319319
|
320320
LL | Fn(u8),
321-
| ------ fn(u8) -> Z {Z::Fn} defined here
321+
| -- fn(u8) -> Z {Z::Fn} defined here
322322
...
323323
LL | let _: Z = Z::Fn;
324324
| - ^^^^^ expected enum `Z`, found fn item
@@ -353,7 +353,7 @@ error[E0308]: mismatched types
353353
--> $DIR/privacy-enum-ctor.rs:43:16
354354
|
355355
LL | Fn(u8),
356-
| ------ fn(u8) -> E {E::Fn} defined here
356+
| -- fn(u8) -> E {E::Fn} defined here
357357
...
358358
LL | let _: E = m::E::Fn;
359359
| - ^^^^^^^^ expected enum `E`, found fn item
@@ -388,7 +388,7 @@ error[E0308]: mismatched types
388388
--> $DIR/privacy-enum-ctor.rs:51:16
389389
|
390390
LL | Fn(u8),
391-
| ------ fn(u8) -> E {E::Fn} defined here
391+
| -- fn(u8) -> E {E::Fn} defined here
392392
...
393393
LL | let _: E = E::Fn;
394394
| - ^^^^^ expected enum `E`, found fn item

src/test/ui/rfc-2008-non-exhaustive/variant.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ note: the tuple variant `Tuple` is defined here
88
--> $DIR/auxiliary/variants.rs:5:23
99
|
1010
LL | #[non_exhaustive] Tuple(u32),
11-
| ^^^^^^^^^^
11+
| ^^^^^
1212

1313
error[E0603]: unit variant `Unit` is private
1414
--> $DIR/variant.rs:14:47
@@ -44,7 +44,7 @@ note: the tuple variant `Tuple` is defined here
4444
--> $DIR/auxiliary/variants.rs:5:23
4545
|
4646
LL | #[non_exhaustive] Tuple(u32),
47-
| ^^^^^^^^^^
47+
| ^^^^^
4848

4949
error[E0603]: tuple variant `Tuple` is private
5050
--> $DIR/variant.rs:26:35
@@ -56,7 +56,7 @@ note: the tuple variant `Tuple` is defined here
5656
--> $DIR/auxiliary/variants.rs:5:23
5757
|
5858
LL | #[non_exhaustive] Tuple(u32),
59-
| ^^^^^^^^^^
59+
| ^^^^^
6060

6161
error[E0639]: cannot create non-exhaustive variant using struct expression
6262
--> $DIR/variant.rs:8:26

src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ error[E0308]: mismatched types
130130
--> $DIR/fn-or-tuple-struct-without-args.rs:35:16
131131
|
132132
LL | A(usize),
133-
| -------- fn(usize) -> E {E::A} defined here
133+
| - fn(usize) -> E {E::A} defined here
134134
...
135135
LL | let _: E = E::A;
136136
| - ^^^^ expected enum `E`, found fn item

0 commit comments

Comments
 (0)