diff options
author | Alexander Regueiro <alexreg@me.com> | 2018-12-18 18:59:00 +0000 |
---|---|---|
committer | Alexander Regueiro <alexreg@me.com> | 2018-12-26 21:54:18 +0000 |
commit | fa07e6238985a329d82ee09de7587f7f90c7a4d2 (patch) | |
tree | 6bcdcf4ad0153547fd7b99fcb3b853fad8dabd8e | |
parent | 8eb1a9e4e7337dd17827e00f0e1d2e10f11de30c (diff) | |
download | rust-fa07e6238985a329d82ee09de7587f7f90c7a4d2.tar.gz |
Fixed handling of unit variants of aliased enums in type NS.
-rw-r--r-- | src/librustc_typeck/astconv.rs | 152 | ||||
-rw-r--r-- | src/librustc_typeck/check/mod.rs | 132 | ||||
-rw-r--r-- | src/test/run-pass/enum-variant-generic-args.rs | 6 | ||||
-rw-r--r-- | src/test/ui/enum-variant-generic-args.rs | 21 | ||||
-rw-r--r-- | src/test/ui/enum-variant-generic-args.stderr | 198 |
5 files changed, 215 insertions, 294 deletions
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 2679f033772..98013dd00dc 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -32,6 +32,10 @@ use std::iter; use std::slice; use super::{check_type_alias_enum_variants_enabled}; +use rustc_data_structures::fx::FxHashSet; + +#[derive(Debug)] +pub struct PathSeg(pub DefId, pub usize); pub trait AstConv<'gcx, 'tcx> { fn tcx<'a>(&'a self) -> TyCtxt<'a, 'gcx, 'tcx>; @@ -1470,6 +1474,134 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { err.span_label(span, "associated type not allowed here").emit(); } + pub fn def_ids_for_path_segments(&self, + segments: &[hir::PathSegment], + self_ty: Option<Ty<'tcx>>, + def: Def) + -> Vec<PathSeg> { + // We need to extract the type parameters supplied by the user in + // the path `path`. Due to the current setup, this is a bit of a + // tricky-process; the problem is that resolve only tells us the + // end-point of the path resolution, and not the intermediate steps. + // Luckily, we can (at least for now) deduce the intermediate steps + // just from the end-point. + // + // There are basically five cases to consider: + // + // 1. Reference to a constructor of a struct: + // + // struct Foo<T>(...) + // + // In this case, the parameters are declared in the type space. + // + // 2. Reference to a constructor of an enum variant: + // + // enum E<T> { Foo(...) } + // + // In this case, the parameters are defined in the type space, + // but may be specified either on the type or the variant. + // + // 3. Reference to a fn item or a free constant: + // + // fn foo<T>() { } + // + // In this case, the path will again always have the form + // `a::b::foo::<T>` where only the final segment should have + // type parameters. However, in this case, those parameters are + // declared on a value, and hence are in the `FnSpace`. + // + // 4. Reference to a method or an associated constant: + // + // impl<A> SomeStruct<A> { + // fn foo<B>(...) + // } + // + // Here we can have a path like + // `a::b::SomeStruct::<A>::foo::<B>`, in which case parameters + // may appear in two places. The penultimate segment, + // `SomeStruct::<A>`, contains parameters in TypeSpace, and the + // final segment, `foo::<B>` contains parameters in fn space. + // + // 5. Reference to a local variable + // + // Local variables can't have any type parameters. + // + // The first step then is to categorize the segments appropriately. + + let tcx = self.tcx(); + + assert!(!segments.is_empty()); + let last = segments.len() - 1; + + let mut path_segs = vec![]; + + match def { + // Case 1. Reference to a struct constructor. + Def::StructCtor(def_id, ..) | + Def::SelfCtor(.., def_id) => { + // Everything but the final segment should have no + // parameters at all. + let generics = tcx.generics_of(def_id); + // Variant and struct constructors use the + // generics of their parent type definition. + let generics_def_id = generics.parent.unwrap_or(def_id); + path_segs.push(PathSeg(generics_def_id, last)); + } + + // Case 2. Reference to a variant constructor. + Def::Variant(def_id) | + Def::VariantCtor(def_id, ..) => { + let adt_def = self_ty.and_then(|t| t.ty_adt_def()); + let (generics_def_id, index) = if let Some(adt_def) = adt_def { + debug_assert!(adt_def.is_enum()); + (adt_def.did, last) + } else if last >= 1 && segments[last - 1].args.is_some() { + // Everything but the penultimate segment should have no + // parameters at all. + let enum_def_id = tcx.parent_def_id(def_id).unwrap(); + (enum_def_id, last - 1) + } else { + // FIXME: lint here recommending `Enum::<...>::Variant` form + // instead of `Enum::Variant::<...>` form. + + // Everything but the final segment should have no + // parameters at all. + let generics = tcx.generics_of(def_id); + // Variant and struct constructors use the + // generics of their parent type definition. + (generics.parent.unwrap_or(def_id), last) + }; + path_segs.push(PathSeg(generics_def_id, index)); + } + + // Case 3. Reference to a top-level value. + Def::Fn(def_id) | + Def::Const(def_id) | + Def::Static(def_id, _) => { + path_segs.push(PathSeg(def_id, last)); + } + + // Case 4. Reference to a method or associated const. + Def::Method(def_id) | + Def::AssociatedConst(def_id) => { + if segments.len() >= 2 { + let generics = tcx.generics_of(def_id); + path_segs.push(PathSeg(generics.parent.unwrap(), last - 1)); + } + path_segs.push(PathSeg(def_id, last)); + } + + // Case 5. Local variable, no generics. + Def::Local(..) | Def::Upvar(..) => {} + + _ => bug!("unexpected definition: {:?}", def), + } + + debug!("path_segs = {:?}", path_segs); + + path_segs + } + // Check a type `Path` and convert it to a `Ty`. pub fn def_to_ty(&self, opt_self_ty: Option<Ty<'tcx>>, @@ -1500,14 +1632,24 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { self.prohibit_generics(path.segments.split_last().unwrap().1); self.ast_path_to_ty(span, did, path.segments.last().unwrap()) } - Def::Variant(did) if permit_variants => { + Def::Variant(_) if permit_variants => { // Convert "variant type" as if it were a real type. // The resulting `Ty` is type of the variant's enum for now. assert_eq!(opt_self_ty, None); - self.prohibit_generics(path.segments.split_last().unwrap().1); - self.ast_path_to_ty(span, - tcx.parent_def_id(did).unwrap(), - path.segments.last().unwrap()) + + let path_segs = self.def_ids_for_path_segments(&path.segments, None, path.def); + let generic_segs: FxHashSet<_> = + path_segs.iter().map(|PathSeg(_, index)| index).collect(); + self.prohibit_generics(path.segments.iter().enumerate().filter_map(|(index, seg)| { + if !generic_segs.contains(&index) { + Some(seg) + } else { + None + } + })); + + let PathSeg(def_id, index) = path_segs.last().unwrap(); + self.ast_path_to_ty(span, *def_id, &path.segments[*index]) } Def::TyParam(did) => { assert_eq!(opt_self_ty, None); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index bf878f87e36..76fbe862211 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -83,7 +83,7 @@ mod generator_interior; mod intrinsic; mod op; -use astconv::AstConv; +use astconv::{AstConv, PathSeg}; use errors::{Applicability, DiagnosticBuilder, DiagnosticId}; use rustc::hir::{self, ExprKind, GenericArg, ItemKind, Node, PatKind, QPath}; use rustc::hir::def::{CtorKind, Def}; @@ -507,9 +507,6 @@ impl<'gcx, 'tcx> EnclosingBreakables<'gcx, 'tcx> { } } -#[derive(Debug)] -struct PathSeg(DefId, usize); - pub struct FnCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { body_id: ast::NodeId, @@ -5060,131 +5057,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Applicability::MachineApplicable); } - fn def_ids_for_path_segments(&self, - segments: &[hir::PathSegment], - self_ty: Option<Ty<'tcx>>, - def: Def) - -> Vec<PathSeg> { - // We need to extract the type parameters supplied by the user in - // the path `path`. Due to the current setup, this is a bit of a - // tricky-process; the problem is that resolve only tells us the - // end-point of the path resolution, and not the intermediate steps. - // Luckily, we can (at least for now) deduce the intermediate steps - // just from the end-point. - // - // There are basically five cases to consider: - // - // 1. Reference to a constructor of a struct: - // - // struct Foo<T>(...) - // - // In this case, the parameters are declared in the type space. - // - // 2. Reference to a constructor of an enum variant: - // - // enum E<T> { Foo(...) } - // - // In this case, the parameters are defined in the type space, - // but may be specified either on the type or the variant. - // - // 3. Reference to a fn item or a free constant: - // - // fn foo<T>() { } - // - // In this case, the path will again always have the form - // `a::b::foo::<T>` where only the final segment should have - // type parameters. However, in this case, those parameters are - // declared on a value, and hence are in the `FnSpace`. - // - // 4. Reference to a method or an associated constant: - // - // impl<A> SomeStruct<A> { - // fn foo<B>(...) - // } - // - // Here we can have a path like - // `a::b::SomeStruct::<A>::foo::<B>`, in which case parameters - // may appear in two places. The penultimate segment, - // `SomeStruct::<A>`, contains parameters in TypeSpace, and the - // final segment, `foo::<B>` contains parameters in fn space. - // - // 5. Reference to a local variable - // - // Local variables can't have any type parameters. - // - // The first step then is to categorize the segments appropriately. - - assert!(!segments.is_empty()); - let last = segments.len() - 1; - - let mut path_segs = vec![]; - - match def { - // Case 1. Reference to a struct constructor. - Def::StructCtor(def_id, ..) | - Def::SelfCtor(.., def_id) => { - // Everything but the final segment should have no - // parameters at all. - let generics = self.tcx.generics_of(def_id); - // Variant and struct constructors use the - // generics of their parent type definition. - let generics_def_id = generics.parent.unwrap_or(def_id); - path_segs.push(PathSeg(generics_def_id, last)); - } - - // Case 2. Reference to a variant constructor. - Def::VariantCtor(def_id, ..) => { - let adt_def = self_ty.and_then(|t| t.ty_adt_def()); - let (generics_def_id, index) = if let Some(adt_def) = adt_def { - debug_assert!(adt_def.is_enum()); - (adt_def.did, last) - } else if last >= 1 && segments[last - 1].args.is_some() { - // Everything but the penultimate segment should have no - // parameters at all. - let enum_def_id = self.tcx.parent_def_id(def_id).unwrap(); - (enum_def_id, last - 1) - } else { - // FIXME: lint here suggesting `Enum::<...>::Variant` form - // instead of `Enum::Variant::<...>` form. - - // Everything but the final segment should have no - // parameters at all. - let generics = self.tcx.generics_of(def_id); - // Variant and struct constructors use the - // generics of their parent type definition. - (generics.parent.unwrap_or(def_id), last) - }; - path_segs.push(PathSeg(generics_def_id, index)); - } - - // Case 3. Reference to a top-level value. - Def::Fn(def_id) | - Def::Const(def_id) | - Def::Static(def_id, _) => { - path_segs.push(PathSeg(def_id, last)); - } - - // Case 4. Reference to a method or associated const. - Def::Method(def_id) | - Def::AssociatedConst(def_id) => { - if segments.len() >= 2 { - let generics = self.tcx.generics_of(def_id); - path_segs.push(PathSeg(generics.parent.unwrap(), last - 1)); - } - path_segs.push(PathSeg(def_id, last)); - } - - // Case 5. Local variable, no generics. - Def::Local(..) | Def::Upvar(..) => {} - - _ => bug!("unexpected definition: {:?}", def), - } - - debug!("path_segs = {:?}", path_segs); - - path_segs - } - // Instantiates the given path, which must refer to an item with the given // number of type parameters and type. pub fn instantiate_value_path(&self, @@ -5204,7 +5076,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let tcx = self.tcx; - let path_segs = self.def_ids_for_path_segments(segments, self_ty, def); + let path_segs = AstConv::def_ids_for_path_segments(self, segments, self_ty, def); let mut user_self_ty = None; match def { diff --git a/src/test/run-pass/enum-variant-generic-args.rs b/src/test/run-pass/enum-variant-generic-args.rs index bb4a4c9cf0c..ace4ebdfa05 100644 --- a/src/test/run-pass/enum-variant-generic-args.rs +++ b/src/test/run-pass/enum-variant-generic-args.rs @@ -8,9 +8,9 @@ type Alias<T> = Enum<T>; type AliasFixed = Enum<()>; macro_rules! is_variant { - (TSVariant, $expr:expr) => (is_variant!(@TSVariant, (_), $expr)); - (SVariant, $expr:expr) => (is_variant!(@SVariant, { v: _ }, $expr)); - (@$variant:ident, $matcher:tt, $expr:expr) => ( + (TSVariant, $expr:expr) => (is_variant!(@check TSVariant, (_), $expr)); + (SVariant, $expr:expr) => (is_variant!(@check SVariant, { v: _ }, $expr)); + (@check $variant:ident, $matcher:tt, $expr:expr) => ( assert!(if let Enum::$variant::<()> $matcher = $expr { true } else { false }, "expr does not have correct type"); ); diff --git a/src/test/ui/enum-variant-generic-args.rs b/src/test/ui/enum-variant-generic-args.rs index 2ae4b756b7c..044d8438815 100644 --- a/src/test/ui/enum-variant-generic-args.rs +++ b/src/test/ui/enum-variant-generic-args.rs @@ -16,13 +16,16 @@ impl<T> Enum<T> { } fn s_variant() { - Self::SVariant::<()>(()); + Self::SVariant::<()> { v: () }; //~^ ERROR type arguments are not allowed on this entity [E0109] - Self::<()>::SVariant(()); + //~^^ ERROR mismatched types [E0308] + Self::<()>::SVariant { v: () }; //~^ ERROR type arguments are not allowed on this entity [E0109] - Self::<()>::SVariant::<()>(()); + //~^^ ERROR mismatched types [E0308] + Self::<()>::SVariant::<()> { v: () }; //~^ ERROR type arguments are not allowed on this entity [E0109] //~^^ ERROR type arguments are not allowed on this entity [E0109] + //~^^^ ERROR mismatched types [E0308] } } @@ -47,19 +50,19 @@ fn main() { // Struct variant - Enum::<()>::SVariant::<()>(()); + Enum::<()>::SVariant::<()> { v: () }; //~^ ERROR type arguments are not allowed on this entity [E0109] - Alias::SVariant::<()>(()); + Alias::SVariant::<()> { v: () }; //~^ ERROR type arguments are not allowed on this entity [E0109] - Alias::<()>::SVariant::<()>(()); + Alias::<()>::SVariant::<()> { v: () }; //~^ ERROR type arguments are not allowed on this entity [E0109] - AliasFixed::SVariant::<()>(()); + AliasFixed::SVariant::<()> { v: () }; //~^ ERROR type arguments are not allowed on this entity [E0109] - AliasFixed::<()>::SVariant(()); + AliasFixed::<()>::SVariant { v: () }; //~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107] - AliasFixed::<()>::SVariant::<()>(()); + AliasFixed::<()>::SVariant::<()> { v: () }; //~^ ERROR type arguments are not allowed on this entity [E0109] //~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107] } diff --git a/src/test/ui/enum-variant-generic-args.stderr b/src/test/ui/enum-variant-generic-args.stderr index 2d622a49e20..4228a807bad 100644 --- a/src/test/ui/enum-variant-generic-args.stderr +++ b/src/test/ui/enum-variant-generic-args.stderr @@ -1,12 +1,3 @@ -error[E0423]: expected function, found struct variant `Enum::SVariant` - --> $DIR/enum-variant-generic-args.rs:50:5 - | -LL | Enum::<()>::SVariant::<()>(()); - | ^^^^^^^^^^^^--------^^^^^^ - | | | - | | did you mean `TSVariant`? - | did you mean `Enum::SVariant { /* fields */ }`? - error[E0109]: type arguments are not allowed on this entity --> $DIR/enum-variant-generic-args.rs:9:27 | @@ -34,226 +25,139 @@ LL | Self::<()>::TSVariant::<()>(()); error[E0109]: type arguments are not allowed on this entity --> $DIR/enum-variant-generic-args.rs:19:26 | -LL | Self::SVariant::<()>(()); +LL | Self::SVariant::<()> { v: () }; | ^^ type argument not allowed -error[E0618]: expected function, found enum variant `<Self>::SVariant::<()>` - --> $DIR/enum-variant-generic-args.rs:19:9 +error[E0308]: mismatched types + --> $DIR/enum-variant-generic-args.rs:19:35 | -LL | enum Enum<T> { TSVariant(T), SVariant { v: T } } - | ----------------- `<Self>::SVariant::<()>` defined here -... -LL | Self::SVariant::<()>(()); - | ^^^^^^^^^^^^^^^^^^^^---- - | | - | call expression requires function -help: `<Self>::SVariant::<()>` is a unit variant, you need to write it without the parenthesis +LL | Self::SVariant::<()> { v: () }; + | ^^ expected type parameter, found () | -LL | <Self>::SVariant::<()>; - | ^^^^^^^^^^^^^^^^^^^^^^ + = note: expected type `T` + found type `()` error[E0109]: type arguments are not allowed on this entity - --> $DIR/enum-variant-generic-args.rs:21:16 + --> $DIR/enum-variant-generic-args.rs:22:16 | -LL | Self::<()>::SVariant(()); +LL | Self::<()>::SVariant { v: () }; | ^^ type argument not allowed -error[E0618]: expected function, found enum variant `<Self<()>>::SVariant` - --> $DIR/enum-variant-generic-args.rs:21:9 +error[E0308]: mismatched types + --> $DIR/enum-variant-generic-args.rs:22:35 | -LL | enum Enum<T> { TSVariant(T), SVariant { v: T } } - | ----------------- `<Self<()>>::SVariant` defined here -... -LL | Self::<()>::SVariant(()); - | ^^^^^^^^^^^^^^^^^^^^---- - | | - | call expression requires function -help: `<Self<()>>::SVariant` is a unit variant, you need to write it without the parenthesis +LL | Self::<()>::SVariant { v: () }; + | ^^ expected type parameter, found () | -LL | <Self<()>>::SVariant; - | ^^^^^^^^^^^^^^^^^^^^ + = note: expected type `T` + found type `()` error[E0109]: type arguments are not allowed on this entity - --> $DIR/enum-variant-generic-args.rs:23:16 + --> $DIR/enum-variant-generic-args.rs:25:16 | -LL | Self::<()>::SVariant::<()>(()); +LL | Self::<()>::SVariant::<()> { v: () }; | ^^ type argument not allowed error[E0109]: type arguments are not allowed on this entity - --> $DIR/enum-variant-generic-args.rs:23:32 + --> $DIR/enum-variant-generic-args.rs:25:32 | -LL | Self::<()>::SVariant::<()>(()); +LL | Self::<()>::SVariant::<()> { v: () }; | ^^ type argument not allowed -error[E0618]: expected function, found enum variant `<Self<()>>::SVariant::<()>` - --> $DIR/enum-variant-generic-args.rs:23:9 +error[E0308]: mismatched types + --> $DIR/enum-variant-generic-args.rs:25:41 | -LL | enum Enum<T> { TSVariant(T), SVariant { v: T } } - | ----------------- `<Self<()>>::SVariant::<()>` defined here -... -LL | Self::<()>::SVariant::<()>(()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^---- - | | - | call expression requires function -help: `<Self<()>>::SVariant::<()>` is a unit variant, you need to write it without the parenthesis +LL | Self::<()>::SVariant::<()> { v: () }; + | ^^ expected type parameter, found () | -LL | <Self<()>>::SVariant::<()>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: expected type `T` + found type `()` error[E0109]: type arguments are not allowed on this entity - --> $DIR/enum-variant-generic-args.rs:32:29 + --> $DIR/enum-variant-generic-args.rs:35:29 | LL | Enum::<()>::TSVariant::<()>(()); | ^^ type argument not allowed error[E0109]: type arguments are not allowed on this entity - --> $DIR/enum-variant-generic-args.rs:35:24 + --> $DIR/enum-variant-generic-args.rs:38:24 | LL | Alias::TSVariant::<()>(()); | ^^ type argument not allowed error[E0109]: type arguments are not allowed on this entity - --> $DIR/enum-variant-generic-args.rs:37:30 + --> $DIR/enum-variant-generic-args.rs:40:30 | LL | Alias::<()>::TSVariant::<()>(()); | ^^ type argument not allowed error[E0109]: type arguments are not allowed on this entity - --> $DIR/enum-variant-generic-args.rs:40:29 + --> $DIR/enum-variant-generic-args.rs:43:29 | LL | AliasFixed::TSVariant::<()>(()); | ^^ type argument not allowed error[E0107]: wrong number of type arguments: expected 0, found 1 - --> $DIR/enum-variant-generic-args.rs:42:18 + --> $DIR/enum-variant-generic-args.rs:45:18 | LL | AliasFixed::<()>::TSVariant(()); | ^^ unexpected type argument error[E0107]: wrong number of type arguments: expected 0, found 1 - --> $DIR/enum-variant-generic-args.rs:44:18 + --> $DIR/enum-variant-generic-args.rs:47:18 | LL | AliasFixed::<()>::TSVariant::<()>(()); | ^^ unexpected type argument error[E0109]: type arguments are not allowed on this entity - --> $DIR/enum-variant-generic-args.rs:44:35 + --> $DIR/enum-variant-generic-args.rs:47:35 | LL | AliasFixed::<()>::TSVariant::<()>(()); | ^^ type argument not allowed error[E0109]: type arguments are not allowed on this entity - --> $DIR/enum-variant-generic-args.rs:53:23 + --> $DIR/enum-variant-generic-args.rs:53:28 | -LL | Alias::SVariant::<()>(()); - | ^^ type argument not allowed +LL | Enum::<()>::SVariant::<()> { v: () }; + | ^^ type argument not allowed -error[E0618]: expected function, found enum variant `<Alias>::SVariant::<()>` - --> $DIR/enum-variant-generic-args.rs:53:5 - | -LL | enum Enum<T> { TSVariant(T), SVariant { v: T } } - | ----------------- `<Alias>::SVariant::<()>` defined here -... -LL | Alias::SVariant::<()>(()); - | ^^^^^^^^^^^^^^^^^^^^^---- - | | - | call expression requires function -help: `<Alias>::SVariant::<()>` is a unit variant, you need to write it without the parenthesis +error[E0109]: type arguments are not allowed on this entity + --> $DIR/enum-variant-generic-args.rs:56:23 | -LL | <Alias>::SVariant::<()>; - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | Alias::SVariant::<()> { v: () }; + | ^^ type argument not allowed error[E0109]: type arguments are not allowed on this entity - --> $DIR/enum-variant-generic-args.rs:55:29 + --> $DIR/enum-variant-generic-args.rs:58:29 | -LL | Alias::<()>::SVariant::<()>(()); +LL | Alias::<()>::SVariant::<()> { v: () }; | ^^ type argument not allowed -error[E0618]: expected function, found enum variant `<Alias<()>>::SVariant::<()>` - --> $DIR/enum-variant-generic-args.rs:55:5 - | -LL | enum Enum<T> { TSVariant(T), SVariant { v: T } } - | ----------------- `<Alias<()>>::SVariant::<()>` defined here -... -LL | Alias::<()>::SVariant::<()>(()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^---- - | | - | call expression requires function -help: `<Alias<()>>::SVariant::<()>` is a unit variant, you need to write it without the parenthesis - | -LL | <Alias<()>>::SVariant::<()>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0109]: type arguments are not allowed on this entity - --> $DIR/enum-variant-generic-args.rs:58:28 + --> $DIR/enum-variant-generic-args.rs:61:28 | -LL | AliasFixed::SVariant::<()>(()); +LL | AliasFixed::SVariant::<()> { v: () }; | ^^ type argument not allowed -error[E0618]: expected function, found enum variant `<AliasFixed>::SVariant::<()>` - --> $DIR/enum-variant-generic-args.rs:58:5 - | -LL | enum Enum<T> { TSVariant(T), SVariant { v: T } } - | ----------------- `<AliasFixed>::SVariant::<()>` defined here -... -LL | AliasFixed::SVariant::<()>(()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^---- - | | - | call expression requires function -help: `<AliasFixed>::SVariant::<()>` is a unit variant, you need to write it without the parenthesis - | -LL | <AliasFixed>::SVariant::<()>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0107]: wrong number of type arguments: expected 0, found 1 - --> $DIR/enum-variant-generic-args.rs:60:18 + --> $DIR/enum-variant-generic-args.rs:63:18 | -LL | AliasFixed::<()>::SVariant(()); +LL | AliasFixed::<()>::SVariant { v: () }; | ^^ unexpected type argument -error[E0618]: expected function, found enum variant `<AliasFixed<()>>::SVariant` - --> $DIR/enum-variant-generic-args.rs:60:5 - | -LL | enum Enum<T> { TSVariant(T), SVariant { v: T } } - | ----------------- `<AliasFixed<()>>::SVariant` defined here -... -LL | AliasFixed::<()>::SVariant(()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^---- - | | - | call expression requires function -help: `<AliasFixed<()>>::SVariant` is a unit variant, you need to write it without the parenthesis - | -LL | <AliasFixed<()>>::SVariant; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0107]: wrong number of type arguments: expected 0, found 1 - --> $DIR/enum-variant-generic-args.rs:62:18 + --> $DIR/enum-variant-generic-args.rs:65:18 | -LL | AliasFixed::<()>::SVariant::<()>(()); +LL | AliasFixed::<()>::SVariant::<()> { v: () }; | ^^ unexpected type argument error[E0109]: type arguments are not allowed on this entity - --> $DIR/enum-variant-generic-args.rs:62:34 + --> $DIR/enum-variant-generic-args.rs:65:34 | -LL | AliasFixed::<()>::SVariant::<()>(()); +LL | AliasFixed::<()>::SVariant::<()> { v: () }; | ^^ type argument not allowed -error[E0618]: expected function, found enum variant `<AliasFixed<()>>::SVariant::<()>` - --> $DIR/enum-variant-generic-args.rs:62:5 - | -LL | enum Enum<T> { TSVariant(T), SVariant { v: T } } - | ----------------- `<AliasFixed<()>>::SVariant::<()>` defined here -... -LL | AliasFixed::<()>::SVariant::<()>(()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---- - | | - | call expression requires function -help: `<AliasFixed<()>>::SVariant::<()>` is a unit variant, you need to write it without the parenthesis - | -LL | <AliasFixed<()>>::SVariant::<()>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 30 previous errors +error: aborting due to 25 previous errors -Some errors occurred: E0107, E0109, E0423, E0618. +Some errors occurred: E0107, E0109, E0308. For more information about an error, try `rustc --explain E0107`. |