Remove unused Span from the set function in State::Active.

This commit is contained in:
Nicholas Nethercote 2023-10-04 09:51:03 +11:00
parent 36aab8df0a
commit 53fe37de2e
3 changed files with 10 additions and 10 deletions

View File

@ -23,7 +23,7 @@ use rustc_session::parse::feature_err;
use rustc_session::Session; use rustc_session::Session;
use rustc_span::edition::{Edition, ALL_EDITIONS}; use rustc_span::edition::{Edition, ALL_EDITIONS};
use rustc_span::symbol::{sym, Symbol}; use rustc_span::symbol::{sym, Symbol};
use rustc_span::{Span, DUMMY_SP}; use rustc_span::Span;
/// A folder that strips out items that do not belong in the current configuration. /// A folder that strips out items that do not belong in the current configuration.
pub struct StripUnconfigured<'a> { pub struct StripUnconfigured<'a> {
@ -67,7 +67,7 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute]) -> Features {
} }
for feature in active_features_up_to(crate_edition) { for feature in active_features_up_to(crate_edition) {
feature.set(&mut features, DUMMY_SP); feature.set(&mut features);
edition_enabled_features.insert(feature.name, crate_edition); edition_enabled_features.insert(feature.name, crate_edition);
} }
@ -98,7 +98,7 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute]) -> Features {
for feature in active_features_up_to(edition) { for feature in active_features_up_to(edition) {
// FIXME(Manishearth) there is currently no way to set // FIXME(Manishearth) there is currently no way to set
// lib features by edition // lib features by edition
feature.set(&mut features, DUMMY_SP); feature.set(&mut features);
edition_enabled_features.insert(feature.name, edition); edition_enabled_features.insert(feature.name, edition);
} }
} }
@ -176,7 +176,7 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute]) -> Features {
} }
if let Some(f) = ACTIVE_FEATURES.iter().find(|f| name == f.name) { if let Some(f) = ACTIVE_FEATURES.iter().find(|f| name == f.name) {
f.set(&mut features, mi.span()); f.set(&mut features);
features.declared_lang_features.push((name, mi.span(), None)); features.declared_lang_features.push((name, mi.span(), None));
features.active_features.insert(name); features.active_features.insert(name);
continue; continue;

View File

@ -9,10 +9,10 @@ use rustc_span::Span;
macro_rules! set { macro_rules! set {
($field: ident) => {{ ($field: ident) => {{
fn f(features: &mut Features, _: Span) { fn f(features: &mut Features) {
features.$field = true; features.$field = true;
} }
f as fn(&mut Features, Span) f as fn(&mut Features)
}}; }};
} }
@ -123,9 +123,9 @@ macro_rules! declare_features {
impl Feature { impl Feature {
/// Sets this feature in `Features`. Panics if called on a non-active feature. /// Sets this feature in `Features`. Panics if called on a non-active feature.
pub fn set(&self, features: &mut Features, span: Span) { pub fn set(&self, features: &mut Features) {
match self.state { match self.state {
State::Active { set } => set(features, span), State::Active { set } => set(features),
_ => panic!("called `set` on feature `{}` which is not `active`", self.name), _ => panic!("called `set` on feature `{}` which is not `active`", self.name),
} }
} }

View File

@ -23,14 +23,14 @@ mod removed;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
use rustc_span::{edition::Edition, symbol::Symbol, Span}; use rustc_span::{edition::Edition, symbol::Symbol};
use std::fmt; use std::fmt;
use std::num::NonZeroU32; use std::num::NonZeroU32;
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub enum State { pub enum State {
Accepted, Accepted,
Active { set: fn(&mut Features, Span) }, Active { set: fn(&mut Features) },
Removed { reason: Option<&'static str> }, Removed { reason: Option<&'static str> },
Stabilized { reason: Option<&'static str> }, Stabilized { reason: Option<&'static str> },
} }