Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #116492

Merged
merged 25 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
13e5875
add some docs to hooks/mod.rs
RalfJung Sep 30, 2023
23efab4
Fix typo in attrs.rs
eltociear Oct 4, 2023
80bf688
Remove an unnecessary `pub(crate)`.
nnethercote Oct 5, 2023
4091936
Make the comment order match variant declaration order.
nnethercote Oct 5, 2023
449b84c
Remove `map_layouts`.
nnethercote Oct 6, 2023
73420fc
Fix a comment.
nnethercote Oct 6, 2023
29ed8e4
Remove the `MaybeTransmutableQuery<&'l Dfa<...>, C>` impl.
nnethercote Oct 6, 2023
442a66d
Remove unneeded dependency.
nnethercote Oct 3, 2023
108e541
Remove unused `FileName::CfgSpec`.
nnethercote Oct 4, 2023
e49a147
Factor out `insert_or_error`.
nnethercote Oct 4, 2023
4b51a3e
Remove unneeded dependency.
nnethercote Oct 6, 2023
093b435
Remove unneeded features.
nnethercote Oct 6, 2023
e7dabc9
Remove unnecessary `pub`.
nnethercote Oct 6, 2023
b80e653
Attempt to describe the intent behind the `From` trait further
scottmcm Aug 6, 2023
44f92c1
Don't mention "recover the original" in `From` docs
scottmcm Oct 6, 2023
1651f1f
Elaborate some caveats to lossless
scottmcm Oct 6, 2023
5432d13
Reuse existing `Some`s in `Option::(x)or`
scottmcm Oct 6, 2023
c95015c
Minor doc clarification in Once::call_once
peterjoel Oct 6, 2023
4dfa5e5
Rollup merge of #114564 - scottmcm:when-to-from, r=dtolnay
matthiaskrgr Oct 6, 2023
fdb136a
Rollup merge of #116297 - RalfJung:hooks, r=oli-obk
matthiaskrgr Oct 6, 2023
81192f2
Rollup merge of #116423 - eltociear:patch-22, r=flip1995
matthiaskrgr Oct 6, 2023
25fbd13
Rollup merge of #116466 - nnethercote:rustc_transmute, r=oli-obk
matthiaskrgr Oct 6, 2023
9796dfd
Rollup merge of #116474 - nnethercote:rustc_assorted, r=spastorino
matthiaskrgr Oct 6, 2023
f8dae0c
Rollup merge of #116481 - scottmcm:tweak-combinators, r=cuviper
matthiaskrgr Oct 6, 2023
7f0cf8c
Rollup merge of #116484 - peterjoel:once-doc-clarify, r=cuviper
matthiaskrgr Oct 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4335,7 +4335,6 @@ dependencies = [
"rustc_errors",
"rustc_hir",
"rustc_index",
"rustc_macros",
"rustc_middle",
"rustc_query_system",
"rustc_serialize",
Expand Down Expand Up @@ -4441,7 +4440,6 @@ dependencies = [
"rustc_hir",
"rustc_interface",
"rustc_middle",
"rustc_session",
"rustc_span",
"rustc_target",
"stable_mir",
Expand Down
85 changes: 23 additions & 62 deletions compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,28 +353,28 @@ pub fn find_body_stability(
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
/// its stability information.
fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, StabilityLevel)> {
let meta = attr.meta()?;
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 since = None;
Expand All @@ -389,16 +389,8 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
};

match mi.name_or_empty() {
sym::feature => {
if !insert_or_error(mi, &mut feature) {
return None;
}
}
sym::since => {
if !insert_or_error(mi, &mut since) {
return None;
}
}
sym::feature => insert_or_error(sess, mi, &mut feature)?,
sym::since => insert_or_error(sess, mi, &mut since)?,
_ => {
handle_errors(
&sess.parse_sess,
Expand Down Expand Up @@ -438,23 +430,6 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, StabilityLevel)> {
let meta = attr.meta()?;
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 reason = None;
Expand All @@ -473,20 +448,10 @@ fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabil
};

match mi.name_or_empty() {
sym::feature => {
if !insert_or_error(mi, &mut feature) {
return None;
}
}
sym::reason => {
if !insert_or_error(mi, &mut reason) {
return None;
}
}
sym::feature => insert_or_error(sess, mi, &mut feature)?,
sym::reason => insert_or_error(sess, mi, &mut reason)?,
sym::issue => {
if !insert_or_error(mi, &mut issue) {
return None;
}
insert_or_error(sess, mi, &mut issue)?;

// These unwraps are safe because `insert_or_error` ensures the meta item
// is a name/value pair string literal.
Expand Down Expand Up @@ -515,11 +480,7 @@ fn parse_unstability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabil
}
is_soft = true;
}
sym::implied_by => {
if !insert_or_error(mi, &mut implied_by) {
return None;
}
}
sym::implied_by => insert_or_error(sess, mi, &mut implied_by)?,
_ => {
handle_errors(
&sess.parse_sess,
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_middle/src/hooks/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
//! "Hooks" provide a way for `tcx` functionality to be provided by some downstream crate without
//! everything in rustc having to depend on that crate. This is somewhat similar to queries, but
//! queries come with a lot of machinery for caching and incremental compilation, whereas hooks are
//! just plain function pointers without any of the query magic.

use crate::mir;
use crate::query::TyCtxtAt;
use crate::ty::{Ty, TyCtxt};
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_query_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }
rustc_macros = { path = "../rustc_macros" }
rustc_middle = { path = "../rustc_middle" }
rustc_query_system = { path = "../rustc_query_system" }
rustc-rayon-core = { version = "0.5.0", optional = true }
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,6 @@ impl Input {
FileName::Anon(_) => None,
FileName::MacroExpansion(_) => None,
FileName::ProcMacroSourceCode(_) => None,
FileName::CfgSpec(_) => None,
FileName::CliCrateAttr(_) => None,
FileName::Custom(_) => None,
FileName::DocTest(path, _) => Some(path),
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_smir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ version = "0.0.0"
edition = "2021"

[dependencies]
rustc_driver = { path = "../rustc_driver" }
rustc_hir = { path = "../rustc_hir" }
rustc_interface = { path = "../rustc_interface" }
rustc_middle = { path = "../rustc_middle" }
rustc_span = { path = "../rustc_span" }
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" }
tracing = "0.1"

[features]
4 changes: 0 additions & 4 deletions compiler/rustc_smir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
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;

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_smir/src/rustc_internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_driver::{Callbacks, Compilation, RunCompiler};
use rustc_interface::{interface, Queries};
use rustc_middle::mir::interpret::AllocId;
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 stable_mir::CompilerError;

Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,7 @@ impl RealFileName {
}

/// Differentiates between real files and common virtual files.
#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash)]
#[derive(Decodable, Encodable)]
#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, Decodable, Encodable)]
pub enum FileName {
Real(RealFileName),
/// Call to `quote!`.
Expand All @@ -292,8 +291,6 @@ pub enum FileName {
// FIXME(jseyfried)
MacroExpansion(Hash64),
ProcMacroSourceCode(Hash64),
/// Strings provided as `--cfg [cfgspec]` stored in a `crate_cfg`.
CfgSpec(Hash64),
/// Strings provided as crate attributes in the CLI.
CliCrateAttr(Hash64),
/// Custom sources for explicit parser calls from plugins and drivers.
Expand Down Expand Up @@ -338,7 +335,6 @@ impl fmt::Display for FileNameDisplay<'_> {
MacroExpansion(_) => write!(fmt, "<macro expansion>"),
Anon(_) => write!(fmt, "<anon>"),
ProcMacroSourceCode(_) => write!(fmt, "<proc-macro source code>"),
CfgSpec(_) => write!(fmt, "<cfgspec>"),
CliCrateAttr(_) => write!(fmt, "<crate attribute>"),
Custom(ref s) => write!(fmt, "<{s}>"),
DocTest(ref path, _) => write!(fmt, "{}", path.display()),
Expand All @@ -364,7 +360,6 @@ impl FileName {
Anon(_)
| MacroExpansion(_)
| ProcMacroSourceCode(_)
| CfgSpec(_)
| CliCrateAttr(_)
| Custom(_)
| QuoteExpansion(_)
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_transmute/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern crate tracing;
pub(crate) use rustc_data_structures::fx::{FxIndexMap as Map, FxIndexSet as Set};

pub mod layout;
pub(crate) mod maybe_transmutable;
mod maybe_transmutable;

#[derive(Default)]
pub struct Assume {
Expand All @@ -19,7 +19,7 @@ pub struct Assume {
pub validity: bool,
}

/// Either we have an error, transmutation is allowed, or we have an optional
/// Either transmutation is allowed, we have an error, or we have an optional
/// Condition that must hold.
#[derive(Debug, Hash, Eq, PartialEq, Clone)]
pub enum Answer<R> {
Expand Down
Loading
Loading