use named_span
in case of tuple variant
This commit is contained in:
parent
3d1b679a3c
commit
0541b4e034
14 changed files with 26 additions and 31 deletions
|
@ -1012,12 +1012,7 @@ impl<'hir> Map<'hir> {
|
|||
ItemKind::Use(path, _) => path.span,
|
||||
_ => named_span(item.span, item.ident, item.kind.generics()),
|
||||
},
|
||||
Node::Variant(variant) => match variant.data {
|
||||
VariantData::Struct(..) | VariantData::Unit(..) => {
|
||||
named_span(variant.span, variant.ident, None)
|
||||
}
|
||||
VariantData::Tuple(..) => variant.span,
|
||||
},
|
||||
Node::Variant(variant) => named_span(variant.span, variant.ident, None),
|
||||
Node::ImplItem(item) => named_span(item.span, item.ident, Some(item.generics)),
|
||||
Node::ForeignItem(item) => match item.kind {
|
||||
ForeignItemKind::Fn(decl, _, _) => until_within(item.span, decl.output.span()),
|
||||
|
|
|
@ -341,7 +341,7 @@ fn report_negative_positive_conflict(
|
|||
positive_impl_def_id: DefId,
|
||||
sg: &mut specialization_graph::Graph,
|
||||
) {
|
||||
let impl_span = tcx.span_of_impl(local_impl_def_id.to_def_id()).unwrap();
|
||||
let impl_span = tcx.def_span(local_impl_def_id);
|
||||
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
|
|
|
@ -19,7 +19,7 @@ LL | XEmpty3 {},
|
|||
| ------- `XE::XEmpty3` defined here
|
||||
LL | XEmpty4,
|
||||
LL | XEmpty5(),
|
||||
| --------- similarly named tuple variant `XEmpty5` defined here
|
||||
| ------- similarly named tuple variant `XEmpty5` defined here
|
||||
|
|
||||
help: use struct pattern syntax instead
|
||||
|
|
||||
|
@ -51,7 +51,7 @@ LL | XEmpty3 {},
|
|||
| ------- `XE::XEmpty3` defined here
|
||||
LL | XEmpty4,
|
||||
LL | XEmpty5(),
|
||||
| --------- similarly named tuple variant `XEmpty5` defined here
|
||||
| ------- similarly named tuple variant `XEmpty5` defined here
|
||||
|
|
||||
help: use struct pattern syntax instead
|
||||
|
|
||||
|
|
|
@ -36,7 +36,7 @@ LL | XE::XEmpty5 => (),
|
|||
LL | XEmpty4,
|
||||
| ------- similarly named unit variant `XEmpty4` defined here
|
||||
LL | XEmpty5(),
|
||||
| --------- `XE::XEmpty5` defined here
|
||||
| ------- `XE::XEmpty5` defined here
|
||||
|
|
||||
help: use the tuple variant pattern syntax instead
|
||||
|
|
||||
|
|
|
@ -108,7 +108,7 @@ LL | XE::XEmpty4() => (),
|
|||
LL | XEmpty4,
|
||||
| ------- `XE::XEmpty4` defined here
|
||||
LL | XEmpty5(),
|
||||
| --------- similarly named tuple variant `XEmpty5` defined here
|
||||
| ------- similarly named tuple variant `XEmpty5` defined here
|
||||
|
|
||||
help: use this syntax instead
|
||||
|
|
||||
|
@ -139,7 +139,7 @@ LL | XE::XEmpty4(..) => (),
|
|||
LL | XEmpty4,
|
||||
| ------- `XE::XEmpty4` defined here
|
||||
LL | XEmpty5(),
|
||||
| --------- similarly named tuple variant `XEmpty5` defined here
|
||||
| ------- similarly named tuple variant `XEmpty5` defined here
|
||||
|
|
||||
help: use this syntax instead
|
||||
|
|
||||
|
|
|
@ -19,7 +19,7 @@ error[E0593]: function is expected to take 0 arguments, but it takes 1 argument
|
|||
--> $DIR/issue-47706.rs:27:9
|
||||
|
|
||||
LL | Bar(i32),
|
||||
| -------- takes 1 argument
|
||||
| --- takes 1 argument
|
||||
...
|
||||
LL | foo(Qux::Bar);
|
||||
| --- ^^^^^^^^ expected function that takes 0 arguments
|
||||
|
|
|
@ -94,7 +94,7 @@ LL | check(xm7::V);
|
|||
LL | V {},
|
||||
| - `xm7::V` defined here
|
||||
LL | TV(),
|
||||
| ---- similarly named tuple variant `TV` defined here
|
||||
| -- similarly named tuple variant `TV` defined here
|
||||
|
|
||||
help: use struct literal syntax instead
|
||||
|
|
||||
|
|
|
@ -60,7 +60,7 @@ LL | E1::Z0() => {}
|
|||
::: $DIR/auxiliary/declarations-for-tuple-field-count-errors.rs:11:15
|
||||
|
|
||||
LL | pub enum E1 { Z0, Z1(), S(u8, u8, u8) }
|
||||
| -- ---- similarly named tuple variant `Z1` defined here
|
||||
| -- -- similarly named tuple variant `Z1` defined here
|
||||
| |
|
||||
| `E1::Z0` defined here
|
||||
|
|
||||
|
@ -82,7 +82,7 @@ LL | E1::Z0(x) => {}
|
|||
::: $DIR/auxiliary/declarations-for-tuple-field-count-errors.rs:11:15
|
||||
|
|
||||
LL | pub enum E1 { Z0, Z1(), S(u8, u8, u8) }
|
||||
| -- ---- similarly named tuple variant `Z1` defined here
|
||||
| -- -- similarly named tuple variant `Z1` defined here
|
||||
| |
|
||||
| `E1::Z0` defined here
|
||||
|
|
||||
|
@ -104,7 +104,7 @@ LL | E1::Z1 => {}
|
|||
::: $DIR/auxiliary/declarations-for-tuple-field-count-errors.rs:11:19
|
||||
|
|
||||
LL | pub enum E1 { Z0, Z1(), S(u8, u8, u8) }
|
||||
| -- ---- `E1::Z1` defined here
|
||||
| -- -- `E1::Z1` defined here
|
||||
| |
|
||||
| similarly named unit variant `Z0` defined here
|
||||
|
|
||||
|
@ -295,7 +295,7 @@ LL | E1::Z1(x) => {}
|
|||
::: $DIR/auxiliary/declarations-for-tuple-field-count-errors.rs:11:19
|
||||
|
|
||||
LL | pub enum E1 { Z0, Z1(), S(u8, u8, u8) }
|
||||
| ---- tuple variant has 0 fields
|
||||
| -- tuple variant has 0 fields
|
||||
|
||||
error[E0023]: this pattern has 0 fields, but the corresponding tuple variant has 3 fields
|
||||
--> $DIR/pat-tuple-field-count-cross.rs:39:9
|
||||
|
|
|
@ -289,7 +289,7 @@ error[E0023]: this pattern has 1 field, but the corresponding tuple variant has
|
|||
--> $DIR/pat-tuple-overfield.rs:71:16
|
||||
|
|
||||
LL | Z1(),
|
||||
| ---- tuple variant has 0 fields
|
||||
| -- tuple variant has 0 fields
|
||||
...
|
||||
LL | E1::Z1(_) => {}
|
||||
| ^ expected 0 fields, found 1
|
||||
|
@ -298,7 +298,7 @@ error[E0023]: this pattern has 2 fields, but the corresponding tuple variant has
|
|||
--> $DIR/pat-tuple-overfield.rs:72:16
|
||||
|
|
||||
LL | Z1(),
|
||||
| ---- tuple variant has 0 fields
|
||||
| -- tuple variant has 0 fields
|
||||
...
|
||||
LL | E1::Z1(_, _) => {}
|
||||
| ^ ^ expected 0 fields, found 2
|
||||
|
|
|
@ -148,7 +148,7 @@ LL | one!("hello", "world");
|
|||
::: $SRC_DIR/core/src/result.rs:LL:COL
|
||||
|
|
||||
LL | Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
|
||||
| --------------------------------------------------- similarly named tuple variant `Ok` defined here
|
||||
| -- similarly named tuple variant `Ok` defined here
|
||||
|
|
||||
= note: this error originates in the macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
|
@ -164,7 +164,7 @@ LL | two!("yay", "rust");
|
|||
::: $SRC_DIR/core/src/result.rs:LL:COL
|
||||
|
|
||||
LL | Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
|
||||
| --------------------------------------------------- similarly named tuple variant `Ok` defined here
|
||||
| -- similarly named tuple variant `Ok` defined here
|
||||
|
|
||||
= note: this error originates in the macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
|
@ -180,7 +180,7 @@ LL | three!("hip", "hop");
|
|||
::: $SRC_DIR/core/src/result.rs:LL:COL
|
||||
|
|
||||
LL | Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
|
||||
| --------------------------------------------------- similarly named tuple variant `Ok` defined here
|
||||
| -- similarly named tuple variant `Ok` defined here
|
||||
|
|
||||
= note: this error originates in the macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ error[E0731]: transparent enum needs exactly one variant, but has 2
|
|||
LL | enum MultipleVariants {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ needs exactly one variant, but has 2
|
||||
LL | Foo(String),
|
||||
| -----------
|
||||
| ---
|
||||
LL | Bar,
|
||||
| --- too many variants in `MultipleVariants`
|
||||
|
||||
|
|
|
@ -318,7 +318,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/privacy-enum-ctor.rs:27:20
|
||||
|
|
||||
LL | Fn(u8),
|
||||
| ------ fn(u8) -> Z {Z::Fn} defined here
|
||||
| -- fn(u8) -> Z {Z::Fn} defined here
|
||||
...
|
||||
LL | let _: Z = Z::Fn;
|
||||
| - ^^^^^ expected enum `Z`, found fn item
|
||||
|
@ -353,7 +353,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/privacy-enum-ctor.rs:43:16
|
||||
|
|
||||
LL | Fn(u8),
|
||||
| ------ fn(u8) -> E {E::Fn} defined here
|
||||
| -- fn(u8) -> E {E::Fn} defined here
|
||||
...
|
||||
LL | let _: E = m::E::Fn;
|
||||
| - ^^^^^^^^ expected enum `E`, found fn item
|
||||
|
@ -388,7 +388,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/privacy-enum-ctor.rs:51:16
|
||||
|
|
||||
LL | Fn(u8),
|
||||
| ------ fn(u8) -> E {E::Fn} defined here
|
||||
| -- fn(u8) -> E {E::Fn} defined here
|
||||
...
|
||||
LL | let _: E = E::Fn;
|
||||
| - ^^^^^ expected enum `E`, found fn item
|
||||
|
|
|
@ -8,7 +8,7 @@ note: the tuple variant `Tuple` is defined here
|
|||
--> $DIR/auxiliary/variants.rs:5:23
|
||||
|
|
||||
LL | #[non_exhaustive] Tuple(u32),
|
||||
| ^^^^^^^^^^
|
||||
| ^^^^^
|
||||
|
||||
error[E0603]: unit variant `Unit` is private
|
||||
--> $DIR/variant.rs:14:47
|
||||
|
@ -44,7 +44,7 @@ note: the tuple variant `Tuple` is defined here
|
|||
--> $DIR/auxiliary/variants.rs:5:23
|
||||
|
|
||||
LL | #[non_exhaustive] Tuple(u32),
|
||||
| ^^^^^^^^^^
|
||||
| ^^^^^
|
||||
|
||||
error[E0603]: tuple variant `Tuple` is private
|
||||
--> $DIR/variant.rs:26:35
|
||||
|
@ -56,7 +56,7 @@ note: the tuple variant `Tuple` is defined here
|
|||
--> $DIR/auxiliary/variants.rs:5:23
|
||||
|
|
||||
LL | #[non_exhaustive] Tuple(u32),
|
||||
| ^^^^^^^^^^
|
||||
| ^^^^^
|
||||
|
||||
error[E0639]: cannot create non-exhaustive variant using struct expression
|
||||
--> $DIR/variant.rs:8:26
|
||||
|
|
|
@ -130,7 +130,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/fn-or-tuple-struct-without-args.rs:35:16
|
||||
|
|
||||
LL | A(usize),
|
||||
| -------- fn(usize) -> E {E::A} defined here
|
||||
| - fn(usize) -> E {E::A} defined here
|
||||
...
|
||||
LL | let _: E = E::A;
|
||||
| - ^^^^ expected enum `E`, found fn item
|
||||
|
|
Loading…
Add table
Reference in a new issue