Rollup merge of #109358 - petrochenkov:nosess, r=cjgillot
rustc: Remove unused `Session` argument from some attribute functions (One auxiliary test file containing one of these functions was unused, so I removed it instead of updating.)
This commit is contained in:
commit
577d85f92f
37 changed files with 173 additions and 299 deletions
|
@ -687,8 +687,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
|||
// compilation mode also comes into play.
|
||||
let desired_strategy = self.sess.panic_strategy();
|
||||
let mut runtime_found = false;
|
||||
let mut needs_panic_runtime =
|
||||
self.sess.contains_name(&krate.attrs, sym::needs_panic_runtime);
|
||||
let mut needs_panic_runtime = attr::contains_name(&krate.attrs, sym::needs_panic_runtime);
|
||||
|
||||
for (cnum, data) in self.cstore.iter_crate_data() {
|
||||
needs_panic_runtime = needs_panic_runtime || data.needs_panic_runtime();
|
||||
|
@ -756,7 +755,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
|||
info!("loading profiler");
|
||||
|
||||
let name = Symbol::intern(&self.sess.opts.unstable_opts.profiler_runtime);
|
||||
if name == sym::profiler_builtins && self.sess.contains_name(&krate.attrs, sym::no_core) {
|
||||
if name == sym::profiler_builtins && attr::contains_name(&krate.attrs, sym::no_core) {
|
||||
self.sess.emit_err(errors::ProfilerBuiltinsNeedsCore);
|
||||
}
|
||||
|
||||
|
@ -770,14 +769,14 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn inject_allocator_crate(&mut self, krate: &ast::Crate) {
|
||||
self.cstore.has_global_allocator = match &*global_allocator_spans(&self.sess, krate) {
|
||||
self.cstore.has_global_allocator = match &*global_allocator_spans(krate) {
|
||||
[span1, span2, ..] => {
|
||||
self.sess.emit_err(errors::NoMultipleGlobalAlloc { span2: *span2, span1: *span1 });
|
||||
true
|
||||
}
|
||||
spans => !spans.is_empty(),
|
||||
};
|
||||
self.cstore.has_alloc_error_handler = match &*alloc_error_handler_spans(&self.sess, krate) {
|
||||
self.cstore.has_alloc_error_handler = match &*alloc_error_handler_spans(krate) {
|
||||
[span1, span2, ..] => {
|
||||
self.sess
|
||||
.emit_err(errors::NoMultipleAllocErrorHandler { span2: *span2, span1: *span1 });
|
||||
|
@ -789,7 +788,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
|||
// Check to see if we actually need an allocator. This desire comes
|
||||
// about through the `#![needs_allocator]` attribute and is typically
|
||||
// written down in liballoc.
|
||||
if !self.sess.contains_name(&krate.attrs, sym::needs_allocator)
|
||||
if !attr::contains_name(&krate.attrs, sym::needs_allocator)
|
||||
&& !self.cstore.iter_crate_data().any(|(_, data)| data.needs_allocator())
|
||||
{
|
||||
return;
|
||||
|
@ -848,7 +847,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
|||
// allocator. At this point our allocator request is typically fulfilled
|
||||
// by the standard library, denoted by the `#![default_lib_allocator]`
|
||||
// attribute.
|
||||
if !self.sess.contains_name(&krate.attrs, sym::default_lib_allocator)
|
||||
if !attr::contains_name(&krate.attrs, sym::default_lib_allocator)
|
||||
&& !self.cstore.iter_crate_data().any(|(_, data)| data.has_default_lib_allocator())
|
||||
{
|
||||
self.sess.emit_err(errors::GlobalAllocRequired);
|
||||
|
@ -970,7 +969,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
|||
}
|
||||
None => item.ident.name,
|
||||
};
|
||||
let dep_kind = if self.sess.contains_name(&item.attrs, sym::no_link) {
|
||||
let dep_kind = if attr::contains_name(&item.attrs, sym::no_link) {
|
||||
CrateDepKind::MacrosOnly
|
||||
} else {
|
||||
CrateDepKind::Explicit
|
||||
|
@ -1016,16 +1015,15 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn global_allocator_spans(sess: &Session, krate: &ast::Crate) -> Vec<Span> {
|
||||
struct Finder<'a> {
|
||||
sess: &'a Session,
|
||||
fn global_allocator_spans(krate: &ast::Crate) -> Vec<Span> {
|
||||
struct Finder {
|
||||
name: Symbol,
|
||||
spans: Vec<Span>,
|
||||
}
|
||||
impl<'ast, 'a> visit::Visitor<'ast> for Finder<'a> {
|
||||
impl<'ast> visit::Visitor<'ast> for Finder {
|
||||
fn visit_item(&mut self, item: &'ast ast::Item) {
|
||||
if item.ident.name == self.name
|
||||
&& self.sess.contains_name(&item.attrs, sym::rustc_std_internal_symbol)
|
||||
&& attr::contains_name(&item.attrs, sym::rustc_std_internal_symbol)
|
||||
{
|
||||
self.spans.push(item.span);
|
||||
}
|
||||
|
@ -1034,21 +1032,20 @@ fn global_allocator_spans(sess: &Session, krate: &ast::Crate) -> Vec<Span> {
|
|||
}
|
||||
|
||||
let name = Symbol::intern(&AllocatorKind::Global.fn_name(sym::alloc));
|
||||
let mut f = Finder { sess, name, spans: Vec::new() };
|
||||
let mut f = Finder { name, spans: Vec::new() };
|
||||
visit::walk_crate(&mut f, krate);
|
||||
f.spans
|
||||
}
|
||||
|
||||
fn alloc_error_handler_spans(sess: &Session, krate: &ast::Crate) -> Vec<Span> {
|
||||
struct Finder<'a> {
|
||||
sess: &'a Session,
|
||||
fn alloc_error_handler_spans(krate: &ast::Crate) -> Vec<Span> {
|
||||
struct Finder {
|
||||
name: Symbol,
|
||||
spans: Vec<Span>,
|
||||
}
|
||||
impl<'ast, 'a> visit::Visitor<'ast> for Finder<'a> {
|
||||
impl<'ast> visit::Visitor<'ast> for Finder {
|
||||
fn visit_item(&mut self, item: &'ast ast::Item) {
|
||||
if item.ident.name == self.name
|
||||
&& self.sess.contains_name(&item.attrs, sym::rustc_std_internal_symbol)
|
||||
&& attr::contains_name(&item.attrs, sym::rustc_std_internal_symbol)
|
||||
{
|
||||
self.spans.push(item.span);
|
||||
}
|
||||
|
@ -1057,7 +1054,7 @@ fn alloc_error_handler_spans(sess: &Session, krate: &ast::Crate) -> Vec<Span> {
|
|||
}
|
||||
|
||||
let name = Symbol::intern(&AllocatorKind::Global.fn_name(sym::oom));
|
||||
let mut f = Finder { sess, name, spans: Vec::new() };
|
||||
let mut f = Finder { name, spans: Vec::new() };
|
||||
visit::walk_crate(&mut f, krate);
|
||||
f.spans
|
||||
}
|
||||
|
|
|
@ -681,17 +681,15 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
has_global_allocator: tcx.has_global_allocator(LOCAL_CRATE),
|
||||
has_alloc_error_handler: tcx.has_alloc_error_handler(LOCAL_CRATE),
|
||||
has_panic_handler: tcx.has_panic_handler(LOCAL_CRATE),
|
||||
has_default_lib_allocator: tcx
|
||||
.sess
|
||||
.contains_name(&attrs, sym::default_lib_allocator),
|
||||
has_default_lib_allocator: attr::contains_name(&attrs, sym::default_lib_allocator),
|
||||
proc_macro_data,
|
||||
debugger_visualizers,
|
||||
compiler_builtins: tcx.sess.contains_name(&attrs, sym::compiler_builtins),
|
||||
needs_allocator: tcx.sess.contains_name(&attrs, sym::needs_allocator),
|
||||
needs_panic_runtime: tcx.sess.contains_name(&attrs, sym::needs_panic_runtime),
|
||||
no_builtins: tcx.sess.contains_name(&attrs, sym::no_builtins),
|
||||
panic_runtime: tcx.sess.contains_name(&attrs, sym::panic_runtime),
|
||||
profiler_runtime: tcx.sess.contains_name(&attrs, sym::profiler_runtime),
|
||||
compiler_builtins: attr::contains_name(&attrs, sym::compiler_builtins),
|
||||
needs_allocator: attr::contains_name(&attrs, sym::needs_allocator),
|
||||
needs_panic_runtime: attr::contains_name(&attrs, sym::needs_panic_runtime),
|
||||
no_builtins: attr::contains_name(&attrs, sym::no_builtins),
|
||||
panic_runtime: attr::contains_name(&attrs, sym::panic_runtime),
|
||||
profiler_runtime: attr::contains_name(&attrs, sym::profiler_runtime),
|
||||
symbol_mangling_version: tcx.sess.opts.get_symbol_mangling_version(),
|
||||
|
||||
crate_deps,
|
||||
|
@ -1747,11 +1745,11 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
// Proc-macros may have attributes like `#[allow_internal_unstable]`,
|
||||
// so downstream crates need access to them.
|
||||
let attrs = hir.attrs(proc_macro);
|
||||
let macro_kind = if tcx.sess.contains_name(attrs, sym::proc_macro) {
|
||||
let macro_kind = if attr::contains_name(attrs, sym::proc_macro) {
|
||||
MacroKind::Bang
|
||||
} else if tcx.sess.contains_name(attrs, sym::proc_macro_attribute) {
|
||||
} else if attr::contains_name(attrs, sym::proc_macro_attribute) {
|
||||
MacroKind::Attr
|
||||
} else if let Some(attr) = tcx.sess.find_by_name(attrs, sym::proc_macro_derive) {
|
||||
} else if let Some(attr) = attr::find_by_name(attrs, sym::proc_macro_derive) {
|
||||
// This unwrap chain should have been checked by the proc-macro harness.
|
||||
name = attr.meta_item_list().unwrap()[0]
|
||||
.meta_item()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue