]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #45771 - petrochenkov:crate, r=nikomatsakis
authorbors <bors@rust-lang.org>
Tue, 21 Nov 2017 12:32:59 +0000 (12:32 +0000)
committerbors <bors@rust-lang.org>
Tue, 21 Nov 2017 12:32:59 +0000 (12:32 +0000)
Support `::crate` in paths

cc https://github.com/rust-lang/rust/issues/45477
Fixes https://github.com/rust-lang/rust/issues/45229

1  2 
src/libsyntax/feature_gate.rs

index 5c7450baa2f7db4746a551d8cb6de086c20c9a08,6b12b55eec7e16c2cc3a64d61d4a4afcfcff49a6..036c941499048d4aa1e743ef5cc0d5d2ddb4abca
@@@ -33,7 -33,7 +33,7 @@@ use syntax_pos::Span
  use errors::{DiagnosticBuilder, Handler, FatalError};
  use visit::{self, FnKind, Visitor};
  use parse::ParseSess;
- use symbol::Symbol;
+ use symbol::{keywords, Symbol};
  
  use std::env;
  
@@@ -381,8 -381,6 +381,8 @@@ declare_features! 
      (active, doc_cfg, "1.21.0", Some(43781)),
      // #[doc(masked)]
      (active, doc_masked, "1.21.0", Some(44027)),
 +    // #[doc(spotlight)]
 +    (active, doc_spotlight, "1.22.0", Some(45040)),
  
      // allow `#[must_use]` on functions and comparison operators (RFC 1940)
      (active, fn_must_use, "1.21.0", Some(43302)),
  
      // #![wasm_import_memory] attribute
      (active, wasm_import_memory, "1.22.0", None),
+     // `crate` in paths
+     (active, crate_in_paths, "1.23.0", Some(45477)),
  );
  
  declare_features! (
@@@ -1302,10 -1303,6 +1305,10 @@@ impl<'a> Visitor<'a> for PostExpansionV
                      gate_feature_post!(&self, doc_masked, attr.span,
                          "#[doc(masked)] is experimental"
                      );
 +                } else if content.iter().any(|c| c.check_name("spotlight")) {
 +                    gate_feature_post!(&self, doc_spotlight, attr.span,
 +                        "#[doc(spotlight)] is experimental"
 +                    );
                  }
              }
          }
          visit::walk_impl_item(self, ii);
      }
  
+     fn visit_path(&mut self, path: &'a ast::Path, _id: NodeId) {
+         for segment in &path.segments {
+             if segment.identifier.name == keywords::Crate.name() {
+                 gate_feature_post!(&self, crate_in_paths, segment.span,
+                                    "`crate` in paths is experimental");
+             }
+         }
+         visit::walk_path(self, path);
+     }
      fn visit_vis(&mut self, vis: &'a ast::Visibility) {
          if let ast::Visibility::Crate(span, ast::CrateSugar::JustCrate) = *vis {
              gate_feature_post!(&self, crate_visibility_modifier, span,