summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_macros/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /compiler/rustc_macros/src
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_macros/src')
-rw-r--r--compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs9
-rw-r--r--compiler/rustc_macros/src/diagnostics/fluent.rs336
-rw-r--r--compiler/rustc_macros/src/diagnostics/mod.rs4
-rw-r--r--compiler/rustc_macros/src/diagnostics/subdiagnostic.rs33
-rw-r--r--compiler/rustc_macros/src/diagnostics/utils.rs9
-rw-r--r--compiler/rustc_macros/src/lib.rs54
-rw-r--r--compiler/rustc_macros/src/newtype.rs2
-rw-r--r--compiler/rustc_macros/src/query.rs14
8 files changed, 35 insertions, 426 deletions
diff --git a/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs b/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs
index 427c82c41..cd6e36874 100644
--- a/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs
+++ b/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs
@@ -9,7 +9,7 @@ use crate::diagnostics::utils::{
FieldInnerTy, FieldMap, HasFieldMap, SetOnce, SpannedOption, SubdiagnosticKind,
};
use proc_macro2::{Ident, Span, TokenStream};
-use quote::{format_ident, quote};
+use quote::{format_ident, quote, quote_spanned};
use syn::Token;
use syn::{parse_quote, spanned::Spanned, Attribute, Meta, Path, Type};
use synstructure::{BindingInfo, Structure, VariantInfo};
@@ -251,7 +251,8 @@ impl<'a> DiagnosticDeriveVariantBuilder<'a> {
let diag = &self.parent.diag;
let field = binding_info.ast();
- let field_binding = &binding_info.binding;
+ let mut field_binding = binding_info.binding.clone();
+ field_binding.set_span(field.ty.span());
let ident = field.ident.as_ref().unwrap();
let ident = format_ident!("{}", ident); // strip `r#` prefix, if present
@@ -284,9 +285,9 @@ impl<'a> DiagnosticDeriveVariantBuilder<'a> {
name == "primary_span" && matches!(inner_ty, FieldInnerTy::Vec(_));
let (binding, needs_destructure) = if needs_clone {
// `primary_span` can accept a `Vec<Span>` so don't destructure that.
- (quote! { #field_binding.clone() }, false)
+ (quote_spanned! {inner_ty.span()=> #field_binding.clone() }, false)
} else {
- (quote! { #field_binding }, true)
+ (quote_spanned! {inner_ty.span()=> #field_binding }, true)
};
let generated_code = self
diff --git a/compiler/rustc_macros/src/diagnostics/fluent.rs b/compiler/rustc_macros/src/diagnostics/fluent.rs
deleted file mode 100644
index 607d51f56..000000000
--- a/compiler/rustc_macros/src/diagnostics/fluent.rs
+++ /dev/null
@@ -1,336 +0,0 @@
-use annotate_snippets::{
- display_list::DisplayList,
- snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation},
-};
-use fluent_bundle::{FluentBundle, FluentError, FluentResource};
-use fluent_syntax::{
- ast::{
- Attribute, Entry, Expression, Identifier, InlineExpression, Message, Pattern,
- PatternElement,
- },
- parser::ParserError,
-};
-use proc_macro::{Diagnostic, Level, Span};
-use proc_macro2::TokenStream;
-use quote::quote;
-use std::{
- collections::{HashMap, HashSet},
- fs::read_to_string,
- path::{Path, PathBuf},
-};
-use syn::{parse_macro_input, Ident, LitStr};
-use unic_langid::langid;
-
-/// Helper function for returning an absolute path for macro-invocation relative file paths.
-///
-/// If the input is already absolute, then the input is returned. If the input is not absolute,
-/// then it is appended to the directory containing the source file with this macro invocation.
-fn invocation_relative_path_to_absolute(span: Span, path: &str) -> PathBuf {
- let path = Path::new(path);
- if path.is_absolute() {
- path.to_path_buf()
- } else {
- // `/a/b/c/foo/bar.rs` contains the current macro invocation
- let mut source_file_path = span.source_file().path();
- // `/a/b/c/foo/`
- source_file_path.pop();
- // `/a/b/c/foo/../locales/en-US/example.ftl`
- source_file_path.push(path);
- source_file_path
- }
-}
-
-/// Tokens to be returned when the macro cannot proceed.
-fn failed(crate_name: &Ident) -> proc_macro::TokenStream {
- quote! {
- pub static DEFAULT_LOCALE_RESOURCE: &'static str = "";
-
- #[allow(non_upper_case_globals)]
- #[doc(hidden)]
- pub(crate) mod fluent_generated {
- pub mod #crate_name {
- }
-
- pub mod _subdiag {
- pub const help: crate::SubdiagnosticMessage =
- crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("help"));
- pub const note: crate::SubdiagnosticMessage =
- crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("note"));
- pub const warn: crate::SubdiagnosticMessage =
- crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("warn"));
- pub const label: crate::SubdiagnosticMessage =
- crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("label"));
- pub const suggestion: crate::SubdiagnosticMessage =
- crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("suggestion"));
- }
- }
- }
- .into()
-}
-
-/// See [rustc_macros::fluent_messages].
-pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
- let crate_name = std::env::var("CARGO_PKG_NAME")
- // If `CARGO_PKG_NAME` is missing, then we're probably running in a test, so use
- // `no_crate`.
- .unwrap_or_else(|_| "no_crate".to_string())
- .replace("rustc_", "");
-
- // Cannot iterate over individual messages in a bundle, so do that using the
- // `FluentResource` instead. Construct a bundle anyway to find out if there are conflicting
- // messages in the resources.
- let mut bundle = FluentBundle::new(vec![langid!("en-US")]);
-
- // Set of Fluent attribute names already output, to avoid duplicate type errors - any given
- // constant created for a given attribute is the same.
- let mut previous_attrs = HashSet::new();
-
- let resource_str = parse_macro_input!(input as LitStr);
- let resource_span = resource_str.span().unwrap();
- let relative_ftl_path = resource_str.value();
- let absolute_ftl_path = invocation_relative_path_to_absolute(resource_span, &relative_ftl_path);
-
- let crate_name = Ident::new(&crate_name, resource_str.span());
-
- // As this macro also outputs an `include_str!` for this file, the macro will always be
- // re-executed when the file changes.
- let resource_contents = match read_to_string(absolute_ftl_path) {
- Ok(resource_contents) => resource_contents,
- Err(e) => {
- Diagnostic::spanned(
- resource_span,
- Level::Error,
- format!("could not open Fluent resource: {e}"),
- )
- .emit();
- return failed(&crate_name);
- }
- };
- let mut bad = false;
- for esc in ["\\n", "\\\"", "\\'"] {
- for _ in resource_contents.matches(esc) {
- bad = true;
- Diagnostic::spanned(resource_span, Level::Error, format!("invalid escape `{esc}` in Fluent resource"))
- .note("Fluent does not interpret these escape sequences (<https://projectfluent.org/fluent/guide/special.html>)")
- .emit();
- }
- }
- if bad {
- return failed(&crate_name);
- }
-
- let resource = match FluentResource::try_new(resource_contents) {
- Ok(resource) => resource,
- Err((this, errs)) => {
- Diagnostic::spanned(resource_span, Level::Error, "could not parse Fluent resource")
- .help("see additional errors emitted")
- .emit();
- for ParserError { pos, slice: _, kind } in errs {
- let mut err = kind.to_string();
- // Entirely unnecessary string modification so that the error message starts
- // with a lowercase as rustc errors do.
- err.replace_range(0..1, &err.chars().next().unwrap().to_lowercase().to_string());
-
- let line_starts: Vec<usize> = std::iter::once(0)
- .chain(
- this.source()
- .char_indices()
- .filter_map(|(i, c)| Some(i + 1).filter(|_| c == '\n')),
- )
- .collect();
- let line_start = line_starts
- .iter()
- .enumerate()
- .map(|(line, idx)| (line + 1, idx))
- .filter(|(_, idx)| **idx <= pos.start)
- .last()
- .unwrap()
- .0;
-
- let snippet = Snippet {
- title: Some(Annotation {
- label: Some(&err),
- id: None,
- annotation_type: AnnotationType::Error,
- }),
- footer: vec![],
- slices: vec![Slice {
- source: this.source(),
- line_start,
- origin: Some(&relative_ftl_path),
- fold: true,
- annotations: vec![SourceAnnotation {
- label: "",
- annotation_type: AnnotationType::Error,
- range: (pos.start, pos.end - 1),
- }],
- }],
- opt: Default::default(),
- };
- let dl = DisplayList::from(snippet);
- eprintln!("{dl}\n");
- }
-
- return failed(&crate_name);
- }
- };
-
- let mut constants = TokenStream::new();
- let mut previous_defns = HashMap::new();
- let mut message_refs = Vec::new();
- for entry in resource.entries() {
- if let Entry::Message(Message { id: Identifier { name }, attributes, value, .. }) = entry {
- let _ = previous_defns.entry(name.to_string()).or_insert(resource_span);
- if name.contains('-') {
- Diagnostic::spanned(
- resource_span,
- Level::Error,
- format!("name `{name}` contains a '-' character"),
- )
- .help("replace any '-'s with '_'s")
- .emit();
- }
-
- if let Some(Pattern { elements }) = value {
- for elt in elements {
- if let PatternElement::Placeable {
- expression:
- Expression::Inline(InlineExpression::MessageReference { id, .. }),
- } = elt
- {
- message_refs.push((id.name, *name));
- }
- }
- }
-
- // `typeck_foo_bar` => `foo_bar` (in `typeck.ftl`)
- // `const_eval_baz` => `baz` (in `const_eval.ftl`)
- // `const-eval-hyphen-having` => `hyphen_having` (in `const_eval.ftl`)
- // The last case we error about above, but we want to fall back gracefully
- // so that only the error is being emitted and not also one about the macro
- // failing.
- let crate_prefix = format!("{crate_name}_");
-
- let snake_name = name.replace('-', "_");
- if !snake_name.starts_with(&crate_prefix) {
- Diagnostic::spanned(
- resource_span,
- Level::Error,
- format!("name `{name}` does not start with the crate name"),
- )
- .help(format!(
- "prepend `{crate_prefix}` to the slug name: `{crate_prefix}{snake_name}`"
- ))
- .emit();
- };
- let snake_name = Ident::new(&snake_name, resource_str.span());
-
- if !previous_attrs.insert(snake_name.clone()) {
- continue;
- }
-
- let msg = format!("Constant referring to Fluent message `{name}` from `{crate_name}`");
- constants.extend(quote! {
- #[doc = #msg]
- pub const #snake_name: crate::DiagnosticMessage =
- crate::DiagnosticMessage::FluentIdentifier(
- std::borrow::Cow::Borrowed(#name),
- None
- );
- });
-
- for Attribute { id: Identifier { name: attr_name }, .. } in attributes {
- let snake_name = Ident::new(
- &format!("{}{}", &crate_prefix, &attr_name.replace('-', "_")),
- resource_str.span(),
- );
- if !previous_attrs.insert(snake_name.clone()) {
- continue;
- }
-
- if attr_name.contains('-') {
- Diagnostic::spanned(
- resource_span,
- Level::Error,
- format!("attribute `{attr_name}` contains a '-' character"),
- )
- .help("replace any '-'s with '_'s")
- .emit();
- }
-
- let msg = format!(
- "Constant referring to Fluent message `{name}.{attr_name}` from `{crate_name}`"
- );
- constants.extend(quote! {
- #[doc = #msg]
- pub const #snake_name: crate::SubdiagnosticMessage =
- crate::SubdiagnosticMessage::FluentAttr(
- std::borrow::Cow::Borrowed(#attr_name)
- );
- });
- }
- }
- }
-
- for (mref, name) in message_refs.into_iter() {
- if !previous_defns.contains_key(mref) {
- Diagnostic::spanned(
- resource_span,
- Level::Error,
- format!("referenced message `{mref}` does not exist (in message `{name}`)"),
- )
- .help(&format!("you may have meant to use a variable reference (`{{${mref}}}`)"))
- .emit();
- }
- }
-
- if let Err(errs) = bundle.add_resource(resource) {
- for e in errs {
- match e {
- FluentError::Overriding { kind, id } => {
- Diagnostic::spanned(
- resource_span,
- Level::Error,
- format!("overrides existing {kind}: `{id}`"),
- )
- .emit();
- }
- FluentError::ResolverError(_) | FluentError::ParserError(_) => unreachable!(),
- }
- }
- }
-
- quote! {
- /// Raw content of Fluent resource for this crate, generated by `fluent_messages` macro,
- /// imported by `rustc_driver` to include all crates' resources in one bundle.
- pub static DEFAULT_LOCALE_RESOURCE: &'static str = include_str!(#relative_ftl_path);
-
- #[allow(non_upper_case_globals)]
- #[doc(hidden)]
- /// Auto-generated constants for type-checked references to Fluent messages.
- pub(crate) mod fluent_generated {
- #constants
-
- /// Constants expected to exist by the diagnostic derive macros to use as default Fluent
- /// identifiers for different subdiagnostic kinds.
- pub mod _subdiag {
- /// Default for `#[help]`
- pub const help: crate::SubdiagnosticMessage =
- crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("help"));
- /// Default for `#[note]`
- pub const note: crate::SubdiagnosticMessage =
- crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("note"));
- /// Default for `#[warn]`
- pub const warn: crate::SubdiagnosticMessage =
- crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("warn"));
- /// Default for `#[label]`
- pub const label: crate::SubdiagnosticMessage =
- crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("label"));
- /// Default for `#[suggestion]`
- pub const suggestion: crate::SubdiagnosticMessage =
- crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("suggestion"));
- }
- }
- }
- .into()
-}
diff --git a/compiler/rustc_macros/src/diagnostics/mod.rs b/compiler/rustc_macros/src/diagnostics/mod.rs
index 78df0cd1d..a536eb3b0 100644
--- a/compiler/rustc_macros/src/diagnostics/mod.rs
+++ b/compiler/rustc_macros/src/diagnostics/mod.rs
@@ -1,12 +1,10 @@
mod diagnostic;
mod diagnostic_builder;
mod error;
-mod fluent;
mod subdiagnostic;
mod utils;
use diagnostic::{DiagnosticDerive, LintDiagnosticDerive};
-pub(crate) use fluent::fluent_messages;
use proc_macro2::TokenStream;
use quote::format_ident;
use subdiagnostic::SubdiagnosticDeriveBuilder;
@@ -142,7 +140,7 @@ pub fn lint_diagnostic_derive(s: Structure<'_>) -> TokenStream {
/// ```fluent
/// parser_expected_identifier = expected identifier
///
-/// parser_expected_identifier-found = expected identifier, found {$found}
+/// parser_expected_identifier_found = expected identifier, found {$found}
///
/// parser_raw_identifier = escape `{$ident}` to use it as an identifier
/// ```
diff --git a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs
index 62d49c1c6..374ba1a45 100644
--- a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs
+++ b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs
@@ -4,17 +4,16 @@ use crate::diagnostics::error::{
invalid_attr, span_err, throw_invalid_attr, throw_span_err, DiagnosticDeriveError,
};
use crate::diagnostics::utils::{
- build_field_mapping, is_doc_comment, new_code_ident,
- report_error_if_not_applied_to_applicability, report_error_if_not_applied_to_span, FieldInfo,
- FieldInnerTy, FieldMap, HasFieldMap, SetOnce, SpannedOption, SubdiagnosticKind,
+ build_field_mapping, build_suggestion_code, is_doc_comment, new_code_ident,
+ report_error_if_not_applied_to_applicability, report_error_if_not_applied_to_span,
+ should_generate_set_arg, AllowMultipleAlternatives, FieldInfo, FieldInnerTy, FieldMap,
+ HasFieldMap, SetOnce, SpannedOption, SubdiagnosticKind,
};
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use syn::{spanned::Spanned, Attribute, Meta, MetaList, Path};
use synstructure::{BindingInfo, Structure, VariantInfo};
-use super::utils::{build_suggestion_code, AllowMultipleAlternatives};
-
/// The central struct for constructing the `add_to_diagnostic` method from an annotated struct.
pub(crate) struct SubdiagnosticDeriveBuilder {
diag: syn::Ident,
@@ -210,19 +209,20 @@ impl<'parent, 'a> SubdiagnosticDeriveVariantBuilder<'parent, 'a> {
}
/// Generates the code for a field with no attributes.
- fn generate_field_set_arg(&mut self, binding: &BindingInfo<'_>) -> TokenStream {
- let ast = binding.ast();
- assert_eq!(ast.attrs.len(), 0, "field with attribute used as diagnostic arg");
-
+ fn generate_field_set_arg(&mut self, binding_info: &BindingInfo<'_>) -> TokenStream {
let diag = &self.parent.diag;
- let ident = ast.ident.as_ref().unwrap();
- // strip `r#` prefix, if present
- let ident = format_ident!("{}", ident);
+
+ let field = binding_info.ast();
+ let mut field_binding = binding_info.binding.clone();
+ field_binding.set_span(field.ty.span());
+
+ let ident = field.ident.as_ref().unwrap();
+ let ident = format_ident!("{}", ident); // strip `r#` prefix, if present
quote! {
#diag.set_arg(
stringify!(#ident),
- #binding
+ #field_binding
);
}
}
@@ -399,7 +399,8 @@ impl<'parent, 'a> SubdiagnosticDeriveVariantBuilder<'parent, 'a> {
clone_suggestion_code: bool,
) -> Result<TokenStream, DiagnosticDeriveError> {
let span = attr.span().unwrap();
- let ident = &list.path.segments.last().unwrap().ident;
+ let mut ident = list.path.segments.last().unwrap().ident.clone();
+ ident.set_span(info.ty.span());
let name = ident.to_string();
let name = name.as_str();
@@ -498,7 +499,7 @@ impl<'parent, 'a> SubdiagnosticDeriveVariantBuilder<'parent, 'a> {
.variant
.bindings()
.iter()
- .filter(|binding| !binding.ast().attrs.is_empty())
+ .filter(|binding| !should_generate_set_arg(binding.ast()))
.map(|binding| self.generate_field_attr_code(binding, kind_stats))
.collect();
@@ -580,7 +581,7 @@ impl<'parent, 'a> SubdiagnosticDeriveVariantBuilder<'parent, 'a> {
.variant
.bindings()
.iter()
- .filter(|binding| binding.ast().attrs.is_empty())
+ .filter(|binding| should_generate_set_arg(binding.ast()))
.map(|binding| self.generate_field_set_arg(binding))
.collect();
diff --git a/compiler/rustc_macros/src/diagnostics/utils.rs b/compiler/rustc_macros/src/diagnostics/utils.rs
index b9b09c662..e2434981f 100644
--- a/compiler/rustc_macros/src/diagnostics/utils.rs
+++ b/compiler/rustc_macros/src/diagnostics/utils.rs
@@ -207,6 +207,12 @@ impl<'ty> FieldInnerTy<'ty> {
FieldInnerTy::Plain(..) => quote! { #inner },
}
}
+
+ pub fn span(&self) -> proc_macro2::Span {
+ match self {
+ FieldInnerTy::Option(ty) | FieldInnerTy::Vec(ty) | FieldInnerTy::Plain(ty) => ty.span(),
+ }
+ }
}
/// Field information passed to the builder. Deliberately omits attrs to discourage the
@@ -851,7 +857,8 @@ impl quote::IdentFragment for SubdiagnosticKind {
/// Returns `true` if `field` should generate a `set_arg` call rather than any other diagnostic
/// call (like `span_label`).
pub(super) fn should_generate_set_arg(field: &Field) -> bool {
- field.attrs.is_empty()
+ // Perhaps this should be an exhaustive list...
+ field.attrs.iter().all(|attr| is_doc_comment(attr))
}
pub(super) fn is_doc_comment(attr: &Attribute) -> bool {
diff --git a/compiler/rustc_macros/src/lib.rs b/compiler/rustc_macros/src/lib.rs
index 737500cc2..904f8eb57 100644
--- a/compiler/rustc_macros/src/lib.rs
+++ b/compiler/rustc_macros/src/lib.rs
@@ -54,60 +54,6 @@ pub fn newtype_index(input: TokenStream) -> TokenStream {
newtype::newtype(input)
}
-/// Implements the `fluent_messages` macro, which performs compile-time validation of the
-/// compiler's Fluent resources (i.e. that the resources parse and don't multiply define the same
-/// messages) and generates constants that make using those messages in diagnostics more ergonomic.
-///
-/// For example, given the following invocation of the macro..
-///
-/// ```ignore (rust)
-/// fluent_messages! { "./typeck.ftl" }
-/// ```
-/// ..where `typeck.ftl` has the following contents..
-///
-/// ```fluent
-/// typeck_field_multiply_specified_in_initializer =
-/// field `{$ident}` specified more than once
-/// .label = used more than once
-/// .label_previous_use = first use of `{$ident}`
-/// ```
-/// ...then the macro parse the Fluent resource, emitting a diagnostic if it fails to do so, and
-/// will generate the following code:
-///
-/// ```ignore (rust)
-/// pub static DEFAULT_LOCALE_RESOURCE: &'static [&'static str] = include_str!("./typeck.ftl");
-///
-/// mod fluent_generated {
-/// mod typeck {
-/// pub const field_multiply_specified_in_initializer: DiagnosticMessage =
-/// DiagnosticMessage::fluent("typeck_field_multiply_specified_in_initializer");
-/// pub const field_multiply_specified_in_initializer_label_previous_use: DiagnosticMessage =
-/// DiagnosticMessage::fluent_attr(
-/// "typeck_field_multiply_specified_in_initializer",
-/// "previous_use_label"
-/// );
-/// }
-/// }
-/// ```
-/// When emitting a diagnostic, the generated constants can be used as follows:
-///
-/// ```ignore (rust)
-/// let mut err = sess.struct_span_err(
-/// span,
-/// fluent::typeck::field_multiply_specified_in_initializer
-/// );
-/// err.span_default_label(span);
-/// err.span_label(
-/// previous_use_span,
-/// fluent::typeck::field_multiply_specified_in_initializer_label_previous_use
-/// );
-/// err.emit();
-/// ```
-#[proc_macro]
-pub fn fluent_messages(input: TokenStream) -> TokenStream {
- diagnostics::fluent_messages(input)
-}
-
decl_derive!([HashStable, attributes(stable_hasher)] => hash_stable::hash_stable_derive);
decl_derive!(
[HashStable_Generic, attributes(stable_hasher)] =>
diff --git a/compiler/rustc_macros/src/newtype.rs b/compiler/rustc_macros/src/newtype.rs
index 78a6f7488..415a89b0f 100644
--- a/compiler/rustc_macros/src/newtype.rs
+++ b/compiler/rustc_macros/src/newtype.rs
@@ -254,7 +254,7 @@ impl Parse for Newtype {
}
}
- impl rustc_index::vec::Idx for #name {
+ impl rustc_index::Idx for #name {
#[inline]
fn new(value: usize) -> Self {
Self::from_usize(value)
diff --git a/compiler/rustc_macros/src/query.rs b/compiler/rustc_macros/src/query.rs
index f85ba3800..d0d41c614 100644
--- a/compiler/rustc_macros/src/query.rs
+++ b/compiler/rustc_macros/src/query.rs
@@ -112,9 +112,6 @@ struct QueryModifiers {
/// Use a separate query provider for local and extern crates
separate_provide_extern: Option<Ident>,
- /// Always remap the ParamEnv's constness before hashing.
- remap_env_constness: Option<Ident>,
-
/// Generate a `feed` method to set the query's value from another query.
feedable: Option<Ident>,
}
@@ -130,7 +127,6 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
let mut eval_always = None;
let mut depth_limit = None;
let mut separate_provide_extern = None;
- let mut remap_env_constness = None;
let mut feedable = None;
while !input.is_empty() {
@@ -189,8 +185,6 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
try_insert!(depth_limit = modifier);
} else if modifier == "separate_provide_extern" {
try_insert!(separate_provide_extern = modifier);
- } else if modifier == "remap_env_constness" {
- try_insert!(remap_env_constness = modifier);
} else if modifier == "feedable" {
try_insert!(feedable = modifier);
} else {
@@ -211,7 +205,6 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
eval_always,
depth_limit,
separate_provide_extern,
- remap_env_constness,
feedable,
})
}
@@ -260,7 +253,7 @@ fn add_query_desc_cached_impl(
quote! {
#[allow(unused_variables, unused_braces, rustc::pass_by_value)]
#[inline]
- pub fn #name<'tcx>(#tcx: TyCtxt<'tcx>, #key: &crate::ty::query::query_keys::#name<'tcx>) -> bool {
+ pub fn #name<'tcx>(#tcx: TyCtxt<'tcx>, #key: &crate::query::queries::#name::Key<'tcx>) -> bool {
#expr
}
}
@@ -269,7 +262,7 @@ fn add_query_desc_cached_impl(
// we're taking `key` by reference, but some rustc types usually prefer being passed by value
#[allow(rustc::pass_by_value)]
#[inline]
- pub fn #name<'tcx>(_: TyCtxt<'tcx>, _: &crate::ty::query::query_keys::#name<'tcx>) -> bool {
+ pub fn #name<'tcx>(_: TyCtxt<'tcx>, _: &crate::query::queries::#name::Key<'tcx>) -> bool {
false
}
}
@@ -280,7 +273,7 @@ fn add_query_desc_cached_impl(
let desc = quote! {
#[allow(unused_variables)]
- pub fn #name<'tcx>(tcx: TyCtxt<'tcx>, key: crate::ty::query::query_keys::#name<'tcx>) -> String {
+ pub fn #name<'tcx>(tcx: TyCtxt<'tcx>, key: crate::query::queries::#name::Key<'tcx>) -> String {
let (#tcx, #key) = (tcx, key);
::rustc_middle::ty::print::with_no_trimmed_paths!(
format!(#desc)
@@ -332,7 +325,6 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
eval_always,
depth_limit,
separate_provide_extern,
- remap_env_constness,
);
if modifiers.cache.is_some() {