rustc: Remove unused Session
argument from some attribute functions
This commit is contained in:
parent
9bdb4881c7
commit
67a2c5bec8
37 changed files with 173 additions and 299 deletions
|
@ -5,7 +5,7 @@ use crate::errors::{
|
|||
InvalidCharacterInCrateName,
|
||||
};
|
||||
use crate::Session;
|
||||
use rustc_ast as ast;
|
||||
use rustc_ast::{self as ast, attr};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::{Span, Symbol};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
@ -56,7 +56,7 @@ pub fn find_crate_name(sess: &Session, attrs: &[ast::Attribute]) -> Symbol {
|
|||
// the command line over one found in the #[crate_name] attribute. If we
|
||||
// find both we ensure that they're the same later on as well.
|
||||
let attr_crate_name =
|
||||
sess.find_by_name(attrs, sym::crate_name).and_then(|at| at.value_str().map(|s| (at, s)));
|
||||
attr::find_by_name(attrs, sym::crate_name).and_then(|at| at.value_str().map(|s| (at, s)));
|
||||
|
||||
if let Some(ref s) = sess.opts.crate_name {
|
||||
let s = Symbol::intern(s);
|
||||
|
|
|
@ -30,7 +30,7 @@ use rustc_macros::HashStable_Generic;
|
|||
pub use rustc_span::def_id::StableCrateId;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::source_map::{FileLoader, RealFileLoader, SourceMap, Span};
|
||||
use rustc_span::{sym, SourceFileHashAlgorithm, Symbol};
|
||||
use rustc_span::{SourceFileHashAlgorithm, Symbol};
|
||||
use rustc_target::asm::InlineAsmArch;
|
||||
use rustc_target::spec::{CodeModel, PanicStrategy, RelocModel, RelroLevel};
|
||||
use rustc_target::spec::{
|
||||
|
@ -1003,40 +1003,6 @@ impl Session {
|
|||
|| self.opts.unstable_opts.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::KERNELADDRESS | SanitizerSet::MEMORY | SanitizerSet::HWADDRESS)
|
||||
}
|
||||
|
||||
pub fn is_proc_macro_attr(&self, attr: &Attribute) -> bool {
|
||||
[sym::proc_macro, sym::proc_macro_attribute, sym::proc_macro_derive]
|
||||
.iter()
|
||||
.any(|kind| attr.has_name(*kind))
|
||||
}
|
||||
|
||||
pub fn contains_name(&self, attrs: &[Attribute], name: Symbol) -> bool {
|
||||
attrs.iter().any(|item| item.has_name(name))
|
||||
}
|
||||
|
||||
pub fn find_by_name<'a>(
|
||||
&'a self,
|
||||
attrs: &'a [Attribute],
|
||||
name: Symbol,
|
||||
) -> Option<&'a Attribute> {
|
||||
attrs.iter().find(|attr| attr.has_name(name))
|
||||
}
|
||||
|
||||
pub fn filter_by_name<'a>(
|
||||
&'a self,
|
||||
attrs: &'a [Attribute],
|
||||
name: Symbol,
|
||||
) -> impl Iterator<Item = &'a Attribute> {
|
||||
attrs.iter().filter(move |attr| attr.has_name(name))
|
||||
}
|
||||
|
||||
pub fn first_attr_value_str_by_name(
|
||||
&self,
|
||||
attrs: &[Attribute],
|
||||
name: Symbol,
|
||||
) -> Option<Symbol> {
|
||||
attrs.iter().find(|at| at.has_name(name)).and_then(|at| at.value_str())
|
||||
}
|
||||
|
||||
pub fn diagnostic_width(&self) -> usize {
|
||||
let default_column_width = 140;
|
||||
if let Some(width) = self.opts.diagnostic_width {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue