Move rustc_middle::limits
to rustc_interface
.
It's always good to make `rustc_middle` smaller. `rustc_interface` is the best destination, because it's the only crate that calls `get_recursive_limit`.
This commit is contained in:
parent
13280eed6a
commit
223c95fd59
9 changed files with 23 additions and 26 deletions
|
@ -33,6 +33,10 @@ interface_ignoring_out_dir = ignoring --out-dir flag due to -o flag
|
||||||
interface_input_file_would_be_overwritten =
|
interface_input_file_would_be_overwritten =
|
||||||
the input file "{$path}" would be overwritten by the generated executable
|
the input file "{$path}" would be overwritten by the generated executable
|
||||||
|
|
||||||
|
interface_limit_invalid =
|
||||||
|
`limit` must be a non-negative integer
|
||||||
|
.label = {$error_str}
|
||||||
|
|
||||||
interface_mixed_bin_crate =
|
interface_mixed_bin_crate =
|
||||||
cannot mix `bin` crate type with others
|
cannot mix `bin` crate type with others
|
||||||
|
|
||||||
|
|
|
@ -127,3 +127,13 @@ pub(crate) struct AbiRequiredTargetFeature<'a> {
|
||||||
pub feature: &'a str,
|
pub feature: &'a str,
|
||||||
pub enabled: &'a str,
|
pub enabled: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(interface_limit_invalid)]
|
||||||
|
pub(crate) struct LimitInvalid<'a> {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
#[label]
|
||||||
|
pub value_span: Span,
|
||||||
|
pub error_str: &'a str,
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
mod callbacks;
|
mod callbacks;
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
pub mod interface;
|
pub mod interface;
|
||||||
|
mod limits;
|
||||||
pub mod passes;
|
pub mod passes;
|
||||||
mod proc_macro_decls;
|
mod proc_macro_decls;
|
||||||
mod queries;
|
mod queries;
|
||||||
|
|
|
@ -11,13 +11,14 @@
|
||||||
use std::num::IntErrorKind;
|
use std::num::IntErrorKind;
|
||||||
|
|
||||||
use rustc_ast::attr::AttributeExt;
|
use rustc_ast::attr::AttributeExt;
|
||||||
|
use rustc_middle::bug;
|
||||||
|
use rustc_middle::query::Providers;
|
||||||
use rustc_session::{Limit, Limits, Session};
|
use rustc_session::{Limit, Limits, Session};
|
||||||
use rustc_span::{Symbol, sym};
|
use rustc_span::{Symbol, sym};
|
||||||
|
|
||||||
use crate::error::LimitInvalid;
|
use crate::errors::LimitInvalid;
|
||||||
use crate::query::Providers;
|
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub(crate) fn provide(providers: &mut Providers) {
|
||||||
providers.limits = |tcx, ()| Limits {
|
providers.limits = |tcx, ()| Limits {
|
||||||
recursion_limit: get_recursion_limit(tcx.hir().krate_attrs(), tcx.sess),
|
recursion_limit: get_recursion_limit(tcx.hir().krate_attrs(), tcx.sess),
|
||||||
move_size_limit: get_limit(
|
move_size_limit: get_limit(
|
||||||
|
@ -42,7 +43,7 @@ pub fn provide(providers: &mut Providers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This one is separate because it must be read prior to macro expansion.
|
// This one is separate because it must be read prior to macro expansion.
|
||||||
pub fn get_recursion_limit(krate_attrs: &[impl AttributeExt], sess: &Session) -> Limit {
|
pub(crate) fn get_recursion_limit(krate_attrs: &[impl AttributeExt], sess: &Session) -> Limit {
|
||||||
get_limit(krate_attrs, sess, sym::recursion_limit, Limit::new(128))
|
get_limit(krate_attrs, sess, sym::recursion_limit, Limit::new(128))
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ use rustc_trait_selection::traits;
|
||||||
use tracing::{info, instrument};
|
use tracing::{info, instrument};
|
||||||
|
|
||||||
use crate::interface::Compiler;
|
use crate::interface::Compiler;
|
||||||
use crate::{errors, proc_macro_decls, util};
|
use crate::{errors, limits, proc_macro_decls, util};
|
||||||
|
|
||||||
pub fn parse<'a>(sess: &'a Session) -> ast::Crate {
|
pub fn parse<'a>(sess: &'a Session) -> ast::Crate {
|
||||||
let krate = sess
|
let krate = sess
|
||||||
|
@ -687,6 +687,7 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
|
||||||
|tcx, _| tcx.arena.alloc_from_iter(tcx.resolutions(()).stripped_cfg_items.steal());
|
|tcx, _| tcx.arena.alloc_from_iter(tcx.resolutions(()).stripped_cfg_items.steal());
|
||||||
providers.resolutions = |tcx, ()| tcx.resolver_for_lowering_raw(()).1;
|
providers.resolutions = |tcx, ()| tcx.resolver_for_lowering_raw(()).1;
|
||||||
providers.early_lint_checks = early_lint_checks;
|
providers.early_lint_checks = early_lint_checks;
|
||||||
|
limits::provide(providers);
|
||||||
proc_macro_decls::provide(providers);
|
proc_macro_decls::provide(providers);
|
||||||
rustc_const_eval::provide(providers);
|
rustc_const_eval::provide(providers);
|
||||||
rustc_middle::hir::provide(providers);
|
rustc_middle::hir::provide(providers);
|
||||||
|
@ -1134,7 +1135,7 @@ fn get_recursion_limit(krate_attrs: &[ast::Attribute], sess: &Session) -> Limit
|
||||||
// because that would require expanding this while in the middle of expansion, which needs to
|
// because that would require expanding this while in the middle of expansion, which needs to
|
||||||
// know the limit before expanding.
|
// know the limit before expanding.
|
||||||
let _ = validate_and_find_value_str_builtin_attr(sym::recursion_limit, sess, krate_attrs);
|
let _ = validate_and_find_value_str_builtin_attr(sym::recursion_limit, sess, krate_attrs);
|
||||||
rustc_middle::middle::limits::get_recursion_limit(krate_attrs, sess)
|
crate::limits::get_recursion_limit(krate_attrs, sess)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validate *all* occurrences of the given "[value-str]" built-in attribute and return the first find.
|
/// Validate *all* occurrences of the given "[value-str]" built-in attribute and return the first find.
|
||||||
|
|
|
@ -81,10 +81,6 @@ middle_failed_writing_file =
|
||||||
middle_layout_references_error =
|
middle_layout_references_error =
|
||||||
the type has an unknown layout
|
the type has an unknown layout
|
||||||
|
|
||||||
middle_limit_invalid =
|
|
||||||
`limit` must be a non-negative integer
|
|
||||||
.label = {$error_str}
|
|
||||||
|
|
||||||
middle_opaque_hidden_type_mismatch =
|
middle_opaque_hidden_type_mismatch =
|
||||||
concrete type differs from previous defining opaque type use
|
concrete type differs from previous defining opaque type use
|
||||||
.label = expected `{$self_ty}`, got `{$other_ty}`
|
.label = expected `{$self_ty}`, got `{$other_ty}`
|
||||||
|
|
|
@ -67,16 +67,6 @@ pub enum TypeMismatchReason {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
|
||||||
#[diag(middle_limit_invalid)]
|
|
||||||
pub(crate) struct LimitInvalid<'a> {
|
|
||||||
#[primary_span]
|
|
||||||
pub span: Span,
|
|
||||||
#[label]
|
|
||||||
pub value_span: Span,
|
|
||||||
pub error_str: &'a str,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(middle_recursion_limit_reached)]
|
#[diag(middle_recursion_limit_reached)]
|
||||||
#[help]
|
#[help]
|
||||||
|
|
|
@ -30,12 +30,7 @@ pub mod lib_features {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub mod limits;
|
|
||||||
pub mod privacy;
|
pub mod privacy;
|
||||||
pub mod region;
|
pub mod region;
|
||||||
pub mod resolve_bound_vars;
|
pub mod resolve_bound_vars;
|
||||||
pub mod stability;
|
pub mod stability;
|
||||||
|
|
||||||
pub fn provide(providers: &mut crate::query::Providers) {
|
|
||||||
limits::provide(providers);
|
|
||||||
}
|
|
||||||
|
|
|
@ -2168,7 +2168,6 @@ pub fn provide(providers: &mut Providers) {
|
||||||
util::provide(providers);
|
util::provide(providers);
|
||||||
print::provide(providers);
|
print::provide(providers);
|
||||||
super::util::bug::provide(providers);
|
super::util::bug::provide(providers);
|
||||||
super::middle::provide(providers);
|
|
||||||
*providers = Providers {
|
*providers = Providers {
|
||||||
trait_impls_of: trait_def::trait_impls_of_provider,
|
trait_impls_of: trait_def::trait_impls_of_provider,
|
||||||
incoherent_impls: trait_def::incoherent_impls_provider,
|
incoherent_impls: trait_def::incoherent_impls_provider,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue