diff options
| author | Jubilee <46493976+workingjubilee@users.noreply.github.com> | 2024-06-06 14:46:21 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-06 14:46:21 -0700 |
| commit | a1baa7b04d3eec56a7fb6f4d68f8f13904ecda96 (patch) | |
| tree | 467b5fe50bd5c1addcf176fc98a68544af1cd35d | |
| parent | 14d9a3e230ad89e4a9215663d4cb985ef3467c41 (diff) | |
| parent | c7ced1ba5305277673c3db45a183693577761734 (diff) | |
| download | rust-a1baa7b04d3eec56a7fb6f4d68f8f13904ecda96.tar.gz rust-a1baa7b04d3eec56a7fb6f4d68f8f13904ecda96.zip | |
Rollup merge of #126035 - oli-obk:query_macro_errors, r=fmease
Some minor query system cleanups * Improves diagnostics on conflicting query flags * removes unnecessary impls * `track_caller` pulled out of https://github.com/rust-lang/rust/pull/115613
| -rw-r--r-- | compiler/rustc_macros/src/query.rs | 21 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/graph.rs | 3 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 1 |
3 files changed, 21 insertions, 4 deletions
diff --git a/compiler/rustc_macros/src/query.rs b/compiler/rustc_macros/src/query.rs index 25675e06e38..ceff1da9763 100644 --- a/compiler/rustc_macros/src/query.rs +++ b/compiler/rustc_macros/src/query.rs @@ -314,6 +314,17 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream { let mut query_description_stream = quote! {}; let mut query_cached_stream = quote! {}; let mut feedable_queries = quote! {}; + let mut errors = quote! {}; + + macro_rules! assert { + ( $cond:expr, $span:expr, $( $tt:tt )+ ) => { + if !$cond { + errors.extend( + Error::new($span, format!($($tt)+)).into_compile_error(), + ); + } + } + } for query in queries.0 { let Query { name, arg, modifiers, .. } = &query; @@ -369,10 +380,15 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream { [#attribute_stream] fn #name(#arg) #result, }); - if modifiers.feedable.is_some() { - assert!(modifiers.anon.is_none(), "Query {name} cannot be both `feedable` and `anon`."); + if let Some(feedable) = &modifiers.feedable { + assert!( + modifiers.anon.is_none(), + feedable.span(), + "Query {name} cannot be both `feedable` and `anon`." + ); assert!( modifiers.eval_always.is_none(), + feedable.span(), "Query {name} cannot be both `feedable` and `eval_always`." ); feedable_queries.extend(quote! { @@ -407,5 +423,6 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream { use super::*; #query_cached_stream } + #errors }) } diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index 76227a78c3d..66fb3136805 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -64,7 +64,6 @@ pub struct MarkFrame<'a> { parent: Option<&'a MarkFrame<'a>>, } -#[derive(PartialEq)] enum DepNodeColor { Red, Green(DepNodeIndex), @@ -925,7 +924,7 @@ impl<D: Deps> DepGraph<D> { /// Returns true if the given node has been marked as red during the /// current compilation session. Used in various assertions pub fn is_red(&self, dep_node: &DepNode) -> bool { - self.node_color(dep_node) == Some(DepNodeColor::Red) + matches!(self.node_color(dep_node), Some(DepNodeColor::Red)) } /// Returns true if the given node has been marked as green during the diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 9bd0002a3d9..3464e1893d0 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2469,6 +2469,7 @@ impl<'test> TestCx<'test> { } } + #[track_caller] fn fatal(&self, err: &str) -> ! { self.error(err); error!("fatal error, panic: {:?}", err); |
