Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize type_alias_enum_variants in Rust 1.37.0 #61682

Merged
merged 21 commits into from
Jul 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ac94bbe
Stabilize type_alias_enum_variants.
Centril May 31, 2019
e5060da
type_alias_enum_variants: Remove feature gate test.
Centril May 31, 2019
05dc864
Move type_alias_enum_variants tests to a folder; Strip feature gates.
Centril Jun 8, 2019
0d27995
type_alias_enum_variants: remove duplicate run-pass test.
Centril Jun 9, 2019
8642258
Cleanup type-alias-enum-variants.rs test.
Centril Jun 9, 2019
4f66364
Rename type-alias-enum-variants.rs to something descriptive.
Centril Jun 9, 2019
f5f1144
type-alias-enum-variants-priority: elaborate on why this exists.
Centril Jun 9, 2019
ff7d6a1
type-alias-enum-variants-priority: rename to something more descriptive.
Centril Jun 9, 2019
6d1ecb3
type-alias-enum-variants-priority-2: account for 'const's + describe …
Centril Jun 9, 2019
fd44b76
type-alias-enum-variants-priority-2: rename to something descriptive.
Centril Jun 9, 2019
c0c48a6
type-alias-enum-variants-priority-3: describe the test.
Centril Jun 9, 2019
d87cae3
type-alias-enum-variants-priority-3: rename to something descriptive.
Centril Jun 9, 2019
77ff384
type-alias-enum-variants-pass: harden; account for unit variants.
Centril Jun 9, 2019
bed1897
type-alias-enum-variants-panic: harden + describe the test.
Centril Jun 9, 2019
d358b5f
type-alias-enum-variants-panic: rename to something descriptive.
Centril Jun 9, 2019
86c74d3
(type_alias_enum_variants); issue-58006: rename to something descript…
Centril Jun 9, 2019
ce48086
enum-variant-generic-args-pats-pass: harden + describe.
Centril Jun 9, 2019
26f98fd
enum-variant-generic-args-pats-pass: rename; test isn't specific to p…
Centril Jun 9, 2019
a70653a
enum-variant-generic-args: describe + account for unit variants.
Centril Jun 9, 2019
46f405e
type_alias_enum_variants: Remove from unstable book.
Centril Jun 9, 2019
57e6869
type_alias_enum_variants: cleanup redundant 'allow(unused)'.
Centril Jun 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

2 changes: 1 addition & 1 deletion src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#![feature(label_break_value)]
#![feature(nll)]
#![feature(rustc_diagnostic_macros)]
#![feature(type_alias_enum_variants)]
#![cfg_attr(bootstrap, feature(type_alias_enum_variants))]

#![recursion_limit="256"]

Expand Down
2 changes: 0 additions & 2 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use std::collections::BTreeSet;
use std::iter;
use std::slice;

use super::{check_type_alias_enum_variants_enabled};
use rustc_data_structures::fx::FxHashSet;

#[derive(Debug)]
Expand Down Expand Up @@ -1599,7 +1598,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
});
if let Some(variant_def) = variant_def {
if permit_variants {
check_type_alias_enum_variants_enabled(tcx, span);
tcx.check_stability(variant_def.def_id, Some(hir_ref_id), span);
return Ok((qself_ty, DefKind::Variant, variant_def.def_id));
} else {
Expand Down
3 changes: 0 additions & 3 deletions src/librustc_typeck/check/method/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use rustc::infer::{self, InferOk};
use syntax::ast;
use syntax_pos::Span;

use crate::{check_type_alias_enum_variants_enabled};
use self::probe::{IsSuggestion, ProbeScope};

pub fn provide(providers: &mut ty::query::Providers<'_>) {
Expand Down Expand Up @@ -417,8 +416,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
tcx.hygienic_eq(method_name, vd.ident, adt_def.did)
});
if let Some(variant_def) = variant_def {
check_type_alias_enum_variants_enabled(tcx, span);

// Braced variants generate unusable names in value namespace (reserved for
// possible future use), so variants resolved as associated items may refer to
// them as well. It's ok to use the variant's id as a ctor id since an
Expand Down
17 changes: 1 addition & 16 deletions src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ use rustc::lint;
use rustc::middle;
use rustc::session;
use rustc::util::common::ErrorReported;
use rustc::session::config::{EntryFnType, nightly_options};
use rustc::session::config::EntryFnType;
use rustc::traits::{ObligationCause, ObligationCauseCode, TraitEngine, TraitEngineExt};
use rustc::ty::subst::SubstsRef;
use rustc::ty::{self, Ty, TyCtxt};
Expand All @@ -124,21 +124,6 @@ pub struct TypeAndSubsts<'tcx> {
ty: Ty<'tcx>,
}

fn check_type_alias_enum_variants_enabled<'tcx>(tcx: TyCtxt<'tcx>, span: Span) {
if !tcx.features().type_alias_enum_variants {
let mut err = tcx.sess.struct_span_err(
span,
"enum variants on type aliases are experimental"
);
if nightly_options::is_nightly_build() {
help!(&mut err,
"add `#![feature(type_alias_enum_variants)]` to the \
crate attributes to enable");
}
err.emit();
}
}

fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl, abi: Abi, span: Span) {
if decl.c_variadic && !(abi == Abi::C || abi == Abi::Cdecl) {
let mut err = struct_span_err!(tcx.sess, span, E0045,
Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,6 @@ declare_features! (
// Allows using `reason` in lint attributes and the `#[expect(lint)]` lint check.
(active, lint_reasons, "1.31.0", Some(54503), None),

// Allows paths to enum variants on type aliases.
(active, type_alias_enum_variants, "1.31.0", Some(49683), None),

// Allows exhaustive integer pattern matching on `usize` and `isize`.
(active, precise_pointer_size_matching, "1.32.0", Some(56354), None),

Expand Down Expand Up @@ -849,6 +846,8 @@ declare_features! (
(accepted, extern_crate_self, "1.34.0", Some(56409), None),
// Allows arbitrary delimited token streams in non-macro attributes.
(accepted, unrestricted_attribute_tokens, "1.34.0", Some(55208), None),
// Allows paths to enum variants on type aliases including `Self`.
(accepted, type_alias_enum_variants, "1.37.0", Some(49683), None),
// Allows using `#[repr(align(X))]` on enums with equivalent semantics
// to wrapping an enum in a wrapper struct with `#[repr(align(X))]`.
(accepted, repr_align_enum, "1.37.0", Some(57996), None),
Expand Down
30 changes: 0 additions & 30 deletions src/test/run-pass/type-alias-enum-variants-2.rs

This file was deleted.

30 changes: 0 additions & 30 deletions src/test/run-pass/type-alias-enum-variants.rs

This file was deleted.

19 changes: 0 additions & 19 deletions src/test/ui/feature-gates/feature-gate-type_alias_enum_variants.rs

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions src/test/ui/type-alias-enum-variants-panic.rs

This file was deleted.

21 changes: 0 additions & 21 deletions src/test/ui/type-alias-enum-variants-panic.stderr

This file was deleted.

13 changes: 0 additions & 13 deletions src/test/ui/type-alias-enum-variants-priority-2.rs

This file was deleted.

12 changes: 0 additions & 12 deletions src/test/ui/type-alias-enum-variants-priority-2.stderr

This file was deleted.

10 changes: 0 additions & 10 deletions src/test/ui/type-alias-enum-variants-priority-3.rs

This file was deleted.

19 changes: 0 additions & 19 deletions src/test/ui/type-alias-enum-variants-priority.rs

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/ui/type-alias-enum-variants.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
// run-pass

#![feature(type_alias_enum_variants)]
// Check that resolving, in the value namespace, to an `enum` variant
// through a type alias is well behaved in the presence of generics.
// We check for situations with:
// 1. a generic type `Alias<T>`, we can type-apply `Alias` when referring to a variant.
// 2. a monotype `AliasFixed` of generic `Enum<T>`, we can refer to variants
// and the type-application of `T` in `AliasFixed` is kept.

#![allow(irrefutable_let_patterns)]

#[allow(dead_code)]
enum Enum<T> { TSVariant(T), SVariant { v: T } }
enum Enum<T> { TSVariant(T), SVariant { v: T }, UVariant }
type Alias<T> = Enum<T>;
type AliasFixed = Enum<()>;

macro_rules! is_variant {
(TSVariant, $expr:expr) => (is_variant!(@check TSVariant, (_), $expr));
(SVariant, $expr:expr) => (is_variant!(@check SVariant, { v: _ }, $expr));
(UVariant, $expr:expr) => (is_variant!(@check UVariant, {}, $expr));
(@check $variant:ident, $matcher:tt, $expr:expr) => (
assert!(if let Enum::$variant::<()> $matcher = $expr { true } else { false },
"expr does not have correct type");
Expand Down Expand Up @@ -40,4 +45,15 @@ fn main() {
is_variant!(SVariant, Alias::<()>::SVariant { v: () });

is_variant!(SVariant, AliasFixed::SVariant { v: () });

// Unit variant

is_variant!(UVariant, Enum::UVariant);
is_variant!(UVariant, Enum::UVariant::<()>);
is_variant!(UVariant, Enum::<()>::UVariant);

is_variant!(UVariant, Alias::UVariant);
is_variant!(UVariant, Alias::<()>::UVariant);

is_variant!(UVariant, AliasFixed::UVariant);
}
Loading