mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-17 01:13:11 +00:00
expand: Remove some unnecessary self
mutability
This commit is contained in:
parent
dc7e771155
commit
4fd23350cd
@ -238,7 +238,7 @@ macro_rules! configure {
|
||||
}
|
||||
|
||||
impl<'a> StripUnconfigured<'a> {
|
||||
pub fn configure<T: AstLike>(&mut self, mut node: T) -> Option<T> {
|
||||
pub fn configure<T: AstLike>(&self, mut node: T) -> Option<T> {
|
||||
self.process_cfg_attrs(&mut node);
|
||||
if self.in_cfg(node.attrs()) {
|
||||
self.try_configure_tokens(&mut node);
|
||||
@ -248,7 +248,7 @@ impl<'a> StripUnconfigured<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn try_configure_tokens<T: AstLike>(&mut self, node: &mut T) {
|
||||
fn try_configure_tokens<T: AstLike>(&self, node: &mut T) {
|
||||
if self.config_tokens {
|
||||
if let Some(Some(tokens)) = node.tokens_mut() {
|
||||
let attr_annotated_tokens = tokens.create_token_stream();
|
||||
@ -257,10 +257,7 @@ impl<'a> StripUnconfigured<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn configure_krate_attrs(
|
||||
&mut self,
|
||||
mut attrs: Vec<ast::Attribute>,
|
||||
) -> Option<Vec<ast::Attribute>> {
|
||||
fn configure_krate_attrs(&self, mut attrs: Vec<ast::Attribute>) -> Option<Vec<ast::Attribute>> {
|
||||
attrs.flat_map_in_place(|attr| self.process_cfg_attr(attr));
|
||||
if self.in_cfg(&attrs) { Some(attrs) } else { None }
|
||||
}
|
||||
@ -269,7 +266,7 @@ impl<'a> StripUnconfigured<'a> {
|
||||
/// This is only used during the invocation of `derive` proc-macros,
|
||||
/// which require that we cfg-expand their entire input.
|
||||
/// Normal cfg-expansion operates on parsed AST nodes via the `configure` method
|
||||
fn configure_tokens(&mut self, stream: &AttrAnnotatedTokenStream) -> AttrAnnotatedTokenStream {
|
||||
fn configure_tokens(&self, stream: &AttrAnnotatedTokenStream) -> AttrAnnotatedTokenStream {
|
||||
fn can_skip(stream: &AttrAnnotatedTokenStream) -> bool {
|
||||
stream.0.iter().all(|(tree, _spacing)| match tree {
|
||||
AttrAnnotatedTokenTree::Attributes(_) => false,
|
||||
@ -325,7 +322,7 @@ impl<'a> StripUnconfigured<'a> {
|
||||
/// Gives compiler warnings if any `cfg_attr` does not contain any
|
||||
/// attributes and is in the original source code. Gives compiler errors if
|
||||
/// the syntax of any `cfg_attr` is incorrect.
|
||||
fn process_cfg_attrs<T: AstLike>(&mut self, node: &mut T) {
|
||||
fn process_cfg_attrs<T: AstLike>(&self, node: &mut T) {
|
||||
node.visit_attrs(|attrs| {
|
||||
attrs.flat_map_in_place(|attr| self.process_cfg_attr(attr));
|
||||
});
|
||||
@ -338,7 +335,7 @@ impl<'a> StripUnconfigured<'a> {
|
||||
/// Gives a compiler warning when the `cfg_attr` contains no attributes and
|
||||
/// is in the original source file. Gives a compiler error if the syntax of
|
||||
/// the attribute is incorrect.
|
||||
fn process_cfg_attr(&mut self, attr: Attribute) -> Vec<Attribute> {
|
||||
fn process_cfg_attr(&self, attr: Attribute) -> Vec<Attribute> {
|
||||
if !attr.has_name(sym::cfg_attr) {
|
||||
return vec![attr];
|
||||
}
|
||||
@ -461,7 +458,7 @@ impl<'a> StripUnconfigured<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn configure_expr(&mut self, expr: &mut P<ast::Expr>) {
|
||||
pub fn configure_expr(&self, expr: &mut P<ast::Expr>) {
|
||||
for attr in expr.attrs.iter() {
|
||||
self.maybe_emit_expr_attr_err(attr);
|
||||
}
|
||||
|
@ -1007,7 +1007,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
|
||||
/// its position and derives following it. We have to collect the derives in order to resolve
|
||||
/// legacy derive helpers (helpers written before derives that introduce them).
|
||||
fn take_first_attr(
|
||||
&mut self,
|
||||
&self,
|
||||
item: &mut impl AstLike,
|
||||
) -> Option<(ast::Attribute, usize, Vec<Path>)> {
|
||||
let mut attr = None;
|
||||
@ -1040,7 +1040,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
|
||||
}
|
||||
|
||||
fn take_stmt_bang(
|
||||
&mut self,
|
||||
&self,
|
||||
stmt: ast::Stmt,
|
||||
) -> Result<(bool, MacCall, Vec<ast::Attribute>), ast::Stmt> {
|
||||
match stmt.kind {
|
||||
@ -1071,7 +1071,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
fn configure<T: AstLike>(&mut self, node: T) -> Option<T> {
|
||||
fn configure<T: AstLike>(&self, node: T) -> Option<T> {
|
||||
self.cfg.configure(node)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user