Rollup merge of #116474 - nnethercote:rustc_assorted, r=spastorino
Assorted small cleanups r? `@spastorino`
This commit is contained in:
commit
9796dfdd56
8 changed files with 28 additions and 81 deletions
|
@ -4335,7 +4335,6 @@ dependencies = [
|
||||||
"rustc_errors",
|
"rustc_errors",
|
||||||
"rustc_hir",
|
"rustc_hir",
|
||||||
"rustc_index",
|
"rustc_index",
|
||||||
"rustc_macros",
|
|
||||||
"rustc_middle",
|
"rustc_middle",
|
||||||
"rustc_query_system",
|
"rustc_query_system",
|
||||||
"rustc_serialize",
|
"rustc_serialize",
|
||||||
|
@ -4441,7 +4440,6 @@ dependencies = [
|
||||||
"rustc_hir",
|
"rustc_hir",
|
||||||
"rustc_interface",
|
"rustc_interface",
|
||||||
"rustc_middle",
|
"rustc_middle",
|
||||||
"rustc_session",
|
|
||||||
"rustc_span",
|
"rustc_span",
|
||||||
"rustc_target",
|
"rustc_target",
|
||||||
"stable_mir",
|
"stable_mir",
|
||||||
|
|
|
@ -353,28 +353,28 @@ pub fn find_body_stability(
|
||||||
body_stab
|
body_stab
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn insert_or_error(sess: &Session, meta: &MetaItem, item: &mut Option<Symbol>) -> Option<()> {
|
||||||
|
if item.is_some() {
|
||||||
|
handle_errors(
|
||||||
|
&sess.parse_sess,
|
||||||
|
meta.span,
|
||||||
|
AttrError::MultipleItem(pprust::path_to_string(&meta.path)),
|
||||||
|
);
|
||||||
|
None
|
||||||
|
} else if let Some(v) = meta.value_str() {
|
||||||
|
*item = Some(v);
|
||||||
|
Some(())
|
||||||
|
} else {
|
||||||
|
sess.emit_err(session_diagnostics::IncorrectMetaItem { span: meta.span });
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Read the content of a `stable`/`rustc_const_stable` attribute, and return the feature name and
|
/// Read the content of a `stable`/`rustc_const_stable` attribute, and return the feature name and
|
||||||
/// its stability information.
|
/// its stability information.
|
||||||
fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, StabilityLevel)> {
|
fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, StabilityLevel)> {
|
||||||
let meta = attr.meta()?;
|
let meta = attr.meta()?;
|
||||||
let MetaItem { kind: MetaItemKind::List(ref metas), .. } = meta else { return None };
|
let MetaItem { kind: MetaItemKind::List(ref metas), .. } = meta else { return None };
|
||||||
let insert_or_error = |meta: &MetaItem, item: &mut Option<Symbol>| {
|
|
||||||
if item.is_some() {
|
|
||||||
handle_errors(
|
|
||||||
&sess.parse_sess,
|
|
||||||
meta.span,
|
|
||||||
AttrError::MultipleItem(pprust::path_to_string(&meta.path)),
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if let Some(v) = meta.value_str() {
|
|
||||||
*item = Some(v);
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
sess.emit_err(session_diagnostics::IncorrectMetaItem { span: meta.span });
|
|
||||||
false
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut feature = None;
|
let mut feature = None;
|
||||||
let mut since = None;
|
let mut since = None;
|
||||||
|
@ -389,16 +389,8 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
|
||||||
};
|
};
|
||||||
|
|
||||||
match mi.name_or_empty() {
|
match mi.name_or_empty() {
|
||||||
sym::feature => {
|
sym::feature => insert_or_error(sess, mi, &mut feature)?,
|
||||||
if !insert_or_error(mi, &mut feature) {
|
sym::since => insert_or_error(sess, mi, &mut since)?,
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sym::since => {
|
|
||||||
if !insert_or_error(mi, &mut since) {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {
|
_ => {
|
||||||
handle_errors(
|
handle_errors(
|
||||||
&sess.parse_sess,
|
&sess.parse_sess,
|
||||||
|
@ -438,23 +430,6 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
|
||||||
fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, StabilityLevel)> {
|
fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, StabilityLevel)> {
|
||||||
let meta = attr.meta()?;
|
let meta = attr.meta()?;
|
||||||
let MetaItem { kind: MetaItemKind::List(ref metas), .. } = meta else { return None };
|
let MetaItem { kind: MetaItemKind::List(ref metas), .. } = meta else { return None };
|
||||||
let insert_or_error = |meta: &MetaItem, item: &mut Option<Symbol>| {
|
|
||||||
if item.is_some() {
|
|
||||||
handle_errors(
|
|
||||||
&sess.parse_sess,
|
|
||||||
meta.span,
|
|
||||||
AttrError::MultipleItem(pprust::path_to_string(&meta.path)),
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if let Some(v) = meta.value_str() {
|
|
||||||
*item = Some(v);
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
sess.emit_err(session_diagnostics::IncorrectMetaItem { span: meta.span });
|
|
||||||
false
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut feature = None;
|
let mut feature = None;
|
||||||
let mut reason = None;
|
let mut reason = None;
|
||||||
|
@ -473,20 +448,10 @@ fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabil
|
||||||
};
|
};
|
||||||
|
|
||||||
match mi.name_or_empty() {
|
match mi.name_or_empty() {
|
||||||
sym::feature => {
|
sym::feature => insert_or_error(sess, mi, &mut feature)?,
|
||||||
if !insert_or_error(mi, &mut feature) {
|
sym::reason => insert_or_error(sess, mi, &mut reason)?,
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sym::reason => {
|
|
||||||
if !insert_or_error(mi, &mut reason) {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sym::issue => {
|
sym::issue => {
|
||||||
if !insert_or_error(mi, &mut issue) {
|
insert_or_error(sess, mi, &mut issue)?;
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
// These unwraps are safe because `insert_or_error` ensures the meta item
|
// These unwraps are safe because `insert_or_error` ensures the meta item
|
||||||
// is a name/value pair string literal.
|
// is a name/value pair string literal.
|
||||||
|
@ -515,11 +480,7 @@ fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabil
|
||||||
}
|
}
|
||||||
is_soft = true;
|
is_soft = true;
|
||||||
}
|
}
|
||||||
sym::implied_by => {
|
sym::implied_by => insert_or_error(sess, mi, &mut implied_by)?,
|
||||||
if !insert_or_error(mi, &mut implied_by) {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {
|
_ => {
|
||||||
handle_errors(
|
handle_errors(
|
||||||
&sess.parse_sess,
|
&sess.parse_sess,
|
||||||
|
|
|
@ -13,7 +13,6 @@ rustc_data_structures = { path = "../rustc_data_structures" }
|
||||||
rustc_errors = { path = "../rustc_errors" }
|
rustc_errors = { path = "../rustc_errors" }
|
||||||
rustc_hir = { path = "../rustc_hir" }
|
rustc_hir = { path = "../rustc_hir" }
|
||||||
rustc_index = { path = "../rustc_index" }
|
rustc_index = { path = "../rustc_index" }
|
||||||
rustc_macros = { path = "../rustc_macros" }
|
|
||||||
rustc_middle = { path = "../rustc_middle" }
|
rustc_middle = { path = "../rustc_middle" }
|
||||||
rustc_query_system = { path = "../rustc_query_system" }
|
rustc_query_system = { path = "../rustc_query_system" }
|
||||||
rustc-rayon-core = { version = "0.5.0", optional = true }
|
rustc-rayon-core = { version = "0.5.0", optional = true }
|
||||||
|
|
|
@ -813,7 +813,6 @@ impl Input {
|
||||||
FileName::Anon(_) => None,
|
FileName::Anon(_) => None,
|
||||||
FileName::MacroExpansion(_) => None,
|
FileName::MacroExpansion(_) => None,
|
||||||
FileName::ProcMacroSourceCode(_) => None,
|
FileName::ProcMacroSourceCode(_) => None,
|
||||||
FileName::CfgSpec(_) => None,
|
|
||||||
FileName::CliCrateAttr(_) => None,
|
FileName::CliCrateAttr(_) => None,
|
||||||
FileName::Custom(_) => None,
|
FileName::Custom(_) => None,
|
||||||
FileName::DocTest(path, _) => Some(path),
|
FileName::DocTest(path, _) => Some(path),
|
||||||
|
|
|
@ -4,14 +4,13 @@ version = "0.0.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
rustc_driver = { path = "../rustc_driver" }
|
||||||
rustc_hir = { path = "../rustc_hir" }
|
rustc_hir = { path = "../rustc_hir" }
|
||||||
|
rustc_interface = { path = "../rustc_interface" }
|
||||||
rustc_middle = { path = "../rustc_middle" }
|
rustc_middle = { path = "../rustc_middle" }
|
||||||
rustc_span = { path = "../rustc_span" }
|
rustc_span = { path = "../rustc_span" }
|
||||||
rustc_target = { path = "../rustc_target" }
|
rustc_target = { path = "../rustc_target" }
|
||||||
rustc_driver = { path = "../rustc_driver" }
|
|
||||||
rustc_interface = { path = "../rustc_interface" }
|
|
||||||
rustc_session = {path = "../rustc_session" }
|
|
||||||
tracing = "0.1"
|
|
||||||
stable_mir = {path = "../stable_mir" }
|
stable_mir = {path = "../stable_mir" }
|
||||||
|
tracing = "0.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
|
@ -10,10 +10,6 @@
|
||||||
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
|
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
|
||||||
test(attr(allow(unused_variables), deny(warnings)))
|
test(attr(allow(unused_variables), deny(warnings)))
|
||||||
)]
|
)]
|
||||||
#![feature(rustc_private)]
|
|
||||||
#![feature(ptr_metadata)]
|
|
||||||
#![feature(type_alias_impl_trait)] // Used to define opaque types.
|
|
||||||
#![feature(intra_doc_pointers)]
|
|
||||||
|
|
||||||
pub mod rustc_internal;
|
pub mod rustc_internal;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ use rustc_driver::{Callbacks, Compilation, RunCompiler};
|
||||||
use rustc_interface::{interface, Queries};
|
use rustc_interface::{interface, Queries};
|
||||||
use rustc_middle::mir::interpret::AllocId;
|
use rustc_middle::mir::interpret::AllocId;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
pub use rustc_span::def_id::{CrateNum, DefId};
|
use rustc_span::def_id::{CrateNum, DefId};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use stable_mir::CompilerError;
|
use stable_mir::CompilerError;
|
||||||
|
|
||||||
|
|
|
@ -280,8 +280,7 @@ impl RealFileName {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Differentiates between real files and common virtual files.
|
/// Differentiates between real files and common virtual files.
|
||||||
#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash)]
|
#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, Decodable, Encodable)]
|
||||||
#[derive(Decodable, Encodable)]
|
|
||||||
pub enum FileName {
|
pub enum FileName {
|
||||||
Real(RealFileName),
|
Real(RealFileName),
|
||||||
/// Call to `quote!`.
|
/// Call to `quote!`.
|
||||||
|
@ -292,8 +291,6 @@ pub enum FileName {
|
||||||
// FIXME(jseyfried)
|
// FIXME(jseyfried)
|
||||||
MacroExpansion(Hash64),
|
MacroExpansion(Hash64),
|
||||||
ProcMacroSourceCode(Hash64),
|
ProcMacroSourceCode(Hash64),
|
||||||
/// Strings provided as `--cfg [cfgspec]` stored in a `crate_cfg`.
|
|
||||||
CfgSpec(Hash64),
|
|
||||||
/// Strings provided as crate attributes in the CLI.
|
/// Strings provided as crate attributes in the CLI.
|
||||||
CliCrateAttr(Hash64),
|
CliCrateAttr(Hash64),
|
||||||
/// Custom sources for explicit parser calls from plugins and drivers.
|
/// Custom sources for explicit parser calls from plugins and drivers.
|
||||||
|
@ -338,7 +335,6 @@ impl fmt::Display for FileNameDisplay<'_> {
|
||||||
MacroExpansion(_) => write!(fmt, "<macro expansion>"),
|
MacroExpansion(_) => write!(fmt, "<macro expansion>"),
|
||||||
Anon(_) => write!(fmt, "<anon>"),
|
Anon(_) => write!(fmt, "<anon>"),
|
||||||
ProcMacroSourceCode(_) => write!(fmt, "<proc-macro source code>"),
|
ProcMacroSourceCode(_) => write!(fmt, "<proc-macro source code>"),
|
||||||
CfgSpec(_) => write!(fmt, "<cfgspec>"),
|
|
||||||
CliCrateAttr(_) => write!(fmt, "<crate attribute>"),
|
CliCrateAttr(_) => write!(fmt, "<crate attribute>"),
|
||||||
Custom(ref s) => write!(fmt, "<{s}>"),
|
Custom(ref s) => write!(fmt, "<{s}>"),
|
||||||
DocTest(ref path, _) => write!(fmt, "{}", path.display()),
|
DocTest(ref path, _) => write!(fmt, "{}", path.display()),
|
||||||
|
@ -364,7 +360,6 @@ impl FileName {
|
||||||
Anon(_)
|
Anon(_)
|
||||||
| MacroExpansion(_)
|
| MacroExpansion(_)
|
||||||
| ProcMacroSourceCode(_)
|
| ProcMacroSourceCode(_)
|
||||||
| CfgSpec(_)
|
|
||||||
| CliCrateAttr(_)
|
| CliCrateAttr(_)
|
||||||
| Custom(_)
|
| Custom(_)
|
||||||
| QuoteExpansion(_)
|
| QuoteExpansion(_)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue