]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/lib.rs
Auto merge of #67000 - spastorino:remove-promoted-from-place, r=oli-obk
[rust.git] / src / libsyntax / lib.rs
index b537f16ffcd9ae15eefa001d7c71e87e0c536219..0184a3214b5b4985748e5d17f6e99f4d52be8f35 100644 (file)
@@ -7,7 +7,7 @@
 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))]
 #![feature(bool_to_option)]
 #![feature(box_syntax)]
-#![feature(const_fn)]
+#![feature(const_fn)] // For the `transmute` in `P::new`
 #![feature(const_transmute)]
 #![feature(crate_visibility_modifier)]
 #![feature(label_break_value)]
 #![recursion_limit = "256"]
 
 use ast::AttrId;
-pub use errors;
 use rustc_data_structures::sync::Lock;
 use rustc_index::bit_set::GrowableBitSet;
-use rustc_span::edition::Edition;
+use rustc_span::edition::{Edition, DEFAULT_EDITION};
 
 #[macro_export]
 macro_rules! unwrap_or {
@@ -51,29 +50,17 @@ fn new(edition: Edition) -> Globals {
     }
 }
 
-pub fn with_globals<F, R>(edition: Edition, f: F) -> R
-where
-    F: FnOnce() -> R,
-{
+pub fn with_globals<R>(edition: Edition, f: impl FnOnce() -> R) -> R {
     let globals = Globals::new(edition);
     GLOBALS.set(&globals, || rustc_span::GLOBALS.set(&globals.rustc_span_globals, f))
 }
 
-pub fn with_default_globals<F, R>(f: F) -> R
-where
-    F: FnOnce() -> R,
-{
-    with_globals(edition::DEFAULT_EDITION, f)
+pub fn with_default_globals<R>(f: impl FnOnce() -> R) -> R {
+    with_globals(DEFAULT_EDITION, f)
 }
 
 scoped_tls::scoped_thread_local!(pub static GLOBALS: Globals);
 
-#[macro_use]
-pub mod diagnostics {
-    #[macro_use]
-    pub mod macros;
-}
-
 pub mod util {
     pub mod classify;
     pub mod comments;
@@ -86,19 +73,11 @@ pub mod util {
 
 pub mod ast;
 pub mod attr;
-pub mod expand;
-pub use rustc_span::source_map;
 pub mod entry;
-pub mod feature_gate {
-    mod check;
-    pub use check::{check_attribute, check_crate, feature_err, feature_err_issue, get_features};
-}
+pub mod expand;
 pub mod mut_visit;
 pub mod ptr;
-pub mod show_span;
 pub use rustc_session::parse as sess;
-pub use rustc_span::edition;
-pub use rustc_span::symbol;
 pub mod token;
 pub mod tokenstream;
 pub mod visit;
@@ -109,9 +88,17 @@ pub mod print {
     pub mod pprust;
 }
 
-pub mod early_buffered_lints;
+use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
 
 /// Requirements for a `StableHashingContext` to be used in this crate.
 /// This is a hack to allow using the `HashStable_Generic` derive macro
 /// instead of implementing everything in librustc.
-pub trait HashStableContext: rustc_span::HashStableContext {}
+pub trait HashStableContext: rustc_span::HashStableContext {
+    fn hash_attr(&mut self, _: &ast::Attribute, hasher: &mut StableHasher);
+}
+
+impl<AstCtx: crate::HashStableContext> HashStable<AstCtx> for ast::Attribute {
+    fn hash_stable(&self, hcx: &mut AstCtx, hasher: &mut StableHasher) {
+        hcx.hash_attr(self, hasher)
+    }
+}