Skip to content

Commit 809dd77

Browse files
committed
rustc: Remove unused Session argument from some attribute functions
1 parent 4e658cc commit 809dd77

File tree

3 files changed

+5
-20
lines changed

3 files changed

+5
-20
lines changed

src/attr.rs

+1-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use rustc_ast::ast;
44
use rustc_ast::HasAttrs;
5-
use rustc_span::{symbol::sym, Span, Symbol};
5+
use rustc_span::{symbol::sym, Span};
66

77
use self::doc_comment::DocCommentFormatter;
88
use crate::comment::{contains_comment, rewrite_doc_comment, CommentStyle};
@@ -19,20 +19,6 @@ use crate::utils::{count_newlines, mk_sp};
1919

2020
mod doc_comment;
2121

22-
pub(crate) fn contains_name(attrs: &[ast::Attribute], name: Symbol) -> bool {
23-
attrs.iter().any(|attr| attr.has_name(name))
24-
}
25-
26-
pub(crate) fn first_attr_value_str_by_name(
27-
attrs: &[ast::Attribute],
28-
name: Symbol,
29-
) -> Option<Symbol> {
30-
attrs
31-
.iter()
32-
.find(|attr| attr.has_name(name))
33-
.and_then(|attr| attr.value_str())
34-
}
35-
3622
/// Returns attributes on the given statement.
3723
pub(crate) fn get_attrs_from_stmt(stmt: &ast::Stmt) -> &[ast::Attribute] {
3824
stmt.attrs()

src/parse/parser.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ use std::panic::{catch_unwind, AssertUnwindSafe};
22
use std::path::{Path, PathBuf};
33

44
use rustc_ast::token::TokenKind;
5-
use rustc_ast::{ast, ptr};
5+
use rustc_ast::{ast, attr, ptr};
66
use rustc_errors::Diagnostic;
77
use rustc_parse::{new_parser_from_file, parser::Parser as RawParser};
88
use rustc_span::{sym, Span};
99
use thin_vec::ThinVec;
1010

11-
use crate::attr::first_attr_value_str_by_name;
1211
use crate::parse::session::ParseSess;
1312
use crate::Input;
1413

@@ -93,7 +92,7 @@ pub(crate) enum ParserError {
9392

9493
impl<'a> Parser<'a> {
9594
pub(crate) fn submod_path_from_attr(attrs: &[ast::Attribute], path: &Path) -> Option<PathBuf> {
96-
let path_sym = first_attr_value_str_by_name(attrs, sym::path)?;
95+
let path_sym = attr::first_attr_value_str_by_name(attrs, sym::path)?;
9796
let path_str = path_sym.as_str();
9897

9998
// On windows, the base path might have the form

src/reorder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
use std::cmp::{Ord, Ordering};
1010

11-
use rustc_ast::ast;
11+
use rustc_ast::{ast, attr};
1212
use rustc_span::{symbol::sym, Span};
1313

1414
use crate::config::{Config, GroupImportsTactic};
@@ -167,7 +167,7 @@ fn rewrite_reorderable_or_regroupable_items(
167167
}
168168

169169
fn contains_macro_use_attr(item: &ast::Item) -> bool {
170-
crate::attr::contains_name(&item.attrs, sym::macro_use)
170+
attr::contains_name(&item.attrs, sym::macro_use)
171171
}
172172

173173
/// Divides imports into three groups, corresponding to standard, external

0 commit comments

Comments
 (0)