mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Format librustc_feature
Use #[rustfmt::skip] on the tidy-parsed macro invocations
This commit is contained in:
parent
6891388e66
commit
8d6d0e71a6
@ -10,10 +10,6 @@ ignore = [
|
||||
# (and generally rustfmt can move around comments in UI-testing incompatible ways)
|
||||
"src/test",
|
||||
|
||||
# tidy issues (line length, etc.)
|
||||
# to be fixed shortly
|
||||
"src/librustc_feature",
|
||||
|
||||
# do not format submodules
|
||||
"src/doc/book",
|
||||
"src/doc/edition-guide",
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! List of the accepted feature gates.
|
||||
|
||||
use super::{State, Feature};
|
||||
use super::{Feature, State};
|
||||
use syntax_pos::symbol::sym;
|
||||
|
||||
macro_rules! declare_features {
|
||||
@ -23,6 +23,7 @@ macro_rules! declare_features {
|
||||
}
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
declare_features! (
|
||||
// -------------------------------------------------------------------------
|
||||
// feature-group-start: for testing purposes
|
||||
|
@ -1,10 +1,10 @@
|
||||
//! List of the active feature gates.
|
||||
|
||||
use super::{State, Feature};
|
||||
use super::{Feature, State};
|
||||
|
||||
use syntax_pos::edition::Edition;
|
||||
use syntax_pos::symbol::{sym, Symbol};
|
||||
use syntax_pos::Span;
|
||||
use syntax_pos::symbol::{Symbol, sym};
|
||||
|
||||
macro_rules! set {
|
||||
($field: ident) => {{
|
||||
@ -12,7 +12,7 @@ macro_rules! set {
|
||||
features.$field = true;
|
||||
}
|
||||
f as fn(&mut Features, Span)
|
||||
}}
|
||||
}};
|
||||
}
|
||||
|
||||
macro_rules! declare_features {
|
||||
@ -72,7 +72,7 @@ impl Feature {
|
||||
pub fn set(&self, features: &mut Features, span: Span) {
|
||||
match self.state {
|
||||
State::Active { set } => set(features, span),
|
||||
_ => panic!("called `set` on feature `{}` which is not `active`", self.name)
|
||||
_ => panic!("called `set` on feature `{}` which is not `active`", self.name),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -91,6 +91,7 @@ impl Feature {
|
||||
// N.B., `tools/tidy/src/features.rs` parses this information directly out of the
|
||||
// source, so take care when modifying it.
|
||||
|
||||
#[rustfmt::skip]
|
||||
declare_features! (
|
||||
// -------------------------------------------------------------------------
|
||||
// feature-group-start: internal feature gates
|
||||
|
@ -1,20 +1,20 @@
|
||||
//! Built-in attributes and `cfg` flag gating.
|
||||
|
||||
use AttributeType::*;
|
||||
use AttributeGate::*;
|
||||
use AttributeType::*;
|
||||
|
||||
use crate::{Features, Stability};
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use syntax_pos::symbol::{Symbol, sym};
|
||||
use lazy_static::lazy_static;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use syntax_pos::symbol::{sym, Symbol};
|
||||
|
||||
type GateFn = fn(&Features) -> bool;
|
||||
|
||||
macro_rules! cfg_fn {
|
||||
($field: ident) => {
|
||||
(|features| { features.$field }) as GateFn
|
||||
}
|
||||
(|features| features.$field) as GateFn
|
||||
};
|
||||
}
|
||||
|
||||
pub type GatedCfg = (Symbol, Symbol, GateFn);
|
||||
@ -66,9 +66,10 @@ pub enum AttributeGate {
|
||||
impl std::fmt::Debug for AttributeGate {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match *self {
|
||||
Self::Gated(ref stab, name, expl, _) =>
|
||||
write!(fmt, "Gated({:?}, {}, {})", stab, name, expl),
|
||||
Self::Ungated => write!(fmt, "Ungated")
|
||||
Self::Gated(ref stab, name, expl, _) => {
|
||||
write!(fmt, "Gated({:?}, {}, {})", stab, name, expl)
|
||||
}
|
||||
Self::Ungated => write!(fmt, "Ungated"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -135,22 +136,31 @@ macro_rules! gated {
|
||||
macro_rules! rustc_attr {
|
||||
(TEST, $attr:ident, $typ:expr, $tpl:expr $(,)?) => {
|
||||
rustc_attr!(
|
||||
$attr, $typ, $tpl,
|
||||
concat!("the `#[", stringify!($attr), "]` attribute is just used for rustc unit tests \
|
||||
$attr,
|
||||
$typ,
|
||||
$tpl,
|
||||
concat!(
|
||||
"the `#[",
|
||||
stringify!($attr),
|
||||
"]` attribute is just used for rustc unit tests \
|
||||
and will never be stable",
|
||||
),
|
||||
)
|
||||
};
|
||||
($attr:ident, $typ:expr, $tpl:expr, $msg:expr $(,)?) => {
|
||||
(sym::$attr, $typ, $tpl,
|
||||
Gated(Stability::Unstable, sym::rustc_attrs, $msg, cfg_fn!(rustc_attrs)))
|
||||
(
|
||||
sym::$attr,
|
||||
$typ,
|
||||
$tpl,
|
||||
Gated(Stability::Unstable, sym::rustc_attrs, $msg, cfg_fn!(rustc_attrs)),
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! experimental {
|
||||
($attr:ident) => {
|
||||
concat!("the `#[", stringify!($attr), "]` attribute is an experimental feature")
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const IMPL_DETAIL: &str = "internal implementation detail";
|
||||
@ -159,6 +169,7 @@ const INTERNAL_UNSTABLE: &str = "this is an internal attribute that will never b
|
||||
pub type BuiltinAttribute = (Symbol, AttributeType, AttributeTemplate, AttributeGate);
|
||||
|
||||
/// Attributes that have a special meaning to rustc or rustdoc.
|
||||
#[rustfmt::skip]
|
||||
pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
||||
// ==========================================================================
|
||||
// Stable attributes:
|
||||
|
@ -11,13 +11,13 @@
|
||||
//! symbol to the `accepted` or `removed` modules respectively.
|
||||
|
||||
mod accepted;
|
||||
mod removed;
|
||||
mod active;
|
||||
mod builtin_attrs;
|
||||
mod removed;
|
||||
|
||||
use std::fmt;
|
||||
use std::num::NonZeroU32;
|
||||
use syntax_pos::{Span, edition::Edition, symbol::Symbol};
|
||||
use syntax_pos::{edition::Edition, symbol::Symbol, Span};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum State {
|
||||
@ -43,7 +43,7 @@ pub struct Feature {
|
||||
pub state: State,
|
||||
pub name: Symbol,
|
||||
pub since: &'static str,
|
||||
issue: Option<u32>, // FIXME: once #58732 is done make this an Option<NonZeroU32>
|
||||
issue: Option<u32>, // FIXME: once #58732 is done make this an Option<NonZeroU32>
|
||||
pub edition: Option<Edition>,
|
||||
description: &'static str,
|
||||
}
|
||||
@ -72,7 +72,7 @@ pub enum UnstableFeatures {
|
||||
/// during the build that feature-related lints are set to warn or above
|
||||
/// because the build turns on warnings-as-errors and uses lots of unstable
|
||||
/// features. As a result, this is always required for building Rust itself.
|
||||
Cheat
|
||||
Cheat,
|
||||
}
|
||||
|
||||
impl UnstableFeatures {
|
||||
@ -84,7 +84,7 @@ impl UnstableFeatures {
|
||||
match (disable_unstable_features, bootstrap) {
|
||||
(_, true) => UnstableFeatures::Cheat,
|
||||
(true, _) => UnstableFeatures::Disallow,
|
||||
(false, _) => UnstableFeatures::Allow
|
||||
(false, _) => UnstableFeatures::Allow,
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ fn find_lang_feature_issue(feature: Symbol) -> Option<NonZeroU32> {
|
||||
|
||||
pub enum GateIssue {
|
||||
Language,
|
||||
Library(Option<NonZeroU32>)
|
||||
Library(Option<NonZeroU32>),
|
||||
}
|
||||
|
||||
pub fn find_feature_issue(feature: Symbol, issue: GateIssue) -> Option<NonZeroU32> {
|
||||
@ -128,10 +128,9 @@ pub fn find_feature_issue(feature: Symbol, issue: GateIssue) -> Option<NonZeroU3
|
||||
}
|
||||
|
||||
pub use accepted::ACCEPTED_FEATURES;
|
||||
pub use active::{ACTIVE_FEATURES, Features, INCOMPLETE_FEATURES};
|
||||
pub use removed::{REMOVED_FEATURES, STABLE_REMOVED_FEATURES};
|
||||
pub use active::{Features, ACTIVE_FEATURES, INCOMPLETE_FEATURES};
|
||||
pub use builtin_attrs::{
|
||||
AttributeGate, AttributeTemplate, AttributeType, find_gated_cfg, GatedCfg,
|
||||
BuiltinAttribute, BUILTIN_ATTRIBUTES, BUILTIN_ATTRIBUTE_MAP,
|
||||
deprecated_attributes, is_builtin_attr_name,
|
||||
deprecated_attributes, find_gated_cfg, is_builtin_attr_name, AttributeGate, AttributeTemplate,
|
||||
AttributeType, BuiltinAttribute, GatedCfg, BUILTIN_ATTRIBUTES, BUILTIN_ATTRIBUTE_MAP,
|
||||
};
|
||||
pub use removed::{REMOVED_FEATURES, STABLE_REMOVED_FEATURES};
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! List of the removed feature gates.
|
||||
|
||||
use super::{State, Feature};
|
||||
use super::{Feature, State};
|
||||
use syntax_pos::symbol::sym;
|
||||
|
||||
macro_rules! declare_features {
|
||||
@ -41,6 +41,7 @@ macro_rules! declare_features {
|
||||
};
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
declare_features! (
|
||||
// -------------------------------------------------------------------------
|
||||
// feature-group-start: removed features
|
||||
@ -111,6 +112,7 @@ declare_features! (
|
||||
// -------------------------------------------------------------------------
|
||||
);
|
||||
|
||||
#[rustfmt::skip]
|
||||
declare_features! (
|
||||
(stable_removed, no_stack_check, "1.0.0", None, None),
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user