Auto merge of #152089 - JonathanBrouwer:rollup-h74gaTC, r=JonathanBrouwer
Rollup of 5 pull requests Successful merges: - rust-lang/rust#151893 (Move the query list into a new `rustc_middle::queries` module) - rust-lang/rust#152060 (ci: Optimize loongarch64-linux dist builders) - rust-lang/rust#151993 (Add uv to the list of possible python runners) - rust-lang/rust#152047 (Convert to inline diagnostics in `rustc_interface`) - rust-lang/rust#152053 (Avoid semicolon suggestion when tail expr is error) Failed merges: - rust-lang/rust#152023 (Some `rustc_query_system` cleanups)
This commit is contained in:
commit
930ecbcdf8
24 changed files with 3001 additions and 3000 deletions
|
|
@ -4114,7 +4114,6 @@ dependencies = [
|
|||
"rustc_errors",
|
||||
"rustc_expand",
|
||||
"rustc_feature",
|
||||
"rustc_fluent_macro",
|
||||
"rustc_fs_util",
|
||||
"rustc_hir",
|
||||
"rustc_hir_analysis",
|
||||
|
|
|
|||
|
|
@ -124,7 +124,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
|
|||
rustc_expand::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_hir_analysis::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_hir_typeck::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_interface::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_lint::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_metadata::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_middle::DEFAULT_LOCALE_RESOURCE,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ rustc_data_structures = { path = "../rustc_data_structures" }
|
|||
rustc_errors = { path = "../rustc_errors" }
|
||||
rustc_expand = { path = "../rustc_expand" }
|
||||
rustc_feature = { path = "../rustc_feature" }
|
||||
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
|
||||
rustc_fs_util = { path = "../rustc_fs_util" }
|
||||
rustc_hir = { path = "../rustc_hir" }
|
||||
rustc_hir_analysis = { path = "../rustc_hir_analysis" }
|
||||
|
|
|
|||
|
|
@ -1,56 +0,0 @@
|
|||
interface_abi_required_feature =
|
||||
target feature `{$feature}` must be {$enabled} to ensure that the ABI of the current target can be implemented correctly
|
||||
.note = this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
interface_abi_required_feature_issue = for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
|
||||
|
||||
interface_crate_name_does_not_match = `--crate-name` and `#[crate_name]` are required to match, but `{$crate_name}` != `{$attr_crate_name}`
|
||||
|
||||
interface_crate_name_invalid = crate names cannot start with a `-`, but `{$crate_name}` has a leading hyphen
|
||||
|
||||
interface_emoji_identifier =
|
||||
identifiers cannot contain emoji: `{$ident}`
|
||||
|
||||
interface_error_writing_dependencies =
|
||||
error writing dependencies to `{$path}`: {$error}
|
||||
|
||||
interface_failed_writing_file =
|
||||
failed to write file {$path}: {$error}"
|
||||
|
||||
interface_ferris_identifier =
|
||||
Ferris cannot be used as an identifier
|
||||
.suggestion = try using their name instead
|
||||
|
||||
interface_generated_file_conflicts_with_directory =
|
||||
the generated executable for the input file "{$input_path}" conflicts with the existing directory "{$dir_path}"
|
||||
|
||||
interface_ignoring_extra_filename = ignoring -C extra-filename flag due to -o flag
|
||||
|
||||
interface_ignoring_out_dir = ignoring --out-dir flag due to -o flag
|
||||
|
||||
interface_input_file_would_be_overwritten =
|
||||
the input file "{$path}" would be overwritten by the generated executable
|
||||
|
||||
interface_mixed_bin_crate =
|
||||
cannot mix `bin` crate type with others
|
||||
|
||||
interface_mixed_proc_macro_crate =
|
||||
cannot mix `proc-macro` crate type with others
|
||||
|
||||
interface_multiple_output_types_adaption =
|
||||
due to multiple output types requested, the explicitly specified output file name will be adapted for each output type
|
||||
|
||||
interface_multiple_output_types_to_stdout = can't use option `-o` or `--emit` to write multiple output types to stdout
|
||||
interface_out_dir_error =
|
||||
failed to find or create the directory specified by `--out-dir`
|
||||
|
||||
interface_proc_macro_crate_panic_abort =
|
||||
building proc macro crate with `panic=abort` or `panic=immediate-abort` may crash the compiler should the proc-macro panic
|
||||
|
||||
interface_temps_dir_error =
|
||||
failed to find or create the directory specified by `--temps-dir`
|
||||
|
||||
interface_unsupported_crate_type_for_codegen_backend =
|
||||
dropping unsupported crate type `{$crate_type}` for codegen backend `{$codegen_backend}`
|
||||
|
||||
interface_unsupported_crate_type_for_target =
|
||||
dropping unsupported crate type `{$crate_type}` for target `{$target_triple}`
|
||||
|
|
@ -7,7 +7,9 @@ use rustc_span::{Span, Symbol};
|
|||
use rustc_target::spec::TargetTuple;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_crate_name_does_not_match)]
|
||||
#[diag(
|
||||
"`--crate-name` and `#[crate_name]` are required to match, but `{$crate_name}` != `{$attr_crate_name}`"
|
||||
)]
|
||||
pub(crate) struct CrateNameDoesNotMatch {
|
||||
#[primary_span]
|
||||
pub(crate) span: Span,
|
||||
|
|
@ -16,23 +18,27 @@ pub(crate) struct CrateNameDoesNotMatch {
|
|||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_crate_name_invalid)]
|
||||
#[diag("crate names cannot start with a `-`, but `{$crate_name}` has a leading hyphen")]
|
||||
pub(crate) struct CrateNameInvalid<'a> {
|
||||
pub(crate) crate_name: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_ferris_identifier)]
|
||||
#[diag("Ferris cannot be used as an identifier")]
|
||||
pub struct FerrisIdentifier {
|
||||
#[primary_span]
|
||||
pub spans: Vec<Span>,
|
||||
#[suggestion(code = "{ferris_fix}", applicability = "maybe-incorrect")]
|
||||
#[suggestion(
|
||||
"try using their name instead",
|
||||
code = "{ferris_fix}",
|
||||
applicability = "maybe-incorrect"
|
||||
)]
|
||||
pub first_span: Span,
|
||||
pub ferris_fix: &'static str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_emoji_identifier)]
|
||||
#[diag("identifiers cannot contain emoji: `{$ident}`")]
|
||||
pub struct EmojiIdentifier {
|
||||
#[primary_span]
|
||||
pub spans: Vec<Span>,
|
||||
|
|
@ -40,86 +46,96 @@ pub struct EmojiIdentifier {
|
|||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_mixed_bin_crate)]
|
||||
#[diag("cannot mix `bin` crate type with others")]
|
||||
pub struct MixedBinCrate;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_mixed_proc_macro_crate)]
|
||||
#[diag("cannot mix `proc-macro` crate type with others")]
|
||||
pub struct MixedProcMacroCrate;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_error_writing_dependencies)]
|
||||
#[diag("error writing dependencies to `{$path}`: {$error}")]
|
||||
pub struct ErrorWritingDependencies<'a> {
|
||||
pub path: &'a Path,
|
||||
pub error: io::Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_input_file_would_be_overwritten)]
|
||||
#[diag("the input file \"{$path}\" would be overwritten by the generated executable")]
|
||||
pub struct InputFileWouldBeOverWritten<'a> {
|
||||
pub path: &'a Path,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_generated_file_conflicts_with_directory)]
|
||||
#[diag(
|
||||
"the generated executable for the input file \"{$input_path}\" conflicts with the existing directory \"{$dir_path}\""
|
||||
)]
|
||||
pub struct GeneratedFileConflictsWithDirectory<'a> {
|
||||
pub input_path: &'a Path,
|
||||
pub dir_path: &'a Path,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_temps_dir_error)]
|
||||
#[diag("failed to find or create the directory specified by `--temps-dir`")]
|
||||
pub struct TempsDirError;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_out_dir_error)]
|
||||
#[diag("failed to find or create the directory specified by `--out-dir`")]
|
||||
pub struct OutDirError;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_failed_writing_file)]
|
||||
#[diag("failed to write file {$path}: {$error}\"")]
|
||||
pub struct FailedWritingFile<'a> {
|
||||
pub path: &'a Path,
|
||||
pub error: io::Error,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_proc_macro_crate_panic_abort)]
|
||||
#[diag(
|
||||
"building proc macro crate with `panic=abort` or `panic=immediate-abort` may crash the compiler should the proc-macro panic"
|
||||
)]
|
||||
pub struct ProcMacroCratePanicAbort;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_multiple_output_types_adaption)]
|
||||
#[diag(
|
||||
"due to multiple output types requested, the explicitly specified output file name will be adapted for each output type"
|
||||
)]
|
||||
pub struct MultipleOutputTypesAdaption;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_ignoring_extra_filename)]
|
||||
#[diag("ignoring -C extra-filename flag due to -o flag")]
|
||||
pub struct IgnoringExtraFilename;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_ignoring_out_dir)]
|
||||
#[diag("ignoring --out-dir flag due to -o flag")]
|
||||
pub struct IgnoringOutDir;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_multiple_output_types_to_stdout)]
|
||||
#[diag("can't use option `-o` or `--emit` to write multiple output types to stdout")]
|
||||
pub struct MultipleOutputTypesToStdout;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_abi_required_feature)]
|
||||
#[note]
|
||||
#[note(interface_abi_required_feature_issue)]
|
||||
#[diag(
|
||||
"target feature `{$feature}` must be {$enabled} to ensure that the ABI of the current target can be implemented correctly"
|
||||
)]
|
||||
#[note(
|
||||
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
|
||||
)]
|
||||
#[note("for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>")]
|
||||
pub(crate) struct AbiRequiredTargetFeature<'a> {
|
||||
pub feature: &'a str,
|
||||
pub enabled: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_unsupported_crate_type_for_codegen_backend)]
|
||||
#[diag("dropping unsupported crate type `{$crate_type}` for codegen backend `{$codegen_backend}`")]
|
||||
pub(crate) struct UnsupportedCrateTypeForCodegenBackend {
|
||||
pub(crate) crate_type: CrateType,
|
||||
pub(crate) codegen_backend: &'static str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(interface_unsupported_crate_type_for_target)]
|
||||
#[diag("dropping unsupported crate type `{$crate_type}` for target `{$target_triple}`")]
|
||||
pub(crate) struct UnsupportedCrateTypeForTarget<'a> {
|
||||
pub(crate) crate_type: CrateType,
|
||||
pub(crate) target_triple: &'a TargetTuple,
|
||||
|
|
|
|||
|
|
@ -55,11 +55,7 @@ pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec<String>) -> Cfg {
|
|||
cfgs.into_iter()
|
||||
.map(|s| {
|
||||
let psess = ParseSess::emitter_with_note(
|
||||
vec![
|
||||
crate::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_parse::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_session::DEFAULT_LOCALE_RESOURCE,
|
||||
],
|
||||
vec![rustc_parse::DEFAULT_LOCALE_RESOURCE, rustc_session::DEFAULT_LOCALE_RESOURCE],
|
||||
format!("this occurred on the command line: `--cfg={s}`"),
|
||||
);
|
||||
let filename = FileName::cfg_spec_source_code(&s);
|
||||
|
|
@ -131,11 +127,7 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
|
|||
|
||||
for s in specs {
|
||||
let psess = ParseSess::emitter_with_note(
|
||||
vec![
|
||||
crate::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_parse::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_session::DEFAULT_LOCALE_RESOURCE,
|
||||
],
|
||||
vec![rustc_parse::DEFAULT_LOCALE_RESOURCE, rustc_session::DEFAULT_LOCALE_RESOURCE],
|
||||
format!("this occurred on the command line: `--check-cfg={s}`"),
|
||||
);
|
||||
let filename = FileName::cfg_spec_source_code(&s);
|
||||
|
|
|
|||
|
|
@ -21,5 +21,3 @@ pub use queries::Linker;
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ fn add_query_desc_cached_impl(
|
|||
cached.extend(quote! {
|
||||
#[allow(unused_variables, unused_braces, rustc::pass_by_value)]
|
||||
#[inline]
|
||||
pub fn #name<'tcx>(#tcx: TyCtxt<'tcx>, #key: &crate::query::queries::#name::Key<'tcx>) -> bool {
|
||||
pub fn #name<'tcx>(#tcx: TyCtxt<'tcx>, #key: &crate::queries::#name::Key<'tcx>) -> bool {
|
||||
#ra_hint
|
||||
#expr
|
||||
}
|
||||
|
|
@ -301,7 +301,7 @@ fn add_query_desc_cached_impl(
|
|||
|
||||
let desc = quote! {
|
||||
#[allow(unused_variables)]
|
||||
pub fn #name<'tcx>(tcx: TyCtxt<'tcx>, key: crate::query::queries::#name::Key<'tcx>) -> String {
|
||||
pub fn #name<'tcx>(tcx: TyCtxt<'tcx>, key: crate::queries::#name::Key<'tcx>) -> String {
|
||||
let (#tcx, #key) = (tcx, key);
|
||||
format!(#desc)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ use rustc_middle::bug;
|
|||
use rustc_middle::metadata::{AmbigModChild, ModChild};
|
||||
use rustc_middle::middle::exported_symbols::ExportedSymbol;
|
||||
use rustc_middle::middle::stability::DeprecationEntry;
|
||||
use rustc_middle::query::{ExternProviders, LocalCrate};
|
||||
use rustc_middle::queries::ExternProviders;
|
||||
use rustc_middle::query::LocalCrate;
|
||||
use rustc_middle::ty::fast_reject::SimplifiedType;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_middle::util::Providers;
|
||||
|
|
@ -134,8 +135,8 @@ macro_rules! provide_one {
|
|||
($tcx:ident, $def_id:ident, $other:ident, $cdata:ident, $name:ident => $compute:block) => {
|
||||
fn $name<'tcx>(
|
||||
$tcx: TyCtxt<'tcx>,
|
||||
def_id_arg: rustc_middle::query::queries::$name::Key<'tcx>,
|
||||
) -> rustc_middle::query::queries::$name::ProvidedValue<'tcx> {
|
||||
def_id_arg: rustc_middle::queries::$name::Key<'tcx>,
|
||||
) -> rustc_middle::queries::$name::ProvidedValue<'tcx> {
|
||||
let _prof_timer =
|
||||
$tcx.prof.generic_activity(concat!("metadata_decode_entry_", stringify!($name)));
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,8 @@ mod values;
|
|||
#[macro_use]
|
||||
pub mod query;
|
||||
#[macro_use]
|
||||
pub mod queries;
|
||||
#[macro_use]
|
||||
pub mod dep_graph;
|
||||
|
||||
// Allows macros to refer to this crate as `::rustc_middle`
|
||||
|
|
|
|||
2775
compiler/rustc_middle/src/queries.rs
Normal file
2775
compiler/rustc_middle/src/queries.rs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -15,7 +15,7 @@ use rustc_span::source_map::Spanned;
|
|||
|
||||
use crate::mir::interpret::EvalToValTreeResult;
|
||||
use crate::mir::mono::{MonoItem, NormalizationErrorInMono};
|
||||
use crate::query::CyclePlaceholder;
|
||||
use crate::query::plumbing::CyclePlaceholder;
|
||||
use crate::traits::solve;
|
||||
use crate::ty::adjustment::CoerceUnsizedInfo;
|
||||
use crate::ty::{self, Ty, TyCtxt};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -12,10 +12,10 @@ pub use sealed::IntoQueryParam;
|
|||
|
||||
use crate::dep_graph;
|
||||
use crate::dep_graph::DepKind;
|
||||
use crate::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache};
|
||||
use crate::query::{
|
||||
use crate::queries::{
|
||||
ExternProviders, PerQueryVTables, Providers, QueryArenas, QueryCaches, QueryEngine, QueryStates,
|
||||
};
|
||||
use crate::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache};
|
||||
use crate::ty::TyCtxt;
|
||||
|
||||
pub type WillCacheOnDiskForKeyFn<'tcx, Key> = fn(tcx: TyCtxt<'tcx>, key: &Key) -> bool;
|
||||
|
|
@ -189,8 +189,8 @@ macro_rules! query_ensure_select {
|
|||
}
|
||||
|
||||
macro_rules! query_helper_param_ty {
|
||||
(DefId) => { impl IntoQueryParam<DefId> };
|
||||
(LocalDefId) => { impl IntoQueryParam<LocalDefId> };
|
||||
(DefId) => { impl $crate::query::IntoQueryParam<DefId> };
|
||||
(LocalDefId) => { impl $crate::query::IntoQueryParam<LocalDefId> };
|
||||
($K:ty) => { $K };
|
||||
}
|
||||
|
||||
|
|
@ -213,7 +213,7 @@ macro_rules! local_key_if_separate_extern {
|
|||
$($K)*
|
||||
};
|
||||
([(separate_provide_extern) $($rest:tt)*] $($K:tt)*) => {
|
||||
<$($K)* as AsLocalKey>::LocalKey
|
||||
<$($K)* as $crate::query::AsLocalKey>::LocalKey
|
||||
};
|
||||
([$other:tt $($modifiers:tt)*] $($K:tt)*) => {
|
||||
local_key_if_separate_extern!([$($modifiers)*] $($K)*)
|
||||
|
|
@ -227,8 +227,8 @@ macro_rules! separate_provide_extern_decl {
|
|||
([(separate_provide_extern) $($rest:tt)*][$name:ident]) => {
|
||||
for<'tcx> fn(
|
||||
TyCtxt<'tcx>,
|
||||
queries::$name::Key<'tcx>,
|
||||
) -> queries::$name::ProvidedValue<'tcx>
|
||||
$name::Key<'tcx>,
|
||||
) -> $name::ProvidedValue<'tcx>
|
||||
};
|
||||
([$other:tt $($modifiers:tt)*][$($args:tt)*]) => {
|
||||
separate_provide_extern_decl!([$($modifiers)*][$($args)*])
|
||||
|
|
@ -266,94 +266,90 @@ macro_rules! define_callbacks {
|
|||
[$($modifiers:tt)*] fn $name:ident($($K:tt)*) -> $V:ty,
|
||||
)*
|
||||
) => {
|
||||
$(#[allow(unused_lifetimes)] pub mod $name {
|
||||
use super::*;
|
||||
use $crate::query::erase::{self, Erased};
|
||||
|
||||
#[allow(unused_lifetimes)]
|
||||
pub mod queries {
|
||||
$(pub mod $name {
|
||||
use super::super::*;
|
||||
use $crate::query::erase::{self, Erased};
|
||||
pub type Key<'tcx> = $($K)*;
|
||||
pub type Value<'tcx> = $V;
|
||||
|
||||
pub type Key<'tcx> = $($K)*;
|
||||
pub type Value<'tcx> = $V;
|
||||
pub type LocalKey<'tcx> = local_key_if_separate_extern!([$($modifiers)*] $($K)*);
|
||||
|
||||
pub type LocalKey<'tcx> = local_key_if_separate_extern!([$($modifiers)*] $($K)*);
|
||||
/// This type alias specifies the type returned from query providers and the type
|
||||
/// used for decoding. For regular queries this is the declared returned type `V`,
|
||||
/// but `arena_cache` will use `<V as ArenaCached>::Provided` instead.
|
||||
pub type ProvidedValue<'tcx> = query_if_arena!(
|
||||
[$($modifiers)*]
|
||||
(<$V as $crate::query::arena_cached::ArenaCached<'tcx>>::Provided)
|
||||
($V)
|
||||
);
|
||||
|
||||
/// This type alias specifies the type returned from query providers and the type
|
||||
/// used for decoding. For regular queries this is the declared returned type `V`,
|
||||
/// but `arena_cache` will use `<V as ArenaCached>::Provided` instead.
|
||||
pub type ProvidedValue<'tcx> = query_if_arena!(
|
||||
[$($modifiers)*]
|
||||
(<$V as $crate::query::arena_cached::ArenaCached<'tcx>>::Provided)
|
||||
($V)
|
||||
);
|
||||
/// This function takes `ProvidedValue` and converts it to an erased `Value` by
|
||||
/// allocating it on an arena if the query has the `arena_cache` modifier. The
|
||||
/// value is then erased and returned. This will happen when computing the query
|
||||
/// using a provider or decoding a stored result.
|
||||
#[inline(always)]
|
||||
pub fn provided_to_erased<'tcx>(
|
||||
_tcx: TyCtxt<'tcx>,
|
||||
provided_value: ProvidedValue<'tcx>,
|
||||
) -> Erased<Value<'tcx>> {
|
||||
// Store the provided value in an arena and get a reference
|
||||
// to it, for queries with `arena_cache`.
|
||||
let value: Value<'tcx> = query_if_arena!([$($modifiers)*]
|
||||
{
|
||||
use $crate::query::arena_cached::ArenaCached;
|
||||
|
||||
/// This function takes `ProvidedValue` and converts it to an erased `Value` by
|
||||
/// allocating it on an arena if the query has the `arena_cache` modifier. The
|
||||
/// value is then erased and returned. This will happen when computing the query
|
||||
/// using a provider or decoding a stored result.
|
||||
#[inline(always)]
|
||||
pub fn provided_to_erased<'tcx>(
|
||||
_tcx: TyCtxt<'tcx>,
|
||||
provided_value: ProvidedValue<'tcx>,
|
||||
) -> Erased<Value<'tcx>> {
|
||||
// Store the provided value in an arena and get a reference
|
||||
// to it, for queries with `arena_cache`.
|
||||
let value: Value<'tcx> = query_if_arena!([$($modifiers)*]
|
||||
{
|
||||
use $crate::query::arena_cached::ArenaCached;
|
||||
|
||||
if mem::needs_drop::<<$V as ArenaCached<'tcx>>::Allocated>() {
|
||||
<$V as ArenaCached>::alloc_in_arena(
|
||||
|v| _tcx.query_system.arenas.$name.alloc(v),
|
||||
provided_value,
|
||||
)
|
||||
} else {
|
||||
<$V as ArenaCached>::alloc_in_arena(
|
||||
|v| _tcx.arena.dropless.alloc(v),
|
||||
provided_value,
|
||||
)
|
||||
}
|
||||
if mem::needs_drop::<<$V as ArenaCached<'tcx>>::Allocated>() {
|
||||
<$V as ArenaCached>::alloc_in_arena(
|
||||
|v| _tcx.query_system.arenas.$name.alloc(v),
|
||||
provided_value,
|
||||
)
|
||||
} else {
|
||||
<$V as ArenaCached>::alloc_in_arena(
|
||||
|v| _tcx.arena.dropless.alloc(v),
|
||||
provided_value,
|
||||
)
|
||||
}
|
||||
// Otherwise, the provided value is the value.
|
||||
(provided_value)
|
||||
);
|
||||
erase::erase_val(value)
|
||||
}
|
||||
// Otherwise, the provided value is the value.
|
||||
(provided_value)
|
||||
);
|
||||
erase::erase_val(value)
|
||||
}
|
||||
|
||||
pub type Storage<'tcx> = <$($K)* as $crate::query::Key>::Cache<Erased<$V>>;
|
||||
|
||||
// Ensure that keys grow no larger than 88 bytes by accident.
|
||||
// Increase this limit if necessary, but do try to keep the size low if possible
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
const _: () = {
|
||||
if size_of::<Key<'static>>() > 88 {
|
||||
panic!("{}", concat!(
|
||||
"the query `",
|
||||
stringify!($name),
|
||||
"` has a key type `",
|
||||
stringify!($($K)*),
|
||||
"` that is too large"
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
pub type Storage<'tcx> = <$($K)* as keys::Key>::Cache<Erased<$V>>;
|
||||
|
||||
// Ensure that keys grow no larger than 88 bytes by accident.
|
||||
// Increase this limit if necessary, but do try to keep the size low if possible
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
const _: () = {
|
||||
if size_of::<Key<'static>>() > 88 {
|
||||
panic!("{}", concat!(
|
||||
"the query `",
|
||||
stringify!($name),
|
||||
"` has a key type `",
|
||||
stringify!($($K)*),
|
||||
"` that is too large"
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
// Ensure that values grow no larger than 64 bytes by accident.
|
||||
// Increase this limit if necessary, but do try to keep the size low if possible
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
#[cfg(not(feature = "rustc_randomized_layouts"))]
|
||||
const _: () = {
|
||||
if size_of::<Value<'static>>() > 64 {
|
||||
panic!("{}", concat!(
|
||||
"the query `",
|
||||
stringify!($name),
|
||||
"` has a value type `",
|
||||
stringify!($V),
|
||||
"` that is too large"
|
||||
));
|
||||
}
|
||||
};
|
||||
})*
|
||||
}
|
||||
// Ensure that values grow no larger than 64 bytes by accident.
|
||||
// Increase this limit if necessary, but do try to keep the size low if possible
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
#[cfg(not(feature = "rustc_randomized_layouts"))]
|
||||
const _: () = {
|
||||
if size_of::<Value<'static>>() > 64 {
|
||||
panic!("{}", concat!(
|
||||
"the query `",
|
||||
stringify!($name),
|
||||
"` has a value type `",
|
||||
stringify!($V),
|
||||
"` that is too large"
|
||||
));
|
||||
}
|
||||
};
|
||||
})*
|
||||
|
||||
/// Holds per-query arenas for queries with the `arena_cache` modifier.
|
||||
#[derive(Default)]
|
||||
|
|
@ -371,10 +367,10 @@ macro_rules! define_callbacks {
|
|||
|
||||
#[derive(Default)]
|
||||
pub struct QueryCaches<'tcx> {
|
||||
$($(#[$attr])* pub $name: queries::$name::Storage<'tcx>,)*
|
||||
$($(#[$attr])* pub $name: $name::Storage<'tcx>,)*
|
||||
}
|
||||
|
||||
impl<'tcx> TyCtxtEnsureOk<'tcx> {
|
||||
impl<'tcx> $crate::query::TyCtxtEnsureOk<'tcx> {
|
||||
$($(#[$attr])*
|
||||
#[inline(always)]
|
||||
pub fn $name(
|
||||
|
|
@ -386,13 +382,13 @@ macro_rules! define_callbacks {
|
|||
self.tcx,
|
||||
self.tcx.query_system.fns.engine.$name,
|
||||
&self.tcx.query_system.caches.$name,
|
||||
key.into_query_param(),
|
||||
$crate::query::IntoQueryParam::into_query_param(key),
|
||||
false,
|
||||
)
|
||||
})*
|
||||
}
|
||||
|
||||
impl<'tcx> TyCtxtEnsureDone<'tcx> {
|
||||
impl<'tcx> $crate::query::TyCtxtEnsureDone<'tcx> {
|
||||
$($(#[$attr])*
|
||||
#[inline(always)]
|
||||
pub fn $name(self, key: query_helper_param_ty!($($K)*)) {
|
||||
|
|
@ -400,7 +396,7 @@ macro_rules! define_callbacks {
|
|||
self.tcx,
|
||||
self.tcx.query_system.fns.engine.$name,
|
||||
&self.tcx.query_system.caches.$name,
|
||||
key.into_query_param(),
|
||||
$crate::query::IntoQueryParam::into_query_param(key),
|
||||
true,
|
||||
);
|
||||
})*
|
||||
|
|
@ -416,7 +412,7 @@ macro_rules! define_callbacks {
|
|||
})*
|
||||
}
|
||||
|
||||
impl<'tcx> TyCtxtAt<'tcx> {
|
||||
impl<'tcx> $crate::query::TyCtxtAt<'tcx> {
|
||||
$($(#[$attr])*
|
||||
#[inline(always)]
|
||||
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V
|
||||
|
|
@ -428,7 +424,7 @@ macro_rules! define_callbacks {
|
|||
self.tcx.query_system.fns.engine.$name,
|
||||
&self.tcx.query_system.caches.$name,
|
||||
self.span,
|
||||
key.into_query_param(),
|
||||
$crate::query::IntoQueryParam::into_query_param(key),
|
||||
))
|
||||
})*
|
||||
}
|
||||
|
|
@ -438,22 +434,22 @@ macro_rules! define_callbacks {
|
|||
/// ("Per" just makes this pluralized name more visually distinct.)
|
||||
pub struct PerQueryVTables<'tcx> {
|
||||
$(
|
||||
pub $name: ::rustc_middle::query::plumbing::QueryVTable<'tcx, queries::$name::Storage<'tcx>>,
|
||||
pub $name: ::rustc_middle::query::plumbing::QueryVTable<'tcx, $name::Storage<'tcx>>,
|
||||
)*
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct QueryStates<'tcx> {
|
||||
$(
|
||||
pub $name: QueryState<'tcx, $($K)*>,
|
||||
pub $name: $crate::query::QueryState<'tcx, $($K)*>,
|
||||
)*
|
||||
}
|
||||
|
||||
pub struct Providers {
|
||||
$(pub $name: for<'tcx> fn(
|
||||
TyCtxt<'tcx>,
|
||||
queries::$name::LocalKey<'tcx>,
|
||||
) -> queries::$name::ProvidedValue<'tcx>,)*
|
||||
$name::LocalKey<'tcx>,
|
||||
) -> $name::ProvidedValue<'tcx>,)*
|
||||
}
|
||||
|
||||
pub struct ExternProviders {
|
||||
|
|
@ -490,8 +486,8 @@ macro_rules! define_callbacks {
|
|||
$(pub $name: for<'tcx> fn(
|
||||
TyCtxt<'tcx>,
|
||||
Span,
|
||||
queries::$name::Key<'tcx>,
|
||||
QueryMode,
|
||||
$name::Key<'tcx>,
|
||||
$crate::query::QueryMode,
|
||||
) -> Option<$crate::query::erase::Erased<$V>>,)*
|
||||
}
|
||||
};
|
||||
|
|
@ -499,14 +495,14 @@ macro_rules! define_callbacks {
|
|||
|
||||
macro_rules! define_feedable {
|
||||
($($(#[$attr:meta])* [$($modifiers:tt)*] fn $name:ident($($K:tt)*) -> $V:ty,)*) => {
|
||||
$(impl<'tcx, K: IntoQueryParam<$($K)*> + Copy> TyCtxtFeed<'tcx, K> {
|
||||
$(impl<'tcx, K: $crate::query::IntoQueryParam<$($K)*> + Copy> TyCtxtFeed<'tcx, K> {
|
||||
$(#[$attr])*
|
||||
#[inline(always)]
|
||||
pub fn $name(self, value: queries::$name::ProvidedValue<'tcx>) {
|
||||
pub fn $name(self, value: $name::ProvidedValue<'tcx>) {
|
||||
let key = self.key().into_query_param();
|
||||
|
||||
let tcx = self.tcx;
|
||||
let erased_value = queries::$name::provided_to_erased(tcx, value);
|
||||
let erased_value = $name::provided_to_erased(tcx, value);
|
||||
|
||||
let dep_kind: dep_graph::DepKind = dep_graph::dep_kinds::$name;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ pub mod bug;
|
|||
|
||||
#[derive(Default, Copy, Clone)]
|
||||
pub struct Providers {
|
||||
pub queries: crate::query::Providers,
|
||||
pub extern_queries: crate::query::ExternProviders,
|
||||
pub queries: crate::queries::Providers,
|
||||
pub extern_queries: crate::queries::ExternProviders,
|
||||
pub hooks: crate::hooks::Providers,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,11 +13,12 @@ use rustc_data_structures::stable_hasher::HashStable;
|
|||
use rustc_data_structures::sync::AtomicU64;
|
||||
use rustc_middle::arena::Arena;
|
||||
use rustc_middle::dep_graph::{self, DepKind, DepKindVTable, DepNodeIndex};
|
||||
use rustc_middle::queries::{
|
||||
self, ExternProviders, Providers, QueryCaches, QueryEngine, QueryStates,
|
||||
};
|
||||
use rustc_middle::query::AsLocalKey;
|
||||
use rustc_middle::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache};
|
||||
use rustc_middle::query::plumbing::{QuerySystem, QuerySystemFns, QueryVTable};
|
||||
use rustc_middle::query::{
|
||||
AsLocalKey, ExternProviders, Providers, QueryCaches, QueryEngine, QueryStates, queries,
|
||||
};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_query_system::Value;
|
||||
use rustc_query_system::dep_graph::SerializedDepNodeIndex;
|
||||
|
|
|
|||
|
|
@ -647,7 +647,7 @@ macro_rules! define_queries {
|
|||
query_state: std::mem::offset_of!(QueryStates<'tcx>, $name),
|
||||
query_cache: std::mem::offset_of!(QueryCaches<'tcx>, $name),
|
||||
will_cache_on_disk_for_key_fn: should_ever_cache_on_disk!([$($modifiers)*] {
|
||||
Some(::rustc_middle::query::cached::$name)
|
||||
Some(queries::cached::$name)
|
||||
} {
|
||||
None
|
||||
}),
|
||||
|
|
@ -671,7 +671,7 @@ macro_rules! define_queries {
|
|||
try_load_from_disk_fn: should_ever_cache_on_disk!([$($modifiers)*] {
|
||||
Some(|tcx, key, prev_index, index| {
|
||||
// Check the `cache_on_disk_if` condition for this key.
|
||||
if !::rustc_middle::query::cached::$name(tcx, key) {
|
||||
if !queries::cached::$name(tcx, key) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
@ -686,7 +686,7 @@ macro_rules! define_queries {
|
|||
}),
|
||||
is_loadable_from_disk_fn: should_ever_cache_on_disk!([$($modifiers)*] {
|
||||
Some(|tcx, key, index| -> bool {
|
||||
::rustc_middle::query::cached::$name(tcx, key) &&
|
||||
::rustc_middle::queries::cached::$name(tcx, key) &&
|
||||
$crate::plumbing::loadable_from_disk(tcx, index)
|
||||
})
|
||||
} {
|
||||
|
|
@ -746,7 +746,7 @@ macro_rules! define_queries {
|
|||
let make_frame = |tcx, key| {
|
||||
let kind = rustc_middle::dep_graph::dep_kinds::$name;
|
||||
let name = stringify!($name);
|
||||
$crate::plumbing::create_query_frame(tcx, rustc_middle::query::descs::$name, key, kind, name)
|
||||
$crate::plumbing::create_query_frame(tcx, queries::descs::$name, key, kind, name)
|
||||
};
|
||||
|
||||
// Call `gather_active_jobs_inner` to do the actual work.
|
||||
|
|
@ -816,8 +816,8 @@ macro_rules! define_queries {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn make_query_vtables<'tcx>() -> ::rustc_middle::query::PerQueryVTables<'tcx> {
|
||||
::rustc_middle::query::PerQueryVTables {
|
||||
pub fn make_query_vtables<'tcx>() -> queries::PerQueryVTables<'tcx> {
|
||||
queries::PerQueryVTables {
|
||||
$(
|
||||
$name: query_impl::$name::make_query_vtable(),
|
||||
)*
|
||||
|
|
|
|||
|
|
@ -954,7 +954,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
|
||||
let new_obligation =
|
||||
self.mk_trait_obligation_with_new_self_ty(obligation.param_env, trait_pred_and_self);
|
||||
if self.predicate_must_hold_modulo_regions(&new_obligation) {
|
||||
if !matches!(tail_expr.kind, hir::ExprKind::Err(_))
|
||||
&& self.predicate_must_hold_modulo_regions(&new_obligation)
|
||||
{
|
||||
err.span_suggestion_short(
|
||||
stmt.span.with_lo(tail_expr.span.hi()),
|
||||
"remove this semicolon",
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@ ENV RUST_CONFIGURE_ARGS \
|
|||
--enable-full-tools \
|
||||
--enable-profiler \
|
||||
--enable-sanitizers \
|
||||
--disable-docs
|
||||
--disable-docs \
|
||||
--set rust.jemalloc \
|
||||
--set rust.lto=thin \
|
||||
--set rust.codegen-units=1
|
||||
|
||||
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $TARGETS
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ ENV RUST_CONFIGURE_ARGS \
|
|||
--enable-profiler \
|
||||
--enable-sanitizers \
|
||||
--disable-docs \
|
||||
--set rust.jemalloc \
|
||||
--set rust.lto=thin \
|
||||
--set rust.codegen-units=1 \
|
||||
--set target.loongarch64-unknown-linux-musl.crt-static=false \
|
||||
--musl-root-loongarch64=/x-tools/loongarch64-unknown-linux-musl/loongarch64-unknown-linux-musl/sysroot/usr
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ use rustc_hir::def::DefKind;
|
|||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_interface::Config;
|
||||
use rustc_interface::interface::Compiler;
|
||||
use rustc_middle::query::queries::mir_borrowck::ProvidedValue;
|
||||
use rustc_middle::queries::mir_borrowck::ProvidedValue;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_middle::util::Providers;
|
||||
use rustc_session::Session;
|
||||
|
|
|
|||
12
tests/ui/type/recover-from-semicolon-trailing-undefined.rs
Normal file
12
tests/ui/type/recover-from-semicolon-trailing-undefined.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
//@ compile-flags: -Znext-solver=globally
|
||||
|
||||
// Regression test for https://github.com/rust-lang/rust/issues/151610
|
||||
|
||||
fn main() {
|
||||
let x_str = {
|
||||
x!("{}", x);
|
||||
//~^ ERROR cannot find macro `x` in this scope
|
||||
};
|
||||
println!("{}", x_str);
|
||||
//~^ ERROR `()` doesn't implement `std::fmt::Display`
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
error: cannot find macro `x` in this scope
|
||||
--> $DIR/recover-from-semicolon-trailing-undefined.rs:7:9
|
||||
|
|
||||
LL | x!("{}", x);
|
||||
| ^
|
||||
|
||||
error[E0277]: `()` doesn't implement `std::fmt::Display`
|
||||
--> $DIR/recover-from-semicolon-trailing-undefined.rs:10:20
|
||||
|
|
||||
LL | let x_str = {
|
||||
| _________________-
|
||||
LL | | x!("{}", x);
|
||||
LL | |
|
||||
LL | | };
|
||||
| |_____- this block is missing a tail expression
|
||||
LL | println!("{}", x_str);
|
||||
| -- ^^^^^ `()` cannot be formatted with the default formatter
|
||||
| |
|
||||
| required by this formatting parameter
|
||||
|
|
||||
= help: the trait `std::fmt::Display` is not implemented for `()`
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
17
x
17
x
|
|
@ -29,16 +29,19 @@ xpy=$(dirname "$(realpath "$0")")/x.py
|
|||
# On MacOS, `py` tries to install "Developer command line tools". Try `python3` first.
|
||||
# NOTE: running `bash -c ./x` from Windows doesn't set OSTYPE.
|
||||
case ${OSTYPE:-} in
|
||||
cygwin*|msys*) SEARCH="py python3 python python2";;
|
||||
*) SEARCH="python3 python py python2";;
|
||||
cygwin*|msys*) SEARCH="py python3 python python2 uv";;
|
||||
*) SEARCH="python3 python py python2 uv";;
|
||||
esac
|
||||
for SEARCH_PYTHON in $SEARCH; do
|
||||
if python=$(command -v $SEARCH_PYTHON) && [ -x "$python" ]; then
|
||||
if [ $SEARCH_PYTHON = py ]; then
|
||||
extra_arg="-3"
|
||||
else
|
||||
extra_arg=""
|
||||
fi
|
||||
case $SEARCH_PYTHON in
|
||||
py)
|
||||
extra_arg="-3";;
|
||||
uv)
|
||||
extra_arg="run";;
|
||||
*)
|
||||
extra_arg="";;
|
||||
esac
|
||||
exec "$python" $extra_arg "$xpy" "$@"
|
||||
fi
|
||||
done
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue