Skip to content

Commit

Permalink
Auto merge of rust-lang#88165 - GuillaumeGomez:rollup-4o0v2ps, r=Guil…
Browse files Browse the repository at this point in the history
…laumeGomez

Rollup of 8 pull requests

Successful merges:

 - rust-lang#86123 (Preserve more spans in internal `rustc_queries!` macro)
 - rust-lang#87874 (Add TcpStream type to TcpListener::incoming docs)
 - rust-lang#88034 (rustc_privacy: Replace `HirId`s and `DefId`s with `LocalDefId`s where possible)
 - rust-lang#88050 (Remove `HashStable` impls for `FileName` and `RealFileName`)
 - rust-lang#88093 ([rustdoc] Wrap code blocks in `<code>` tag)
 - rust-lang#88146 (Add tests for some `feature(const_evaluatable_checked)` incr comp issues)
 - rust-lang#88153 (Update .mailmap)
 - rust-lang#88159 (Use a trait instead of the now disallowed missing trait there)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Aug 19, 2021
2 parents 7960030 + 1095bb1 commit 6d64f7f
Show file tree
Hide file tree
Showing 21 changed files with 638 additions and 405 deletions.
1 change: 1 addition & 0 deletions .mailmap
Expand Up @@ -113,6 +113,7 @@ Hanna Kruppe <hanna.kruppe@gmail.com> <robin.kruppe@gmail.com>
Heather <heather@cynede.net> <Cynede@Gentoo.org>
Heather <heather@cynede.net> <Heather@cynede.net>
Herman J. Radtke III <herman@hermanradtke.com> Herman J. Radtke III <hermanradtke@gmail.com>
Hirochika Matsumoto <git@hkmatsumoto.com> <matsujika@gmail.com>
Ian Jackson <ijackson@chiark.greenend.org.uk> <ian.jackson@citrix.com>
Ian Jackson <ijackson@chiark.greenend.org.uk> <ijackson+github@slimy.greenend.org.uk>
Ian Jackson <ijackson@chiark.greenend.org.uk> <iwj@xenproject.org>
Expand Down
104 changes: 56 additions & 48 deletions compiler/rustc_macros/src/query.rs
@@ -1,6 +1,6 @@
use proc_macro::TokenStream;
use proc_macro2::{Delimiter, TokenTree};
use quote::quote;
use quote::{quote, quote_spanned};
use syn::parse::{Parse, ParseStream, Result};
use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
Expand Down Expand Up @@ -42,19 +42,19 @@ enum QueryModifier {
LoadCached(Ident, Ident, Block),

/// A cycle error for this query aborting the compilation with a fatal error.
FatalCycle,
FatalCycle(Ident),

/// A cycle error results in a delay_bug call
CycleDelayBug,
CycleDelayBug(Ident),

/// Don't hash the result, instead just mark a query red if it runs
NoHash,
NoHash(Ident),

/// Generate a dep node based on the dependencies of the query
Anon,
Anon(Ident),

/// Always evaluate the query, ignoring its dependencies
EvalAlways,
EvalAlways(Ident),
}

impl Parse for QueryModifier {
Expand Down Expand Up @@ -111,15 +111,15 @@ impl Parse for QueryModifier {
let ty = args.parse()?;
Ok(QueryModifier::Storage(ty))
} else if modifier == "fatal_cycle" {
Ok(QueryModifier::FatalCycle)
Ok(QueryModifier::FatalCycle(modifier))
} else if modifier == "cycle_delay_bug" {
Ok(QueryModifier::CycleDelayBug)
Ok(QueryModifier::CycleDelayBug(modifier))
} else if modifier == "no_hash" {
Ok(QueryModifier::NoHash)
Ok(QueryModifier::NoHash(modifier))
} else if modifier == "anon" {
Ok(QueryModifier::Anon)
Ok(QueryModifier::Anon(modifier))
} else if modifier == "eval_always" {
Ok(QueryModifier::EvalAlways)
Ok(QueryModifier::EvalAlways(modifier))
} else {
Err(Error::new(modifier.span(), "unknown query modifier"))
}
Expand Down Expand Up @@ -203,19 +203,19 @@ struct QueryModifiers {
load_cached: Option<(Ident, Ident, Block)>,

/// A cycle error for this query aborting the compilation with a fatal error.
fatal_cycle: bool,
fatal_cycle: Option<Ident>,

/// A cycle error results in a delay_bug call
cycle_delay_bug: bool,
cycle_delay_bug: Option<Ident>,

/// Don't hash the result, instead just mark a query red if it runs
no_hash: bool,
no_hash: Option<Ident>,

/// Generate a dep node based on the dependencies of the query
anon: bool,
anon: Option<Ident>,

// Always evaluate the query, ignoring its dependencies
eval_always: bool,
eval_always: Option<Ident>,
}

/// Process query modifiers into a struct, erroring on duplicates
Expand All @@ -224,11 +224,11 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
let mut storage = None;
let mut cache = None;
let mut desc = None;
let mut fatal_cycle = false;
let mut cycle_delay_bug = false;
let mut no_hash = false;
let mut anon = false;
let mut eval_always = false;
let mut fatal_cycle = None;
let mut cycle_delay_bug = None;
let mut no_hash = None;
let mut anon = None;
let mut eval_always = None;
for modifier in query.modifiers.0.drain(..) {
match modifier {
QueryModifier::LoadCached(tcx, id, block) => {
Expand Down Expand Up @@ -289,35 +289,35 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
}
desc = Some((tcx, list));
}
QueryModifier::FatalCycle => {
if fatal_cycle {
QueryModifier::FatalCycle(ident) => {
if fatal_cycle.is_some() {
panic!("duplicate modifier `fatal_cycle` for query `{}`", query.name);
}
fatal_cycle = true;
fatal_cycle = Some(ident);
}
QueryModifier::CycleDelayBug => {
if cycle_delay_bug {
QueryModifier::CycleDelayBug(ident) => {
if cycle_delay_bug.is_some() {
panic!("duplicate modifier `cycle_delay_bug` for query `{}`", query.name);
}
cycle_delay_bug = true;
cycle_delay_bug = Some(ident);
}
QueryModifier::NoHash => {
if no_hash {
QueryModifier::NoHash(ident) => {
if no_hash.is_some() {
panic!("duplicate modifier `no_hash` for query `{}`", query.name);
}
no_hash = true;
no_hash = Some(ident);
}
QueryModifier::Anon => {
if anon {
QueryModifier::Anon(ident) => {
if anon.is_some() {
panic!("duplicate modifier `anon` for query `{}`", query.name);
}
anon = true;
anon = Some(ident);
}
QueryModifier::EvalAlways => {
if eval_always {
QueryModifier::EvalAlways(ident) => {
if eval_always.is_some() {
panic!("duplicate modifier `eval_always` for query `{}`", query.name);
}
eval_always = true;
eval_always = Some(ident);
}
}
}
Expand Down Expand Up @@ -454,31 +454,39 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
let mut attributes = Vec::new();

// Pass on the fatal_cycle modifier
if modifiers.fatal_cycle {
attributes.push(quote! { fatal_cycle });
if let Some(fatal_cycle) = &modifiers.fatal_cycle {
attributes.push(quote! { #fatal_cycle });
};
// Pass on the storage modifier
if let Some(ref ty) = modifiers.storage {
attributes.push(quote! { storage(#ty) });
let span = ty.span();
attributes.push(quote_spanned! {span=> storage(#ty) });
};
// Pass on the cycle_delay_bug modifier
if modifiers.cycle_delay_bug {
attributes.push(quote! { cycle_delay_bug });
if let Some(cycle_delay_bug) = &modifiers.cycle_delay_bug {
attributes.push(quote! { #cycle_delay_bug });
};
// Pass on the no_hash modifier
if modifiers.no_hash {
attributes.push(quote! { no_hash });
if let Some(no_hash) = &modifiers.no_hash {
attributes.push(quote! { #no_hash });
};
// Pass on the anon modifier
if modifiers.anon {
attributes.push(quote! { anon });
if let Some(anon) = &modifiers.anon {
attributes.push(quote! { #anon });
};
// Pass on the eval_always modifier
if modifiers.eval_always {
attributes.push(quote! { eval_always });
if let Some(eval_always) = &modifiers.eval_always {
attributes.push(quote! { #eval_always });
};

let attribute_stream = quote! {#(#attributes),*};
// This uses the span of the query definition for the commas,
// which can be important if we later encounter any ambiguity
// errors with any of the numerous macro_rules! macros that
// we use. Using the call-site span would result in a span pointing
// at the entire `rustc_queries!` invocation, which wouldn't
// be very useful.
let span = name.span();
let attribute_stream = quote_spanned! {span=> #(#attributes),*};
let doc_comments = query.doc_comments.iter();
// Add the query to the group
query_stream.extend(quote! {
Expand Down

0 comments on commit 6d64f7f

Please sign in to comment.