mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-27 19:16:36 +00:00
We already do this for a number of crates, e.g. `rustc_middle`, `rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`. For the ones we don't, in many cases the attributes are a mess. - There is no consistency about order of attribute kinds (e.g. `allow`/`deny`/`feature`). - Within attribute kind groups (e.g. the `feature` attributes), sometimes the order is alphabetical, and sometimes there is no particular order. - Sometimes the attributes of a particular kind aren't even grouped all together, e.g. there might be a `feature`, then an `allow`, then another `feature`. This commit extends the existing sorting to all compiler crates, increasing consistency. If any new attribute line is added there is now only one place it can go -- no need for arbitrary decisions. Exceptions: - `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`, because they have no crate attributes. - `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's ignored in `rustfmt.toml`).
63 lines
1.6 KiB
Rust
63 lines
1.6 KiB
Rust
//! The Rust Abstract Syntax Tree (AST).
|
|
//!
|
|
//! # Note
|
|
//!
|
|
//! This API is completely unstable and subject to change.
|
|
|
|
// tidy-alphabetical-start
|
|
#![allow(internal_features)]
|
|
#![doc(
|
|
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
|
|
test(attr(deny(warnings)))
|
|
)]
|
|
#![doc(rust_logo)]
|
|
#![feature(associated_type_defaults)]
|
|
#![feature(box_patterns)]
|
|
#![feature(if_let_guard)]
|
|
#![feature(let_chains)]
|
|
#![feature(negative_impls)]
|
|
#![feature(never_type)]
|
|
#![feature(rustdoc_internals)]
|
|
#![feature(stmt_expr_attributes)]
|
|
// tidy-alphabetical-end
|
|
|
|
pub mod util {
|
|
pub mod case;
|
|
pub mod classify;
|
|
pub mod comments;
|
|
pub mod literal;
|
|
pub mod parser;
|
|
pub mod unicode;
|
|
}
|
|
|
|
pub mod ast;
|
|
pub mod ast_traits;
|
|
pub mod attr;
|
|
pub mod entry;
|
|
pub mod expand;
|
|
pub mod format;
|
|
pub mod mut_visit;
|
|
pub mod node_id;
|
|
pub mod ptr;
|
|
pub mod token;
|
|
pub mod tokenstream;
|
|
pub mod visit;
|
|
|
|
pub use self::ast::*;
|
|
pub use self::ast_traits::{AstDeref, AstNodeWrapper, HasAttrs, HasNodeId, HasSpan, HasTokens};
|
|
|
|
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 `rustc_middle`.
|
|
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)
|
|
}
|
|
}
|