1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
13 //! This module implements the gating necessary for preventing certain compiler
14 //! features from being used by default. This module will crawl a pre-expanded
15 //! AST to ensure that there are no features which are used that are not
18 //! Features are enabled in programs via the crate-level attributes of
19 //! `#![feature(...)]` with a comma-separated list of features.
21 //! For the purpose of future feature-tracking, once code for detection of feature
22 //! gate usage is added, *do not remove it again* even once the feature
26 use self::AttributeType
::*;
32 use attr
::AttrMetaMethods
;
33 use codemap
::{CodeMap, Span}
;
34 use diagnostic
::SpanHandler
;
37 use parse
::token
::{self, InternedString}
;
39 use std
::ascii
::AsciiExt
;
41 // If you change this list without updating src/doc/reference.md, @cmr will be sad
42 // Don't ever remove anything from this list; set them to 'Removed'.
43 // The version numbers here correspond to the version in which the current status
44 // was set. This is most important for knowing when a particular feature became
46 // NB: The featureck.py script parses this information directly out of the source
47 // so take care when modifying it.
48 const KNOWN_FEATURES
: &'
static [(&'
static str, &'
static str, Status
)] = &[
49 ("globs", "1.0.0", Accepted
),
50 ("macro_rules", "1.0.0", Accepted
),
51 ("struct_variant", "1.0.0", Accepted
),
52 ("asm", "1.0.0", Active
),
53 ("managed_boxes", "1.0.0", Removed
),
54 ("non_ascii_idents", "1.0.0", Active
),
55 ("thread_local", "1.0.0", Active
),
56 ("link_args", "1.0.0", Active
),
57 ("plugin_registrar", "1.0.0", Active
),
58 ("log_syntax", "1.0.0", Active
),
59 ("trace_macros", "1.0.0", Active
),
60 ("concat_idents", "1.0.0", Active
),
61 ("intrinsics", "1.0.0", Active
),
62 ("lang_items", "1.0.0", Active
),
64 ("simd", "1.0.0", Active
),
65 ("default_type_params", "1.0.0", Accepted
),
66 ("quote", "1.0.0", Active
),
67 ("link_llvm_intrinsics", "1.0.0", Active
),
68 ("linkage", "1.0.0", Active
),
69 ("struct_inherit", "1.0.0", Removed
),
71 ("quad_precision_float", "1.0.0", Removed
),
73 ("rustc_diagnostic_macros", "1.0.0", Active
),
74 ("unboxed_closures", "1.0.0", Active
),
75 ("reflect", "1.0.0", Active
),
76 ("import_shadowing", "1.0.0", Removed
),
77 ("advanced_slice_patterns", "1.0.0", Active
),
78 ("tuple_indexing", "1.0.0", Accepted
),
79 ("associated_types", "1.0.0", Accepted
),
80 ("visible_private_types", "1.0.0", Active
),
81 ("slicing_syntax", "1.0.0", Accepted
),
82 ("box_syntax", "1.0.0", Active
),
83 ("on_unimplemented", "1.0.0", Active
),
84 ("simd_ffi", "1.0.0", Active
),
85 ("allocator", "1.0.0", Active
),
87 ("if_let", "1.0.0", Accepted
),
88 ("while_let", "1.0.0", Accepted
),
90 ("plugin", "1.0.0", Active
),
91 ("start", "1.0.0", Active
),
92 ("main", "1.0.0", Active
),
94 ("fundamental", "1.0.0", Active
),
96 // A temporary feature gate used to enable parser extensions needed
97 // to bootstrap fix for #5723.
98 ("issue_5723_bootstrap", "1.0.0", Accepted
),
100 // A way to temporarily opt out of opt in copy. This will *never* be accepted.
101 ("opt_out_copy", "1.0.0", Removed
),
103 // OIBIT specific features
104 ("optin_builtin_traits", "1.0.0", Active
),
106 // macro reexport needs more discussion and stabilization
107 ("macro_reexport", "1.0.0", Active
),
109 // These are used to test this portion of the compiler, they don't actually
111 ("test_accepted_feature", "1.0.0", Accepted
),
112 ("test_removed_feature", "1.0.0", Removed
),
114 // Allows use of #[staged_api]
115 ("staged_api", "1.0.0", Active
),
117 // Allows using items which are missing stability attributes
118 ("unmarked_api", "1.0.0", Active
),
120 // Allows using #![no_std]
121 ("no_std", "1.0.0", Active
),
123 // Allows using `box` in patterns; RFC 469
124 ("box_patterns", "1.0.0", Active
),
126 // Allows using the unsafe_no_drop_flag attribute (unlikely to
127 // switch to Accepted; see RFC 320)
128 ("unsafe_no_drop_flag", "1.0.0", Active
),
130 // Allows the use of custom attributes; RFC 572
131 ("custom_attribute", "1.0.0", Active
),
133 // Allows the use of #[derive(Anything)] as sugar for
134 // #[derive_Anything].
135 ("custom_derive", "1.0.0", Active
),
137 // Allows the use of rustc_* attributes; RFC 572
138 ("rustc_attrs", "1.0.0", Active
),
140 // Allows the use of `static_assert`
141 ("static_assert", "1.0.0", Active
),
143 // Allows the use of #[allow_internal_unstable]. This is an
144 // attribute on macro_rules! and can't use the attribute handling
145 // below (it has to be checked before expansion possibly makes
146 // macros disappear).
147 ("allow_internal_unstable", "1.0.0", Active
),
149 // #23121. Array patterns have some hazards yet.
150 ("slice_patterns", "1.0.0", Active
),
152 // Allows use of unary negate on unsigned integers, e.g. -e for e: u8
153 ("negate_unsigned", "1.0.0", Active
),
155 // Allows the definition of associated constants in `trait` or `impl`
157 ("associated_consts", "1.0.0", Active
),
159 // (changing above list without updating src/doc/reference.md makes @cmr sad)
162 /// Represents an active feature that is currently being implemented or
163 /// currently being considered for addition/removal.
166 /// Represents a feature which has since been removed (it was once Active)
169 /// This language feature has since been Accepted (it was once Active)
173 // Attributes that have a special meaning to rustc or rustdoc
174 pub const KNOWN_ATTRIBUTES
: &'
static [(&'
static str, AttributeType
)] = &[
182 ("macro_reexport", Normal
),
183 ("macro_use", Normal
),
184 ("macro_export", Normal
),
185 ("plugin_registrar", Normal
),
188 ("cfg_attr", Normal
),
197 ("automatically_derived", Normal
),
198 ("no_mangle", Normal
),
201 ("should_panic", Normal
),
203 ("no_implicit_prelude", Normal
),
204 ("reexport_test_harness_main", Normal
),
205 ("link_args", Normal
),
206 ("macro_escape", Normal
),
208 ("staged_api", Gated("staged_api",
209 "staged_api is for use by rustc only")),
210 ("plugin", Gated("plugin",
211 "compiler plugins are experimental \
212 and possibly buggy")),
213 ("no_std", Gated("no_std",
214 "no_std is experimental")),
215 ("lang", Gated("lang_items",
216 "language items are subject to change")),
217 ("linkage", Gated("linkage",
218 "the `linkage` attribute is experimental \
219 and not portable across platforms")),
220 ("thread_local", Gated("thread_local",
221 "`#[thread_local]` is an experimental feature, and does not \
222 currently handle destructors. There is no corresponding \
223 `#[task_local]` mapping to the task model")),
225 ("rustc_on_unimplemented", Gated("on_unimplemented",
226 "the `#[rustc_on_unimplemented]` attribute \
227 is an experimental feature")),
228 ("allocator", Gated("allocator",
229 "the `#[allocator]` attribute is an experimental feature")),
230 ("rustc_variance", Gated("rustc_attrs",
231 "the `#[rustc_variance]` attribute \
232 is an experimental feature")),
233 ("rustc_error", Gated("rustc_attrs",
234 "the `#[rustc_error]` attribute \
235 is an experimental feature")),
236 ("rustc_move_fragments", Gated("rustc_attrs",
237 "the `#[rustc_move_fragments]` attribute \
238 is an experimental feature")),
240 ("allow_internal_unstable", Gated("allow_internal_unstable",
241 EXPLAIN_ALLOW_INTERNAL_UNSTABLE
)),
243 ("fundamental", Gated("fundamental",
244 "the `#[fundamental]` attribute \
245 is an experimental feature")),
247 // FIXME: #14408 whitelist docs since rustdoc looks at them
248 ("doc", Whitelisted
),
250 // FIXME: #14406 these are processed in trans, which happens after the
252 ("cold", Whitelisted
),
253 ("export_name", Whitelisted
),
254 ("inline", Whitelisted
),
255 ("link", Whitelisted
),
256 ("link_name", Whitelisted
),
257 ("link_section", Whitelisted
),
258 ("no_builtins", Whitelisted
),
259 ("no_mangle", Whitelisted
),
260 ("no_stack_check", Whitelisted
),
261 ("packed", Whitelisted
),
262 ("static_assert", Gated("static_assert",
263 "`#[static_assert]` is an experimental feature, and has a poor API")),
264 ("no_debug", Whitelisted
),
265 ("omit_gdb_pretty_printer_section", Whitelisted
),
266 ("unsafe_no_drop_flag", Gated("unsafe_no_drop_flag",
267 "unsafe_no_drop_flag has unstable semantics \
268 and may be removed in the future")),
271 ("prelude_import", Whitelisted
),
273 // FIXME: #14407 these are only looked at on-demand so we can't
274 // guarantee they'll have already been checked
275 ("deprecated", Whitelisted
),
276 ("must_use", Whitelisted
),
277 ("stable", Whitelisted
),
278 ("unstable", Whitelisted
),
280 ("rustc_paren_sugar", Gated("unboxed_closures",
281 "unboxed_closures are still evolving")),
282 ("rustc_reflect_like", Gated("reflect",
283 "defining reflective traits is still evolving")),
285 // Crate level attributes
286 ("crate_name", CrateLevel
),
287 ("crate_type", CrateLevel
),
288 ("crate_id", CrateLevel
),
289 ("feature", CrateLevel
),
290 ("no_start", CrateLevel
),
291 ("no_main", CrateLevel
),
292 ("no_builtins", CrateLevel
),
293 ("recursion_limit", CrateLevel
),
296 #[derive(PartialEq, Copy, Clone, Debug)]
297 pub enum AttributeType
{
298 /// Normal, builtin attribute that is consumed
299 /// by the compiler before the unused_attribute check
302 /// Builtin attribute that may not be consumed by the compiler
303 /// before the unused_attribute check. These attributes
304 /// will be ignored by the unused_attribute lint
307 /// Is gated by a given feature gate and reason
308 /// These get whitelisted too
309 Gated(&'
static str, &'
static str),
311 /// Builtin attribute that is only allowed at the crate level
315 /// A set of features to be used by later passes.
316 pub struct Features
{
317 pub unboxed_closures
: bool
,
318 pub rustc_diagnostic_macros
: bool
,
319 pub visible_private_types
: bool
,
320 pub allow_quote
: bool
,
322 pub allow_log_syntax
: bool
,
323 pub allow_concat_idents
: bool
,
324 pub allow_trace_macros
: bool
,
325 pub allow_internal_unstable
: bool
,
326 pub allow_custom_derive
: bool
,
328 pub unmarked_api
: bool
,
329 pub negate_unsigned
: bool
,
330 /// spans of #![feature] attrs for stable language features. for error reporting
331 pub declared_stable_lang_features
: Vec
<Span
>,
332 /// #![feature] attrs for non-language (library) features
333 pub declared_lib_features
: Vec
<(InternedString
, Span
)>
337 pub fn new() -> Features
{
339 unboxed_closures
: false,
340 rustc_diagnostic_macros
: false,
341 visible_private_types
: false,
344 allow_log_syntax
: false,
345 allow_concat_idents
: false,
346 allow_trace_macros
: false,
347 allow_internal_unstable
: false,
348 allow_custom_derive
: false,
351 negate_unsigned
: false,
352 declared_stable_lang_features
: Vec
::new(),
353 declared_lib_features
: Vec
::new()
359 features
: Vec
<&'
static str>,
360 span_handler
: &'a SpanHandler
,
364 impl<'a
> Context
<'a
> {
365 fn gate_feature(&self, feature
: &str, span
: Span
, explain
: &str) {
366 let has_feature
= self.has_feature(feature
);
367 debug
!("gate_feature(feature = {:?}, span = {:?}); has? {}", feature
, span
, has_feature
);
369 emit_feature_err(self.span_handler
, feature
, span
, explain
);
372 fn has_feature(&self, feature
: &str) -> bool
{
373 self.features
.iter().any(|&n
| n
== feature
)
376 fn check_attribute(&self, attr
: &ast
::Attribute
) {
377 debug
!("check_attribute(attr = {:?})", attr
);
378 let name
= &*attr
.name();
379 for &(n
, ty
) in KNOWN_ATTRIBUTES
{
381 if let Gated(gate
, desc
) = ty
{
382 self.gate_feature(gate
, attr
.span
, desc
);
384 debug
!("check_attribute: {:?} is known, {:?}", name
, ty
);
388 if name
.starts_with("rustc_") {
389 self.gate_feature("rustc_attrs", attr
.span
,
390 "unless otherwise specified, attributes \
391 with the prefix `rustc_` \
392 are reserved for internal compiler diagnostics");
393 } else if name
.starts_with("derive_") {
394 self.gate_feature("custom_derive", attr
.span
,
395 "attributes of the form `#[derive_*]` are reserved \
398 self.gate_feature("custom_attribute", attr
.span
,
399 &format
!("The attribute `{}` is currently \
400 unknown to the compiler and \
402 added to it in the future",
408 pub fn emit_feature_err(diag
: &SpanHandler
, feature
: &str, span
: Span
, explain
: &str) {
409 diag
.span_err(span
, explain
);
411 // #23973: do not suggest `#![feature(...)]` if we are in beta/stable
412 if option_env
!("CFG_DISABLE_UNSTABLE_FEATURES").is_some() { return; }
413 diag
.fileline_help(span
, &format
!("add #![feature({})] to the \
414 crate attributes to enable",
418 pub fn emit_feature_warn(diag
: &SpanHandler
, feature
: &str, span
: Span
, explain
: &str) {
419 diag
.span_warn(span
, explain
);
421 // #23973: do not suggest `#![feature(...)]` if we are in beta/stable
422 if option_env
!("CFG_DISABLE_UNSTABLE_FEATURES").is_some() { return; }
423 if diag
.handler
.can_emit_warnings
{
424 diag
.fileline_help(span
, &format
!("add #![feature({})] to the \
425 crate attributes to silence this warning",
430 pub const EXPLAIN_ASM
: &'
static str =
431 "inline assembly is not stable enough for use and is subject to change";
433 pub const EXPLAIN_LOG_SYNTAX
: &'
static str =
434 "`log_syntax!` is not stable enough for use and is subject to change";
436 pub const EXPLAIN_CONCAT_IDENTS
: &'
static str =
437 "`concat_idents` is not stable enough for use and is subject to change";
439 pub const EXPLAIN_TRACE_MACROS
: &'
static str =
440 "`trace_macros` is not stable enough for use and is subject to change";
441 pub const EXPLAIN_ALLOW_INTERNAL_UNSTABLE
: &'
static str =
442 "allow_internal_unstable side-steps feature gating and stability checks";
444 pub const EXPLAIN_CUSTOM_DERIVE
: &'
static str =
445 "`#[derive]` for custom traits is not stable enough for use and is subject to change";
447 struct MacroVisitor
<'a
> {
448 context
: &'a Context
<'a
>
451 impl<'a
, 'v
> Visitor
<'v
> for MacroVisitor
<'a
> {
452 fn visit_mac(&mut self, mac
: &ast
::Mac
) {
453 let ast
::MacInvocTT(ref path
, _
, _
) = mac
.node
;
454 let id
= path
.segments
.last().unwrap().identifier
;
456 // Issue 22234: If you add a new case here, make sure to also
457 // add code to catch the macro during or after expansion.
459 // We still keep this MacroVisitor (rather than *solely*
460 // relying on catching cases during or after expansion) to
461 // catch uses of these macros within conditionally-compiled
462 // code, e.g. `#[cfg]`-guarded functions.
464 if id
== token
::str_to_ident("asm") {
465 self.context
.gate_feature("asm", path
.span
, EXPLAIN_ASM
);
468 else if id
== token
::str_to_ident("log_syntax") {
469 self.context
.gate_feature("log_syntax", path
.span
, EXPLAIN_LOG_SYNTAX
);
472 else if id
== token
::str_to_ident("trace_macros") {
473 self.context
.gate_feature("trace_macros", path
.span
, EXPLAIN_TRACE_MACROS
);
476 else if id
== token
::str_to_ident("concat_idents") {
477 self.context
.gate_feature("concat_idents", path
.span
, EXPLAIN_CONCAT_IDENTS
);
481 fn visit_attribute(&mut self, attr
: &'v ast
::Attribute
) {
482 self.context
.check_attribute(attr
);
486 struct PostExpansionVisitor
<'a
> {
487 context
: &'a Context
<'a
>
490 impl<'a
> PostExpansionVisitor
<'a
> {
491 fn gate_feature(&self, feature
: &str, span
: Span
, explain
: &str) {
492 if !self.context
.cm
.span_allows_unstable(span
) {
493 self.context
.gate_feature(feature
, span
, explain
)
498 impl<'a
, 'v
> Visitor
<'v
> for PostExpansionVisitor
<'a
> {
499 fn visit_attribute(&mut self, attr
: &ast
::Attribute
) {
500 if !self.context
.cm
.span_allows_unstable(attr
.span
) {
501 self.context
.check_attribute(attr
);
505 fn visit_name(&mut self, sp
: Span
, name
: ast
::Name
) {
506 if !token
::get_name(name
).is_ascii() {
507 self.gate_feature("non_ascii_idents", sp
,
508 "non-ascii idents are not fully supported.");
512 fn visit_item(&mut self, i
: &ast
::Item
) {
514 ast
::ItemExternCrate(_
) => {
515 if attr
::contains_name(&i
.attrs
[..], "macro_reexport") {
516 self.gate_feature("macro_reexport", i
.span
,
517 "macros reexports are experimental \
518 and possibly buggy");
522 ast
::ItemForeignMod(ref foreign_module
) => {
523 if attr
::contains_name(&i
.attrs
[..], "link_args") {
524 self.gate_feature("link_args", i
.span
,
525 "the `link_args` attribute is not portable \
526 across platforms, it is recommended to \
527 use `#[link(name = \"foo\")]` instead")
529 if foreign_module
.abi
== Abi
::RustIntrinsic
{
530 self.gate_feature("intrinsics",
532 "intrinsics are subject to change")
537 if attr
::contains_name(&i
.attrs
[..], "plugin_registrar") {
538 self.gate_feature("plugin_registrar", i
.span
,
539 "compiler plugins are experimental and possibly buggy");
541 if attr
::contains_name(&i
.attrs
[..], "start") {
542 self.gate_feature("start", i
.span
,
543 "a #[start] function is an experimental \
544 feature whose signature may change \
547 if attr
::contains_name(&i
.attrs
[..], "main") {
548 self.gate_feature("main", i
.span
,
549 "declaration of a nonstandard #[main] \
550 function may change over time, for now \
551 a top-level `fn main()` is required");
555 ast
::ItemStruct(..) => {
556 if attr
::contains_name(&i
.attrs
[..], "simd") {
557 self.gate_feature("simd", i
.span
,
558 "SIMD types are experimental and possibly buggy");
562 ast
::ItemDefaultImpl(..) => {
563 self.gate_feature("optin_builtin_traits",
565 "default trait implementations are experimental \
566 and possibly buggy");
569 ast
::ItemImpl(_
, polarity
, _
, _
, _
, _
) => {
571 ast
::ImplPolarity
::Negative
=> {
572 self.gate_feature("optin_builtin_traits",
574 "negative trait bounds are not yet fully implemented; \
575 use marker types for now");
584 visit
::walk_item(self, i
);
587 fn visit_foreign_item(&mut self, i
: &ast
::ForeignItem
) {
588 let links_to_llvm
= match attr
::first_attr_value_str_by_name(&i
.attrs
,
590 Some(val
) => val
.starts_with("llvm."),
594 self.gate_feature("link_llvm_intrinsics", i
.span
,
595 "linking to LLVM intrinsics is experimental");
598 visit
::walk_foreign_item(self, i
)
601 fn visit_expr(&mut self, e
: &ast
::Expr
) {
603 ast
::ExprBox(..) | ast
::ExprUnary(ast
::UnOp
::UnUniq
, _
) => {
604 self.gate_feature("box_syntax",
606 "box expression syntax is experimental; \
607 you can call `Box::new` instead.");
611 visit
::walk_expr(self, e
);
614 fn visit_pat(&mut self, pattern
: &ast
::Pat
) {
616 ast
::PatVec(_
, Some(_
), ref last
) if !last
.is_empty() => {
617 self.gate_feature("advanced_slice_patterns",
619 "multiple-element slice matches anywhere \
620 but at the end of a slice (e.g. \
621 `[0, ..xs, 0]`) are experimental")
624 self.gate_feature("slice_patterns",
626 "slice pattern syntax is experimental");
629 self.gate_feature("box_patterns",
631 "box pattern syntax is experimental");
635 visit
::walk_pat(self, pattern
)
638 fn visit_fn(&mut self,
639 fn_kind
: visit
::FnKind
<'v
>,
640 fn_decl
: &'v ast
::FnDecl
,
641 block
: &'v ast
::Block
,
645 visit
::FkItemFn(_
, _
, _
, abi
, _
) if abi
== Abi
::RustIntrinsic
=> {
646 self.gate_feature("intrinsics",
648 "intrinsics are subject to change")
650 visit
::FkItemFn(_
, _
, _
, abi
, _
) |
651 visit
::FkMethod(_
, &ast
::MethodSig { abi, .. }
, _
) if abi
== Abi
::RustCall
=> {
652 self.gate_feature("unboxed_closures",
654 "rust-call ABI is subject to change")
658 visit
::walk_fn(self, fn_kind
, fn_decl
, block
, span
);
661 fn visit_trait_item(&mut self, ti
: &'v ast
::TraitItem
) {
663 ast
::ConstTraitItem(..) => {
664 self.gate_feature("associated_consts",
666 "associated constants are experimental")
670 visit
::walk_trait_item(self, ti
);
673 fn visit_impl_item(&mut self, ii
: &'v ast
::ImplItem
) {
675 ast
::ConstImplItem(..) => {
676 self.gate_feature("associated_consts",
678 "associated constants are experimental")
682 visit
::walk_impl_item(self, ii
);
686 fn check_crate_inner
<F
>(cm
: &CodeMap
, span_handler
: &SpanHandler
,
690 where F
: FnOnce(&mut Context
, &ast
::Crate
)
692 let mut cx
= Context
{
693 features
: Vec
::new(),
694 span_handler
: span_handler
,
698 let mut accepted_features
= Vec
::new();
699 let mut unknown_features
= Vec
::new();
701 for attr
in &krate
.attrs
{
702 if !attr
.check_name("feature") {
706 match attr
.meta_item_list() {
708 span_handler
.span_err(attr
.span
, "malformed feature attribute, \
709 expected #![feature(...)]");
713 let name
= match mi
.node
{
714 ast
::MetaWord(ref word
) => (*word
).clone(),
716 span_handler
.span_err(mi
.span
,
717 "malformed feature, expected just \
722 match KNOWN_FEATURES
.iter()
723 .find(|& &(n
, _
, _
)| name
== n
) {
724 Some(&(name
, _
, Active
)) => {
725 cx
.features
.push(name
);
727 Some(&(_
, _
, Removed
)) => {
728 span_handler
.span_err(mi
.span
, "feature has been removed");
730 Some(&(_
, _
, Accepted
)) => {
731 accepted_features
.push(mi
.span
);
734 unknown_features
.push((name
, mi
.span
));
742 check(&mut cx
, krate
);
744 // FIXME (pnkfelix): Before adding the 99th entry below, change it
745 // to a single-pass (instead of N calls to `.has_feature`).
748 unboxed_closures
: cx
.has_feature("unboxed_closures"),
749 rustc_diagnostic_macros
: cx
.has_feature("rustc_diagnostic_macros"),
750 visible_private_types
: cx
.has_feature("visible_private_types"),
751 allow_quote
: cx
.has_feature("quote"),
752 allow_asm
: cx
.has_feature("asm"),
753 allow_log_syntax
: cx
.has_feature("log_syntax"),
754 allow_concat_idents
: cx
.has_feature("concat_idents"),
755 allow_trace_macros
: cx
.has_feature("trace_macros"),
756 allow_internal_unstable
: cx
.has_feature("allow_internal_unstable"),
757 allow_custom_derive
: cx
.has_feature("custom_derive"),
758 simd_ffi
: cx
.has_feature("simd_ffi"),
759 unmarked_api
: cx
.has_feature("unmarked_api"),
760 negate_unsigned
: cx
.has_feature("negate_unsigned"),
761 declared_stable_lang_features
: accepted_features
,
762 declared_lib_features
: unknown_features
766 pub fn check_crate_macros(cm
: &CodeMap
, span_handler
: &SpanHandler
, krate
: &ast
::Crate
)
768 check_crate_inner(cm
, span_handler
, krate
,
769 |ctx
, krate
| visit
::walk_crate(&mut MacroVisitor { context: ctx }
, krate
))
772 pub fn check_crate(cm
: &CodeMap
, span_handler
: &SpanHandler
, krate
: &ast
::Crate
)
775 check_crate_inner(cm
, span_handler
, krate
,
776 |ctx
, krate
| visit
::walk_crate(&mut PostExpansionVisitor { context: ctx }
,