summary refs log tree commit diff
path: root/src/libsyntax/feature_gate
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-12-22 17:42:04 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2019-12-22 17:42:47 -0500
commita06baa56b95674fc626b3c3fd680d6a65357fe60 (patch)
treecd9d867c2ca3cff5c1d6b3bd73377c44649fb075 /src/libsyntax/feature_gate
parent8eb7c58dbb7b32701af113bc58722d0d1fefb1eb (diff)
downloadrust-a06baa56b95674fc626b3c3fd680d6a65357fe60.tar.gz
rust-a06baa56b95674fc626b3c3fd680d6a65357fe60.zip
Format the world
Diffstat (limited to 'src/libsyntax/feature_gate')
-rw-r--r--src/libsyntax/feature_gate/check.rs447
1 files changed, 269 insertions, 178 deletions
diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs
index aacd14c3af7..6fd926f2048 100644
--- a/src/libsyntax/feature_gate/check.rs
+++ b/src/libsyntax/feature_gate/check.rs
@@ -1,45 +1,52 @@
-use rustc_feature::{ACCEPTED_FEATURES, ACTIVE_FEATURES, REMOVED_FEATURES, STABLE_REMOVED_FEATURES};
-use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP};
-use rustc_feature::{Features, Feature, State as FeatureState, UnstableFeatures};
 use rustc_feature::{find_feature_issue, GateIssue};
+use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP};
+use rustc_feature::{Feature, Features, State as FeatureState, UnstableFeatures};
+use rustc_feature::{
+    ACCEPTED_FEATURES, ACTIVE_FEATURES, REMOVED_FEATURES, STABLE_REMOVED_FEATURES,
+};
 
 use crate::ast::{self, AssocTyConstraint, AssocTyConstraintKind, NodeId};
 use crate::ast::{GenericParam, GenericParamKind, PatKind, RangeEnd, VariantData};
 use crate::attr;
+use crate::edition::{Edition, ALL_EDITIONS};
+use crate::sess::ParseSess;
 use crate::source_map::Spanned;
-use crate::edition::{ALL_EDITIONS, Edition};
+use crate::symbol::{sym, Symbol};
 use crate::visit::{self, FnKind, Visitor};
-use crate::sess::ParseSess;
-use crate::symbol::{Symbol, sym};
 
 use errors::{Applicability, DiagnosticBuilder, Handler};
-use rustc_data_structures::fx::FxHashMap;
-use syntax_pos::{Span, DUMMY_SP, MultiSpan};
 use log::debug;
+use rustc_data_structures::fx::FxHashMap;
+use syntax_pos::{MultiSpan, Span, DUMMY_SP};
 
 use rustc_error_codes::*;
 
 macro_rules! gate_feature_fn {
     ($cx: expr, $has_feature: expr, $span: expr, $name: expr, $explain: expr, $level: expr) => {{
-        let (cx, has_feature, span,
-             name, explain, level) = (&*$cx, $has_feature, $span, $name, $explain, $level);
+        let (cx, has_feature, span, name, explain, level) =
+            (&*$cx, $has_feature, $span, $name, $explain, $level);
         let has_feature: bool = has_feature(&$cx.features);
         debug!("gate_feature(feature = {:?}, span = {:?}); has? {}", name, span, has_feature);
         if !has_feature && !span.allows_unstable($name) {
             leveled_feature_err(cx.parse_sess, name, span, GateIssue::Language, explain, level)
                 .emit();
         }
-    }}
+    }};
 }
 
 macro_rules! gate_feature {
     ($cx: expr, $feature: ident, $span: expr, $explain: expr) => {
-        gate_feature_fn!($cx, |x:&Features| x.$feature, $span,
-                         sym::$feature, $explain, GateStrength::Hard)
+        gate_feature_fn!(
+            $cx,
+            |x: &Features| x.$feature,
+            $span,
+            sym::$feature,
+            $explain,
+            GateStrength::Hard
+        )
     };
     ($cx: expr, $feature: ident, $span: expr, $explain: expr, $level: expr) => {
-        gate_feature_fn!($cx, |x:&Features| x.$feature, $span,
-                         sym::$feature, $explain, $level)
+        gate_feature_fn!($cx, |x: &Features| x.$feature, $span, sym::$feature, $explain, $level)
     };
 }
 
@@ -111,7 +118,6 @@ fn leveled_feature_err<'a>(
     }
 
     err
-
 }
 
 struct PostExpansionVisitor<'a> {
@@ -131,7 +137,7 @@ macro_rules! gate_feature_post {
         if !span.allows_unstable(sym::$feature) {
             gate_feature!(cx, $feature, span, $explain, $level)
         }
-    }}
+    }};
 }
 
 impl<'a> PostExpansionVisitor<'a> {
@@ -140,65 +146,95 @@ impl<'a> PostExpansionVisitor<'a> {
 
         match &*symbol_unescaped.as_str() {
             // Stable
-            "Rust" |
-            "C" |
-            "cdecl" |
-            "stdcall" |
-            "fastcall" |
-            "aapcs" |
-            "win64" |
-            "sysv64" |
-            "system" => {}
+            "Rust" | "C" | "cdecl" | "stdcall" | "fastcall" | "aapcs" | "win64" | "sysv64"
+            | "system" => {}
             "rust-intrinsic" => {
-                gate_feature_post!(&self, intrinsics, span,
-                                   "intrinsics are subject to change");
-            },
+                gate_feature_post!(&self, intrinsics, span, "intrinsics are subject to change");
+            }
             "platform-intrinsic" => {
-                gate_feature_post!(&self, platform_intrinsics, span,
-                                   "platform intrinsics are experimental and possibly buggy");
-            },
+                gate_feature_post!(
+                    &self,
+                    platform_intrinsics,
+                    span,
+                    "platform intrinsics are experimental and possibly buggy"
+                );
+            }
             "vectorcall" => {
-                gate_feature_post!(&self, abi_vectorcall, span,
-                                   "vectorcall is experimental and subject to change");
-            },
+                gate_feature_post!(
+                    &self,
+                    abi_vectorcall,
+                    span,
+                    "vectorcall is experimental and subject to change"
+                );
+            }
             "thiscall" => {
-                gate_feature_post!(&self, abi_thiscall, span,
-                                   "thiscall is experimental and subject to change");
-            },
+                gate_feature_post!(
+                    &self,
+                    abi_thiscall,
+                    span,
+                    "thiscall is experimental and subject to change"
+                );
+            }
             "rust-call" => {
-                gate_feature_post!(&self, unboxed_closures, span,
-                                   "rust-call ABI is subject to change");
-            },
+                gate_feature_post!(
+                    &self,
+                    unboxed_closures,
+                    span,
+                    "rust-call ABI is subject to change"
+                );
+            }
             "ptx-kernel" => {
-                gate_feature_post!(&self, abi_ptx, span,
-                                   "PTX ABIs are experimental and subject to change");
-            },
+                gate_feature_post!(
+                    &self,
+                    abi_ptx,
+                    span,
+                    "PTX ABIs are experimental and subject to change"
+                );
+            }
             "unadjusted" => {
-                gate_feature_post!(&self, abi_unadjusted, span,
-                                   "unadjusted ABI is an implementation detail and perma-unstable");
-            },
+                gate_feature_post!(
+                    &self,
+                    abi_unadjusted,
+                    span,
+                    "unadjusted ABI is an implementation detail and perma-unstable"
+                );
+            }
             "msp430-interrupt" => {
-                gate_feature_post!(&self, abi_msp430_interrupt, span,
-                                   "msp430-interrupt ABI is experimental and subject to change");
-            },
+                gate_feature_post!(
+                    &self,
+                    abi_msp430_interrupt,
+                    span,
+                    "msp430-interrupt ABI is experimental and subject to change"
+                );
+            }
             "x86-interrupt" => {
-                gate_feature_post!(&self, abi_x86_interrupt, span,
-                                   "x86-interrupt ABI is experimental and subject to change");
-            },
+                gate_feature_post!(
+                    &self,
+                    abi_x86_interrupt,
+                    span,
+                    "x86-interrupt ABI is experimental and subject to change"
+                );
+            }
             "amdgpu-kernel" => {
-                gate_feature_post!(&self, abi_amdgpu_kernel, span,
-                                   "amdgpu-kernel ABI is experimental and subject to change");
-            },
+                gate_feature_post!(
+                    &self,
+                    abi_amdgpu_kernel,
+                    span,
+                    "amdgpu-kernel ABI is experimental and subject to change"
+                );
+            }
             "efiapi" => {
-                gate_feature_post!(&self, abi_efiapi, span,
-                                   "efiapi ABI is experimental and subject to change");
-            },
-            abi => {
-                self.parse_sess.span_diagnostic.delay_span_bug(
+                gate_feature_post!(
+                    &self,
+                    abi_efiapi,
                     span,
-                    &format!("unrecognized ABI not caught in lowering: {}", abi),
-                )
+                    "efiapi ABI is experimental and subject to change"
+                );
             }
+            abi => self
+                .parse_sess
+                .span_diagnostic
+                .delay_span_bug(span, &format!("unrecognized ABI not caught in lowering: {}", abi)),
         }
     }
 
@@ -214,12 +250,14 @@ impl<'a> PostExpansionVisitor<'a> {
             VariantData::Unit(..) => false,
         });
 
-        let discriminant_spans = variants.iter().filter(|variant| match variant.data {
-            VariantData::Tuple(..) | VariantData::Struct(..) => false,
-            VariantData::Unit(..) => true,
-        })
-        .filter_map(|variant| variant.disr_expr.as_ref().map(|c| c.value.span))
-        .collect::<Vec<_>>();
+        let discriminant_spans = variants
+            .iter()
+            .filter(|variant| match variant.data {
+                VariantData::Tuple(..) | VariantData::Struct(..) => false,
+                VariantData::Unit(..) => true,
+            })
+            .filter_map(|variant| variant.disr_expr.as_ref().map(|c| c.value.span))
+            .collect::<Vec<_>>();
 
         if !discriminant_spans.is_empty() && has_fields {
             let mut err = feature_err(
@@ -234,16 +272,10 @@ impl<'a> PostExpansionVisitor<'a> {
             for variant in variants.iter() {
                 match &variant.data {
                     VariantData::Struct(..) => {
-                        err.span_label(
-                            variant.span,
-                            "struct variant defined here",
-                        );
+                        err.span_label(variant.span, "struct variant defined here");
                     }
                     VariantData::Tuple(..) => {
-                        err.span_label(
-                            variant.span,
-                            "tuple variant defined here",
-                        );
+                        err.span_label(variant.span, "tuple variant defined here");
                     }
                     VariantData::Unit(..) => {}
                 }
@@ -344,20 +376,32 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
 
             ast::ItemKind::Fn(..) => {
                 if attr::contains_name(&i.attrs[..], sym::plugin_registrar) {
-                    gate_feature_post!(&self, plugin_registrar, i.span,
-                                       "compiler plugins are experimental and possibly buggy");
+                    gate_feature_post!(
+                        &self,
+                        plugin_registrar,
+                        i.span,
+                        "compiler plugins are experimental and possibly buggy"
+                    );
                 }
                 if attr::contains_name(&i.attrs[..], sym::start) {
-                    gate_feature_post!(&self, start, i.span,
-                                      "a `#[start]` function is an experimental \
+                    gate_feature_post!(
+                        &self,
+                        start,
+                        i.span,
+                        "a `#[start]` function is an experimental \
                                        feature whose signature may change \
-                                       over time");
+                                       over time"
+                    );
                 }
                 if attr::contains_name(&i.attrs[..], sym::main) {
-                    gate_feature_post!(&self, main, i.span,
-                                       "declaration of a non-standard `#[main]` \
+                    gate_feature_post!(
+                        &self,
+                        main,
+                        i.span,
+                        "declaration of a non-standard `#[main]` \
                                         function may change over time, for now \
-                                        a top-level `fn main()` is required");
+                                        a top-level `fn main()` is required"
+                    );
                 }
             }
 
@@ -365,24 +409,28 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
                 for attr in attr::filter_by_name(&i.attrs[..], sym::repr) {
                     for item in attr.meta_item_list().unwrap_or_else(Vec::new) {
                         if item.check_name(sym::simd) {
-                            gate_feature_post!(&self, repr_simd, attr.span,
-                                               "SIMD types are experimental and possibly buggy");
+                            gate_feature_post!(
+                                &self,
+                                repr_simd,
+                                attr.span,
+                                "SIMD types are experimental and possibly buggy"
+                            );
                         }
                     }
                 }
             }
 
-            ast::ItemKind::Enum(ast::EnumDef{ref variants, ..}, ..) => {
+            ast::ItemKind::Enum(ast::EnumDef { ref variants, .. }, ..) => {
                 for variant in variants {
                     match (&variant.data, &variant.disr_expr) {
-                        (ast::VariantData::Unit(..), _) => {},
-                        (_, Some(disr_expr)) =>
-                            gate_feature_post!(
-                                &self,
-                                arbitrary_enum_discriminant,
-                                disr_expr.value.span,
-                                "discriminants on non-unit variants are experimental"),
-                        _ => {},
+                        (ast::VariantData::Unit(..), _) => {}
+                        (_, Some(disr_expr)) => gate_feature_post!(
+                            &self,
+                            arbitrary_enum_discriminant,
+                            disr_expr.value.span,
+                            "discriminants on non-unit variants are experimental"
+                        ),
+                        _ => {}
                     }
                 }
 
@@ -394,34 +442,33 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
 
             ast::ItemKind::Impl(_, polarity, defaultness, ..) => {
                 if polarity == ast::ImplPolarity::Negative {
-                    gate_feature_post!(&self, optin_builtin_traits,
-                                       i.span,
-                                       "negative trait bounds are not yet fully implemented; \
-                                        use marker types for now");
+                    gate_feature_post!(
+                        &self,
+                        optin_builtin_traits,
+                        i.span,
+                        "negative trait bounds are not yet fully implemented; \
+                                        use marker types for now"
+                    );
                 }
 
                 if let ast::Defaultness::Default = defaultness {
-                    gate_feature_post!(&self, specialization,
-                                       i.span,
-                                       "specialization is unstable");
+                    gate_feature_post!(&self, specialization, i.span, "specialization is unstable");
                 }
             }
 
             ast::ItemKind::Trait(ast::IsAuto::Yes, ..) => {
-                gate_feature_post!(&self, optin_builtin_traits,
-                                   i.span,
-                                   "auto traits are experimental and possibly buggy");
-            }
-
-            ast::ItemKind::TraitAlias(..) => {
                 gate_feature_post!(
                     &self,
-                    trait_alias,
+                    optin_builtin_traits,
                     i.span,
-                    "trait aliases are experimental"
+                    "auto traits are experimental and possibly buggy"
                 );
             }
 
+            ast::ItemKind::TraitAlias(..) => {
+                gate_feature_post!(&self, trait_alias, i.span, "trait aliases are experimental");
+            }
+
             ast::ItemKind::MacroDef(ast::MacroDef { legacy: false, .. }) => {
                 let msg = "`macro` is experimental";
                 gate_feature_post!(&self, decl_macro, i.span, msg);
@@ -437,21 +484,23 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
 
     fn visit_foreign_item(&mut self, i: &'a ast::ForeignItem) {
         match i.kind {
-            ast::ForeignItemKind::Fn(..) |
-            ast::ForeignItemKind::Static(..) => {
+            ast::ForeignItemKind::Fn(..) | ast::ForeignItemKind::Static(..) => {
                 let link_name = attr::first_attr_value_str_by_name(&i.attrs, sym::link_name);
                 let links_to_llvm = match link_name {
                     Some(val) => val.as_str().starts_with("llvm."),
-                    _ => false
+                    _ => false,
                 };
                 if links_to_llvm {
-                    gate_feature_post!(&self, link_llvm_intrinsics, i.span,
-                                       "linking to LLVM intrinsics is experimental");
+                    gate_feature_post!(
+                        &self,
+                        link_llvm_intrinsics,
+                        i.span,
+                        "linking to LLVM intrinsics is experimental"
+                    );
                 }
             }
             ast::ForeignItemKind::Ty => {
-                    gate_feature_post!(&self, extern_types, i.span,
-                                       "extern types are experimental");
+                gate_feature_post!(&self, extern_types, i.span, "extern types are experimental");
             }
             ast::ForeignItemKind::Macro(..) => {}
         }
@@ -465,8 +514,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
                 self.check_extern(bare_fn_ty.ext);
             }
             ast::TyKind::Never => {
-                gate_feature_post!(&self, never_type, ty.span,
-                                   "The `!` type is experimental");
+                gate_feature_post!(&self, never_type, ty.span, "The `!` type is experimental");
             }
             _ => {}
         }
@@ -487,7 +535,9 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
         match e.kind {
             ast::ExprKind::Box(_) => {
                 gate_feature_post!(
-                    &self, box_syntax, e.span,
+                    &self,
+                    box_syntax,
+                    e.span,
                     "box expression syntax is experimental; you can call `Box::new` instead"
                 );
             }
@@ -495,8 +545,12 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
                 // To avoid noise about type ascription in common syntax errors, only emit if it
                 // is the *only* error.
                 if self.parse_sess.span_diagnostic.err_count() == 0 {
-                    gate_feature_post!(&self, type_ascription, e.span,
-                                       "type ascription is experimental");
+                    gate_feature_post!(
+                        &self,
+                        type_ascription,
+                        e.span,
+                        "type ascription is experimental"
+                    );
                 }
             }
             ast::ExprKind::TryBlock(_) => {
@@ -504,8 +558,12 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
             }
             ast::ExprKind::Block(_, opt_label) => {
                 if let Some(label) = opt_label {
-                    gate_feature_post!(&self, label_break_value, label.ident.span,
-                                    "labels on blocks are unstable");
+                    gate_feature_post!(
+                        &self,
+                        label_break_value,
+                        label.ident.span,
+                        "labels on blocks are unstable"
+                    );
                 }
             }
             _ => {}
@@ -537,24 +595,33 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
                 }
             }
             PatKind::Box(..) => {
-                gate_feature_post!(&self, box_patterns,
-                                  pattern.span,
-                                  "box pattern syntax is experimental");
+                gate_feature_post!(
+                    &self,
+                    box_patterns,
+                    pattern.span,
+                    "box pattern syntax is experimental"
+                );
             }
             PatKind::Range(_, _, Spanned { node: RangeEnd::Excluded, .. }) => {
-                gate_feature_post!(&self, exclusive_range_pattern, pattern.span,
-                                   "exclusive range pattern syntax is experimental");
+                gate_feature_post!(
+                    &self,
+                    exclusive_range_pattern,
+                    pattern.span,
+                    "exclusive range pattern syntax is experimental"
+                );
             }
             _ => {}
         }
         visit::walk_pat(self, pattern)
     }
 
-    fn visit_fn(&mut self,
-                fn_kind: FnKind<'a>,
-                fn_decl: &'a ast::FnDecl,
-                span: Span,
-                _node_id: NodeId) {
+    fn visit_fn(
+        &mut self,
+        fn_kind: FnKind<'a>,
+        fn_decl: &'a ast::FnDecl,
+        span: Span,
+        _node_id: NodeId,
+    ) {
         if let Some(header) = fn_kind.header() {
             // Stability of const fn methods are covered in
             // `visit_trait_item` and `visit_impl_item` below; this is
@@ -571,9 +638,12 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
 
     fn visit_generic_param(&mut self, param: &'a GenericParam) {
         match param.kind {
-            GenericParamKind::Const { .. } =>
-                gate_feature_post!(&self, const_generics, param.ident.span,
-                    "const generics are unstable"),
+            GenericParamKind::Const { .. } => gate_feature_post!(
+                &self,
+                const_generics,
+                param.ident.span,
+                "const generics are unstable"
+            ),
             _ => {}
         }
         visit::walk_generic_param(self, param)
@@ -581,9 +651,12 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
 
     fn visit_assoc_ty_constraint(&mut self, constraint: &'a AssocTyConstraint) {
         match constraint.kind {
-            AssocTyConstraintKind::Bound { .. } =>
-                gate_feature_post!(&self, associated_type_bounds, constraint.span,
-                    "associated type bounds are unstable"),
+            AssocTyConstraintKind::Bound { .. } => gate_feature_post!(
+                &self,
+                associated_type_bounds,
+                constraint.span,
+                "associated type bounds are unstable"
+            ),
             _ => {}
         }
         visit::walk_assoc_ty_constraint(self, constraint)
@@ -602,7 +675,9 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
             ast::AssocItemKind::TyAlias(_, ref default) => {
                 if let Some(_) = default {
                     gate_feature_post!(
-                        &self, associated_type_defaults, ti.span,
+                        &self,
+                        associated_type_defaults,
+                        ti.span,
                         "associated type defaults are unstable"
                     );
                 }
@@ -621,7 +696,9 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
             ast::AssocItemKind::Fn(ref sig, _) => {
                 if sig.decl.c_variadic() {
                     gate_feature_post!(
-                        &self, c_variadic, ii.span,
+                        &self,
+                        c_variadic,
+                        ii.span,
                         "C-variadic functions are unstable"
                     );
                 }
@@ -639,15 +716,23 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
 
     fn visit_vis(&mut self, vis: &'a ast::Visibility) {
         if let ast::VisibilityKind::Crate(ast::CrateSugar::JustCrate) = vis.node {
-            gate_feature_post!(&self, crate_visibility_modifier, vis.span,
-                               "`crate` visibility modifier is experimental");
+            gate_feature_post!(
+                &self,
+                crate_visibility_modifier,
+                vis.span,
+                "`crate` visibility modifier is experimental"
+            );
         }
         visit::walk_vis(self, vis)
     }
 }
 
-pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
-                    crate_edition: Edition, allow_features: &Option<Vec<String>>) -> Features {
+pub fn get_features(
+    span_handler: &Handler,
+    krate_attrs: &[ast::Attribute],
+    crate_edition: Edition,
+    allow_features: &Option<Vec<String>>,
+) -> Features {
     fn feature_removed(span_handler: &Handler, span: Span, reason: Option<&str>) {
         let mut err = struct_span_err!(span_handler, span, E0557, "feature has been removed");
         err.span_label(span, "feature has been removed");
@@ -677,7 +762,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
     // `edition_enabled_features` is completed before it's queried.
     for attr in krate_attrs {
         if !attr.check_name(sym::feature) {
-            continue
+            continue;
         }
 
         let list = match attr.meta_item_list() {
@@ -710,7 +795,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
 
     for attr in krate_attrs {
         if !attr.check_name(sym::feature) {
-            continue
+            continue;
         }
 
         let list = match attr.meta_item_list() {
@@ -726,17 +811,19 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
             let name = match mi.ident() {
                 Some(ident) if mi.is_word() => ident.name,
                 Some(ident) => {
-                    bad_input(mi.span()).span_suggestion(
-                        mi.span(),
-                        "expected just one word",
-                        format!("{}", ident.name),
-                        Applicability::MaybeIncorrect,
-                    ).emit();
-                    continue
+                    bad_input(mi.span())
+                        .span_suggestion(
+                            mi.span(),
+                            "expected just one word",
+                            format!("{}", ident.name),
+                            Applicability::MaybeIncorrect,
+                        )
+                        .emit();
+                    continue;
                 }
                 None => {
                     bad_input(mi.span()).span_label(mi.span(), "expected just one word").emit();
-                    continue
+                    continue;
                 }
             };
 
@@ -748,7 +835,8 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
                     "the feature `{}` is included in the Rust {} edition",
                     name,
                     edition,
-                ).emit();
+                )
+                .emit();
                 continue;
             }
 
@@ -760,8 +848,8 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
             let removed = REMOVED_FEATURES.iter().find(|f| name == f.name);
             let stable_removed = STABLE_REMOVED_FEATURES.iter().find(|f| name == f.name);
             if let Some(Feature { state, .. }) = removed.or(stable_removed) {
-                if let FeatureState::Removed { reason }
-                | FeatureState::Stabilized { reason } = state
+                if let FeatureState::Removed { reason } | FeatureState::Stabilized { reason } =
+                    state
                 {
                     feature_removed(span_handler, mi.span(), *reason);
                     continue;
@@ -776,9 +864,13 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
 
             if let Some(allowed) = allow_features.as_ref() {
                 if allowed.iter().find(|&f| name.as_str() == *f).is_none() {
-                    span_err!(span_handler, mi.span(), E0725,
-                              "the feature `{}` is not in the list of allowed features",
-                              name);
+                    span_err!(
+                        span_handler,
+                        mi.span(),
+                        E0725,
+                        "the feature `{}` is not in the list of allowed features",
+                        name
+                    );
                     continue;
                 }
             }
@@ -796,21 +888,18 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
     features
 }
 
-fn active_features_up_to(edition: Edition) -> impl Iterator<Item=&'static Feature> {
-    ACTIVE_FEATURES.iter()
-    .filter(move |feature| {
-        if let Some(feature_edition) = feature.edition {
-            feature_edition <= edition
-        } else {
-            false
-        }
+fn active_features_up_to(edition: Edition) -> impl Iterator<Item = &'static Feature> {
+    ACTIVE_FEATURES.iter().filter(move |feature| {
+        if let Some(feature_edition) = feature.edition { feature_edition <= edition } else { false }
     })
 }
 
-pub fn check_crate(krate: &ast::Crate,
-                   parse_sess: &ParseSess,
-                   features: &Features,
-                   unstable: UnstableFeatures) {
+pub fn check_crate(
+    krate: &ast::Crate,
+    parse_sess: &ParseSess,
+    features: &Features,
+    unstable: UnstableFeatures,
+) {
     maybe_stage_features(&parse_sess.span_diagnostic, krate, unstable);
     let mut visitor = PostExpansionVisitor { parse_sess, features };
 
@@ -820,7 +909,7 @@ pub fn check_crate(krate: &ast::Crate,
             for span in spans.get(&sym::$gate).unwrap_or(&vec![]) {
                 gate_feature!(&visitor, $gate, *span, $msg);
             }
-        }
+        };
     }
     gate_all!(let_chains, "`let` expressions in this position are experimental");
     gate_all!(async_closure, "async closures are unstable");
@@ -840,7 +929,7 @@ pub fn check_crate(krate: &ast::Crate,
                     gate_feature!(&visitor, $gate, *span, $msg);
                 }
             }
-        }
+        };
     }
 
     gate_all!(trait_alias, "trait aliases are experimental");
@@ -866,7 +955,9 @@ fn maybe_stage_features(span_handler: &Handler, krate: &ast::Crate, unstable: Un
     if !unstable.is_nightly_build() {
         for attr in krate.attrs.iter().filter(|attr| attr.check_name(sym::feature)) {
             span_err!(
-                span_handler, attr.span, E0554,
+                span_handler,
+                attr.span,
+                E0554,
                 "`#![feature]` may not be used on the {} release channel",
                 option_env!("CFG_RELEASE_CHANNEL").unwrap_or("(unknown)")
             );