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