Rollup merge of #110397 - Nilstrieb:speedy-bootstrap-2, r=fee1-dead,jyn514
Move some utils out of `rustc_const_eval` This allows us to get rid of the `rustc_const_eval->rustc_borrowck` dependency edge which was delaying the compilation of borrowck. The added utils in `rustc_middle` are small and should not affect compile times there.
This commit is contained in:
commit
508d661105
@ -4421,7 +4421,6 @@ dependencies = [
|
|||||||
"either",
|
"either",
|
||||||
"itertools",
|
"itertools",
|
||||||
"polonius-engine",
|
"polonius-engine",
|
||||||
"rustc_const_eval",
|
|
||||||
"rustc_data_structures",
|
"rustc_data_structures",
|
||||||
"rustc_errors",
|
"rustc_errors",
|
||||||
"rustc_graphviz",
|
"rustc_graphviz",
|
||||||
|
@ -20,7 +20,6 @@ rustc_infer = { path = "../rustc_infer" }
|
|||||||
rustc_lexer = { path = "../rustc_lexer" }
|
rustc_lexer = { path = "../rustc_lexer" }
|
||||||
rustc_macros = { path = "../rustc_macros" }
|
rustc_macros = { path = "../rustc_macros" }
|
||||||
rustc_middle = { path = "../rustc_middle" }
|
rustc_middle = { path = "../rustc_middle" }
|
||||||
rustc_const_eval = { path = "../rustc_const_eval" }
|
|
||||||
rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
|
rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
|
||||||
rustc_serialize = { path = "../rustc_serialize" }
|
rustc_serialize = { path = "../rustc_serialize" }
|
||||||
rustc_session = { path = "../rustc_session" }
|
rustc_session = { path = "../rustc_session" }
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use either::Either;
|
use either::Either;
|
||||||
use rustc_const_eval::util::CallKind;
|
|
||||||
use rustc_data_structures::captures::Captures;
|
use rustc_data_structures::captures::Captures;
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
@ -18,6 +17,7 @@ use rustc_middle::mir::{
|
|||||||
ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind, VarBindingForm,
|
ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind, VarBindingForm,
|
||||||
};
|
};
|
||||||
use rustc_middle::ty::{self, suggest_constraining_type_params, PredicateKind, Ty};
|
use rustc_middle::ty::{self, suggest_constraining_type_params, PredicateKind, Ty};
|
||||||
|
use rustc_middle::util::CallKind;
|
||||||
use rustc_mir_dataflow::move_paths::{InitKind, MoveOutIndex, MovePathIndex};
|
use rustc_mir_dataflow::move_paths::{InitKind, MoveOutIndex, MovePathIndex};
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::hygiene::DesugaringKind;
|
use rustc_span::hygiene::DesugaringKind;
|
||||||
@ -2424,7 +2424,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
Some((method_did, method_substs)),
|
Some((method_did, method_substs)),
|
||||||
) = (
|
) = (
|
||||||
&self.body[loan.reserve_location.block].terminator,
|
&self.body[loan.reserve_location.block].terminator,
|
||||||
rustc_const_eval::util::find_self_call(
|
rustc_middle::util::find_self_call(
|
||||||
tcx,
|
tcx,
|
||||||
self.body,
|
self.body,
|
||||||
loan.assigned_place.local,
|
loan.assigned_place.local,
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
//! Borrow checker diagnostics.
|
//! Borrow checker diagnostics.
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use rustc_const_eval::util::{call_kind, CallDesugaringKind};
|
|
||||||
use rustc_errors::{Applicability, Diagnostic};
|
use rustc_errors::{Applicability, Diagnostic};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{CtorKind, Namespace};
|
use rustc_hir::def::{CtorKind, Namespace};
|
||||||
@ -15,6 +14,7 @@ use rustc_middle::mir::{
|
|||||||
};
|
};
|
||||||
use rustc_middle::ty::print::Print;
|
use rustc_middle::ty::print::Print;
|
||||||
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
|
||||||
|
use rustc_middle::util::{call_kind, CallDesugaringKind};
|
||||||
use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult};
|
use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult};
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::{symbol::sym, Span, Symbol, DUMMY_SP};
|
use rustc_span::{symbol::sym, Span, Symbol, DUMMY_SP};
|
||||||
@ -45,7 +45,7 @@ pub(crate) use mutability_errors::AccessKind;
|
|||||||
pub(crate) use outlives_suggestion::OutlivesSuggestionBuilder;
|
pub(crate) use outlives_suggestion::OutlivesSuggestionBuilder;
|
||||||
pub(crate) use region_errors::{ErrorConstraintInfo, RegionErrorKind, RegionErrors};
|
pub(crate) use region_errors::{ErrorConstraintInfo, RegionErrorKind, RegionErrors};
|
||||||
pub(crate) use region_name::{RegionName, RegionNameSource};
|
pub(crate) use region_name::{RegionName, RegionNameSource};
|
||||||
pub(crate) use rustc_const_eval::util::CallKind;
|
pub(crate) use rustc_middle::util::CallKind;
|
||||||
|
|
||||||
pub(super) struct DescribePlaceOpt {
|
pub(super) struct DescribePlaceOpt {
|
||||||
pub including_downcast: bool,
|
pub including_downcast: bool,
|
||||||
@ -874,7 +874,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
}) = &self.body[location.block].terminator
|
}) = &self.body[location.block].terminator
|
||||||
{
|
{
|
||||||
let Some((method_did, method_substs)) =
|
let Some((method_did, method_substs)) =
|
||||||
rustc_const_eval::util::find_self_call(
|
rustc_middle::util::find_self_call(
|
||||||
self.infcx.tcx,
|
self.infcx.tcx,
|
||||||
&self.body,
|
&self.body,
|
||||||
target_temp,
|
target_temp,
|
||||||
|
@ -15,8 +15,8 @@ use rustc_span::{sym, BytePos, Span};
|
|||||||
use rustc_target::abi::FieldIdx;
|
use rustc_target::abi::FieldIdx;
|
||||||
|
|
||||||
use crate::diagnostics::BorrowedContentSource;
|
use crate::diagnostics::BorrowedContentSource;
|
||||||
|
use crate::util::FindAssignments;
|
||||||
use crate::MirBorrowckCtxt;
|
use crate::MirBorrowckCtxt;
|
||||||
use rustc_const_eval::util::collect_writes::FindAssignments;
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||||
pub(crate) enum AccessKind {
|
pub(crate) enum AccessKind {
|
||||||
|
@ -88,6 +88,7 @@ mod session_diagnostics;
|
|||||||
mod type_check;
|
mod type_check;
|
||||||
mod universal_regions;
|
mod universal_regions;
|
||||||
mod used_muts;
|
mod used_muts;
|
||||||
|
mod util;
|
||||||
|
|
||||||
/// A public API provided for the Rust compiler consumers.
|
/// A public API provided for the Rust compiler consumers.
|
||||||
pub mod consumers;
|
pub mod consumers;
|
||||||
|
3
compiler/rustc_borrowck/src/util/mod.rs
Normal file
3
compiler/rustc_borrowck/src/util/mod.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
mod collect_writes;
|
||||||
|
|
||||||
|
pub use collect_writes::FindAssignments;
|
@ -14,6 +14,7 @@ use rustc_middle::ty::print::with_no_trimmed_paths;
|
|||||||
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
|
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
|
||||||
use rustc_middle::ty::{suggest_constraining_type_param, Adt, Closure, FnDef, FnPtr, Param, Ty};
|
use rustc_middle::ty::{suggest_constraining_type_param, Adt, Closure, FnDef, FnPtr, Param, Ty};
|
||||||
use rustc_middle::ty::{Binder, TraitRef};
|
use rustc_middle::ty::{Binder, TraitRef};
|
||||||
|
use rustc_middle::util::{call_kind, CallDesugaringKind, CallKind};
|
||||||
use rustc_session::parse::feature_err;
|
use rustc_session::parse::feature_err;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
use rustc_span::{BytePos, Pos, Span, Symbol};
|
use rustc_span::{BytePos, Pos, Span, Symbol};
|
||||||
@ -21,7 +22,6 @@ use rustc_trait_selection::traits::SelectionContext;
|
|||||||
|
|
||||||
use super::ConstCx;
|
use super::ConstCx;
|
||||||
use crate::errors;
|
use crate::errors;
|
||||||
use crate::util::{call_kind, CallDesugaringKind, CallKind};
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
pub enum Status {
|
pub enum Status {
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
mod alignment;
|
mod alignment;
|
||||||
mod call_kind;
|
|
||||||
mod check_validity_requirement;
|
mod check_validity_requirement;
|
||||||
pub mod collect_writes;
|
|
||||||
mod compare_types;
|
mod compare_types;
|
||||||
mod find_self_call;
|
|
||||||
mod type_name;
|
mod type_name;
|
||||||
|
|
||||||
pub use self::alignment::is_disaligned;
|
pub use self::alignment::is_disaligned;
|
||||||
pub use self::call_kind::{call_kind, CallDesugaringKind, CallKind};
|
|
||||||
pub use self::check_validity_requirement::check_validity_requirement;
|
pub use self::check_validity_requirement::check_validity_requirement;
|
||||||
pub use self::compare_types::{is_equal_up_to_subtyping, is_subtype};
|
pub use self::compare_types::{is_equal_up_to_subtyping, is_subtype};
|
||||||
pub use self::find_self_call::find_self_call;
|
|
||||||
pub use self::type_name::type_name;
|
pub use self::type_name::type_name;
|
||||||
|
@ -99,13 +99,9 @@ pub mod mir;
|
|||||||
pub mod thir;
|
pub mod thir;
|
||||||
pub mod traits;
|
pub mod traits;
|
||||||
pub mod ty;
|
pub mod ty;
|
||||||
|
pub mod util;
|
||||||
mod values;
|
mod values;
|
||||||
|
|
||||||
pub mod util {
|
|
||||||
pub mod bug;
|
|
||||||
pub mod common;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allows macros to refer to this crate as `::rustc_middle`
|
// Allows macros to refer to this crate as `::rustc_middle`
|
||||||
extern crate self as rustc_middle;
|
extern crate self as rustc_middle;
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
//! as well as errors when attempting to call a non-const function in a const
|
//! as well as errors when attempting to call a non-const function in a const
|
||||||
//! context.
|
//! context.
|
||||||
|
|
||||||
|
use crate::ty::subst::SubstsRef;
|
||||||
|
use crate::ty::{AssocItemContainer, Instance, ParamEnv, Ty, TyCtxt};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_hir::{lang_items, LangItem};
|
use rustc_hir::{lang_items, LangItem};
|
||||||
use rustc_middle::ty::subst::SubstsRef;
|
|
||||||
use rustc_middle::ty::{AssocItemContainer, Instance, ParamEnv, Ty, TyCtxt};
|
|
||||||
use rustc_span::symbol::Ident;
|
use rustc_span::symbol::Ident;
|
||||||
use rustc_span::{sym, DesugaringKind, Span};
|
use rustc_span::{sym, DesugaringKind, Span};
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
use rustc_middle::mir::*;
|
use crate::mir::*;
|
||||||
use rustc_middle::ty::subst::SubstsRef;
|
use crate::ty::subst::SubstsRef;
|
||||||
use rustc_middle::ty::{self, TyCtxt};
|
use crate::ty::{self, TyCtxt};
|
||||||
use rustc_span::def_id::DefId;
|
use rustc_span::def_id::DefId;
|
||||||
|
|
||||||
/// Checks if the specified `local` is used as the `self` parameter of a method call
|
/// Checks if the specified `local` is used as the `self` parameter of a method call
|
7
compiler/rustc_middle/src/util/mod.rs
Normal file
7
compiler/rustc_middle/src/util/mod.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
pub mod bug;
|
||||||
|
pub mod call_kind;
|
||||||
|
pub mod common;
|
||||||
|
pub mod find_self_call;
|
||||||
|
|
||||||
|
pub use call_kind::{call_kind, CallDesugaringKind, CallKind};
|
||||||
|
pub use find_self_call::find_self_call;
|
@ -134,7 +134,12 @@ impl<'tcx> Visitor<'tcx> for ConstMutationChecker<'_, 'tcx> {
|
|||||||
// the `self` parameter of a method call (as the terminator of our current
|
// the `self` parameter of a method call (as the terminator of our current
|
||||||
// BasicBlock). If so, we emit a more specific lint.
|
// BasicBlock). If so, we emit a more specific lint.
|
||||||
let method_did = self.target_local.and_then(|target_local| {
|
let method_did = self.target_local.and_then(|target_local| {
|
||||||
crate::util::find_self_call(self.tcx, &self.body, target_local, loc.block)
|
rustc_middle::util::find_self_call(
|
||||||
|
self.tcx,
|
||||||
|
&self.body,
|
||||||
|
target_local,
|
||||||
|
loc.block,
|
||||||
|
)
|
||||||
});
|
});
|
||||||
let lint_loc =
|
let lint_loc =
|
||||||
if method_did.is_some() { self.body.terminator_loc(loc.block) } else { loc };
|
if method_did.is_some() { self.body.terminator_loc(loc.block) } else { loc };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user