Run rustfmt --file-lines ...
for changes from previous commits.
This commit is contained in:
parent
21ac960334
commit
fff08cb043
176 changed files with 2212 additions and 2132 deletions
|
@ -30,8 +30,7 @@ struct LoopScope {
|
||||||
break_index: CFGIndex, // where to go on a `break`
|
break_index: CFGIndex, // where to go on a `break`
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn construct<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
pub fn construct<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, body: &hir::Body) -> CFG {
|
||||||
body: &hir::Body) -> CFG {
|
|
||||||
let mut graph = graph::Graph::new();
|
let mut graph = graph::Graph::new();
|
||||||
let entry = graph.add_node(CFGNodeData::Entry);
|
let entry = graph.add_node(CFGNodeData::Entry);
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,7 @@ pub type CFGNode = graph::Node<CFGNodeData>;
|
||||||
pub type CFGEdge = graph::Edge<CFGEdgeData>;
|
pub type CFGEdge = graph::Edge<CFGEdgeData>;
|
||||||
|
|
||||||
impl CFG {
|
impl CFG {
|
||||||
pub fn new<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
pub fn new<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, body: &hir::Body) -> CFG {
|
||||||
body: &hir::Body) -> CFG {
|
|
||||||
construct::construct(tcx, body)
|
construct::construct(tcx, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -480,7 +480,8 @@ trait DepNodeParams<'gcx: 'tcx, 'tcx>: fmt::Debug {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'gcx: 'tcx, 'tcx, T> DepNodeParams<'gcx, 'tcx> for T
|
impl<'gcx: 'tcx, 'tcx, T> DepNodeParams<'gcx, 'tcx> for T
|
||||||
where T: HashStable<StableHashingContext<'tcx>> + fmt::Debug
|
where
|
||||||
|
T: HashStable<StableHashingContext<'tcx>> + fmt::Debug,
|
||||||
{
|
{
|
||||||
default const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
|
default const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,6 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DepGraph {
|
impl DepGraph {
|
||||||
|
|
||||||
pub fn new(prev_graph: PreviousDepGraph,
|
pub fn new(prev_graph: PreviousDepGraph,
|
||||||
prev_work_products: FxHashMap<WorkProductId, WorkProduct>) -> DepGraph {
|
prev_work_products: FxHashMap<WorkProductId, WorkProduct>) -> DepGraph {
|
||||||
let prev_graph_node_count = prev_graph.node_count();
|
let prev_graph_node_count = prev_graph.node_count();
|
||||||
|
@ -559,7 +558,7 @@ impl DepGraph {
|
||||||
pub fn try_mark_green_and_read(
|
pub fn try_mark_green_and_read(
|
||||||
&self,
|
&self,
|
||||||
tcx: TyCtxt<'_, '_>,
|
tcx: TyCtxt<'_, '_>,
|
||||||
dep_node: &DepNode
|
dep_node: &DepNode,
|
||||||
) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> {
|
) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> {
|
||||||
self.try_mark_green(tcx, dep_node).map(|(prev_index, dep_node_index)| {
|
self.try_mark_green(tcx, dep_node).map(|(prev_index, dep_node_index)| {
|
||||||
debug_assert!(self.is_green(&dep_node));
|
debug_assert!(self.is_green(&dep_node));
|
||||||
|
@ -571,7 +570,7 @@ impl DepGraph {
|
||||||
pub fn try_mark_green(
|
pub fn try_mark_green(
|
||||||
&self,
|
&self,
|
||||||
tcx: TyCtxt<'_, '_>,
|
tcx: TyCtxt<'_, '_>,
|
||||||
dep_node: &DepNode
|
dep_node: &DepNode,
|
||||||
) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> {
|
) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> {
|
||||||
debug_assert!(!dep_node.kind.is_eval_always());
|
debug_assert!(!dep_node.kind.is_eval_always());
|
||||||
|
|
||||||
|
@ -607,7 +606,7 @@ impl DepGraph {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
data: &DepGraphData,
|
data: &DepGraphData,
|
||||||
prev_dep_node_index: SerializedDepNodeIndex,
|
prev_dep_node_index: SerializedDepNodeIndex,
|
||||||
dep_node: &DepNode
|
dep_node: &DepNode,
|
||||||
) -> Option<DepNodeIndex> {
|
) -> Option<DepNodeIndex> {
|
||||||
debug!("try_mark_previous_green({:?}) - BEGIN", dep_node);
|
debug!("try_mark_previous_green({:?}) - BEGIN", dep_node);
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,7 @@ impl DepGraphSafe for DefId {
|
||||||
|
|
||||||
/// The type context itself can be used to access all kinds of tracked
|
/// The type context itself can be used to access all kinds of tracked
|
||||||
/// state, but those accesses should always generate read events.
|
/// state, but those accesses should always generate read events.
|
||||||
impl<'gcx, 'tcx> DepGraphSafe for TyCtxt<'gcx, 'tcx> {
|
impl<'gcx, 'tcx> DepGraphSafe for TyCtxt<'gcx, 'tcx> {}
|
||||||
}
|
|
||||||
|
|
||||||
/// Tuples make it easy to build up state.
|
/// Tuples make it easy to build up state.
|
||||||
impl<A, B> DepGraphSafe for (A, B)
|
impl<A, B> DepGraphSafe for (A, B)
|
||||||
|
|
|
@ -14,11 +14,7 @@ use crate::ty::{self, TyCtxt};
|
||||||
impl<'tcx, V> Canonical<'tcx, V> {
|
impl<'tcx, V> Canonical<'tcx, V> {
|
||||||
/// Instantiate the wrapped value, replacing each canonical value
|
/// Instantiate the wrapped value, replacing each canonical value
|
||||||
/// with the value given in `var_values`.
|
/// with the value given in `var_values`.
|
||||||
pub fn substitute(
|
pub fn substitute(&self, tcx: TyCtxt<'_, 'tcx>, var_values: &CanonicalVarValues<'tcx>) -> V
|
||||||
&self,
|
|
||||||
tcx: TyCtxt<'_, 'tcx>,
|
|
||||||
var_values: &CanonicalVarValues<'tcx>,
|
|
||||||
) -> V
|
|
||||||
where
|
where
|
||||||
V: TypeFoldable<'tcx>,
|
V: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,12 +58,14 @@ pub enum RelationDir {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
|
impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
|
||||||
pub fn super_combine_tys<R>(&self,
|
pub fn super_combine_tys<R>(
|
||||||
relation: &mut R,
|
&self,
|
||||||
a: Ty<'tcx>,
|
relation: &mut R,
|
||||||
b: Ty<'tcx>)
|
a: Ty<'tcx>,
|
||||||
-> RelateResult<'tcx, Ty<'tcx>>
|
b: Ty<'tcx>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>
|
) -> RelateResult<'tcx, Ty<'tcx>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
{
|
{
|
||||||
let a_is_expected = relation.a_is_expected();
|
let a_is_expected = relation.a_is_expected();
|
||||||
|
|
||||||
|
|
|
@ -338,7 +338,10 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'gcx, 'tcx, T> fmt::Display for Highlighted<'gcx, 'tcx, T>
|
impl<'gcx, 'tcx, T> fmt::Display for Highlighted<'gcx, 'tcx, T>
|
||||||
where T: for<'a, 'b, 'c> Print<'gcx, 'tcx,
|
where
|
||||||
|
T: for<'a, 'b, 'c> Print<
|
||||||
|
'gcx,
|
||||||
|
'tcx,
|
||||||
FmtPrinter<'a, 'gcx, 'tcx, &'b mut fmt::Formatter<'c>>,
|
FmtPrinter<'a, 'gcx, 'tcx, &'b mut fmt::Formatter<'c>>,
|
||||||
Error = fmt::Error,
|
Error = fmt::Error,
|
||||||
>,
|
>,
|
||||||
|
|
|
@ -27,7 +27,7 @@ use crate::ty::TyVar;
|
||||||
use crate::ty::{self, Ty};
|
use crate::ty::{self, Ty};
|
||||||
use crate::ty::relate::{RelateResult, TypeRelation};
|
use crate::ty::relate::{RelateResult, TypeRelation};
|
||||||
|
|
||||||
pub trait LatticeDir<'f, 'gcx: 'f+'tcx, 'tcx: 'f> : TypeRelation<'gcx, 'tcx> {
|
pub trait LatticeDir<'f, 'gcx: 'f + 'tcx, 'tcx: 'f>: TypeRelation<'gcx, 'tcx> {
|
||||||
fn infcx(&self) -> &'f InferCtxt<'f, 'gcx, 'tcx>;
|
fn infcx(&self) -> &'f InferCtxt<'f, 'gcx, 'tcx>;
|
||||||
|
|
||||||
fn cause(&self) -> &ObligationCause<'tcx>;
|
fn cause(&self) -> &ObligationCause<'tcx>;
|
||||||
|
|
|
@ -28,11 +28,12 @@ impl<'tcx> FreeRegionMap<'tcx> {
|
||||||
/// cases, this is more conservative than necessary, in order to
|
/// cases, this is more conservative than necessary, in order to
|
||||||
/// avoid making arbitrary choices. See
|
/// avoid making arbitrary choices. See
|
||||||
/// `TransitiveRelation::postdom_upper_bound` for more details.
|
/// `TransitiveRelation::postdom_upper_bound` for more details.
|
||||||
pub fn lub_free_regions<'gcx>(&self,
|
pub fn lub_free_regions<'gcx>(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
&self,
|
||||||
r_a: Region<'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
r_b: Region<'tcx>)
|
r_a: Region<'tcx>,
|
||||||
-> Region<'tcx> {
|
r_b: Region<'tcx>,
|
||||||
|
) -> Region<'tcx> {
|
||||||
debug!("lub_free_regions(r_a={:?}, r_b={:?})", r_a, r_b);
|
debug!("lub_free_regions(r_a={:?}, r_b={:?})", r_a, r_b);
|
||||||
assert!(is_free(r_a));
|
assert!(is_free(r_a));
|
||||||
assert!(is_free(r_b));
|
assert!(is_free(r_b));
|
||||||
|
|
|
@ -1423,10 +1423,7 @@ pub fn late_lint_mod<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
|
fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tcx, 'tcx>, pass: T) {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
|
||||||
pass: T
|
|
||||||
) {
|
|
||||||
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
|
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
|
||||||
|
|
||||||
let krate = tcx.hir().krate();
|
let krate = tcx.hir().krate();
|
||||||
|
@ -1461,7 +1458,7 @@ fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
|
||||||
|
|
||||||
fn late_lint_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
|
fn late_lint_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
builtin_lints: T
|
builtin_lints: T,
|
||||||
) {
|
) {
|
||||||
let mut passes = tcx.sess.lint_store.borrow().late_passes.lock().take().unwrap();
|
let mut passes = tcx.sess.lint_store.borrow().late_passes.lock().take().unwrap();
|
||||||
|
|
||||||
|
|
|
@ -766,9 +766,7 @@ pub fn maybe_lint_level_root(tcx: TyCtxt<'_, '_>, id: hir::HirId) -> bool {
|
||||||
attrs.iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some())
|
attrs.iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lint_levels<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum)
|
fn lint_levels<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum) -> &'tcx LintLevelMap {
|
||||||
-> &'tcx LintLevelMap
|
|
||||||
{
|
|
||||||
assert_eq!(cnum, LOCAL_CRATE);
|
assert_eq!(cnum, LOCAL_CRATE);
|
||||||
let mut builder = LintLevelMapBuilder {
|
let mut builder = LintLevelMapBuilder {
|
||||||
levels: LintLevelSets::builder(tcx.sess),
|
levels: LintLevelSets::builder(tcx.sess),
|
||||||
|
|
|
@ -211,9 +211,7 @@ pub trait CrateStore {
|
||||||
fn crates_untracked(&self) -> Vec<CrateNum>;
|
fn crates_untracked(&self) -> Vec<CrateNum>;
|
||||||
|
|
||||||
// utility functions
|
// utility functions
|
||||||
fn encode_metadata<'tcx>(&self,
|
fn encode_metadata<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> EncodedMetadata;
|
||||||
tcx: TyCtxt<'tcx, 'tcx>)
|
|
||||||
-> EncodedMetadata;
|
|
||||||
fn metadata_encoding_version(&self) -> &[u8];
|
fn metadata_encoding_version(&self) -> &[u8];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,9 +226,7 @@ pub type CrateStoreDyn = dyn CrateStore + sync::Sync;
|
||||||
// In order to get this left-to-right dependency ordering, we perform a
|
// In order to get this left-to-right dependency ordering, we perform a
|
||||||
// topological sort of all crates putting the leaves at the right-most
|
// topological sort of all crates putting the leaves at the right-most
|
||||||
// positions.
|
// positions.
|
||||||
pub fn used_crates(tcx: TyCtxt<'_, '_>, prefer: LinkagePreference)
|
pub fn used_crates(tcx: TyCtxt<'_, '_>, prefer: LinkagePreference) -> Vec<(CrateNum, LibSource)> {
|
||||||
-> Vec<(CrateNum, LibSource)>
|
|
||||||
{
|
|
||||||
let mut libs = tcx.crates()
|
let mut libs = tcx.crates()
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
|
|
|
@ -26,8 +26,7 @@ use syntax_pos;
|
||||||
// explored. For example, if it's a live Node::Item that is a
|
// explored. For example, if it's a live Node::Item that is a
|
||||||
// function, then we should explore its block to check for codes that
|
// function, then we should explore its block to check for codes that
|
||||||
// may need to be marked as live.
|
// may need to be marked as live.
|
||||||
fn should_explore<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn should_explore<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, hir_id: hir::HirId) -> bool {
|
||||||
hir_id: hir::HirId) -> bool {
|
|
||||||
match tcx.hir().find_by_hir_id(hir_id) {
|
match tcx.hir().find_by_hir_id(hir_id) {
|
||||||
Some(Node::Item(..)) |
|
Some(Node::Item(..)) |
|
||||||
Some(Node::ImplItem(..)) |
|
Some(Node::ImplItem(..)) |
|
||||||
|
@ -302,9 +301,11 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_>,
|
fn has_allow_dead_code_or_lang_attr(
|
||||||
id: hir::HirId,
|
tcx: TyCtxt<'_, '_>,
|
||||||
attrs: &[ast::Attribute]) -> bool {
|
id: hir::HirId,
|
||||||
|
attrs: &[ast::Attribute],
|
||||||
|
) -> bool {
|
||||||
if attr::contains_name(attrs, sym::lang) {
|
if attr::contains_name(attrs, sym::lang) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -451,10 +452,11 @@ fn create_and_seed_worklist<'tcx>(
|
||||||
(life_seeder.worklist, life_seeder.struct_constructors)
|
(life_seeder.worklist, life_seeder.struct_constructors)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_live<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn find_live<'tcx>(
|
||||||
access_levels: &privacy::AccessLevels,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
krate: &hir::Crate)
|
access_levels: &privacy::AccessLevels,
|
||||||
-> FxHashSet<hir::HirId> {
|
krate: &hir::Crate,
|
||||||
|
) -> FxHashSet<hir::HirId> {
|
||||||
let (worklist, struct_constructors) = create_and_seed_worklist(tcx, access_levels, krate);
|
let (worklist, struct_constructors) = create_and_seed_worklist(tcx, access_levels, krate);
|
||||||
let mut symbol_visitor = MarkSymbolVisitor {
|
let mut symbol_visitor = MarkSymbolVisitor {
|
||||||
worklist,
|
worklist,
|
||||||
|
|
|
@ -92,9 +92,7 @@ pub fn calculate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) {
|
||||||
sess.dependency_formats.set(fmts);
|
sess.dependency_formats.set(fmts);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn calculate_type<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn calculate_type<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: config::CrateType) -> DependencyList {
|
||||||
ty: config::CrateType) -> DependencyList {
|
|
||||||
|
|
||||||
let sess = &tcx.sess;
|
let sess = &tcx.sess;
|
||||||
|
|
||||||
if !sess.opts.output_types.should_codegen() {
|
if !sess.opts.output_types.should_codegen() {
|
||||||
|
@ -242,10 +240,12 @@ fn calculate_type<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_library(tcx: TyCtxt<'_, '_>,
|
fn add_library(
|
||||||
cnum: CrateNum,
|
tcx: TyCtxt<'_, '_>,
|
||||||
link: LinkagePreference,
|
cnum: CrateNum,
|
||||||
m: &mut FxHashMap<CrateNum, LinkagePreference>) {
|
link: LinkagePreference,
|
||||||
|
m: &mut FxHashMap<CrateNum, LinkagePreference>,
|
||||||
|
) {
|
||||||
match m.get(&cnum) {
|
match m.get(&cnum) {
|
||||||
Some(&link2) => {
|
Some(&link2) => {
|
||||||
// If the linkages differ, then we'd have two copies of the library
|
// If the linkages differ, then we'd have two copies of the library
|
||||||
|
|
|
@ -38,9 +38,7 @@ pub enum ExportedSymbol<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> ExportedSymbol<'tcx> {
|
impl<'tcx> ExportedSymbol<'tcx> {
|
||||||
pub fn symbol_name(&self,
|
pub fn symbol_name(&self, tcx: TyCtxt<'tcx, '_>) -> ty::SymbolName {
|
||||||
tcx: TyCtxt<'tcx, '_>)
|
|
||||||
-> ty::SymbolName {
|
|
||||||
match *self {
|
match *self {
|
||||||
ExportedSymbol::NonGeneric(def_id) => {
|
ExportedSymbol::NonGeneric(def_id) => {
|
||||||
tcx.symbol_name(ty::Instance::mono(tcx, def_id))
|
tcx.symbol_name(ty::Instance::mono(tcx, def_id))
|
||||||
|
@ -54,10 +52,11 @@ impl<'tcx> ExportedSymbol<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compare_stable(&self,
|
pub fn compare_stable(
|
||||||
tcx: TyCtxt<'tcx, '_>,
|
&self,
|
||||||
other: &ExportedSymbol<'tcx>)
|
tcx: TyCtxt<'tcx, '_>,
|
||||||
-> cmp::Ordering {
|
other: &ExportedSymbol<'tcx>,
|
||||||
|
) -> cmp::Ordering {
|
||||||
match *self {
|
match *self {
|
||||||
ExportedSymbol::NonGeneric(self_def_id) => match *other {
|
ExportedSymbol::NonGeneric(self_def_id) => match *other {
|
||||||
ExportedSymbol::NonGeneric(other_def_id) => {
|
ExportedSymbol::NonGeneric(other_def_id) => {
|
||||||
|
|
|
@ -266,15 +266,15 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx, 'tcx> {
|
||||||
/// `None` means that rvalues will be given more conservative lifetimes.
|
/// `None` means that rvalues will be given more conservative lifetimes.
|
||||||
///
|
///
|
||||||
/// See also `with_infer`, which is used *during* typeck.
|
/// See also `with_infer`, which is used *during* typeck.
|
||||||
pub fn new(delegate: &'a mut (dyn Delegate<'tcx>+'a),
|
pub fn new(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
delegate: &'a mut (dyn Delegate<'tcx> + 'a),
|
||||||
body_owner: DefId,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
body_owner: DefId,
|
||||||
region_scope_tree: &'a region::ScopeTree,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
tables: &'a ty::TypeckTables<'tcx>,
|
region_scope_tree: &'a region::ScopeTree,
|
||||||
rvalue_promotable_map: Option<&'tcx ItemLocalSet>)
|
tables: &'a ty::TypeckTables<'tcx>,
|
||||||
-> Self
|
rvalue_promotable_map: Option<&'tcx ItemLocalSet>,
|
||||||
{
|
) -> Self {
|
||||||
ExprUseVisitor {
|
ExprUseVisitor {
|
||||||
mc: mc::MemCategorizationContext::new(tcx,
|
mc: mc::MemCategorizationContext::new(tcx,
|
||||||
body_owner,
|
body_owner,
|
||||||
|
|
|
@ -25,7 +25,7 @@ pub fn provide(providers: &mut Providers<'_>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ItemVisitor<'tcx> {
|
struct ItemVisitor<'tcx> {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ExprVisitor<'tcx> {
|
struct ExprVisitor<'tcx> {
|
||||||
|
@ -36,9 +36,7 @@ struct ExprVisitor<'tcx> {
|
||||||
|
|
||||||
/// If the type is `Option<T>`, it will return `T`, otherwise
|
/// If the type is `Option<T>`, it will return `T`, otherwise
|
||||||
/// the type itself. Works on most `Option`-like types.
|
/// the type itself. Works on most `Option`-like types.
|
||||||
fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
ty: Ty<'tcx>)
|
|
||||||
-> Ty<'tcx> {
|
|
||||||
let (def, substs) = match ty.sty {
|
let (def, substs) = match ty.sty {
|
||||||
ty::Adt(def, substs) => (def, substs),
|
ty::Adt(def, substs) => (def, substs),
|
||||||
_ => return ty
|
_ => return ty
|
||||||
|
|
|
@ -352,12 +352,14 @@ impl IrMaps<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'tcx>,
|
fn visit_fn<'a, 'tcx: 'a>(
|
||||||
fk: FnKind<'tcx>,
|
ir: &mut IrMaps<'tcx>,
|
||||||
decl: &'tcx hir::FnDecl,
|
fk: FnKind<'tcx>,
|
||||||
body_id: hir::BodyId,
|
decl: &'tcx hir::FnDecl,
|
||||||
sp: Span,
|
body_id: hir::BodyId,
|
||||||
id: hir::HirId) {
|
sp: Span,
|
||||||
|
id: hir::HirId,
|
||||||
|
) {
|
||||||
debug!("visit_fn");
|
debug!("visit_fn");
|
||||||
|
|
||||||
// swap in a new set of IR maps for this function body:
|
// swap in a new set of IR maps for this function body:
|
||||||
|
|
|
@ -287,7 +287,7 @@ impl HirNode for hir::Pat {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MemCategorizationContext<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
pub struct MemCategorizationContext<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
|
||||||
pub tcx: TyCtxt<'gcx, 'tcx>,
|
pub tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
pub body_owner: DefId,
|
pub body_owner: DefId,
|
||||||
pub upvars: Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>>,
|
pub upvars: Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>>,
|
||||||
|
@ -339,8 +339,11 @@ impl MutabilityCategory {
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_local(tcx: TyCtxt<'_, '_>, tables: &ty::TypeckTables<'_>,
|
fn from_local(
|
||||||
id: ast::NodeId) -> MutabilityCategory {
|
tcx: TyCtxt<'_, '_>,
|
||||||
|
tables: &ty::TypeckTables<'_>,
|
||||||
|
id: ast::NodeId,
|
||||||
|
) -> MutabilityCategory {
|
||||||
let ret = match tcx.hir().get(id) {
|
let ret = match tcx.hir().get(id) {
|
||||||
Node::Binding(p) => match p.node {
|
Node::Binding(p) => match p.node {
|
||||||
PatKind::Binding(..) => {
|
PatKind::Binding(..) => {
|
||||||
|
@ -400,12 +403,13 @@ impl MutabilityCategory {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx, 'tcx> {
|
impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx, 'tcx> {
|
||||||
pub fn new(tcx: TyCtxt<'tcx, 'tcx>,
|
pub fn new(
|
||||||
body_owner: DefId,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
region_scope_tree: &'a region::ScopeTree,
|
body_owner: DefId,
|
||||||
tables: &'a ty::TypeckTables<'tcx>,
|
region_scope_tree: &'a region::ScopeTree,
|
||||||
rvalue_promotable_map: Option<&'tcx ItemLocalSet>)
|
tables: &'a ty::TypeckTables<'tcx>,
|
||||||
-> MemCategorizationContext<'a, 'tcx, 'tcx> {
|
rvalue_promotable_map: Option<&'tcx ItemLocalSet>,
|
||||||
|
) -> MemCategorizationContext<'a, 'tcx, 'tcx> {
|
||||||
MemCategorizationContext {
|
MemCategorizationContext {
|
||||||
tcx,
|
tcx,
|
||||||
body_owner,
|
body_owner,
|
||||||
|
|
|
@ -27,9 +27,7 @@ use crate::hir::intravisit;
|
||||||
// Returns true if the given item must be inlined because it may be
|
// Returns true if the given item must be inlined because it may be
|
||||||
// monomorphized or it was marked with `#[inline]`. This will only return
|
// monomorphized or it was marked with `#[inline]`. This will only return
|
||||||
// true for functions.
|
// true for functions.
|
||||||
fn item_might_be_inlined(tcx: TyCtxt<'tcx, 'tcx>,
|
fn item_might_be_inlined(tcx: TyCtxt<'tcx, 'tcx>, item: &hir::Item, attrs: CodegenFnAttrs) -> bool {
|
||||||
item: &hir::Item,
|
|
||||||
attrs: CodegenFnAttrs) -> bool {
|
|
||||||
if attrs.requests_inline() {
|
if attrs.requests_inline() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -44,9 +42,11 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn method_might_be_inlined<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn method_might_be_inlined<'tcx>(
|
||||||
impl_item: &hir::ImplItem,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
impl_src: DefId) -> bool {
|
impl_item: &hir::ImplItem,
|
||||||
|
impl_src: DefId,
|
||||||
|
) -> bool {
|
||||||
let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id.owner_def_id());
|
let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id.owner_def_id());
|
||||||
let generics = tcx.generics_of(tcx.hir().local_def_id_from_hir_id(impl_item.hir_id));
|
let generics = tcx.generics_of(tcx.hir().local_def_id_from_hir_id(impl_item.hir_id));
|
||||||
if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {
|
if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {
|
||||||
|
|
|
@ -646,9 +646,11 @@ impl<'tcx> ScopeTree {
|
||||||
|
|
||||||
/// Assuming that the provided region was defined within this `ScopeTree`,
|
/// Assuming that the provided region was defined within this `ScopeTree`,
|
||||||
/// returns the outermost `Scope` that the region outlives.
|
/// returns the outermost `Scope` that the region outlives.
|
||||||
pub fn early_free_scope<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn early_free_scope<'gcx>(
|
||||||
br: &ty::EarlyBoundRegion)
|
&self,
|
||||||
-> Scope {
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
|
br: &ty::EarlyBoundRegion,
|
||||||
|
) -> Scope {
|
||||||
let param_owner = tcx.parent(br.def_id).unwrap();
|
let param_owner = tcx.parent(br.def_id).unwrap();
|
||||||
|
|
||||||
let param_owner_id = tcx.hir().as_local_hir_id(param_owner).unwrap();
|
let param_owner_id = tcx.hir().as_local_hir_id(param_owner).unwrap();
|
||||||
|
@ -677,8 +679,7 @@ impl<'tcx> ScopeTree {
|
||||||
|
|
||||||
/// Assuming that the provided region was defined within this `ScopeTree`,
|
/// Assuming that the provided region was defined within this `ScopeTree`,
|
||||||
/// returns the outermost `Scope` that the region outlives.
|
/// returns the outermost `Scope` that the region outlives.
|
||||||
pub fn free_scope<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>, fr: &ty::FreeRegion)
|
pub fn free_scope<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>, fr: &ty::FreeRegion) -> Scope {
|
||||||
-> Scope {
|
|
||||||
let param_owner = match fr.bound_region {
|
let param_owner = match fr.bound_region {
|
||||||
ty::BoundRegion::BrNamed(def_id, _) => {
|
ty::BoundRegion::BrNamed(def_id, _) => {
|
||||||
tcx.parent(def_id).unwrap()
|
tcx.parent(def_id).unwrap()
|
||||||
|
@ -734,9 +735,11 @@ impl<'tcx> ScopeTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Records the lifetime of a local variable as `cx.var_parent`
|
/// Records the lifetime of a local variable as `cx.var_parent`
|
||||||
fn record_var_lifetime(visitor: &mut RegionResolutionVisitor<'_>,
|
fn record_var_lifetime(
|
||||||
var_id: hir::ItemLocalId,
|
visitor: &mut RegionResolutionVisitor<'_>,
|
||||||
_sp: Span) {
|
var_id: hir::ItemLocalId,
|
||||||
|
_sp: Span,
|
||||||
|
) {
|
||||||
match visitor.cx.var_parent {
|
match visitor.cx.var_parent {
|
||||||
None => {
|
None => {
|
||||||
// this can happen in extern fn declarations like
|
// this can happen in extern fn declarations like
|
||||||
|
@ -977,9 +980,11 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
|
||||||
visitor.cx = prev_cx;
|
visitor.cx = prev_cx;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_local<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>,
|
fn resolve_local<'tcx>(
|
||||||
pat: Option<&'tcx hir::Pat>,
|
visitor: &mut RegionResolutionVisitor<'tcx>,
|
||||||
init: Option<&'tcx hir::Expr>) {
|
pat: Option<&'tcx hir::Pat>,
|
||||||
|
init: Option<&'tcx hir::Expr>,
|
||||||
|
) {
|
||||||
debug!("resolve_local(pat={:?}, init={:?})", pat, init);
|
debug!("resolve_local(pat={:?}, init={:?})", pat, init);
|
||||||
|
|
||||||
let blk_scope = visitor.cx.var_parent.map(|(p, _)| p);
|
let blk_scope = visitor.cx.var_parent.map(|(p, _)| p);
|
||||||
|
@ -1130,8 +1135,8 @@ fn resolve_local<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>,
|
||||||
fn record_rvalue_scope_if_borrow_expr<'tcx>(
|
fn record_rvalue_scope_if_borrow_expr<'tcx>(
|
||||||
visitor: &mut RegionResolutionVisitor<'tcx>,
|
visitor: &mut RegionResolutionVisitor<'tcx>,
|
||||||
expr: &hir::Expr,
|
expr: &hir::Expr,
|
||||||
blk_id: Option<Scope>)
|
blk_id: Option<Scope>,
|
||||||
{
|
) {
|
||||||
match expr.node {
|
match expr.node {
|
||||||
hir::ExprKind::AddrOf(_, ref subexpr) => {
|
hir::ExprKind::AddrOf(_, ref subexpr) => {
|
||||||
record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id);
|
record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id);
|
||||||
|
@ -1178,9 +1183,11 @@ fn resolve_local<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>,
|
||||||
/// | <rvalue>
|
/// | <rvalue>
|
||||||
///
|
///
|
||||||
/// Note: ET is intended to match "rvalues or places based on rvalues".
|
/// Note: ET is intended to match "rvalues or places based on rvalues".
|
||||||
fn record_rvalue_scope<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>,
|
fn record_rvalue_scope<'tcx>(
|
||||||
expr: &hir::Expr,
|
visitor: &mut RegionResolutionVisitor<'tcx>,
|
||||||
blk_scope: Option<Scope>) {
|
expr: &hir::Expr,
|
||||||
|
blk_scope: Option<Scope>,
|
||||||
|
) {
|
||||||
let mut expr = expr;
|
let mut expr = expr;
|
||||||
loop {
|
loop {
|
||||||
// Note: give all the expressions matching `ET` with the
|
// Note: give all the expressions matching `ET` with the
|
||||||
|
@ -1327,9 +1334,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn region_scope_tree<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId)
|
fn region_scope_tree<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx ScopeTree {
|
||||||
-> &'tcx ScopeTree
|
|
||||||
{
|
|
||||||
let closure_base_def_id = tcx.closure_base_def_id(def_id);
|
let closure_base_def_id = tcx.closure_base_def_id(def_id);
|
||||||
if closure_base_def_id != def_id {
|
if closure_base_def_id != def_id {
|
||||||
return tcx.region_scope_tree(closure_base_def_id);
|
return tcx.region_scope_tree(closure_base_def_id);
|
||||||
|
|
|
@ -368,10 +368,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
|
||||||
/// entire crate. You should not read the result of this query
|
/// entire crate. You should not read the result of this query
|
||||||
/// directly, but rather use `named_region_map`, `is_late_bound_map`,
|
/// directly, but rather use `named_region_map`, `is_late_bound_map`,
|
||||||
/// etc.
|
/// etc.
|
||||||
fn resolve_lifetimes<'tcx>(
|
fn resolve_lifetimes<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, for_krate: CrateNum) -> &'tcx ResolveLifetimes {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
|
||||||
for_krate: CrateNum,
|
|
||||||
) -> &'tcx ResolveLifetimes {
|
|
||||||
assert_eq!(for_krate, LOCAL_CRATE);
|
assert_eq!(for_krate, LOCAL_CRATE);
|
||||||
|
|
||||||
let named_region_map = krate(tcx);
|
let named_region_map = krate(tcx);
|
||||||
|
@ -1256,9 +1253,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compute_object_lifetime_defaults(
|
fn compute_object_lifetime_defaults(tcx: TyCtxt<'_, '_>) -> HirIdMap<Vec<ObjectLifetimeDefault>> {
|
||||||
tcx: TyCtxt<'_, '_>,
|
|
||||||
) -> HirIdMap<Vec<ObjectLifetimeDefault>> {
|
|
||||||
let mut map = HirIdMap::default();
|
let mut map = HirIdMap::default();
|
||||||
for item in tcx.hir().krate().items.values() {
|
for item in tcx.hir().krate().items.values() {
|
||||||
match item.node {
|
match item.node {
|
||||||
|
|
|
@ -452,7 +452,7 @@ impl<'tcx> Index<'tcx> {
|
||||||
AnnotationKind::Required,
|
AnnotationKind::Required,
|
||||||
|v| intravisit::walk_crate(v, krate));
|
|v| intravisit::walk_crate(v, krate));
|
||||||
}
|
}
|
||||||
return index
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn local_stability(&self, id: HirId) -> Option<&'tcx Stability> {
|
pub fn local_stability(&self, id: HirId) -> Option<&'tcx Stability> {
|
||||||
|
@ -924,7 +924,7 @@ fn unnecessary_stable_feature_lint<'tcx>(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
feature: Symbol,
|
feature: Symbol,
|
||||||
since: Symbol
|
since: Symbol,
|
||||||
) {
|
) {
|
||||||
tcx.lint_hir(lint::builtin::STABLE_FEATURES,
|
tcx.lint_hir(lint::builtin::STABLE_FEATURES,
|
||||||
hir::CRATE_HIR_ID,
|
hir::CRATE_HIR_ID,
|
||||||
|
|
|
@ -75,18 +75,15 @@ impl<'tcx> fmt::Display for FrameInfo<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'gcx, 'tcx> ConstEvalErr<'tcx> {
|
impl<'gcx, 'tcx> ConstEvalErr<'tcx> {
|
||||||
pub fn struct_error(&self,
|
pub fn struct_error(
|
||||||
|
&self,
|
||||||
tcx: TyCtxtAt<'gcx, 'tcx>,
|
tcx: TyCtxtAt<'gcx, 'tcx>,
|
||||||
message: &str)
|
message: &str,
|
||||||
-> Result<DiagnosticBuilder<'tcx>, ErrorHandled>
|
) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
|
||||||
{
|
|
||||||
self.struct_generic(tcx, message, None)
|
self.struct_generic(tcx, message, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn report_as_error(&self,
|
pub fn report_as_error(&self, tcx: TyCtxtAt<'gcx, 'tcx>, message: &str) -> ErrorHandled {
|
||||||
tcx: TyCtxtAt<'gcx, 'tcx>,
|
|
||||||
message: &str
|
|
||||||
) -> ErrorHandled {
|
|
||||||
let err = self.struct_error(tcx, message);
|
let err = self.struct_error(tcx, message);
|
||||||
match err {
|
match err {
|
||||||
Ok(mut err) => {
|
Ok(mut err) => {
|
||||||
|
@ -97,7 +94,8 @@ impl<'gcx, 'tcx> ConstEvalErr<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn report_as_lint(&self,
|
pub fn report_as_lint(
|
||||||
|
&self,
|
||||||
tcx: TyCtxtAt<'gcx, 'tcx>,
|
tcx: TyCtxtAt<'gcx, 'tcx>,
|
||||||
message: &str,
|
message: &str,
|
||||||
lint_root: hir::HirId,
|
lint_root: hir::HirId,
|
||||||
|
@ -172,10 +170,7 @@ impl<'gcx, 'tcx> ConstEvalErr<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn struct_error<'gcx, 'tcx>(
|
pub fn struct_error<'gcx, 'tcx>(tcx: TyCtxtAt<'gcx, 'tcx>, msg: &str) -> DiagnosticBuilder<'tcx> {
|
||||||
tcx: TyCtxtAt<'gcx, 'tcx>,
|
|
||||||
msg: &str,
|
|
||||||
) -> DiagnosticBuilder<'tcx> {
|
|
||||||
struct_span_err!(tcx.sess, tcx.span, E0080, "{}", msg)
|
struct_span_err!(tcx.sess, tcx.span, E0080, "{}", msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,12 +142,10 @@ pub struct AllocDecodingSession<'s> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'s> AllocDecodingSession<'s> {
|
impl<'s> AllocDecodingSession<'s> {
|
||||||
|
|
||||||
// Decodes an AllocId in a thread-safe way.
|
// Decodes an AllocId in a thread-safe way.
|
||||||
pub fn decode_alloc_id<D>(&self,
|
pub fn decode_alloc_id<D>(&self, decoder: &mut D) -> Result<AllocId, D::Error>
|
||||||
decoder: &mut D)
|
where
|
||||||
-> Result<AllocId, D::Error>
|
D: TyDecoder<'tcx>,
|
||||||
where D: TyDecoder<'tcx>,
|
|
||||||
{
|
{
|
||||||
// Read the index of the allocation
|
// Read the index of the allocation
|
||||||
let idx = decoder.read_u32()? as usize;
|
let idx = decoder.read_u32()? as usize;
|
||||||
|
|
|
@ -3158,7 +3158,7 @@ pub enum ClosureOutlivesSubject<'tcx> {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TypeFoldable implementations for MIR types
|
* TypeFoldable implementations for MIR types
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CloneTypeFoldableAndLiftImpls! {
|
CloneTypeFoldableAndLiftImpls! {
|
||||||
BlockTailInfo,
|
BlockTailInfo,
|
||||||
|
|
|
@ -87,9 +87,7 @@ impl<'tcx> MonoItem<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn instantiation_mode(&self,
|
pub fn instantiation_mode(&self, tcx: TyCtxt<'tcx, 'tcx>) -> InstantiationMode {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>)
|
|
||||||
-> InstantiationMode {
|
|
||||||
let inline_in_all_cgus =
|
let inline_in_all_cgus =
|
||||||
tcx.sess.opts.debugging_opts.inline_in_all_cgus.unwrap_or_else(|| {
|
tcx.sess.opts.debugging_opts.inline_in_all_cgus.unwrap_or_else(|| {
|
||||||
tcx.sess.opts.optimize != OptLevel::No
|
tcx.sess.opts.optimize != OptLevel::No
|
||||||
|
@ -195,11 +193,12 @@ impl<'tcx> MonoItem<'tcx> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fn to_string_internal<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn to_string_internal<'tcx>(
|
||||||
prefix: &str,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
instance: Instance<'tcx>,
|
prefix: &str,
|
||||||
debug: bool)
|
instance: Instance<'tcx>,
|
||||||
-> String {
|
debug: bool,
|
||||||
|
) -> String {
|
||||||
let mut result = String::with_capacity(32);
|
let mut result = String::with_capacity(32);
|
||||||
result.push_str(prefix);
|
result.push_str(prefix);
|
||||||
let printer = DefPathBasedNames::new(tcx, false, false);
|
let printer = DefPathBasedNames::new(tcx, false, false);
|
||||||
|
@ -369,17 +368,16 @@ impl<'tcx> CodegenUnit<'tcx> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn items_in_deterministic_order(&self,
|
pub fn items_in_deterministic_order(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>)
|
&self,
|
||||||
-> Vec<(MonoItem<'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
(Linkage, Visibility))> {
|
) -> Vec<(MonoItem<'tcx>, (Linkage, Visibility))> {
|
||||||
// The codegen tests rely on items being process in the same order as
|
// The codegen tests rely on items being process in the same order as
|
||||||
// they appear in the file, so for local items, we sort by node_id first
|
// they appear in the file, so for local items, we sort by node_id first
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub struct ItemSortKey(Option<HirId>, SymbolName);
|
pub struct ItemSortKey(Option<HirId>, SymbolName);
|
||||||
|
|
||||||
fn item_sort_key<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn item_sort_key<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, item: MonoItem<'tcx>) -> ItemSortKey {
|
||||||
item: MonoItem<'tcx>) -> ItemSortKey {
|
|
||||||
ItemSortKey(match item {
|
ItemSortKey(match item {
|
||||||
MonoItem::Fn(ref instance) => {
|
MonoItem::Fn(ref instance) => {
|
||||||
match instance.def {
|
match instance.def {
|
||||||
|
|
|
@ -33,8 +33,7 @@ impl<'gcx, 'tcx> PlaceTy<'tcx> {
|
||||||
/// not carry a `Ty` for `T`.)
|
/// not carry a `Ty` for `T`.)
|
||||||
///
|
///
|
||||||
/// Note that the resulting type has not been normalized.
|
/// Note that the resulting type has not been normalized.
|
||||||
pub fn field_ty(self, tcx: TyCtxt<'gcx, 'tcx>, f: &Field) -> Ty<'tcx>
|
pub fn field_ty(self, tcx: TyCtxt<'gcx, 'tcx>, f: &Field) -> Ty<'tcx> {
|
||||||
{
|
|
||||||
let answer = match self.ty.sty {
|
let answer = match self.ty.sty {
|
||||||
ty::Adt(adt_def, substs) => {
|
ty::Adt(adt_def, substs) => {
|
||||||
let variant_def = match self.variant_index {
|
let variant_def = match self.variant_index {
|
||||||
|
@ -57,10 +56,7 @@ impl<'gcx, 'tcx> PlaceTy<'tcx> {
|
||||||
/// Convenience wrapper around `projection_ty_core` for
|
/// Convenience wrapper around `projection_ty_core` for
|
||||||
/// `PlaceElem`, where we can just use the `Ty` that is already
|
/// `PlaceElem`, where we can just use the `Ty` that is already
|
||||||
/// stored inline on field projection elems.
|
/// stored inline on field projection elems.
|
||||||
pub fn projection_ty(self, tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn projection_ty(self, tcx: TyCtxt<'gcx, 'tcx>, elem: &PlaceElem<'tcx>) -> PlaceTy<'tcx> {
|
||||||
elem: &PlaceElem<'tcx>)
|
|
||||||
-> PlaceTy<'tcx>
|
|
||||||
{
|
|
||||||
self.projection_ty_core(tcx, elem, |_, _, ty| ty)
|
self.projection_ty_core(tcx, elem, |_, _, ty| ty)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,10 +69,11 @@ impl<'gcx, 'tcx> PlaceTy<'tcx> {
|
||||||
self,
|
self,
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
elem: &ProjectionElem<V, T>,
|
elem: &ProjectionElem<V, T>,
|
||||||
mut handle_field: impl FnMut(&Self, &Field, &T) -> Ty<'tcx>)
|
mut handle_field: impl FnMut(&Self, &Field, &T) -> Ty<'tcx>,
|
||||||
-> PlaceTy<'tcx>
|
) -> PlaceTy<'tcx>
|
||||||
where
|
where
|
||||||
V: ::std::fmt::Debug, T: ::std::fmt::Debug
|
V: ::std::fmt::Debug,
|
||||||
|
T: ::std::fmt::Debug,
|
||||||
{
|
{
|
||||||
let answer = match *elem {
|
let answer = match *elem {
|
||||||
ProjectionElem::Deref => {
|
ProjectionElem::Deref => {
|
||||||
|
@ -122,7 +119,8 @@ BraceStructTypeFoldableImpl! {
|
||||||
|
|
||||||
impl<'tcx> Place<'tcx> {
|
impl<'tcx> Place<'tcx> {
|
||||||
pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> PlaceTy<'tcx>
|
pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> PlaceTy<'tcx>
|
||||||
where D: HasLocalDecls<'tcx>
|
where
|
||||||
|
D: HasLocalDecls<'tcx>,
|
||||||
{
|
{
|
||||||
match *self {
|
match *self {
|
||||||
Place::Base(PlaceBase::Local(index)) =>
|
Place::Base(PlaceBase::Local(index)) =>
|
||||||
|
@ -142,7 +140,8 @@ pub enum RvalueInitializationState {
|
||||||
|
|
||||||
impl<'tcx> Rvalue<'tcx> {
|
impl<'tcx> Rvalue<'tcx> {
|
||||||
pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx>
|
pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx>
|
||||||
where D: HasLocalDecls<'tcx>
|
where
|
||||||
|
D: HasLocalDecls<'tcx>,
|
||||||
{
|
{
|
||||||
match *self {
|
match *self {
|
||||||
Rvalue::Use(ref operand) => operand.ty(local_decls, tcx),
|
Rvalue::Use(ref operand) => operand.ty(local_decls, tcx),
|
||||||
|
@ -223,7 +222,8 @@ impl<'tcx> Rvalue<'tcx> {
|
||||||
|
|
||||||
impl<'tcx> Operand<'tcx> {
|
impl<'tcx> Operand<'tcx> {
|
||||||
pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx>
|
pub fn ty<'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx>
|
||||||
where D: HasLocalDecls<'tcx>
|
where
|
||||||
|
D: HasLocalDecls<'tcx>,
|
||||||
{
|
{
|
||||||
match self {
|
match self {
|
||||||
&Operand::Copy(ref l) |
|
&Operand::Copy(ref l) |
|
||||||
|
@ -234,10 +234,12 @@ impl<'tcx> Operand<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> BinOp {
|
impl<'tcx> BinOp {
|
||||||
pub fn ty<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn ty<'gcx>(
|
||||||
lhs_ty: Ty<'tcx>,
|
&self,
|
||||||
rhs_ty: Ty<'tcx>)
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
-> Ty<'tcx> {
|
lhs_ty: Ty<'tcx>,
|
||||||
|
rhs_ty: Ty<'tcx>,
|
||||||
|
) -> Ty<'tcx> {
|
||||||
// FIXME: handle SIMD correctly
|
// FIXME: handle SIMD correctly
|
||||||
match self {
|
match self {
|
||||||
&BinOp::Add | &BinOp::Sub | &BinOp::Mul | &BinOp::Div | &BinOp::Rem |
|
&BinOp::Add | &BinOp::Sub | &BinOp::Mul | &BinOp::Div | &BinOp::Rem |
|
||||||
|
|
|
@ -18,11 +18,10 @@ use crate::ty::fold::TypeFoldable;
|
||||||
/// that type check should guarantee to us that all nested
|
/// that type check should guarantee to us that all nested
|
||||||
/// obligations *could be* resolved if we wanted to.
|
/// obligations *could be* resolved if we wanted to.
|
||||||
/// Assumes that this is run after the entire crate has been successfully type-checked.
|
/// Assumes that this is run after the entire crate has been successfully type-checked.
|
||||||
pub fn codegen_fulfill_obligation<'tcx>(ty: TyCtxt<'tcx, 'tcx>,
|
pub fn codegen_fulfill_obligation<'tcx>(
|
||||||
(param_env, trait_ref):
|
ty: TyCtxt<'tcx, 'tcx>,
|
||||||
(ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>))
|
(param_env, trait_ref): (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>),
|
||||||
-> Vtable<'tcx, ()>
|
) -> Vtable<'tcx, ()> {
|
||||||
{
|
|
||||||
// Remove any references to regions; this helps improve caching.
|
// Remove any references to regions; this helps improve caching.
|
||||||
let trait_ref = ty.erase_regions(&trait_ref);
|
let trait_ref = ty.erase_regions(&trait_ref);
|
||||||
|
|
||||||
|
|
|
@ -183,10 +183,10 @@ fn overlap_within_probe(
|
||||||
Some(OverlapResult { impl_header, intercrate_ambiguity_causes, involves_placeholder })
|
Some(OverlapResult { impl_header, intercrate_ambiguity_causes, involves_placeholder })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn trait_ref_is_knowable<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn trait_ref_is_knowable<'gcx, 'tcx>(
|
||||||
trait_ref: ty::TraitRef<'tcx>)
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
-> Option<Conflict>
|
trait_ref: ty::TraitRef<'tcx>,
|
||||||
{
|
) -> Option<Conflict> {
|
||||||
debug!("trait_ref_is_knowable(trait_ref={:?})", trait_ref);
|
debug!("trait_ref_is_knowable(trait_ref={:?})", trait_ref);
|
||||||
if orphan_check_trait_ref(tcx, trait_ref, InCrate::Remote).is_ok() {
|
if orphan_check_trait_ref(tcx, trait_ref, InCrate::Remote).is_ok() {
|
||||||
// A downstream or cousin crate is allowed to implement some
|
// A downstream or cousin crate is allowed to implement some
|
||||||
|
@ -229,9 +229,10 @@ pub fn trait_ref_is_knowable<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn trait_ref_is_local_or_fundamental<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn trait_ref_is_local_or_fundamental<'gcx, 'tcx>(
|
||||||
trait_ref: ty::TraitRef<'tcx>)
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
-> bool {
|
trait_ref: ty::TraitRef<'tcx>,
|
||||||
|
) -> bool {
|
||||||
trait_ref.def_id.krate == LOCAL_CRATE || tcx.has_attr(trait_ref.def_id, sym::fundamental)
|
trait_ref.def_id.krate == LOCAL_CRATE || tcx.has_attr(trait_ref.def_id, sym::fundamental)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,10 +247,10 @@ pub enum OrphanCheckErr<'tcx> {
|
||||||
///
|
///
|
||||||
/// 1. All type parameters in `Self` must be "covered" by some local type constructor.
|
/// 1. All type parameters in `Self` must be "covered" by some local type constructor.
|
||||||
/// 2. Some local type must appear in `Self`.
|
/// 2. Some local type must appear in `Self`.
|
||||||
pub fn orphan_check<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn orphan_check<'gcx, 'tcx>(
|
||||||
impl_def_id: DefId)
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
-> Result<(), OrphanCheckErr<'tcx>>
|
impl_def_id: DefId,
|
||||||
{
|
) -> Result<(), OrphanCheckErr<'tcx>> {
|
||||||
debug!("orphan_check({:?})", impl_def_id);
|
debug!("orphan_check({:?})", impl_def_id);
|
||||||
|
|
||||||
// We only except this routine to be invoked on implementations
|
// We only except this routine to be invoked on implementations
|
||||||
|
@ -353,11 +354,11 @@ pub fn orphan_check<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
///
|
///
|
||||||
/// Note that this function is never called for types that have both type
|
/// Note that this function is never called for types that have both type
|
||||||
/// parameters and inference variables.
|
/// parameters and inference variables.
|
||||||
fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt<'_, '_>,
|
fn orphan_check_trait_ref<'tcx>(
|
||||||
trait_ref: ty::TraitRef<'tcx>,
|
tcx: TyCtxt<'_, '_>,
|
||||||
in_crate: InCrate)
|
trait_ref: ty::TraitRef<'tcx>,
|
||||||
-> Result<(), OrphanCheckErr<'tcx>>
|
in_crate: InCrate,
|
||||||
{
|
) -> Result<(), OrphanCheckErr<'tcx>> {
|
||||||
debug!("orphan_check_trait_ref(trait_ref={:?}, in_crate={:?})",
|
debug!("orphan_check_trait_ref(trait_ref={:?}, in_crate={:?})",
|
||||||
trait_ref, in_crate);
|
trait_ref, in_crate);
|
||||||
|
|
||||||
|
@ -430,8 +431,7 @@ fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt<'_, '_>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn uncovered_tys<'tcx>(tcx: TyCtxt<'_, '_>, ty: Ty<'tcx>, in_crate: InCrate)
|
fn uncovered_tys<'tcx>(tcx: TyCtxt<'_, '_>, ty: Ty<'tcx>, in_crate: InCrate) -> Vec<Ty<'tcx>> {
|
||||||
-> Vec<Ty<'tcx>> {
|
|
||||||
if ty_is_local_constructor(ty, in_crate) {
|
if ty_is_local_constructor(ty, in_crate) {
|
||||||
vec![]
|
vec![]
|
||||||
} else if fundamental_ty(ty) {
|
} else if fundamental_ty(ty) {
|
||||||
|
|
|
@ -1242,15 +1242,17 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
|
|
||||||
fn report_closure_arg_mismatch(&self,
|
fn report_closure_arg_mismatch(
|
||||||
span: Span,
|
&self,
|
||||||
found_span: Option<Span>,
|
span: Span,
|
||||||
expected_ref: ty::PolyTraitRef<'tcx>,
|
found_span: Option<Span>,
|
||||||
found: ty::PolyTraitRef<'tcx>)
|
expected_ref: ty::PolyTraitRef<'tcx>,
|
||||||
-> DiagnosticBuilder<'tcx>
|
found: ty::PolyTraitRef<'tcx>,
|
||||||
{
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
fn build_fn_sig_string<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
|
fn build_fn_sig_string<'gcx, 'tcx>(
|
||||||
trait_ref: &ty::TraitRef<'tcx>) -> String {
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
|
trait_ref: &ty::TraitRef<'tcx>,
|
||||||
|
) -> String {
|
||||||
let inputs = trait_ref.substs.type_at(1);
|
let inputs = trait_ref.substs.type_at(1);
|
||||||
let sig = if let ty::Tuple(inputs) = inputs.sty {
|
let sig = if let ty::Tuple(inputs) = inputs.sty {
|
||||||
tcx.mk_fn_sig(
|
tcx.mk_fn_sig(
|
||||||
|
@ -1447,10 +1449,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
/// Returns `true` if the trait predicate may apply for *some* assignment
|
/// Returns `true` if the trait predicate may apply for *some* assignment
|
||||||
/// to the type parameters.
|
/// to the type parameters.
|
||||||
fn predicate_can_apply(&self,
|
fn predicate_can_apply(
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
&self,
|
||||||
pred: ty::PolyTraitRef<'tcx>)
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
-> bool {
|
pred: ty::PolyTraitRef<'tcx>,
|
||||||
|
) -> bool {
|
||||||
struct ParamToVarFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
struct ParamToVarFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||||
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
|
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
|
||||||
var_map: FxHashMap<Ty<'tcx>, Ty<'tcx>>
|
var_map: FxHashMap<Ty<'tcx>, Ty<'tcx>>
|
||||||
|
|
|
@ -710,13 +710,13 @@ pub fn type_known_to_meet_bound_modulo_regions<'a, 'gcx, 'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_normalize_predicates<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn do_normalize_predicates<'tcx>(
|
||||||
region_context: DefId,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
cause: ObligationCause<'tcx>,
|
region_context: DefId,
|
||||||
elaborated_env: ty::ParamEnv<'tcx>,
|
cause: ObligationCause<'tcx>,
|
||||||
predicates: Vec<ty::Predicate<'tcx>>)
|
elaborated_env: ty::ParamEnv<'tcx>,
|
||||||
-> Result<Vec<ty::Predicate<'tcx>>, ErrorReported>
|
predicates: Vec<ty::Predicate<'tcx>>,
|
||||||
{
|
) -> Result<Vec<ty::Predicate<'tcx>>, ErrorReported> {
|
||||||
debug!(
|
debug!(
|
||||||
"do_normalize_predicates(predicates={:?}, region_context={:?}, cause={:?})",
|
"do_normalize_predicates(predicates={:?}, region_context={:?}, cause={:?})",
|
||||||
predicates,
|
predicates,
|
||||||
|
@ -795,12 +795,12 @@ fn do_normalize_predicates<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
|
|
||||||
// FIXME: this is gonna need to be removed ...
|
// FIXME: this is gonna need to be removed ...
|
||||||
/// Normalizes the parameter environment, reporting errors if they occur.
|
/// Normalizes the parameter environment, reporting errors if they occur.
|
||||||
pub fn normalize_param_env_or_error<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
pub fn normalize_param_env_or_error<'tcx>(
|
||||||
region_context: DefId,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
unnormalized_env: ty::ParamEnv<'tcx>,
|
region_context: DefId,
|
||||||
cause: ObligationCause<'tcx>)
|
unnormalized_env: ty::ParamEnv<'tcx>,
|
||||||
-> ty::ParamEnv<'tcx>
|
cause: ObligationCause<'tcx>,
|
||||||
{
|
) -> ty::ParamEnv<'tcx> {
|
||||||
// I'm not wild about reporting errors here; I'd prefer to
|
// I'm not wild about reporting errors here; I'd prefer to
|
||||||
// have the errors get reported at a defined place (e.g.,
|
// have the errors get reported at a defined place (e.g.,
|
||||||
// during typeck). Instead I have all parameter
|
// during typeck). Instead I have all parameter
|
||||||
|
@ -936,10 +936,10 @@ pub fn fully_normalize<'a, 'gcx, 'tcx, T>(
|
||||||
/// environment. If this returns false, then either normalize
|
/// environment. If this returns false, then either normalize
|
||||||
/// encountered an error or one of the predicates did not hold. Used
|
/// encountered an error or one of the predicates did not hold. Used
|
||||||
/// when creating vtables to check for unsatisfiable methods.
|
/// when creating vtables to check for unsatisfiable methods.
|
||||||
fn normalize_and_test_predicates<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn normalize_and_test_predicates<'tcx>(
|
||||||
predicates: Vec<ty::Predicate<'tcx>>)
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
-> bool
|
predicates: Vec<ty::Predicate<'tcx>>,
|
||||||
{
|
) -> bool {
|
||||||
debug!("normalize_and_test_predicates(predicates={:?})",
|
debug!("normalize_and_test_predicates(predicates={:?})",
|
||||||
predicates);
|
predicates);
|
||||||
|
|
||||||
|
@ -965,10 +965,10 @@ fn normalize_and_test_predicates<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn substitute_normalize_and_test_predicates<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn substitute_normalize_and_test_predicates<'tcx>(
|
||||||
key: (DefId, SubstsRef<'tcx>))
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
-> bool
|
key: (DefId, SubstsRef<'tcx>),
|
||||||
{
|
) -> bool {
|
||||||
debug!("substitute_normalize_and_test_predicates(key={:?})",
|
debug!("substitute_normalize_and_test_predicates(key={:?})",
|
||||||
key);
|
key);
|
||||||
|
|
||||||
|
@ -985,9 +985,8 @@ fn substitute_normalize_and_test_predicates<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
#[inline] // FIXME(#35870): avoid closures being unexported due to `impl Trait`.
|
#[inline] // FIXME(#35870): avoid closures being unexported due to `impl Trait`.
|
||||||
fn vtable_methods<'tcx>(
|
fn vtable_methods<'tcx>(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
trait_ref: ty::PolyTraitRef<'tcx>)
|
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||||
-> &'tcx [Option<(DefId, SubstsRef<'tcx>)>]
|
) -> &'tcx [Option<(DefId, SubstsRef<'tcx>)>] {
|
||||||
{
|
|
||||||
debug!("vtable_methods({:?})", trait_ref);
|
debug!("vtable_methods({:?})", trait_ref);
|
||||||
|
|
||||||
tcx.arena.alloc_from_iter(
|
tcx.arena.alloc_from_iter(
|
||||||
|
|
|
@ -84,7 +84,6 @@ pub enum MethodViolationCode {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TyCtxt<'tcx, 'tcx> {
|
impl<'tcx> TyCtxt<'tcx, 'tcx> {
|
||||||
|
|
||||||
/// Returns the object safety violations that affect
|
/// Returns the object safety violations that affect
|
||||||
/// astconv -- currently, `Self` in supertraits. This is needed
|
/// astconv -- currently, `Self` in supertraits. This is needed
|
||||||
/// because `object_safety_violations` can't be used during
|
/// because `object_safety_violations` can't be used during
|
||||||
|
@ -703,7 +702,6 @@ impl<'tcx> TyCtxt<'tcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn is_object_safe_provider<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
pub(super) fn is_object_safe_provider<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, trait_def_id: DefId) -> bool {
|
||||||
trait_def_id: DefId) -> bool {
|
|
||||||
tcx.object_safety_violations(trait_def_id).is_empty()
|
tcx.object_safety_violations(trait_def_id).is_empty()
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,12 +35,13 @@ impl OnUnimplementedNote {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_error(tcx: TyCtxt<'_, '_>, span: Span,
|
fn parse_error(
|
||||||
message: &str,
|
tcx: TyCtxt<'_, '_>,
|
||||||
label: &str,
|
span: Span,
|
||||||
note: Option<&str>)
|
message: &str,
|
||||||
-> ErrorReported
|
label: &str,
|
||||||
{
|
note: Option<&str>,
|
||||||
|
) -> ErrorReported {
|
||||||
let mut diag = struct_span_err!(
|
let mut diag = struct_span_err!(
|
||||||
tcx.sess, span, E0232, "{}", message);
|
tcx.sess, span, E0232, "{}", message);
|
||||||
diag.span_label(span, label);
|
diag.span_label(span, label);
|
||||||
|
@ -52,13 +53,13 @@ fn parse_error(tcx: TyCtxt<'_, '_>, span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'gcx, 'tcx> OnUnimplementedDirective {
|
impl<'gcx, 'tcx> OnUnimplementedDirective {
|
||||||
fn parse(tcx: TyCtxt<'gcx, 'tcx>,
|
fn parse(
|
||||||
trait_def_id: DefId,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
items: &[NestedMetaItem],
|
trait_def_id: DefId,
|
||||||
span: Span,
|
items: &[NestedMetaItem],
|
||||||
is_root: bool)
|
span: Span,
|
||||||
-> Result<Self, ErrorReported>
|
is_root: bool,
|
||||||
{
|
) -> Result<Self, ErrorReported> {
|
||||||
let mut errored = false;
|
let mut errored = false;
|
||||||
let mut item_iter = items.iter();
|
let mut item_iter = items.iter();
|
||||||
|
|
||||||
|
@ -132,12 +133,11 @@ impl<'gcx, 'tcx> OnUnimplementedDirective {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn of_item(
|
||||||
pub fn of_item(tcx: TyCtxt<'gcx, 'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
trait_def_id: DefId,
|
trait_def_id: DefId,
|
||||||
impl_def_id: DefId)
|
impl_def_id: DefId,
|
||||||
-> Result<Option<Self>, ErrorReported>
|
) -> Result<Option<Self>, ErrorReported> {
|
||||||
{
|
|
||||||
let attrs = tcx.get_attrs(impl_def_id);
|
let attrs = tcx.get_attrs(impl_def_id);
|
||||||
|
|
||||||
let attr = if let Some(item) = attr::find_by_name(&attrs, sym::rustc_on_unimplemented) {
|
let attr = if let Some(item) = attr::find_by_name(&attrs, sym::rustc_on_unimplemented) {
|
||||||
|
@ -164,12 +164,12 @@ impl<'gcx, 'tcx> OnUnimplementedDirective {
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn evaluate(&self,
|
pub fn evaluate(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
&self,
|
||||||
trait_ref: ty::TraitRef<'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
options: &[(Symbol, Option<String>)])
|
trait_ref: ty::TraitRef<'tcx>,
|
||||||
-> OnUnimplementedNote
|
options: &[(Symbol, Option<String>)],
|
||||||
{
|
) -> OnUnimplementedNote {
|
||||||
let mut message = None;
|
let mut message = None;
|
||||||
let mut label = None;
|
let mut label = None;
|
||||||
let mut note = None;
|
let mut note = None;
|
||||||
|
@ -215,12 +215,12 @@ impl<'gcx, 'tcx> OnUnimplementedDirective {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'gcx, 'tcx> OnUnimplementedFormatString {
|
impl<'gcx, 'tcx> OnUnimplementedFormatString {
|
||||||
fn try_parse(tcx: TyCtxt<'gcx, 'tcx>,
|
fn try_parse(
|
||||||
trait_def_id: DefId,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
from: LocalInternedString,
|
trait_def_id: DefId,
|
||||||
err_sp: Span)
|
from: LocalInternedString,
|
||||||
-> Result<Self, ErrorReported>
|
err_sp: Span,
|
||||||
{
|
) -> Result<Self, ErrorReported> {
|
||||||
let result = OnUnimplementedFormatString(from);
|
let result = OnUnimplementedFormatString(from);
|
||||||
result.verify(tcx, trait_def_id, err_sp)?;
|
result.verify(tcx, trait_def_id, err_sp)?;
|
||||||
Ok(result)
|
Ok(result)
|
||||||
|
|
|
@ -85,12 +85,7 @@ pub struct DropckOutlivesResult<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> DropckOutlivesResult<'tcx> {
|
impl<'tcx> DropckOutlivesResult<'tcx> {
|
||||||
pub fn report_overflows(
|
pub fn report_overflows(&self, tcx: TyCtxt<'_, 'tcx>, span: Span, ty: Ty<'tcx>) {
|
||||||
&self,
|
|
||||||
tcx: TyCtxt<'_, 'tcx>,
|
|
||||||
span: Span,
|
|
||||||
ty: Ty<'tcx>,
|
|
||||||
) {
|
|
||||||
if let Some(overflow_ty) = self.overflows.iter().next() {
|
if let Some(overflow_ty) = self.overflows.iter().next() {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_err!(
|
||||||
tcx.sess,
|
tcx.sess,
|
||||||
|
|
|
@ -149,10 +149,10 @@ pub fn find_associated_item<'tcx>(
|
||||||
/// Specialization is determined by the sets of types to which the impls apply;
|
/// Specialization is determined by the sets of types to which the impls apply;
|
||||||
/// `impl1` specializes `impl2` if it applies to a subset of the types `impl2` applies
|
/// `impl1` specializes `impl2` if it applies to a subset of the types `impl2` applies
|
||||||
/// to.
|
/// to.
|
||||||
pub(super) fn specializes<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
pub(super) fn specializes<'tcx>(
|
||||||
(impl1_def_id, impl2_def_id): (DefId, DefId))
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
-> bool
|
(impl1_def_id, impl2_def_id): (DefId, DefId),
|
||||||
{
|
) -> bool {
|
||||||
debug!("specializes({:?}, {:?})", impl1_def_id, impl2_def_id);
|
debug!("specializes({:?}, {:?})", impl1_def_id, impl2_def_id);
|
||||||
|
|
||||||
// The feature gate should prevent introducing new specializations, but not
|
// The feature gate should prevent introducing new specializations, but not
|
||||||
|
|
|
@ -83,9 +83,7 @@ enum Inserted {
|
||||||
|
|
||||||
impl<'gcx, 'tcx> Children {
|
impl<'gcx, 'tcx> Children {
|
||||||
/// Insert an impl into this set of children without comparing to any existing impls.
|
/// Insert an impl into this set of children without comparing to any existing impls.
|
||||||
fn insert_blindly(&mut self,
|
fn insert_blindly(&mut self, tcx: TyCtxt<'gcx, 'tcx>, impl_def_id: DefId) {
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
|
||||||
impl_def_id: DefId) {
|
|
||||||
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
|
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
|
||||||
if let Some(sty) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) {
|
if let Some(sty) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) {
|
||||||
debug!("insert_blindly: impl_def_id={:?} sty={:?}", impl_def_id, sty);
|
debug!("insert_blindly: impl_def_id={:?} sty={:?}", impl_def_id, sty);
|
||||||
|
@ -99,9 +97,7 @@ impl<'gcx, 'tcx> Children {
|
||||||
/// Removes an impl from this set of children. Used when replacing
|
/// Removes an impl from this set of children. Used when replacing
|
||||||
/// an impl with a parent. The impl must be present in the list of
|
/// an impl with a parent. The impl must be present in the list of
|
||||||
/// children already.
|
/// children already.
|
||||||
fn remove_existing(&mut self,
|
fn remove_existing(&mut self, tcx: TyCtxt<'gcx, 'tcx>, impl_def_id: DefId) {
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
|
||||||
impl_def_id: DefId) {
|
|
||||||
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
|
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
|
||||||
let vec: &mut Vec<DefId>;
|
let vec: &mut Vec<DefId>;
|
||||||
if let Some(sty) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) {
|
if let Some(sty) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) {
|
||||||
|
@ -118,12 +114,12 @@ impl<'gcx, 'tcx> Children {
|
||||||
|
|
||||||
/// Attempt to insert an impl into this set of children, while comparing for
|
/// Attempt to insert an impl into this set of children, while comparing for
|
||||||
/// specialization relationships.
|
/// specialization relationships.
|
||||||
fn insert(&mut self,
|
fn insert(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
&mut self,
|
||||||
impl_def_id: DefId,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
simplified_self: Option<SimplifiedType>)
|
impl_def_id: DefId,
|
||||||
-> Result<Inserted, OverlapError>
|
simplified_self: Option<SimplifiedType>,
|
||||||
{
|
) -> Result<Inserted, OverlapError> {
|
||||||
let mut last_lint = None;
|
let mut last_lint = None;
|
||||||
let mut replace_children = Vec::new();
|
let mut replace_children = Vec::new();
|
||||||
|
|
||||||
|
@ -293,10 +289,11 @@ impl<'gcx, 'tcx> Graph {
|
||||||
/// Insert a local impl into the specialization graph. If an existing impl
|
/// Insert a local impl into the specialization graph. If an existing impl
|
||||||
/// conflicts with it (has overlap, but neither specializes the other),
|
/// conflicts with it (has overlap, but neither specializes the other),
|
||||||
/// information about the area of overlap is returned in the `Err`.
|
/// information about the area of overlap is returned in the `Err`.
|
||||||
pub fn insert(&mut self,
|
pub fn insert(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
&mut self,
|
||||||
impl_def_id: DefId)
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
-> Result<Option<FutureCompatOverlapError>, OverlapError> {
|
impl_def_id: DefId,
|
||||||
|
) -> Result<Option<FutureCompatOverlapError>, OverlapError> {
|
||||||
assert!(impl_def_id.is_local());
|
assert!(impl_def_id.is_local());
|
||||||
|
|
||||||
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
|
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
|
||||||
|
@ -386,10 +383,12 @@ impl<'gcx, 'tcx> Graph {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Insert cached metadata mapping from a child impl back to its parent.
|
/// Insert cached metadata mapping from a child impl back to its parent.
|
||||||
pub fn record_impl_from_cstore(&mut self,
|
pub fn record_impl_from_cstore(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
&mut self,
|
||||||
parent: DefId,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
child: DefId) {
|
parent: DefId,
|
||||||
|
child: DefId,
|
||||||
|
) {
|
||||||
if self.parent.insert(child, parent).is_some() {
|
if self.parent.insert(child, parent).is_some() {
|
||||||
bug!("When recording an impl from the crate store, information about its parent \
|
bug!("When recording an impl from the crate store, information about its parent \
|
||||||
was already present.");
|
was already present.");
|
||||||
|
@ -423,10 +422,7 @@ impl<'gcx, 'tcx> Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterate over the items defined directly by the given (impl or trait) node.
|
/// Iterate over the items defined directly by the given (impl or trait) node.
|
||||||
pub fn items(
|
pub fn items(&self, tcx: TyCtxt<'gcx, 'tcx>) -> ty::AssocItemsIterator<'gcx, 'tcx> {
|
||||||
&self,
|
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
|
||||||
) -> ty::AssocItemsIterator<'gcx, 'tcx> {
|
|
||||||
tcx.associated_items(self.def_id())
|
tcx.associated_items(self.def_id())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,10 +504,11 @@ impl<'gcx, 'tcx> Ancestors<'gcx> {
|
||||||
|
|
||||||
/// Walk up the specialization ancestors of a given impl, starting with that
|
/// Walk up the specialization ancestors of a given impl, starting with that
|
||||||
/// impl itself.
|
/// impl itself.
|
||||||
pub fn ancestors(tcx: TyCtxt<'tcx, '_>,
|
pub fn ancestors(
|
||||||
trait_def_id: DefId,
|
tcx: TyCtxt<'tcx, '_>,
|
||||||
start_from_impl: DefId)
|
trait_def_id: DefId,
|
||||||
-> Ancestors<'tcx> {
|
start_from_impl: DefId,
|
||||||
|
) -> Ancestors<'tcx> {
|
||||||
let specialization_graph = tcx.specialization_graph_of(trait_def_id);
|
let specialization_graph = tcx.specialization_graph_of(trait_def_id);
|
||||||
Ancestors {
|
Ancestors {
|
||||||
trait_def_id,
|
trait_def_id,
|
||||||
|
|
|
@ -12,9 +12,10 @@ use crate::util::nodemap::FxHashSet;
|
||||||
|
|
||||||
use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext, Normalized};
|
use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext, Normalized};
|
||||||
|
|
||||||
fn anonymize_predicate<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
|
fn anonymize_predicate<'gcx, 'tcx>(
|
||||||
pred: &ty::Predicate<'tcx>)
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
-> ty::Predicate<'tcx> {
|
pred: &ty::Predicate<'tcx>,
|
||||||
|
) -> ty::Predicate<'tcx> {
|
||||||
match *pred {
|
match *pred {
|
||||||
ty::Predicate::Trait(ref data) =>
|
ty::Predicate::Trait(ref data) =>
|
||||||
ty::Predicate::Trait(tcx.anonymize_late_bound_regions(data)),
|
ty::Predicate::Trait(tcx.anonymize_late_bound_regions(data)),
|
||||||
|
@ -95,26 +96,23 @@ pub struct Elaborator<'gcx, 'tcx> {
|
||||||
|
|
||||||
pub fn elaborate_trait_ref<'gcx, 'tcx>(
|
pub fn elaborate_trait_ref<'gcx, 'tcx>(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
trait_ref: ty::PolyTraitRef<'tcx>)
|
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||||
-> Elaborator<'gcx, 'tcx>
|
) -> Elaborator<'gcx, 'tcx> {
|
||||||
{
|
|
||||||
elaborate_predicates(tcx, vec![trait_ref.to_predicate()])
|
elaborate_predicates(tcx, vec![trait_ref.to_predicate()])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn elaborate_trait_refs<'gcx, 'tcx>(
|
pub fn elaborate_trait_refs<'gcx, 'tcx>(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>)
|
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
|
||||||
-> Elaborator<'gcx, 'tcx>
|
) -> Elaborator<'gcx, 'tcx> {
|
||||||
{
|
|
||||||
let predicates = trait_refs.map(|trait_ref| trait_ref.to_predicate()).collect();
|
let predicates = trait_refs.map(|trait_ref| trait_ref.to_predicate()).collect();
|
||||||
elaborate_predicates(tcx, predicates)
|
elaborate_predicates(tcx, predicates)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn elaborate_predicates<'gcx, 'tcx>(
|
pub fn elaborate_predicates<'gcx, 'tcx>(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
mut predicates: Vec<ty::Predicate<'tcx>>)
|
mut predicates: Vec<ty::Predicate<'tcx>>,
|
||||||
-> Elaborator<'gcx, 'tcx>
|
) -> Elaborator<'gcx, 'tcx> {
|
||||||
{
|
|
||||||
let mut visited = PredicateSet::new(tcx);
|
let mut visited = PredicateSet::new(tcx);
|
||||||
predicates.retain(|pred| visited.insert(pred));
|
predicates.retain(|pred| visited.insert(pred));
|
||||||
Elaborator { stack: predicates, visited }
|
Elaborator { stack: predicates, visited }
|
||||||
|
@ -256,15 +254,17 @@ impl Iterator for Elaborator<'gcx, 'tcx> {
|
||||||
|
|
||||||
pub type Supertraits<'gcx, 'tcx> = FilterToTraits<Elaborator<'gcx, 'tcx>>;
|
pub type Supertraits<'gcx, 'tcx> = FilterToTraits<Elaborator<'gcx, 'tcx>>;
|
||||||
|
|
||||||
pub fn supertraits<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn supertraits<'gcx, 'tcx>(
|
||||||
trait_ref: ty::PolyTraitRef<'tcx>)
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
-> Supertraits<'gcx, 'tcx> {
|
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||||
|
) -> Supertraits<'gcx, 'tcx> {
|
||||||
elaborate_trait_ref(tcx, trait_ref).filter_to_traits()
|
elaborate_trait_ref(tcx, trait_ref).filter_to_traits()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn transitive_bounds<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn transitive_bounds<'gcx, 'tcx>(
|
||||||
bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>)
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
-> Supertraits<'gcx, 'tcx> {
|
bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
|
||||||
|
) -> Supertraits<'gcx, 'tcx> {
|
||||||
elaborate_trait_refs(tcx, bounds).filter_to_traits()
|
elaborate_trait_refs(tcx, bounds).filter_to_traits()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ impl<'tcx> TraitAliasExpansionInfo<'tcx> {
|
||||||
|
|
||||||
pub fn expand_trait_aliases<'gcx, 'tcx>(
|
pub fn expand_trait_aliases<'gcx, 'tcx>(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
trait_refs: impl IntoIterator<Item = (ty::PolyTraitRef<'tcx>, Span)>
|
trait_refs: impl IntoIterator<Item = (ty::PolyTraitRef<'tcx>, Span)>,
|
||||||
) -> TraitAliasExpander<'gcx, 'tcx> {
|
) -> TraitAliasExpander<'gcx, 'tcx> {
|
||||||
let items: Vec<_> = trait_refs
|
let items: Vec<_> = trait_refs
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -420,10 +420,10 @@ pub struct SupertraitDefIds<'gcx, 'tcx> {
|
||||||
visited: FxHashSet<DefId>,
|
visited: FxHashSet<DefId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn supertrait_def_ids<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn supertrait_def_ids<'gcx, 'tcx>(
|
||||||
trait_def_id: DefId)
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
-> SupertraitDefIds<'gcx, 'tcx>
|
trait_def_id: DefId,
|
||||||
{
|
) -> SupertraitDefIds<'gcx, 'tcx> {
|
||||||
SupertraitDefIds {
|
SupertraitDefIds {
|
||||||
tcx,
|
tcx,
|
||||||
stack: vec![trait_def_id],
|
stack: vec![trait_def_id],
|
||||||
|
|
|
@ -20,7 +20,7 @@ use crate::mir::interpret::ConstValue;
|
||||||
/// important thing about the result is Ok/Err. Also, matching never
|
/// important thing about the result is Ok/Err. Also, matching never
|
||||||
/// affects any type variables or unification state.
|
/// affects any type variables or unification state.
|
||||||
pub struct Match<'gcx, 'tcx> {
|
pub struct Match<'gcx, 'tcx> {
|
||||||
tcx: TyCtxt<'gcx, 'tcx>
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Match<'gcx, 'tcx> {
|
impl Match<'gcx, 'tcx> {
|
||||||
|
|
|
@ -104,8 +104,11 @@ pub struct OverloadedDeref<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'gcx, 'tcx> OverloadedDeref<'tcx> {
|
impl<'gcx, 'tcx> OverloadedDeref<'tcx> {
|
||||||
pub fn method_call(&self, tcx: TyCtxt<'gcx, 'tcx>, source: Ty<'tcx>)
|
pub fn method_call(
|
||||||
-> (DefId, SubstsRef<'tcx>) {
|
&self,
|
||||||
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
|
source: Ty<'tcx>,
|
||||||
|
) -> (DefId, SubstsRef<'tcx>) {
|
||||||
let trait_def_id = match self.mutbl {
|
let trait_def_id = match self.mutbl {
|
||||||
hir::MutImmutable => tcx.lang_items().deref_trait(),
|
hir::MutImmutable => tcx.lang_items().deref_trait(),
|
||||||
hir::MutMutable => tcx.lang_items().deref_mut_trait()
|
hir::MutMutable => tcx.lang_items().deref_mut_trait()
|
||||||
|
|
|
@ -132,25 +132,28 @@ pub trait TyDecoder<'tcx>: Decoder {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn decode_arena_allocable<D, T: ArenaAllocatable + Decodable>(
|
pub fn decode_arena_allocable<D, T: ArenaAllocatable + Decodable>(
|
||||||
decoder: &mut D
|
decoder: &mut D,
|
||||||
) -> Result<&'tcx T, D::Error>
|
) -> Result<&'tcx T, D::Error>
|
||||||
where D: TyDecoder<'tcx>,
|
where
|
||||||
|
D: TyDecoder<'tcx>,
|
||||||
{
|
{
|
||||||
Ok(decoder.tcx().arena.alloc(Decodable::decode(decoder)?))
|
Ok(decoder.tcx().arena.alloc(Decodable::decode(decoder)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn decode_arena_allocable_slice<D, T: ArenaAllocatable + Decodable>(
|
pub fn decode_arena_allocable_slice<D, T: ArenaAllocatable + Decodable>(
|
||||||
decoder: &mut D
|
decoder: &mut D,
|
||||||
) -> Result<&'tcx [T], D::Error>
|
) -> Result<&'tcx [T], D::Error>
|
||||||
where D: TyDecoder<'tcx>,
|
where
|
||||||
|
D: TyDecoder<'tcx>,
|
||||||
{
|
{
|
||||||
Ok(decoder.tcx().arena.alloc_from_iter(<Vec<T> as Decodable>::decode(decoder)?))
|
Ok(decoder.tcx().arena.alloc_from_iter(<Vec<T> as Decodable>::decode(decoder)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn decode_cnum<D>(decoder: &mut D) -> Result<CrateNum, D::Error>
|
pub fn decode_cnum<D>(decoder: &mut D) -> Result<CrateNum, D::Error>
|
||||||
where D: TyDecoder<'tcx>,
|
where
|
||||||
|
D: TyDecoder<'tcx>,
|
||||||
{
|
{
|
||||||
let cnum = CrateNum::from_u32(u32::decode(decoder)?);
|
let cnum = CrateNum::from_u32(u32::decode(decoder)?);
|
||||||
Ok(decoder.map_encoded_cnum_to_current(cnum))
|
Ok(decoder.map_encoded_cnum_to_current(cnum))
|
||||||
|
@ -158,7 +161,8 @@ pub fn decode_cnum<D>(decoder: &mut D) -> Result<CrateNum, D::Error>
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn decode_ty<D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
|
pub fn decode_ty<D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
|
||||||
where D: TyDecoder<'tcx>,
|
where
|
||||||
|
D: TyDecoder<'tcx>,
|
||||||
{
|
{
|
||||||
// Handle shorthands first, if we have an usize > 0x80.
|
// Handle shorthands first, if we have an usize > 0x80.
|
||||||
if decoder.positioned_at_shorthand() {
|
if decoder.positioned_at_shorthand() {
|
||||||
|
@ -176,9 +180,9 @@ pub fn decode_ty<D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn decode_predicates<D>(decoder: &mut D)
|
pub fn decode_predicates<D>(decoder: &mut D) -> Result<ty::GenericPredicates<'tcx>, D::Error>
|
||||||
-> Result<ty::GenericPredicates<'tcx>, D::Error>
|
where
|
||||||
where D: TyDecoder<'tcx>,
|
D: TyDecoder<'tcx>,
|
||||||
{
|
{
|
||||||
Ok(ty::GenericPredicates {
|
Ok(ty::GenericPredicates {
|
||||||
parent: Decodable::decode(decoder)?,
|
parent: Decodable::decode(decoder)?,
|
||||||
|
@ -201,7 +205,8 @@ pub fn decode_predicates<D>(decoder: &mut D)
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn decode_substs<D>(decoder: &mut D) -> Result<SubstsRef<'tcx>, D::Error>
|
pub fn decode_substs<D>(decoder: &mut D) -> Result<SubstsRef<'tcx>, D::Error>
|
||||||
where D: TyDecoder<'tcx>,
|
where
|
||||||
|
D: TyDecoder<'tcx>,
|
||||||
{
|
{
|
||||||
let len = decoder.read_usize()?;
|
let len = decoder.read_usize()?;
|
||||||
let tcx = decoder.tcx();
|
let tcx = decoder.tcx();
|
||||||
|
@ -210,33 +215,36 @@ pub fn decode_substs<D>(decoder: &mut D) -> Result<SubstsRef<'tcx>, D::Error>
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn decode_region<D>(decoder: &mut D) -> Result<ty::Region<'tcx>, D::Error>
|
pub fn decode_region<D>(decoder: &mut D) -> Result<ty::Region<'tcx>, D::Error>
|
||||||
where D: TyDecoder<'tcx>,
|
where
|
||||||
|
D: TyDecoder<'tcx>,
|
||||||
{
|
{
|
||||||
Ok(decoder.tcx().mk_region(Decodable::decode(decoder)?))
|
Ok(decoder.tcx().mk_region(Decodable::decode(decoder)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn decode_ty_slice<D>(decoder: &mut D)
|
pub fn decode_ty_slice<D>(decoder: &mut D) -> Result<&'tcx ty::List<Ty<'tcx>>, D::Error>
|
||||||
-> Result<&'tcx ty::List<Ty<'tcx>>, D::Error>
|
where
|
||||||
where D: TyDecoder<'tcx>,
|
D: TyDecoder<'tcx>,
|
||||||
{
|
{
|
||||||
let len = decoder.read_usize()?;
|
let len = decoder.read_usize()?;
|
||||||
Ok(decoder.tcx().mk_type_list((0..len).map(|_| Decodable::decode(decoder)))?)
|
Ok(decoder.tcx().mk_type_list((0..len).map(|_| Decodable::decode(decoder)))?)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn decode_adt_def<D>(decoder: &mut D)
|
pub fn decode_adt_def<D>(decoder: &mut D) -> Result<&'tcx ty::AdtDef, D::Error>
|
||||||
-> Result<&'tcx ty::AdtDef, D::Error>
|
where
|
||||||
where D: TyDecoder<'tcx>,
|
D: TyDecoder<'tcx>,
|
||||||
{
|
{
|
||||||
let def_id = DefId::decode(decoder)?;
|
let def_id = DefId::decode(decoder)?;
|
||||||
Ok(decoder.tcx().adt_def(def_id))
|
Ok(decoder.tcx().adt_def(def_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn decode_existential_predicate_slice<D>(decoder: &mut D)
|
pub fn decode_existential_predicate_slice<D>(
|
||||||
-> Result<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>, D::Error>
|
decoder: &mut D,
|
||||||
where D: TyDecoder<'tcx>,
|
) -> Result<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>, D::Error>
|
||||||
|
where
|
||||||
|
D: TyDecoder<'tcx>,
|
||||||
{
|
{
|
||||||
let len = decoder.read_usize()?;
|
let len = decoder.read_usize()?;
|
||||||
Ok(decoder.tcx()
|
Ok(decoder.tcx()
|
||||||
|
@ -244,9 +252,9 @@ pub fn decode_existential_predicate_slice<D>(decoder: &mut D)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn decode_canonical_var_infos<D>(decoder: &mut D)
|
pub fn decode_canonical_var_infos<D>(decoder: &mut D) -> Result<CanonicalVarInfos<'tcx>, D::Error>
|
||||||
-> Result<CanonicalVarInfos<'tcx>, D::Error>
|
where
|
||||||
where D: TyDecoder<'tcx>,
|
D: TyDecoder<'tcx>,
|
||||||
{
|
{
|
||||||
let len = decoder.read_usize()?;
|
let len = decoder.read_usize()?;
|
||||||
let interned: Result<Vec<CanonicalVarInfo>, _> = (0..len).map(|_| Decodable::decode(decoder))
|
let interned: Result<Vec<CanonicalVarInfo>, _> = (0..len).map(|_| Decodable::decode(decoder))
|
||||||
|
@ -256,17 +264,17 @@ pub fn decode_canonical_var_infos<D>(decoder: &mut D)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn decode_const<D>(decoder: &mut D)
|
pub fn decode_const<D>(decoder: &mut D) -> Result<&'tcx ty::Const<'tcx>, D::Error>
|
||||||
-> Result<&'tcx ty::Const<'tcx>, D::Error>
|
where
|
||||||
where D: TyDecoder<'tcx>,
|
D: TyDecoder<'tcx>,
|
||||||
{
|
{
|
||||||
Ok(decoder.tcx().mk_const(Decodable::decode(decoder)?))
|
Ok(decoder.tcx().mk_const(Decodable::decode(decoder)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn decode_allocation<D>(decoder: &mut D)
|
pub fn decode_allocation<D>(decoder: &mut D) -> Result<&'tcx Allocation, D::Error>
|
||||||
-> Result<&'tcx Allocation, D::Error>
|
where
|
||||||
where D: TyDecoder<'tcx>,
|
D: TyDecoder<'tcx>,
|
||||||
{
|
{
|
||||||
Ok(decoder.tcx().intern_const_alloc(Decodable::decode(decoder)?))
|
Ok(decoder.tcx().intern_const_alloc(Decodable::decode(decoder)?))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1678,10 +1678,7 @@ impl<'gcx> GlobalCtxt<'gcx> {
|
||||||
/// Call the closure with a local `TyCtxt` using the given arena.
|
/// Call the closure with a local `TyCtxt` using the given arena.
|
||||||
/// `interners` is a slot passed so we can create a CtxtInterners
|
/// `interners` is a slot passed so we can create a CtxtInterners
|
||||||
/// with the same lifetime as `arena`.
|
/// with the same lifetime as `arena`.
|
||||||
pub fn enter_local<'tcx, F, R>(
|
pub fn enter_local<'tcx, F, R>(&'gcx self, f: F) -> R
|
||||||
&'gcx self,
|
|
||||||
f: F
|
|
||||||
) -> R
|
|
||||||
where
|
where
|
||||||
F: FnOnce(TyCtxt<'gcx, 'tcx>) -> R,
|
F: FnOnce(TyCtxt<'gcx, 'tcx>) -> R,
|
||||||
'gcx: 'tcx,
|
'gcx: 'tcx,
|
||||||
|
@ -1732,41 +1729,41 @@ pub trait Lift<'tcx>: fmt::Debug {
|
||||||
macro_rules! nop_lift {
|
macro_rules! nop_lift {
|
||||||
($ty:ty => $lifted:ty) => {
|
($ty:ty => $lifted:ty) => {
|
||||||
impl<'a, 'tcx> Lift<'tcx> for $ty {
|
impl<'a, 'tcx> Lift<'tcx> for $ty {
|
||||||
type Lifted = $lifted;
|
type Lifted = $lifted;
|
||||||
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<Self::Lifted> {
|
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<Self::Lifted> {
|
||||||
if tcx.interners.arena.in_arena(*self as *const _) {
|
if tcx.interners.arena.in_arena(*self as *const _) {
|
||||||
return Some(unsafe { mem::transmute(*self) });
|
return Some(unsafe { mem::transmute(*self) });
|
||||||
|
}
|
||||||
|
// Also try in the global tcx if we're not that.
|
||||||
|
if !tcx.is_global() {
|
||||||
|
self.lift_to_tcx(tcx.global_tcx())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Also try in the global tcx if we're not that.
|
|
||||||
if !tcx.is_global() {
|
|
||||||
self.lift_to_tcx(tcx.global_tcx())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! nop_list_lift {
|
macro_rules! nop_list_lift {
|
||||||
($ty:ty => $lifted:ty) => {
|
($ty:ty => $lifted:ty) => {
|
||||||
impl<'a, 'tcx> Lift<'tcx> for &'a List<$ty> {
|
impl<'a, 'tcx> Lift<'tcx> for &'a List<$ty> {
|
||||||
type Lifted = &'tcx List<$lifted>;
|
type Lifted = &'tcx List<$lifted>;
|
||||||
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<Self::Lifted> {
|
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<Self::Lifted> {
|
||||||
if self.is_empty() {
|
if self.is_empty() {
|
||||||
return Some(List::empty());
|
return Some(List::empty());
|
||||||
|
}
|
||||||
|
if tcx.interners.arena.in_arena(*self as *const _) {
|
||||||
|
return Some(unsafe { mem::transmute(*self) });
|
||||||
|
}
|
||||||
|
// Also try in the global tcx if we're not that.
|
||||||
|
if !tcx.is_global() {
|
||||||
|
self.lift_to_tcx(tcx.global_tcx())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if tcx.interners.arena.in_arena(*self as *const _) {
|
|
||||||
return Some(unsafe { mem::transmute(*self) });
|
|
||||||
}
|
|
||||||
// Also try in the global tcx if we're not that.
|
|
||||||
if !tcx.is_global() {
|
|
||||||
self.lift_to_tcx(tcx.global_tcx())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1941,7 +1938,8 @@ pub mod tls {
|
||||||
/// This happens once per rustc session and TyCtxts only exists
|
/// This happens once per rustc session and TyCtxts only exists
|
||||||
/// inside the `f` function.
|
/// inside the `f` function.
|
||||||
pub fn enter_global<'gcx, F, R>(gcx: &'gcx GlobalCtxt<'gcx>, f: F) -> R
|
pub fn enter_global<'gcx, F, R>(gcx: &'gcx GlobalCtxt<'gcx>, f: F) -> R
|
||||||
where F: FnOnce(TyCtxt<'gcx, 'gcx>) -> R
|
where
|
||||||
|
F: FnOnce(TyCtxt<'gcx, 'gcx>) -> R,
|
||||||
{
|
{
|
||||||
// Update GCX_PTR to indicate there's a GlobalCtxt available
|
// Update GCX_PTR to indicate there's a GlobalCtxt available
|
||||||
GCX_PTR.with(|lock| {
|
GCX_PTR.with(|lock| {
|
||||||
|
@ -1978,7 +1976,8 @@ pub mod tls {
|
||||||
/// Creates a TyCtxt and ImplicitCtxt based on the GCX_PTR thread local.
|
/// Creates a TyCtxt and ImplicitCtxt based on the GCX_PTR thread local.
|
||||||
/// This is used in the deadlock handler.
|
/// This is used in the deadlock handler.
|
||||||
pub unsafe fn with_global<F, R>(f: F) -> R
|
pub unsafe fn with_global<F, R>(f: F) -> R
|
||||||
where F: for<'gcx, 'tcx> FnOnce(TyCtxt<'gcx, 'tcx>) -> R
|
where
|
||||||
|
F: for<'gcx, 'tcx> FnOnce(TyCtxt<'gcx, 'tcx>) -> R,
|
||||||
{
|
{
|
||||||
let gcx = GCX_PTR.with(|lock| *lock.lock());
|
let gcx = GCX_PTR.with(|lock| *lock.lock());
|
||||||
assert!(gcx != 0);
|
assert!(gcx != 0);
|
||||||
|
@ -2031,7 +2030,8 @@ pub mod tls {
|
||||||
/// the current ImplicitCtxt's tcx field.
|
/// the current ImplicitCtxt's tcx field.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn with_related_context<'gcx, 'tcx1, F, R>(tcx: TyCtxt<'gcx, 'tcx1>, f: F) -> R
|
pub fn with_related_context<'gcx, 'tcx1, F, R>(tcx: TyCtxt<'gcx, 'tcx1>, f: F) -> R
|
||||||
where F: for<'b, 'tcx2> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx2>) -> R
|
where
|
||||||
|
F: for<'b, 'tcx2> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx2>) -> R,
|
||||||
{
|
{
|
||||||
with_context(|context| {
|
with_context(|context| {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -2049,7 +2049,8 @@ pub mod tls {
|
||||||
/// a different local interner from the current ImplicitCtxt's tcx field.
|
/// a different local interner from the current ImplicitCtxt's tcx field.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn with_fully_related_context<'gcx, 'tcx, F, R>(tcx: TyCtxt<'gcx, 'tcx>, f: F) -> R
|
pub fn with_fully_related_context<'gcx, 'tcx, F, R>(tcx: TyCtxt<'gcx, 'tcx>, f: F) -> R
|
||||||
where F: for<'b> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx>) -> R
|
where
|
||||||
|
F: for<'b> FnOnce(&ImplicitCtxt<'b, 'gcx, 'tcx>) -> R,
|
||||||
{
|
{
|
||||||
with_context(|context| {
|
with_context(|context| {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -2065,7 +2066,8 @@ pub mod tls {
|
||||||
/// Panics if there is no ImplicitCtxt available
|
/// Panics if there is no ImplicitCtxt available
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn with<F, R>(f: F) -> R
|
pub fn with<F, R>(f: F) -> R
|
||||||
where F: for<'gcx, 'tcx> FnOnce(TyCtxt<'gcx, 'tcx>) -> R
|
where
|
||||||
|
F: for<'gcx, 'tcx> FnOnce(TyCtxt<'gcx, 'tcx>) -> R,
|
||||||
{
|
{
|
||||||
with_context(|context| f(context.tcx))
|
with_context(|context| f(context.tcx))
|
||||||
}
|
}
|
||||||
|
@ -2074,7 +2076,8 @@ pub mod tls {
|
||||||
/// The closure is passed None if there is no ImplicitCtxt available
|
/// The closure is passed None if there is no ImplicitCtxt available
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn with_opt<F, R>(f: F) -> R
|
pub fn with_opt<F, R>(f: F) -> R
|
||||||
where F: for<'gcx, 'tcx> FnOnce(Option<TyCtxt<'gcx, 'tcx>>) -> R
|
where
|
||||||
|
F: for<'gcx, 'tcx> FnOnce(Option<TyCtxt<'gcx, 'tcx>>) -> R,
|
||||||
{
|
{
|
||||||
with_context_opt(|opt_context| f(opt_context.map(|context| context.tcx)))
|
with_context_opt(|opt_context| f(opt_context.map(|context| context.tcx)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,11 +55,11 @@ pub enum SimplifiedTypeGen<D>
|
||||||
/// then we can't say much about whether two types would unify. Put another way,
|
/// then we can't say much about whether two types would unify. Put another way,
|
||||||
/// `can_simplify_params` should be true if type parameters appear free in `ty` and `false` if they
|
/// `can_simplify_params` should be true if type parameters appear free in `ty` and `false` if they
|
||||||
/// are to be considered bound.
|
/// are to be considered bound.
|
||||||
pub fn simplify_type<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn simplify_type<'gcx, 'tcx>(
|
||||||
ty: Ty<'_>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
can_simplify_params: bool)
|
ty: Ty<'_>,
|
||||||
-> Option<SimplifiedType>
|
can_simplify_params: bool,
|
||||||
{
|
) -> Option<SimplifiedType> {
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
ty::Bool => Some(BoolSimplifiedType),
|
ty::Bool => Some(BoolSimplifiedType),
|
||||||
ty::Char => Some(CharSimplifiedType),
|
ty::Char => Some(CharSimplifiedType),
|
||||||
|
|
|
@ -155,7 +155,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
|
||||||
/// default implementation that does an "identity" fold. Within each
|
/// default implementation that does an "identity" fold. Within each
|
||||||
/// identity fold, it should invoke `foo.fold_with(self)` to fold each
|
/// identity fold, it should invoke `foo.fold_with(self)` to fold each
|
||||||
/// sub-item.
|
/// sub-item.
|
||||||
pub trait TypeFolder<'gcx: 'tcx, 'tcx> : Sized {
|
pub trait TypeFolder<'gcx: 'tcx, 'tcx>: Sized {
|
||||||
fn tcx<'a>(&'a self) -> TyCtxt<'gcx, 'tcx>;
|
fn tcx<'a>(&'a self) -> TyCtxt<'gcx, 'tcx>;
|
||||||
|
|
||||||
fn fold_binder<T>(&mut self, t: &Binder<T>) -> Binder<T>
|
fn fold_binder<T>(&mut self, t: &Binder<T>) -> Binder<T>
|
||||||
|
@ -199,9 +199,10 @@ pub trait TypeVisitor<'tcx> : Sized {
|
||||||
// Some sample folders
|
// Some sample folders
|
||||||
|
|
||||||
pub struct BottomUpFolder<'gcx, 'tcx, F, G, H>
|
pub struct BottomUpFolder<'gcx, 'tcx, F, G, H>
|
||||||
where F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
|
where
|
||||||
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
|
F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
|
||||||
H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>,
|
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
|
||||||
|
H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>,
|
||||||
{
|
{
|
||||||
pub tcx: TyCtxt<'gcx, 'tcx>,
|
pub tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
pub ty_op: F,
|
pub ty_op: F,
|
||||||
|
@ -210,11 +211,14 @@ pub struct BottomUpFolder<'gcx, 'tcx, F, G, H>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'gcx, 'tcx, F, G, H> TypeFolder<'gcx, 'tcx> for BottomUpFolder<'gcx, 'tcx, F, G, H>
|
impl<'gcx, 'tcx, F, G, H> TypeFolder<'gcx, 'tcx> for BottomUpFolder<'gcx, 'tcx, F, G, H>
|
||||||
where F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
|
where
|
||||||
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
|
F: FnMut(Ty<'tcx>) -> Ty<'tcx>,
|
||||||
H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>,
|
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
|
||||||
|
H: FnMut(&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>,
|
||||||
{
|
{
|
||||||
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { self.tcx }
|
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> {
|
||||||
|
self.tcx
|
||||||
|
}
|
||||||
|
|
||||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
let t = ty.super_fold_with(self);
|
let t = ty.super_fold_with(self);
|
||||||
|
@ -361,7 +365,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
|
||||||
/// visited by this folder; only regions that occur free will be
|
/// visited by this folder; only regions that occur free will be
|
||||||
/// visited by `fld_r`.
|
/// visited by `fld_r`.
|
||||||
|
|
||||||
pub struct RegionFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
pub struct RegionFolder<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
skipped_regions: &'a mut bool,
|
skipped_regions: &'a mut bool,
|
||||||
|
|
||||||
|
@ -373,10 +377,8 @@ pub struct RegionFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||||
/// Callback invokes for each free region. The `DebruijnIndex`
|
/// Callback invokes for each free region. The `DebruijnIndex`
|
||||||
/// points to the binder *just outside* the ones we have passed
|
/// points to the binder *just outside* the ones we have passed
|
||||||
/// through.
|
/// through.
|
||||||
fold_region_fn: &'a mut (dyn FnMut(
|
fold_region_fn:
|
||||||
ty::Region<'tcx>,
|
&'a mut (dyn FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx> + 'a),
|
||||||
ty::DebruijnIndex,
|
|
||||||
) -> ty::Region<'tcx> + 'a),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> RegionFolder<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> RegionFolder<'a, 'gcx, 'tcx> {
|
||||||
|
@ -396,7 +398,9 @@ impl<'a, 'gcx, 'tcx> RegionFolder<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionFolder<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for RegionFolder<'a, 'gcx, 'tcx> {
|
||||||
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { self.tcx }
|
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> {
|
||||||
|
self.tcx
|
||||||
|
}
|
||||||
|
|
||||||
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
|
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
|
||||||
self.current_index.shift_in(1);
|
self.current_index.shift_in(1);
|
||||||
|
@ -445,9 +449,10 @@ impl<'a, 'gcx, 'tcx> BoundVarReplacer<'a, 'gcx, 'tcx> {
|
||||||
fld_t: &'a mut G,
|
fld_t: &'a mut G,
|
||||||
fld_c: &'a mut H,
|
fld_c: &'a mut H,
|
||||||
) -> Self
|
) -> Self
|
||||||
where F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
|
where
|
||||||
G: FnMut(ty::BoundTy) -> Ty<'tcx>,
|
F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
|
||||||
H: FnMut(ty::BoundVar, Ty<'tcx>) -> &'tcx ty::Const<'tcx>,
|
G: FnMut(ty::BoundTy) -> Ty<'tcx>,
|
||||||
|
H: FnMut(ty::BoundVar, Ty<'tcx>) -> &'tcx ty::Const<'tcx>,
|
||||||
{
|
{
|
||||||
BoundVarReplacer {
|
BoundVarReplacer {
|
||||||
tcx,
|
tcx,
|
||||||
|
@ -460,7 +465,9 @@ impl<'a, 'gcx, 'tcx> BoundVarReplacer<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for BoundVarReplacer<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for BoundVarReplacer<'a, 'gcx, 'tcx> {
|
||||||
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { self.tcx }
|
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> {
|
||||||
|
self.tcx
|
||||||
|
}
|
||||||
|
|
||||||
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
|
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
|
||||||
self.current_index.shift_in(1);
|
self.current_index.shift_in(1);
|
||||||
|
@ -741,7 +748,9 @@ impl Shifter<'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TypeFolder<'gcx, 'tcx> for Shifter<'gcx, 'tcx> {
|
impl TypeFolder<'gcx, 'tcx> for Shifter<'gcx, 'tcx> {
|
||||||
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> { self.tcx }
|
fn tcx<'b>(&'b self) -> TyCtxt<'gcx, 'tcx> {
|
||||||
|
self.tcx
|
||||||
|
}
|
||||||
|
|
||||||
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
|
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T> {
|
||||||
self.current_index.shift_in(1);
|
self.current_index.shift_in(1);
|
||||||
|
@ -820,7 +829,7 @@ impl TypeFolder<'gcx, 'tcx> for Shifter<'gcx, 'tcx> {
|
||||||
pub fn shift_region<'gcx, 'tcx>(
|
pub fn shift_region<'gcx, 'tcx>(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
region: ty::Region<'tcx>,
|
region: ty::Region<'tcx>,
|
||||||
amount: u32
|
amount: u32,
|
||||||
) -> ty::Region<'tcx> {
|
) -> ty::Region<'tcx> {
|
||||||
match region {
|
match region {
|
||||||
ty::ReLateBound(debruijn, br) if amount > 0 => {
|
ty::ReLateBound(debruijn, br) if amount > 0 => {
|
||||||
|
@ -832,22 +841,20 @@ pub fn shift_region<'gcx, 'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shift_vars<'gcx, 'tcx, T>(
|
pub fn shift_vars<'gcx, 'tcx, T>(tcx: TyCtxt<'gcx, 'tcx>, value: &T, amount: u32) -> T
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
where
|
||||||
value: &T,
|
T: TypeFoldable<'tcx>,
|
||||||
amount: u32
|
{
|
||||||
) -> T where T: TypeFoldable<'tcx> {
|
|
||||||
debug!("shift_vars(value={:?}, amount={})",
|
debug!("shift_vars(value={:?}, amount={})",
|
||||||
value, amount);
|
value, amount);
|
||||||
|
|
||||||
value.fold_with(&mut Shifter::new(tcx, amount, Direction::In))
|
value.fold_with(&mut Shifter::new(tcx, amount, Direction::In))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shift_out_vars<'gcx, 'tcx, T>(
|
pub fn shift_out_vars<'gcx, 'tcx, T>(tcx: TyCtxt<'gcx, 'tcx>, value: &T, amount: u32) -> T
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
where
|
||||||
value: &T,
|
T: TypeFoldable<'tcx>,
|
||||||
amount: u32
|
{
|
||||||
) -> T where T: TypeFoldable<'tcx> {
|
|
||||||
debug!("shift_out_vars(value={:?}, amount={})",
|
debug!("shift_out_vars(value={:?}, amount={})",
|
||||||
value, amount);
|
value, amount);
|
||||||
|
|
||||||
|
|
|
@ -52,17 +52,14 @@ impl<'gcx, 'tcx> DefIdForest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tests whether the forest contains a given DefId.
|
/// Tests whether the forest contains a given DefId.
|
||||||
pub fn contains(&self,
|
pub fn contains(&self, tcx: TyCtxt<'gcx, 'tcx>, id: DefId) -> bool {
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
|
||||||
id: DefId) -> bool
|
|
||||||
{
|
|
||||||
self.root_ids.iter().any(|root_id| tcx.is_descendant_of(id, *root_id))
|
self.root_ids.iter().any(|root_id| tcx.is_descendant_of(id, *root_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculate the intersection of a collection of forests.
|
/// Calculate the intersection of a collection of forests.
|
||||||
pub fn intersection<I>(tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn intersection<I>(tcx: TyCtxt<'gcx, 'tcx>, iter: I) -> DefIdForest
|
||||||
iter: I) -> DefIdForest
|
where
|
||||||
where I: IntoIterator<Item=DefIdForest>
|
I: IntoIterator<Item = DefIdForest>,
|
||||||
{
|
{
|
||||||
let mut iter = iter.into_iter();
|
let mut iter = iter.into_iter();
|
||||||
let mut ret = if let Some(first) = iter.next() {
|
let mut ret = if let Some(first) = iter.next() {
|
||||||
|
@ -97,9 +94,9 @@ impl<'gcx, 'tcx> DefIdForest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculate the union of a collection of forests.
|
/// Calculate the union of a collection of forests.
|
||||||
pub fn union<I>(tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn union<I>(tcx: TyCtxt<'gcx, 'tcx>, iter: I) -> DefIdForest
|
||||||
iter: I) -> DefIdForest
|
where
|
||||||
where I: IntoIterator<Item=DefIdForest>
|
I: IntoIterator<Item = DefIdForest>,
|
||||||
{
|
{
|
||||||
let mut ret = DefIdForest::empty();
|
let mut ret = DefIdForest::empty();
|
||||||
let mut next_ret = SmallVec::new();
|
let mut next_ret = SmallVec::new();
|
||||||
|
|
|
@ -108,11 +108,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
|
||||||
|
|
||||||
impl<'gcx, 'tcx> AdtDef {
|
impl<'gcx, 'tcx> AdtDef {
|
||||||
/// Calculate the forest of DefIds from which this adt is visibly uninhabited.
|
/// Calculate the forest of DefIds from which this adt is visibly uninhabited.
|
||||||
fn uninhabited_from(
|
fn uninhabited_from(&self, tcx: TyCtxt<'gcx, 'tcx>, substs: SubstsRef<'tcx>) -> DefIdForest {
|
||||||
&self,
|
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
|
||||||
substs: SubstsRef<'tcx>) -> DefIdForest
|
|
||||||
{
|
|
||||||
// Non-exhaustive ADTs from other crates are always considered inhabited.
|
// Non-exhaustive ADTs from other crates are always considered inhabited.
|
||||||
if self.is_variant_list_non_exhaustive() && !self.did.is_local() {
|
if self.is_variant_list_non_exhaustive() && !self.did.is_local() {
|
||||||
DefIdForest::empty()
|
DefIdForest::empty()
|
||||||
|
@ -130,8 +126,8 @@ impl<'gcx, 'tcx> VariantDef {
|
||||||
&self,
|
&self,
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
substs: SubstsRef<'tcx>,
|
substs: SubstsRef<'tcx>,
|
||||||
adt_kind: AdtKind) -> DefIdForest
|
adt_kind: AdtKind,
|
||||||
{
|
) -> DefIdForest {
|
||||||
let is_enum = match adt_kind {
|
let is_enum = match adt_kind {
|
||||||
// For now, `union`s are never considered uninhabited.
|
// For now, `union`s are never considered uninhabited.
|
||||||
// The precise semantics of inhabitedness with respect to unions is currently undecided.
|
// The precise semantics of inhabitedness with respect to unions is currently undecided.
|
||||||
|
@ -182,8 +178,7 @@ impl<'gcx, 'tcx> FieldDef {
|
||||||
|
|
||||||
impl<'gcx, 'tcx> TyS<'tcx> {
|
impl<'gcx, 'tcx> TyS<'tcx> {
|
||||||
/// Calculate the forest of DefIds from which this type is visibly uninhabited.
|
/// Calculate the forest of DefIds from which this type is visibly uninhabited.
|
||||||
fn uninhabited_from(&self, tcx: TyCtxt<'gcx, 'tcx>) -> DefIdForest
|
fn uninhabited_from(&self, tcx: TyCtxt<'gcx, 'tcx>) -> DefIdForest {
|
||||||
{
|
|
||||||
match self.sty {
|
match self.sty {
|
||||||
Adt(def, substs) => def.uninhabited_from(tcx, substs),
|
Adt(def, substs) => def.uninhabited_from(tcx, substs),
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,7 @@ pub enum InstanceDef<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Instance<'tcx> {
|
impl<'tcx> Instance<'tcx> {
|
||||||
pub fn ty(&self,
|
pub fn ty(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Ty<'tcx> {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>)
|
|
||||||
-> Ty<'tcx>
|
|
||||||
{
|
|
||||||
let ty = tcx.type_of(self.def.def_id());
|
let ty = tcx.type_of(self.def.def_id());
|
||||||
tcx.subst_and_normalize_erasing_regions(
|
tcx.subst_and_normalize_erasing_regions(
|
||||||
self.substs,
|
self.substs,
|
||||||
|
@ -140,10 +137,7 @@ impl<'tcx> InstanceDef<'tcx> {
|
||||||
tcx.get_attrs(self.def_id())
|
tcx.get_attrs(self.def_id())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_inline(
|
pub fn is_inline(&self, tcx: TyCtxt<'tcx, 'tcx>) -> bool {
|
||||||
&self,
|
|
||||||
tcx: TyCtxt<'tcx, 'tcx>
|
|
||||||
) -> bool {
|
|
||||||
use crate::hir::map::DefPathData;
|
use crate::hir::map::DefPathData;
|
||||||
let def_id = match *self {
|
let def_id = match *self {
|
||||||
ty::InstanceDef::Item(def_id) => def_id,
|
ty::InstanceDef::Item(def_id) => def_id,
|
||||||
|
@ -156,10 +150,7 @@ impl<'tcx> InstanceDef<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn requires_local(
|
pub fn requires_local(&self, tcx: TyCtxt<'tcx, 'tcx>) -> bool {
|
||||||
&self,
|
|
||||||
tcx: TyCtxt<'tcx, 'tcx>
|
|
||||||
) -> bool {
|
|
||||||
if self.is_inline(tcx) {
|
if self.is_inline(tcx) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -245,10 +236,12 @@ impl<'b, 'tcx> Instance<'tcx> {
|
||||||
/// Presuming that coherence and type-check have succeeded, if this method is invoked
|
/// Presuming that coherence and type-check have succeeded, if this method is invoked
|
||||||
/// in a monomorphic context (i.e., like during codegen), then it is guaranteed to return
|
/// in a monomorphic context (i.e., like during codegen), then it is guaranteed to return
|
||||||
/// `Some`.
|
/// `Some`.
|
||||||
pub fn resolve(tcx: TyCtxt<'tcx, 'tcx>,
|
pub fn resolve(
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
def_id: DefId,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
substs: SubstsRef<'tcx>) -> Option<Instance<'tcx>> {
|
def_id: DefId,
|
||||||
|
substs: SubstsRef<'tcx>,
|
||||||
|
) -> Option<Instance<'tcx>> {
|
||||||
debug!("resolve(def_id={:?}, substs={:?})", def_id, substs);
|
debug!("resolve(def_id={:?}, substs={:?})", def_id, substs);
|
||||||
let result = if let Some(trait_def_id) = tcx.trait_of_item(def_id) {
|
let result = if let Some(trait_def_id) = tcx.trait_of_item(def_id) {
|
||||||
debug!(" => associated item, attempting to find impl in param_env {:#?}", param_env);
|
debug!(" => associated item, attempting to find impl in param_env {:#?}", param_env);
|
||||||
|
@ -297,10 +290,12 @@ impl<'b, 'tcx> Instance<'tcx> {
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resolve_for_vtable(tcx: TyCtxt<'tcx, 'tcx>,
|
pub fn resolve_for_vtable(
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
def_id: DefId,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
substs: SubstsRef<'tcx>) -> Option<Instance<'tcx>> {
|
def_id: DefId,
|
||||||
|
substs: SubstsRef<'tcx>,
|
||||||
|
) -> Option<Instance<'tcx>> {
|
||||||
debug!("resolve(def_id={:?}, substs={:?})", def_id, substs);
|
debug!("resolve(def_id={:?}, substs={:?})", def_id, substs);
|
||||||
let fn_sig = tcx.fn_sig(def_id);
|
let fn_sig = tcx.fn_sig(def_id);
|
||||||
let is_vtable_shim =
|
let is_vtable_shim =
|
||||||
|
@ -320,9 +315,8 @@ impl<'b, 'tcx> Instance<'tcx> {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
substs: ty::ClosureSubsts<'tcx>,
|
substs: ty::ClosureSubsts<'tcx>,
|
||||||
requested_kind: ty::ClosureKind)
|
requested_kind: ty::ClosureKind,
|
||||||
-> Instance<'tcx>
|
) -> Instance<'tcx> {
|
||||||
{
|
|
||||||
let actual_kind = substs.closure_kind(def_id, tcx);
|
let actual_kind = substs.closure_kind(def_id, tcx);
|
||||||
|
|
||||||
match needs_fn_once_adapter_shim(actual_kind, requested_kind) {
|
match needs_fn_once_adapter_shim(actual_kind, requested_kind) {
|
||||||
|
@ -331,11 +325,7 @@ impl<'b, 'tcx> Instance<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resolve_drop_in_place(
|
pub fn resolve_drop_in_place(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> ty::Instance<'tcx> {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
|
||||||
ty: Ty<'tcx>)
|
|
||||||
-> ty::Instance<'tcx>
|
|
||||||
{
|
|
||||||
let def_id = tcx.require_lang_item(DropInPlaceFnLangItem);
|
let def_id = tcx.require_lang_item(DropInPlaceFnLangItem);
|
||||||
let substs = tcx.intern_substs(&[ty.into()]);
|
let substs = tcx.intern_substs(&[ty.into()]);
|
||||||
Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap()
|
Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap()
|
||||||
|
@ -344,9 +334,8 @@ impl<'b, 'tcx> Instance<'tcx> {
|
||||||
pub fn fn_once_adapter_instance(
|
pub fn fn_once_adapter_instance(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
closure_did: DefId,
|
closure_did: DefId,
|
||||||
substs: ty::ClosureSubsts<'tcx>)
|
substs: ty::ClosureSubsts<'tcx>,
|
||||||
-> Instance<'tcx>
|
) -> Instance<'tcx> {
|
||||||
{
|
|
||||||
debug!("fn_once_adapter_shim({:?}, {:?})",
|
debug!("fn_once_adapter_shim({:?}, {:?})",
|
||||||
closure_did,
|
closure_did,
|
||||||
substs);
|
substs);
|
||||||
|
|
|
@ -28,17 +28,16 @@ use rustc_target::abi::call::{
|
||||||
ArgAttribute, ArgAttributes, ArgType, Conv, FnType, IgnoreMode, PassMode, Reg, RegKind
|
ArgAttribute, ArgAttributes, ArgType, Conv, FnType, IgnoreMode, PassMode, Reg, RegKind
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pub trait IntegerExt {
|
pub trait IntegerExt {
|
||||||
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, signed: bool) -> Ty<'tcx>;
|
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, signed: bool) -> Ty<'tcx>;
|
||||||
fn from_attr<C: HasDataLayout>(cx: &C, ity: attr::IntType) -> Integer;
|
fn from_attr<C: HasDataLayout>(cx: &C, ity: attr::IntType) -> Integer;
|
||||||
fn repr_discr<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn repr_discr<'tcx>(
|
||||||
ty: Ty<'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
repr: &ReprOptions,
|
ty: Ty<'tcx>,
|
||||||
min: i128,
|
repr: &ReprOptions,
|
||||||
max: i128)
|
min: i128,
|
||||||
-> (Integer, bool);
|
max: i128,
|
||||||
|
) -> (Integer, bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntegerExt for Integer {
|
impl IntegerExt for Integer {
|
||||||
|
@ -77,12 +76,13 @@ impl IntegerExt for Integer {
|
||||||
/// signed discriminant range and #[repr] attribute.
|
/// signed discriminant range and #[repr] attribute.
|
||||||
/// N.B.: u128 values above i128::MAX will be treated as signed, but
|
/// N.B.: u128 values above i128::MAX will be treated as signed, but
|
||||||
/// that shouldn't affect anything, other than maybe debuginfo.
|
/// that shouldn't affect anything, other than maybe debuginfo.
|
||||||
fn repr_discr<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn repr_discr<'tcx>(
|
||||||
ty: Ty<'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
repr: &ReprOptions,
|
ty: Ty<'tcx>,
|
||||||
min: i128,
|
repr: &ReprOptions,
|
||||||
max: i128)
|
min: i128,
|
||||||
-> (Integer, bool) {
|
max: i128,
|
||||||
|
) -> (Integer, bool) {
|
||||||
// Theoretically, negative values could be larger in unsigned representation
|
// Theoretically, negative values could be larger in unsigned representation
|
||||||
// than the unsigned representation of the signed minimum. However, if there
|
// than the unsigned representation of the signed minimum. However, if there
|
||||||
// are any negative values, the only valid unsigned representation is u128
|
// are any negative values, the only valid unsigned representation is u128
|
||||||
|
@ -171,10 +171,10 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn layout_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn layout_raw<'tcx>(
|
||||||
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
-> Result<&'tcx LayoutDetails, LayoutError<'tcx>>
|
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
|
||||||
{
|
) -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> {
|
||||||
ty::tls::with_related_context(tcx, move |icx| {
|
ty::tls::with_related_context(tcx, move |icx| {
|
||||||
let rec_limit = *tcx.sess.recursion_limit.get();
|
let rec_limit = *tcx.sess.recursion_limit.get();
|
||||||
let (param_env, ty) = query.into_parts();
|
let (param_env, ty) = query.into_parts();
|
||||||
|
@ -1604,10 +1604,11 @@ pub enum SizeSkeleton<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> SizeSkeleton<'tcx> {
|
impl<'tcx> SizeSkeleton<'tcx> {
|
||||||
pub fn compute(ty: Ty<'tcx>,
|
pub fn compute(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
ty: Ty<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>)
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
-> Result<SizeSkeleton<'tcx>, LayoutError<'tcx>> {
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
|
) -> Result<SizeSkeleton<'tcx>, LayoutError<'tcx>> {
|
||||||
debug_assert!(!ty.has_infer_types());
|
debug_assert!(!ty.has_infer_types());
|
||||||
|
|
||||||
// First try computing a static layout.
|
// First try computing a static layout.
|
||||||
|
|
|
@ -957,11 +957,11 @@ impl<'gcx, 'tcx> Generics {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn region_param(&'tcx self,
|
pub fn region_param(
|
||||||
param: &EarlyBoundRegion,
|
&'tcx self,
|
||||||
tcx: TyCtxt<'gcx, 'tcx>)
|
param: &EarlyBoundRegion,
|
||||||
-> &'tcx GenericParamDef
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
{
|
) -> &'tcx GenericParamDef {
|
||||||
if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
|
if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
|
||||||
let param = &self.params[index as usize];
|
let param = &self.params[index as usize];
|
||||||
match param.kind {
|
match param.kind {
|
||||||
|
@ -975,10 +975,11 @@ impl<'gcx, 'tcx> Generics {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the `GenericParamDef` associated with this `ParamTy`.
|
/// Returns the `GenericParamDef` associated with this `ParamTy`.
|
||||||
pub fn type_param(&'tcx self,
|
pub fn type_param(
|
||||||
param: &ParamTy,
|
&'tcx self,
|
||||||
tcx: TyCtxt<'gcx, 'tcx>)
|
param: &ParamTy,
|
||||||
-> &'tcx GenericParamDef {
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
|
) -> &'tcx GenericParamDef {
|
||||||
if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
|
if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
|
||||||
let param = &self.params[index as usize];
|
let param = &self.params[index as usize];
|
||||||
match param.kind {
|
match param.kind {
|
||||||
|
@ -992,10 +993,11 @@ impl<'gcx, 'tcx> Generics {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the `ConstParameterDef` associated with this `ParamConst`.
|
/// Returns the `ConstParameterDef` associated with this `ParamConst`.
|
||||||
pub fn const_param(&'tcx self,
|
pub fn const_param(
|
||||||
param: &ParamConst,
|
&'tcx self,
|
||||||
tcx: TyCtxt<'gcx, 'tcx>)
|
param: &ParamConst,
|
||||||
-> &GenericParamDef {
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
|
) -> &GenericParamDef {
|
||||||
if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
|
if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
|
||||||
let param = &self.params[index as usize];
|
let param = &self.params[index as usize];
|
||||||
match param.kind {
|
match param.kind {
|
||||||
|
@ -1020,23 +1022,32 @@ impl<'tcx> serialize::UseSpecializedEncodable for GenericPredicates<'tcx> {}
|
||||||
impl<'tcx> serialize::UseSpecializedDecodable for GenericPredicates<'tcx> {}
|
impl<'tcx> serialize::UseSpecializedDecodable for GenericPredicates<'tcx> {}
|
||||||
|
|
||||||
impl<'gcx, 'tcx> GenericPredicates<'tcx> {
|
impl<'gcx, 'tcx> GenericPredicates<'tcx> {
|
||||||
pub fn instantiate(&self, tcx: TyCtxt<'gcx, 'tcx>, substs: SubstsRef<'tcx>)
|
pub fn instantiate(
|
||||||
-> InstantiatedPredicates<'tcx> {
|
&self,
|
||||||
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
|
substs: SubstsRef<'tcx>,
|
||||||
|
) -> InstantiatedPredicates<'tcx> {
|
||||||
let mut instantiated = InstantiatedPredicates::empty();
|
let mut instantiated = InstantiatedPredicates::empty();
|
||||||
self.instantiate_into(tcx, &mut instantiated, substs);
|
self.instantiate_into(tcx, &mut instantiated, substs);
|
||||||
instantiated
|
instantiated
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn instantiate_own(&self, tcx: TyCtxt<'gcx, 'tcx>, substs: SubstsRef<'tcx>)
|
pub fn instantiate_own(
|
||||||
-> InstantiatedPredicates<'tcx> {
|
&self,
|
||||||
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
|
substs: SubstsRef<'tcx>,
|
||||||
|
) -> InstantiatedPredicates<'tcx> {
|
||||||
InstantiatedPredicates {
|
InstantiatedPredicates {
|
||||||
predicates: self.predicates.iter().map(|(p, _)| p.subst(tcx, substs)).collect(),
|
predicates: self.predicates.iter().map(|(p, _)| p.subst(tcx, substs)).collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn instantiate_into(&self, tcx: TyCtxt<'gcx, 'tcx>,
|
fn instantiate_into(
|
||||||
instantiated: &mut InstantiatedPredicates<'tcx>,
|
&self,
|
||||||
substs: SubstsRef<'tcx>) {
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
|
instantiated: &mut InstantiatedPredicates<'tcx>,
|
||||||
|
substs: SubstsRef<'tcx>,
|
||||||
|
) {
|
||||||
if let Some(def_id) = self.parent {
|
if let Some(def_id) = self.parent {
|
||||||
tcx.predicates_of(def_id).instantiate_into(tcx, instantiated, substs);
|
tcx.predicates_of(def_id).instantiate_into(tcx, instantiated, substs);
|
||||||
}
|
}
|
||||||
|
@ -1045,25 +1056,28 @@ impl<'gcx, 'tcx> GenericPredicates<'tcx> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn instantiate_identity(&self, tcx: TyCtxt<'gcx, 'tcx>)
|
pub fn instantiate_identity(&self, tcx: TyCtxt<'gcx, 'tcx>) -> InstantiatedPredicates<'tcx> {
|
||||||
-> InstantiatedPredicates<'tcx> {
|
|
||||||
let mut instantiated = InstantiatedPredicates::empty();
|
let mut instantiated = InstantiatedPredicates::empty();
|
||||||
self.instantiate_identity_into(tcx, &mut instantiated);
|
self.instantiate_identity_into(tcx, &mut instantiated);
|
||||||
instantiated
|
instantiated
|
||||||
}
|
}
|
||||||
|
|
||||||
fn instantiate_identity_into(&self, tcx: TyCtxt<'gcx, 'tcx>,
|
fn instantiate_identity_into(
|
||||||
instantiated: &mut InstantiatedPredicates<'tcx>) {
|
&self,
|
||||||
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
|
instantiated: &mut InstantiatedPredicates<'tcx>,
|
||||||
|
) {
|
||||||
if let Some(def_id) = self.parent {
|
if let Some(def_id) = self.parent {
|
||||||
tcx.predicates_of(def_id).instantiate_identity_into(tcx, instantiated);
|
tcx.predicates_of(def_id).instantiate_identity_into(tcx, instantiated);
|
||||||
}
|
}
|
||||||
instantiated.predicates.extend(self.predicates.iter().map(|&(p, _)| p))
|
instantiated.predicates.extend(self.predicates.iter().map(|&(p, _)| p))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn instantiate_supertrait(&self, tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn instantiate_supertrait(
|
||||||
poly_trait_ref: &ty::PolyTraitRef<'tcx>)
|
&self,
|
||||||
-> InstantiatedPredicates<'tcx>
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
{
|
poly_trait_ref: &ty::PolyTraitRef<'tcx>,
|
||||||
|
) -> InstantiatedPredicates<'tcx> {
|
||||||
assert_eq!(self.parent, None);
|
assert_eq!(self.parent, None);
|
||||||
InstantiatedPredicates {
|
InstantiatedPredicates {
|
||||||
predicates: self.predicates.iter().map(|(pred, _)| {
|
predicates: self.predicates.iter().map(|(pred, _)| {
|
||||||
|
@ -1134,10 +1148,11 @@ impl<'gcx, 'tcx> Predicate<'tcx> {
|
||||||
/// poly-trait-ref holds. This is slightly different from a normal
|
/// poly-trait-ref holds. This is slightly different from a normal
|
||||||
/// substitution in terms of what happens with bound regions. See
|
/// substitution in terms of what happens with bound regions. See
|
||||||
/// lengthy comment below for details.
|
/// lengthy comment below for details.
|
||||||
pub fn subst_supertrait(&self, tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn subst_supertrait(
|
||||||
trait_ref: &ty::PolyTraitRef<'tcx>)
|
&self,
|
||||||
-> ty::Predicate<'tcx>
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
{
|
trait_ref: &ty::PolyTraitRef<'tcx>,
|
||||||
|
) -> ty::Predicate<'tcx> {
|
||||||
// The interaction between HRTB and supertraits is not entirely
|
// The interaction between HRTB and supertraits is not entirely
|
||||||
// obvious. Let me walk you (and myself) through an example.
|
// obvious. Let me walk you (and myself) through an example.
|
||||||
//
|
//
|
||||||
|
@ -2140,7 +2155,6 @@ impl ReprOptions {
|
||||||
pub fn inhibit_union_abi_opt(&self) -> bool {
|
pub fn inhibit_union_abi_opt(&self) -> bool {
|
||||||
self.c()
|
self.c()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'gcx, 'tcx> AdtDef {
|
impl<'gcx, 'tcx> AdtDef {
|
||||||
|
@ -2150,7 +2164,7 @@ impl<'gcx, 'tcx> AdtDef {
|
||||||
did: DefId,
|
did: DefId,
|
||||||
kind: AdtKind,
|
kind: AdtKind,
|
||||||
variants: IndexVec<VariantIdx, VariantDef>,
|
variants: IndexVec<VariantIdx, VariantDef>,
|
||||||
repr: ReprOptions
|
repr: ReprOptions,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
debug!("AdtDef::new({:?}, {:?}, {:?}, {:?})", did, kind, variants, repr);
|
debug!("AdtDef::new({:?}, {:?}, {:?}, {:?})", did, kind, variants, repr);
|
||||||
let mut flags = AdtFlags::NO_ADT_FLAGS;
|
let mut flags = AdtFlags::NO_ADT_FLAGS;
|
||||||
|
@ -2427,10 +2441,11 @@ impl<'gcx, 'tcx> AdtDef {
|
||||||
/// discriminant (the last one before the requested variant),
|
/// discriminant (the last one before the requested variant),
|
||||||
/// assuming there are no constant-evaluation errors there.
|
/// assuming there are no constant-evaluation errors there.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn discriminant_for_variant(&self,
|
pub fn discriminant_for_variant(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
&self,
|
||||||
variant_index: VariantIdx)
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
-> Discr<'tcx> {
|
variant_index: VariantIdx,
|
||||||
|
) -> Discr<'tcx> {
|
||||||
let (val, offset) = self.discriminant_def_for_variant(variant_index);
|
let (val, offset) = self.discriminant_def_for_variant(variant_index);
|
||||||
let explicit_value = val
|
let explicit_value = val
|
||||||
.and_then(|expr_did| self.eval_explicit_discr(tcx, expr_did))
|
.and_then(|expr_did| self.eval_explicit_discr(tcx, expr_did))
|
||||||
|
@ -2483,10 +2498,7 @@ impl<'gcx, 'tcx> AdtDef {
|
||||||
tcx.adt_sized_constraint(self.did).0
|
tcx.adt_sized_constraint(self.did).0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sized_constraint_for_ty(&self,
|
fn sized_constraint_for_ty(&self, tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> Vec<Ty<'tcx>> {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
|
||||||
ty: Ty<'tcx>)
|
|
||||||
-> Vec<Ty<'tcx>> {
|
|
||||||
let result = match ty.sty {
|
let result = match ty.sty {
|
||||||
Bool | Char | Int(..) | Uint(..) | Float(..) |
|
Bool | Char | Int(..) | Uint(..) | Float(..) |
|
||||||
RawPtr(..) | Ref(..) | FnDef(..) | FnPtr(_) |
|
RawPtr(..) | Ref(..) | FnDef(..) | FnPtr(_) |
|
||||||
|
@ -2763,9 +2775,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
|
||||||
/// Returns an iterator of the `DefId`s for all body-owners in this
|
/// Returns an iterator of the `DefId`s for all body-owners in this
|
||||||
/// crate. If you would prefer to iterate over the bodies
|
/// crate. If you would prefer to iterate over the bodies
|
||||||
/// themselves, you can do `self.hir().krate().body_ids.iter()`.
|
/// themselves, you can do `self.hir().krate().body_ids.iter()`.
|
||||||
pub fn body_owners(
|
pub fn body_owners(self) -> impl Iterator<Item = DefId> + Captures<'gcx> + 'tcx {
|
||||||
self,
|
|
||||||
) -> impl Iterator<Item = DefId> + Captures<'gcx> + 'tcx {
|
|
||||||
self.hir().krate()
|
self.hir().krate()
|
||||||
.body_ids
|
.body_ids
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -2889,10 +2899,7 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn associated_items(
|
pub fn associated_items(self, def_id: DefId) -> AssocItemsIterator<'gcx, 'tcx> {
|
||||||
self,
|
|
||||||
def_id: DefId,
|
|
||||||
) -> AssocItemsIterator<'gcx, 'tcx> {
|
|
||||||
// Ideally, we would use `-> impl Iterator` here, but it falls
|
// Ideally, we would use `-> impl Iterator` here, but it falls
|
||||||
// afoul of the conservative "capture [restrictions]" we put
|
// afoul of the conservative "capture [restrictions]" we put
|
||||||
// in place, so we use a hand-written iterator.
|
// in place, so we use a hand-written iterator.
|
||||||
|
@ -3176,9 +3183,7 @@ pub struct AdtSizedConstraint<'tcx>(pub &'tcx [Ty<'tcx>]);
|
||||||
/// such.
|
/// such.
|
||||||
/// - a Error, if a type contained itself. The representability
|
/// - a Error, if a type contained itself. The representability
|
||||||
/// check should catch this case.
|
/// check should catch this case.
|
||||||
fn adt_sized_constraint<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn adt_sized_constraint<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> AdtSizedConstraint<'tcx> {
|
||||||
def_id: DefId)
|
|
||||||
-> AdtSizedConstraint<'tcx> {
|
|
||||||
let def = tcx.adt_def(def_id);
|
let def = tcx.adt_def(def_id);
|
||||||
|
|
||||||
let result = tcx.mk_type_list(def.variants.iter().flat_map(|v| {
|
let result = tcx.mk_type_list(def.variants.iter().flat_map(|v| {
|
||||||
|
@ -3192,9 +3197,7 @@ fn adt_sized_constraint<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
AdtSizedConstraint(result)
|
AdtSizedConstraint(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn associated_item_def_ids<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn associated_item_def_ids<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> &'tcx [DefId] {
|
||||||
def_id: DefId)
|
|
||||||
-> &'tcx [DefId] {
|
|
||||||
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||||
let item = tcx.hir().expect_item_by_hir_id(id);
|
let item = tcx.hir().expect_item_by_hir_id(id);
|
||||||
match item.node {
|
match item.node {
|
||||||
|
@ -3247,10 +3250,7 @@ pub fn is_impl_trait_defn(tcx: TyCtxt<'_, '_>, def_id: DefId) -> Option<DefId> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See `ParamEnv` struct definition for details.
|
/// See `ParamEnv` struct definition for details.
|
||||||
fn param_env<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn param_env<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> ParamEnv<'tcx> {
|
||||||
def_id: DefId)
|
|
||||||
-> ParamEnv<'tcx>
|
|
||||||
{
|
|
||||||
// The param_env of an impl Trait type is its defining function's param_env
|
// The param_env of an impl Trait type is its defining function's param_env
|
||||||
if let Some(parent) = is_impl_trait_defn(tcx, def_id) {
|
if let Some(parent) = is_impl_trait_defn(tcx, def_id) {
|
||||||
return param_env(tcx, parent);
|
return param_env(tcx, parent);
|
||||||
|
@ -3285,28 +3285,25 @@ fn param_env<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
traits::normalize_param_env_or_error(tcx, def_id, unnormalized_env, cause)
|
traits::normalize_param_env_or_error(tcx, def_id, unnormalized_env, cause)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn crate_disambiguator<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn crate_disambiguator<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, crate_num: CrateNum) -> CrateDisambiguator {
|
||||||
crate_num: CrateNum) -> CrateDisambiguator {
|
|
||||||
assert_eq!(crate_num, LOCAL_CRATE);
|
assert_eq!(crate_num, LOCAL_CRATE);
|
||||||
tcx.sess.local_crate_disambiguator()
|
tcx.sess.local_crate_disambiguator()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn original_crate_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn original_crate_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, crate_num: CrateNum) -> Symbol {
|
||||||
crate_num: CrateNum) -> Symbol {
|
|
||||||
assert_eq!(crate_num, LOCAL_CRATE);
|
assert_eq!(crate_num, LOCAL_CRATE);
|
||||||
tcx.crate_name.clone()
|
tcx.crate_name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn crate_hash<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn crate_hash<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, crate_num: CrateNum) -> Svh {
|
||||||
crate_num: CrateNum)
|
|
||||||
-> Svh {
|
|
||||||
assert_eq!(crate_num, LOCAL_CRATE);
|
assert_eq!(crate_num, LOCAL_CRATE);
|
||||||
tcx.hir().crate_hash
|
tcx.hir().crate_hash
|
||||||
}
|
}
|
||||||
|
|
||||||
fn instance_def_size_estimate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn instance_def_size_estimate<'tcx>(
|
||||||
instance_def: InstanceDef<'tcx>)
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
-> usize {
|
instance_def: InstanceDef<'tcx>,
|
||||||
|
) -> usize {
|
||||||
match instance_def {
|
match instance_def {
|
||||||
InstanceDef::Item(..) |
|
InstanceDef::Item(..) |
|
||||||
InstanceDef::DropGlue(..) => {
|
InstanceDef::DropGlue(..) => {
|
||||||
|
@ -3321,10 +3318,7 @@ fn instance_def_size_estimate<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
/// If `def_id` is an issue 33140 hack impl, returns its self type; otherwise, returns `None`.
|
/// If `def_id` is an issue 33140 hack impl, returns its self type; otherwise, returns `None`.
|
||||||
///
|
///
|
||||||
/// See [`ImplOverlapKind::Issue33140`] for more details.
|
/// See [`ImplOverlapKind::Issue33140`] for more details.
|
||||||
fn issue33140_self_ty<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn issue33140_self_ty<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Option<Ty<'tcx>> {
|
||||||
def_id: DefId)
|
|
||||||
-> Option<Ty<'tcx>>
|
|
||||||
{
|
|
||||||
debug!("issue33140_self_ty({:?})", def_id);
|
debug!("issue33140_self_ty({:?})", def_id);
|
||||||
|
|
||||||
let trait_ref = tcx.impl_trait_ref(def_id).unwrap_or_else(|| {
|
let trait_ref = tcx.impl_trait_ref(def_id).unwrap_or_else(|| {
|
||||||
|
|
|
@ -54,14 +54,12 @@ pub(crate) trait QueryDescription<'tcx>: QueryAccessors<'tcx> {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_load_from_disk(_: TyCtxt<'tcx, 'tcx>,
|
fn try_load_from_disk(_: TyCtxt<'tcx, 'tcx>, _: SerializedDepNodeIndex) -> Option<Self::Value> {
|
||||||
_: SerializedDepNodeIndex)
|
|
||||||
-> Option<Self::Value> {
|
|
||||||
bug!("QueryDescription::load_from_disk() called for an unsupported query.")
|
bug!("QueryDescription::load_from_disk() called for an unsupported query.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, M: QueryAccessors<'tcx, Key=DefId>> QueryDescription<'tcx> for M {
|
impl<'tcx, M: QueryAccessors<'tcx, Key = DefId>> QueryDescription<'tcx> for M {
|
||||||
default fn describe(tcx: TyCtxt<'_, '_>, def_id: DefId) -> Cow<'static, str> {
|
default fn describe(tcx: TyCtxt<'_, '_>, def_id: DefId) -> Cow<'static, str> {
|
||||||
if !tcx.sess.verbose() {
|
if !tcx.sess.verbose() {
|
||||||
format!("processing `{}`", tcx.def_path_str(def_id)).into()
|
format!("processing `{}`", tcx.def_path_str(def_id)).into()
|
||||||
|
|
|
@ -340,7 +340,7 @@ fn connected_to_root<'tcx>(
|
||||||
fn pick_query<'a, 'tcx, T, F: Fn(&T) -> (Span, Lrc<QueryJob<'tcx>>)>(
|
fn pick_query<'a, 'tcx, T, F: Fn(&T) -> (Span, Lrc<QueryJob<'tcx>>)>(
|
||||||
tcx: TyCtxt<'tcx, '_>,
|
tcx: TyCtxt<'tcx, '_>,
|
||||||
queries: &'a [T],
|
queries: &'a [T],
|
||||||
f: F
|
f: F,
|
||||||
) -> &'a T {
|
) -> &'a T {
|
||||||
// Deterministically pick an entry point
|
// Deterministically pick an entry point
|
||||||
// FIXME: Sort this instead
|
// FIXME: Sort this instead
|
||||||
|
@ -366,7 +366,7 @@ fn pick_query<'a, 'tcx, T, F: Fn(&T) -> (Span, Lrc<QueryJob<'tcx>>)>(
|
||||||
fn remove_cycle<'tcx>(
|
fn remove_cycle<'tcx>(
|
||||||
jobs: &mut Vec<Lrc<QueryJob<'tcx>>>,
|
jobs: &mut Vec<Lrc<QueryJob<'tcx>>>,
|
||||||
wakelist: &mut Vec<Lrc<QueryWaiter<'tcx>>>,
|
wakelist: &mut Vec<Lrc<QueryWaiter<'tcx>>>,
|
||||||
tcx: TyCtxt<'tcx, '_>
|
tcx: TyCtxt<'tcx, '_>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut visited = FxHashSet::default();
|
let mut visited = FxHashSet::default();
|
||||||
let mut stack = Vec::new();
|
let mut stack = Vec::new();
|
||||||
|
|
|
@ -136,7 +136,7 @@ impl<'tcx> Key for (&'tcx ty::Const<'tcx>, mir::Field) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Key for ty::PolyTraitRef<'tcx>{
|
impl<'tcx> Key for ty::PolyTraitRef<'tcx> {
|
||||||
fn query_crate(&self) -> CrateNum {
|
fn query_crate(&self) -> CrateNum {
|
||||||
self.def_id().krate
|
self.def_id().krate
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,12 +156,14 @@ impl<'sess> OnDiskCache<'sess> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn serialize<'tcx, E>(&self,
|
pub fn serialize<'tcx, E>(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
&self,
|
||||||
encoder: &mut E)
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
-> Result<(), E::Error>
|
encoder: &mut E,
|
||||||
where E: ty_codec::TyEncoder
|
) -> Result<(), E::Error>
|
||||||
{
|
where
|
||||||
|
E: ty_codec::TyEncoder,
|
||||||
|
{
|
||||||
// Serializing the DepGraph should not modify it:
|
// Serializing the DepGraph should not modify it:
|
||||||
tcx.dep_graph.with_ignore(|| {
|
tcx.dep_graph.with_ignore(|| {
|
||||||
// Allocate SourceFileIndices
|
// Allocate SourceFileIndices
|
||||||
|
@ -326,10 +328,11 @@ impl<'sess> OnDiskCache<'sess> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loads a diagnostic emitted during the previous compilation session.
|
/// Loads a diagnostic emitted during the previous compilation session.
|
||||||
pub fn load_diagnostics<'tcx>(&self,
|
pub fn load_diagnostics<'tcx>(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
&self,
|
||||||
dep_node_index: SerializedDepNodeIndex)
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
-> Vec<Diagnostic> {
|
dep_node_index: SerializedDepNodeIndex,
|
||||||
|
) -> Vec<Diagnostic> {
|
||||||
let diagnostics: Option<EncodedDiagnostics> = self.load_indexed(
|
let diagnostics: Option<EncodedDiagnostics> = self.load_indexed(
|
||||||
tcx,
|
tcx,
|
||||||
dep_node_index,
|
dep_node_index,
|
||||||
|
@ -354,11 +357,13 @@ impl<'sess> OnDiskCache<'sess> {
|
||||||
|
|
||||||
/// Returns the cached query result if there is something in the cache for
|
/// Returns the cached query result if there is something in the cache for
|
||||||
/// the given `SerializedDepNodeIndex`; otherwise returns `None`.
|
/// the given `SerializedDepNodeIndex`; otherwise returns `None`.
|
||||||
pub fn try_load_query_result<'tcx, T>(&self,
|
pub fn try_load_query_result<'tcx, T>(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
&self,
|
||||||
dep_node_index: SerializedDepNodeIndex)
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
-> Option<T>
|
dep_node_index: SerializedDepNodeIndex,
|
||||||
where T: Decodable
|
) -> Option<T>
|
||||||
|
where
|
||||||
|
T: Decodable,
|
||||||
{
|
{
|
||||||
self.load_indexed(tcx,
|
self.load_indexed(tcx,
|
||||||
dep_node_index,
|
dep_node_index,
|
||||||
|
@ -382,14 +387,15 @@ impl<'sess> OnDiskCache<'sess> {
|
||||||
x.extend(Into::<Vec<_>>::into(diagnostics));
|
x.extend(Into::<Vec<_>>::into(diagnostics));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_indexed<'tcx, T>(&self,
|
fn load_indexed<'tcx, T>(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
&self,
|
||||||
dep_node_index: SerializedDepNodeIndex,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
index: &FxHashMap<SerializedDepNodeIndex,
|
dep_node_index: SerializedDepNodeIndex,
|
||||||
AbsoluteBytePos>,
|
index: &FxHashMap<SerializedDepNodeIndex, AbsoluteBytePos>,
|
||||||
debug_tag: &'static str)
|
debug_tag: &'static str,
|
||||||
-> Option<T>
|
) -> Option<T>
|
||||||
where T: Decodable
|
where
|
||||||
|
T: Decodable,
|
||||||
{
|
{
|
||||||
let pos = index.get(&dep_node_index).cloned()?;
|
let pos = index.get(&dep_node_index).cloned()?;
|
||||||
|
|
||||||
|
@ -423,10 +429,10 @@ impl<'sess> OnDiskCache<'sess> {
|
||||||
// current-session-CrateNum. There might be CrateNums from the previous
|
// current-session-CrateNum. There might be CrateNums from the previous
|
||||||
// Session that don't occur in the current one. For these, the mapping
|
// Session that don't occur in the current one. For these, the mapping
|
||||||
// maps to None.
|
// maps to None.
|
||||||
fn compute_cnum_map(tcx: TyCtxt<'_, '_>,
|
fn compute_cnum_map(
|
||||||
prev_cnums: &[(u32, String, CrateDisambiguator)])
|
tcx: TyCtxt<'_, '_>,
|
||||||
-> IndexVec<CrateNum, Option<CrateNum>>
|
prev_cnums: &[(u32, String, CrateDisambiguator)],
|
||||||
{
|
) -> IndexVec<CrateNum, Option<CrateNum>> {
|
||||||
tcx.dep_graph.with_ignore(|| {
|
tcx.dep_graph.with_ignore(|| {
|
||||||
let current_cnums = tcx.all_crate_nums(LOCAL_CRATE).iter().map(|&cnum| {
|
let current_cnums = tcx.all_crate_nums(LOCAL_CRATE).iter().map(|&cnum| {
|
||||||
let crate_name = tcx.original_crate_name(cnum)
|
let crate_name = tcx.original_crate_name(cnum)
|
||||||
|
@ -524,7 +530,6 @@ fn decode_tagged<'a, 'tcx, D, T, V>(decoder: &mut D,
|
||||||
Ok(value)
|
Ok(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl<'a, 'tcx> ty_codec::TyDecoder<'tcx> for CacheDecoder<'a, 'tcx> {
|
impl<'a, 'tcx> ty_codec::TyDecoder<'tcx> for CacheDecoder<'a, 'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
|
fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
|
||||||
|
@ -583,7 +588,7 @@ impl<'a, 'tcx> ty_codec::TyDecoder<'tcx> for CacheDecoder<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
implement_ty_decoder!( CacheDecoder<'a, 'tcx> );
|
implement_ty_decoder!(CacheDecoder<'a, 'tcx>);
|
||||||
|
|
||||||
impl<'a, 'tcx> SpecializedDecoder<interpret::AllocId> for CacheDecoder<'a, 'tcx> {
|
impl<'a, 'tcx> SpecializedDecoder<interpret::AllocId> for CacheDecoder<'a, 'tcx> {
|
||||||
fn specialized_decode(&mut self) -> Result<interpret::AllocId, Self::Error> {
|
fn specialized_decode(&mut self) -> Result<interpret::AllocId, Self::Error> {
|
||||||
|
@ -724,7 +729,8 @@ impl<'a, 'tcx> SpecializedDecoder<Fingerprint> for CacheDecoder<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, T: Decodable> SpecializedDecoder<mir::ClearCrossCrate<T>>
|
impl<'a, 'tcx, T: Decodable> SpecializedDecoder<mir::ClearCrossCrate<T>>
|
||||||
for CacheDecoder<'a, 'tcx> {
|
for CacheDecoder<'a, 'tcx>
|
||||||
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn specialized_decode(&mut self) -> Result<mir::ClearCrossCrate<T>, Self::Error> {
|
fn specialized_decode(&mut self) -> Result<mir::ClearCrossCrate<T>, Self::Error> {
|
||||||
let discr = u8::decode(self)?;
|
let discr = u8::decode(self)?;
|
||||||
|
@ -757,7 +763,8 @@ struct CacheEncoder<'a, 'tcx, E: ty_codec::TyEncoder> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, E> CacheEncoder<'a, 'tcx, E>
|
impl<'a, 'tcx, E> CacheEncoder<'a, 'tcx, E>
|
||||||
where E: 'a + ty_codec::TyEncoder
|
where
|
||||||
|
E: 'a + ty_codec::TyEncoder,
|
||||||
{
|
{
|
||||||
fn source_file_index(&mut self, source_file: Lrc<SourceFile>) -> SourceFileIndex {
|
fn source_file_index(&mut self, source_file: Lrc<SourceFile>) -> SourceFileIndex {
|
||||||
self.file_to_file_index[&(&*source_file as *const SourceFile)]
|
self.file_to_file_index[&(&*source_file as *const SourceFile)]
|
||||||
|
@ -784,7 +791,8 @@ impl<'a, 'tcx, E> CacheEncoder<'a, 'tcx, E>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, E> SpecializedEncoder<interpret::AllocId> for CacheEncoder<'a, 'tcx, E>
|
impl<'a, 'tcx, E> SpecializedEncoder<interpret::AllocId> for CacheEncoder<'a, 'tcx, E>
|
||||||
where E: 'a + ty_codec::TyEncoder
|
where
|
||||||
|
E: 'a + ty_codec::TyEncoder,
|
||||||
{
|
{
|
||||||
fn specialized_encode(&mut self, alloc_id: &interpret::AllocId) -> Result<(), Self::Error> {
|
fn specialized_encode(&mut self, alloc_id: &interpret::AllocId) -> Result<(), Self::Error> {
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
|
@ -803,7 +811,8 @@ impl<'a, 'tcx, E> SpecializedEncoder<interpret::AllocId> for CacheEncoder<'a, 't
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, E> SpecializedEncoder<Span> for CacheEncoder<'a, 'tcx, E>
|
impl<'a, 'tcx, E> SpecializedEncoder<Span> for CacheEncoder<'a, 'tcx, E>
|
||||||
where E: 'a + ty_codec::TyEncoder
|
where
|
||||||
|
E: 'a + ty_codec::TyEncoder,
|
||||||
{
|
{
|
||||||
fn specialized_encode(&mut self, span: &Span) -> Result<(), Self::Error> {
|
fn specialized_encode(&mut self, span: &Span) -> Result<(), Self::Error> {
|
||||||
|
|
||||||
|
@ -859,7 +868,8 @@ impl<'a, 'tcx, E> SpecializedEncoder<Span> for CacheEncoder<'a, 'tcx, E>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, E> ty_codec::TyEncoder for CacheEncoder<'a, 'tcx, E>
|
impl<'a, 'tcx, E> ty_codec::TyEncoder for CacheEncoder<'a, 'tcx, E>
|
||||||
where E: 'a + ty_codec::TyEncoder
|
where
|
||||||
|
E: 'a + ty_codec::TyEncoder,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn position(&self) -> usize {
|
fn position(&self) -> usize {
|
||||||
|
@ -868,7 +878,8 @@ impl<'a, 'tcx, E> ty_codec::TyEncoder for CacheEncoder<'a, 'tcx, E>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, E> SpecializedEncoder<CrateNum> for CacheEncoder<'a, 'tcx, E>
|
impl<'a, 'tcx, E> SpecializedEncoder<CrateNum> for CacheEncoder<'a, 'tcx, E>
|
||||||
where E: 'a + ty_codec::TyEncoder
|
where
|
||||||
|
E: 'a + ty_codec::TyEncoder,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn specialized_encode(&mut self, cnum: &CrateNum) -> Result<(), Self::Error> {
|
fn specialized_encode(&mut self, cnum: &CrateNum) -> Result<(), Self::Error> {
|
||||||
|
@ -877,7 +888,8 @@ impl<'a, 'tcx, E> SpecializedEncoder<CrateNum> for CacheEncoder<'a, 'tcx, E>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, E> SpecializedEncoder<Ty<'tcx>> for CacheEncoder<'a, 'tcx, E>
|
impl<'a, 'tcx, E> SpecializedEncoder<Ty<'tcx>> for CacheEncoder<'a, 'tcx, E>
|
||||||
where E: 'a + ty_codec::TyEncoder
|
where
|
||||||
|
E: 'a + ty_codec::TyEncoder,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn specialized_encode(&mut self, ty: &Ty<'tcx>) -> Result<(), Self::Error> {
|
fn specialized_encode(&mut self, ty: &Ty<'tcx>) -> Result<(), Self::Error> {
|
||||||
|
@ -886,9 +898,9 @@ impl<'a, 'tcx, E> SpecializedEncoder<Ty<'tcx>> for CacheEncoder<'a, 'tcx, E>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, E> SpecializedEncoder<ty::GenericPredicates<'tcx>>
|
impl<'a, 'tcx, E> SpecializedEncoder<ty::GenericPredicates<'tcx>> for CacheEncoder<'a, 'tcx, E>
|
||||||
for CacheEncoder<'a, 'tcx, E>
|
where
|
||||||
where E: 'a + ty_codec::TyEncoder
|
E: 'a + ty_codec::TyEncoder,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn specialized_encode(&mut self,
|
fn specialized_encode(&mut self,
|
||||||
|
@ -900,7 +912,8 @@ impl<'a, 'tcx, E> SpecializedEncoder<ty::GenericPredicates<'tcx>>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, E> SpecializedEncoder<hir::HirId> for CacheEncoder<'a, 'tcx, E>
|
impl<'a, 'tcx, E> SpecializedEncoder<hir::HirId> for CacheEncoder<'a, 'tcx, E>
|
||||||
where E: 'a + ty_codec::TyEncoder
|
where
|
||||||
|
E: 'a + ty_codec::TyEncoder,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn specialized_encode(&mut self, id: &hir::HirId) -> Result<(), Self::Error> {
|
fn specialized_encode(&mut self, id: &hir::HirId) -> Result<(), Self::Error> {
|
||||||
|
@ -916,9 +929,9 @@ impl<'a, 'tcx, E> SpecializedEncoder<hir::HirId> for CacheEncoder<'a, 'tcx, E>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl<'a, 'tcx, E> SpecializedEncoder<DefId> for CacheEncoder<'a, 'tcx, E>
|
impl<'a, 'tcx, E> SpecializedEncoder<DefId> for CacheEncoder<'a, 'tcx, E>
|
||||||
where E: 'a + ty_codec::TyEncoder
|
where
|
||||||
|
E: 'a + ty_codec::TyEncoder,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn specialized_encode(&mut self, id: &DefId) -> Result<(), Self::Error> {
|
fn specialized_encode(&mut self, id: &DefId) -> Result<(), Self::Error> {
|
||||||
|
@ -928,7 +941,8 @@ impl<'a, 'tcx, E> SpecializedEncoder<DefId> for CacheEncoder<'a, 'tcx, E>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, E> SpecializedEncoder<LocalDefId> for CacheEncoder<'a, 'tcx, E>
|
impl<'a, 'tcx, E> SpecializedEncoder<LocalDefId> for CacheEncoder<'a, 'tcx, E>
|
||||||
where E: 'a + ty_codec::TyEncoder
|
where
|
||||||
|
E: 'a + ty_codec::TyEncoder,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn specialized_encode(&mut self, id: &LocalDefId) -> Result<(), Self::Error> {
|
fn specialized_encode(&mut self, id: &LocalDefId) -> Result<(), Self::Error> {
|
||||||
|
@ -937,7 +951,8 @@ impl<'a, 'tcx, E> SpecializedEncoder<LocalDefId> for CacheEncoder<'a, 'tcx, E>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, E> SpecializedEncoder<DefIndex> for CacheEncoder<'a, 'tcx, E>
|
impl<'a, 'tcx, E> SpecializedEncoder<DefIndex> for CacheEncoder<'a, 'tcx, E>
|
||||||
where E: 'a + ty_codec::TyEncoder
|
where
|
||||||
|
E: 'a + ty_codec::TyEncoder,
|
||||||
{
|
{
|
||||||
fn specialized_encode(&mut self, _: &DefIndex) -> Result<(), Self::Error> {
|
fn specialized_encode(&mut self, _: &DefIndex) -> Result<(), Self::Error> {
|
||||||
bug!("Encoding DefIndex without context.")
|
bug!("Encoding DefIndex without context.")
|
||||||
|
@ -947,7 +962,8 @@ impl<'a, 'tcx, E> SpecializedEncoder<DefIndex> for CacheEncoder<'a, 'tcx, E>
|
||||||
// NodeIds are not stable across compilation sessions, so we store them in their
|
// NodeIds are not stable across compilation sessions, so we store them in their
|
||||||
// HirId representation. This allows use to map them to the current NodeId.
|
// HirId representation. This allows use to map them to the current NodeId.
|
||||||
impl<'a, 'tcx, E> SpecializedEncoder<NodeId> for CacheEncoder<'a, 'tcx, E>
|
impl<'a, 'tcx, E> SpecializedEncoder<NodeId> for CacheEncoder<'a, 'tcx, E>
|
||||||
where E: 'a + ty_codec::TyEncoder
|
where
|
||||||
|
E: 'a + ty_codec::TyEncoder,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn specialized_encode(&mut self, node_id: &NodeId) -> Result<(), Self::Error> {
|
fn specialized_encode(&mut self, node_id: &NodeId) -> Result<(), Self::Error> {
|
||||||
|
@ -956,18 +972,16 @@ impl<'a, 'tcx, E> SpecializedEncoder<NodeId> for CacheEncoder<'a, 'tcx, E>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> SpecializedEncoder<Fingerprint>
|
impl<'a, 'tcx> SpecializedEncoder<Fingerprint> for CacheEncoder<'a, 'tcx, opaque::Encoder> {
|
||||||
for CacheEncoder<'a, 'tcx, opaque::Encoder>
|
|
||||||
{
|
|
||||||
fn specialized_encode(&mut self, f: &Fingerprint) -> Result<(), Self::Error> {
|
fn specialized_encode(&mut self, f: &Fingerprint) -> Result<(), Self::Error> {
|
||||||
f.encode_opaque(&mut self.encoder)
|
f.encode_opaque(&mut self.encoder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, E, T> SpecializedEncoder<mir::ClearCrossCrate<T>>
|
impl<'a, 'tcx, E, T> SpecializedEncoder<mir::ClearCrossCrate<T>> for CacheEncoder<'a, 'tcx, E>
|
||||||
for CacheEncoder<'a, 'tcx, E>
|
where
|
||||||
where E: 'a + ty_codec::TyEncoder,
|
E: 'a + ty_codec::TyEncoder,
|
||||||
T: Encodable,
|
T: Encodable,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn specialized_encode(&mut self,
|
fn specialized_encode(&mut self,
|
||||||
|
@ -994,7 +1008,8 @@ macro_rules! encoder_methods {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, E> Encoder for CacheEncoder<'a, 'tcx, E>
|
impl<'a, 'tcx, E> Encoder for CacheEncoder<'a, 'tcx, E>
|
||||||
where E: 'a + ty_codec::TyEncoder
|
where
|
||||||
|
E: 'a + ty_codec::TyEncoder,
|
||||||
{
|
{
|
||||||
type Error = E::Error;
|
type Error = E::Error;
|
||||||
|
|
||||||
|
@ -1064,13 +1079,15 @@ impl<'a> SpecializedDecoder<IntEncodedWithFixedSize> for opaque::Decoder<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_query_results<'a, 'tcx, Q, E>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn encode_query_results<'a, 'tcx, Q, E>(
|
||||||
encoder: &mut CacheEncoder<'a, 'tcx, E>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
query_result_index: &mut EncodedQueryResultIndex)
|
encoder: &mut CacheEncoder<'a, 'tcx, E>,
|
||||||
-> Result<(), E::Error>
|
query_result_index: &mut EncodedQueryResultIndex,
|
||||||
where Q: super::config::QueryDescription<'tcx>,
|
) -> Result<(), E::Error>
|
||||||
E: 'a + TyEncoder,
|
where
|
||||||
Q::Value: Encodable,
|
Q: super::config::QueryDescription<'tcx>,
|
||||||
|
E: 'a + TyEncoder,
|
||||||
|
Q::Value: Encodable,
|
||||||
{
|
{
|
||||||
let desc = &format!("encode_query_results for {}",
|
let desc = &format!("encode_query_results for {}",
|
||||||
unsafe { ::std::intrinsics::type_name::<Q>() });
|
unsafe { ::std::intrinsics::type_name::<Q>() });
|
||||||
|
|
|
@ -256,10 +256,10 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
|
||||||
self,
|
self,
|
||||||
job: Lrc<QueryJob<'gcx>>,
|
job: Lrc<QueryJob<'gcx>>,
|
||||||
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
|
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
|
||||||
compute: F)
|
compute: F,
|
||||||
-> R
|
) -> R
|
||||||
where
|
where
|
||||||
F: for<'lcx> FnOnce(TyCtxt<'gcx, 'lcx>) -> R
|
F: for<'lcx> FnOnce(TyCtxt<'gcx, 'lcx>) -> R,
|
||||||
{
|
{
|
||||||
// The TyCtxt stored in TLS has the same global interner lifetime
|
// The TyCtxt stored in TLS has the same global interner lifetime
|
||||||
// as `self`, so we use `with_related_context` to relate the 'gcx lifetimes
|
// as `self`, so we use `with_related_context` to relate the 'gcx lifetimes
|
||||||
|
@ -285,9 +285,8 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
|
||||||
#[cold]
|
#[cold]
|
||||||
pub(super) fn report_cycle(
|
pub(super) fn report_cycle(
|
||||||
self,
|
self,
|
||||||
CycleError { usage, cycle: stack }: CycleError<'gcx>
|
CycleError { usage, cycle: stack }: CycleError<'gcx>,
|
||||||
) -> DiagnosticBuilder<'tcx>
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
{
|
|
||||||
assert!(!stack.is_empty());
|
assert!(!stack.is_empty());
|
||||||
|
|
||||||
let fix_span = |span: Span, query: &Query<'gcx>| {
|
let fix_span = |span: Span, query: &Query<'gcx>| {
|
||||||
|
@ -1148,10 +1147,7 @@ macro_rules! define_provider_struct {
|
||||||
/// then `force_from_dep_node()` should not fail for it. Otherwise, you can just
|
/// then `force_from_dep_node()` should not fail for it. Otherwise, you can just
|
||||||
/// add it to the "We don't have enough information to reconstruct..." group in
|
/// add it to the "We don't have enough information to reconstruct..." group in
|
||||||
/// the match below.
|
/// the match below.
|
||||||
pub fn force_from_dep_node<'tcx>(
|
pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, dep_node: &DepNode) -> bool {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
|
||||||
dep_node: &DepNode
|
|
||||||
) -> bool {
|
|
||||||
use crate::dep_graph::RecoverKey;
|
use crate::dep_graph::RecoverKey;
|
||||||
|
|
||||||
// We must avoid ever having to call force_from_dep_node() for a
|
// We must avoid ever having to call force_from_dep_node() for a
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub enum Cause {
|
||||||
ExistentialRegionBound, // relating an existential region bound
|
ExistentialRegionBound, // relating an existential region bound
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait TypeRelation<'gcx: 'tcx, 'tcx> : Sized {
|
pub trait TypeRelation<'gcx: 'tcx, 'tcx>: Sized {
|
||||||
fn tcx(&self) -> TyCtxt<'gcx, 'tcx>;
|
fn tcx(&self) -> TyCtxt<'gcx, 'tcx>;
|
||||||
|
|
||||||
/// Returns a static string we can use for printouts.
|
/// Returns a static string we can use for printouts.
|
||||||
|
@ -94,20 +94,26 @@ pub trait TypeRelation<'gcx: 'tcx, 'tcx> : Sized {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Relate<'tcx>: TypeFoldable<'tcx> {
|
pub trait Relate<'tcx>: TypeFoldable<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R, a: &Self, b: &Self)
|
fn relate<'a, 'gcx, R>(relation: &mut R, a: &Self, b: &Self) -> RelateResult<'tcx, Self>
|
||||||
-> RelateResult<'tcx, Self>
|
where
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a;
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Relate impls
|
// Relate impls
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for ty::TypeAndMut<'tcx> {
|
impl<'tcx> Relate<'tcx> for ty::TypeAndMut<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &ty::TypeAndMut<'tcx>,
|
relation: &mut R,
|
||||||
b: &ty::TypeAndMut<'tcx>)
|
a: &ty::TypeAndMut<'tcx>,
|
||||||
-> RelateResult<'tcx, ty::TypeAndMut<'tcx>>
|
b: &ty::TypeAndMut<'tcx>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, ty::TypeAndMut<'tcx>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
debug!("{}.mts({:?}, {:?})",
|
debug!("{}.mts({:?}, {:?})",
|
||||||
relation.tag(),
|
relation.tag(),
|
||||||
|
@ -127,12 +133,16 @@ impl<'tcx> Relate<'tcx> for ty::TypeAndMut<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn relate_substs<'a, 'gcx, 'tcx, R>(relation: &mut R,
|
pub fn relate_substs<'a, 'gcx, 'tcx, R>(
|
||||||
variances: Option<&[ty::Variance]>,
|
relation: &mut R,
|
||||||
a_subst: SubstsRef<'tcx>,
|
variances: Option<&[ty::Variance]>,
|
||||||
b_subst: SubstsRef<'tcx>)
|
a_subst: SubstsRef<'tcx>,
|
||||||
-> RelateResult<'tcx, SubstsRef<'tcx>>
|
b_subst: SubstsRef<'tcx>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, SubstsRef<'tcx>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
let tcx = relation.tcx();
|
let tcx = relation.tcx();
|
||||||
|
|
||||||
|
@ -145,11 +155,15 @@ pub fn relate_substs<'a, 'gcx, 'tcx, R>(relation: &mut R,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
|
impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &ty::FnSig<'tcx>,
|
relation: &mut R,
|
||||||
b: &ty::FnSig<'tcx>)
|
a: &ty::FnSig<'tcx>,
|
||||||
-> RelateResult<'tcx, ty::FnSig<'tcx>>
|
b: &ty::FnSig<'tcx>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, ty::FnSig<'tcx>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
let tcx = relation.tcx();
|
let tcx = relation.tcx();
|
||||||
|
|
||||||
|
@ -185,11 +199,15 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for ast::Unsafety {
|
impl<'tcx> Relate<'tcx> for ast::Unsafety {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &ast::Unsafety,
|
relation: &mut R,
|
||||||
b: &ast::Unsafety)
|
a: &ast::Unsafety,
|
||||||
-> RelateResult<'tcx, ast::Unsafety>
|
b: &ast::Unsafety,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, ast::Unsafety>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
if a != b {
|
if a != b {
|
||||||
Err(TypeError::UnsafetyMismatch(expected_found(relation, a, b)))
|
Err(TypeError::UnsafetyMismatch(expected_found(relation, a, b)))
|
||||||
|
@ -200,11 +218,15 @@ impl<'tcx> Relate<'tcx> for ast::Unsafety {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for abi::Abi {
|
impl<'tcx> Relate<'tcx> for abi::Abi {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &abi::Abi,
|
relation: &mut R,
|
||||||
b: &abi::Abi)
|
a: &abi::Abi,
|
||||||
-> RelateResult<'tcx, abi::Abi>
|
b: &abi::Abi,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, abi::Abi>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
if a == b {
|
if a == b {
|
||||||
Ok(*a)
|
Ok(*a)
|
||||||
|
@ -215,11 +237,15 @@ impl<'tcx> Relate<'tcx> for abi::Abi {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for ty::ProjectionTy<'tcx> {
|
impl<'tcx> Relate<'tcx> for ty::ProjectionTy<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &ty::ProjectionTy<'tcx>,
|
relation: &mut R,
|
||||||
b: &ty::ProjectionTy<'tcx>)
|
a: &ty::ProjectionTy<'tcx>,
|
||||||
-> RelateResult<'tcx, ty::ProjectionTy<'tcx>>
|
b: &ty::ProjectionTy<'tcx>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, ty::ProjectionTy<'tcx>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
if a.item_def_id != b.item_def_id {
|
if a.item_def_id != b.item_def_id {
|
||||||
Err(TypeError::ProjectionMismatched(
|
Err(TypeError::ProjectionMismatched(
|
||||||
|
@ -235,11 +261,15 @@ impl<'tcx> Relate<'tcx> for ty::ProjectionTy<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for ty::ExistentialProjection<'tcx> {
|
impl<'tcx> Relate<'tcx> for ty::ExistentialProjection<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &ty::ExistentialProjection<'tcx>,
|
relation: &mut R,
|
||||||
b: &ty::ExistentialProjection<'tcx>)
|
a: &ty::ExistentialProjection<'tcx>,
|
||||||
-> RelateResult<'tcx, ty::ExistentialProjection<'tcx>>
|
b: &ty::ExistentialProjection<'tcx>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, ty::ExistentialProjection<'tcx>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
if a.item_def_id != b.item_def_id {
|
if a.item_def_id != b.item_def_id {
|
||||||
Err(TypeError::ProjectionMismatched(
|
Err(TypeError::ProjectionMismatched(
|
||||||
|
@ -257,11 +287,15 @@ impl<'tcx> Relate<'tcx> for ty::ExistentialProjection<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for Vec<ty::PolyExistentialProjection<'tcx>> {
|
impl<'tcx> Relate<'tcx> for Vec<ty::PolyExistentialProjection<'tcx>> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &Vec<ty::PolyExistentialProjection<'tcx>>,
|
relation: &mut R,
|
||||||
b: &Vec<ty::PolyExistentialProjection<'tcx>>)
|
a: &Vec<ty::PolyExistentialProjection<'tcx>>,
|
||||||
-> RelateResult<'tcx, Vec<ty::PolyExistentialProjection<'tcx>>>
|
b: &Vec<ty::PolyExistentialProjection<'tcx>>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, Vec<ty::PolyExistentialProjection<'tcx>>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
// To be compatible, `a` and `b` must be for precisely the
|
// To be compatible, `a` and `b` must be for precisely the
|
||||||
// same set of traits and item names. We always require that
|
// same set of traits and item names. We always require that
|
||||||
|
@ -280,11 +314,15 @@ impl<'tcx> Relate<'tcx> for Vec<ty::PolyExistentialProjection<'tcx>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for ty::TraitRef<'tcx> {
|
impl<'tcx> Relate<'tcx> for ty::TraitRef<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &ty::TraitRef<'tcx>,
|
relation: &mut R,
|
||||||
b: &ty::TraitRef<'tcx>)
|
a: &ty::TraitRef<'tcx>,
|
||||||
-> RelateResult<'tcx, ty::TraitRef<'tcx>>
|
b: &ty::TraitRef<'tcx>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, ty::TraitRef<'tcx>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
// Different traits cannot be related
|
// Different traits cannot be related
|
||||||
if a.def_id != b.def_id {
|
if a.def_id != b.def_id {
|
||||||
|
@ -297,11 +335,15 @@ impl<'tcx> Relate<'tcx> for ty::TraitRef<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for ty::ExistentialTraitRef<'tcx> {
|
impl<'tcx> Relate<'tcx> for ty::ExistentialTraitRef<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &ty::ExistentialTraitRef<'tcx>,
|
relation: &mut R,
|
||||||
b: &ty::ExistentialTraitRef<'tcx>)
|
a: &ty::ExistentialTraitRef<'tcx>,
|
||||||
-> RelateResult<'tcx, ty::ExistentialTraitRef<'tcx>>
|
b: &ty::ExistentialTraitRef<'tcx>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, ty::ExistentialTraitRef<'tcx>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
// Different traits cannot be related
|
// Different traits cannot be related
|
||||||
if a.def_id != b.def_id {
|
if a.def_id != b.def_id {
|
||||||
|
@ -323,11 +365,15 @@ TupleStructTypeFoldableImpl! {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for GeneratorWitness<'tcx> {
|
impl<'tcx> Relate<'tcx> for GeneratorWitness<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &GeneratorWitness<'tcx>,
|
relation: &mut R,
|
||||||
b: &GeneratorWitness<'tcx>)
|
a: &GeneratorWitness<'tcx>,
|
||||||
-> RelateResult<'tcx, GeneratorWitness<'tcx>>
|
b: &GeneratorWitness<'tcx>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, GeneratorWitness<'tcx>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
assert_eq!(a.0.len(), b.0.len());
|
assert_eq!(a.0.len(), b.0.len());
|
||||||
let tcx = relation.tcx();
|
let tcx = relation.tcx();
|
||||||
|
@ -337,11 +383,15 @@ impl<'tcx> Relate<'tcx> for GeneratorWitness<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for Ty<'tcx> {
|
impl<'tcx> Relate<'tcx> for Ty<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &Ty<'tcx>,
|
relation: &mut R,
|
||||||
b: &Ty<'tcx>)
|
a: &Ty<'tcx>,
|
||||||
-> RelateResult<'tcx, Ty<'tcx>>
|
b: &Ty<'tcx>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, Ty<'tcx>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
relation.tys(a, b)
|
relation.tys(a, b)
|
||||||
}
|
}
|
||||||
|
@ -350,11 +400,15 @@ impl<'tcx> Relate<'tcx> for Ty<'tcx> {
|
||||||
/// The main "type relation" routine. Note that this does not handle
|
/// The main "type relation" routine. Note that this does not handle
|
||||||
/// inference artifacts, so you should filter those out before calling
|
/// inference artifacts, so you should filter those out before calling
|
||||||
/// it.
|
/// it.
|
||||||
pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
|
pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(
|
||||||
a: Ty<'tcx>,
|
relation: &mut R,
|
||||||
b: Ty<'tcx>)
|
a: Ty<'tcx>,
|
||||||
-> RelateResult<'tcx, Ty<'tcx>>
|
b: Ty<'tcx>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, Ty<'tcx>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
let tcx = relation.tcx();
|
let tcx = relation.tcx();
|
||||||
debug!("super_relate_tys: a={:?} b={:?}", a, b);
|
debug!("super_relate_tys: a={:?} b={:?}", a, b);
|
||||||
|
@ -553,10 +607,12 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
|
||||||
pub fn super_relate_consts<'a, 'gcx, 'tcx, R>(
|
pub fn super_relate_consts<'a, 'gcx, 'tcx, R>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: &'tcx ty::Const<'tcx>,
|
a: &'tcx ty::Const<'tcx>,
|
||||||
b: &'tcx ty::Const<'tcx>
|
b: &'tcx ty::Const<'tcx>,
|
||||||
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>>
|
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>>
|
||||||
where
|
where
|
||||||
R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
let tcx = relation.tcx();
|
let tcx = relation.tcx();
|
||||||
|
|
||||||
|
@ -632,12 +688,12 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::ExistentialPredicate<'tcx>> {
|
impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::ExistentialPredicate<'tcx>> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(relation: &mut R, a: &Self, b: &Self) -> RelateResult<'tcx, Self>
|
||||||
a: &Self,
|
where
|
||||||
b: &Self)
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
-> RelateResult<'tcx, Self>
|
'gcx: 'a + 'tcx,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a {
|
'tcx: 'a,
|
||||||
|
{
|
||||||
if a.len() != b.len() {
|
if a.len() != b.len() {
|
||||||
return Err(TypeError::ExistentialMismatch(expected_found(relation, a, b)));
|
return Err(TypeError::ExistentialMismatch(expected_found(relation, a, b)));
|
||||||
}
|
}
|
||||||
|
@ -657,11 +713,15 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::ExistentialPredicate<'tcx>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for ty::ClosureSubsts<'tcx> {
|
impl<'tcx> Relate<'tcx> for ty::ClosureSubsts<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &ty::ClosureSubsts<'tcx>,
|
relation: &mut R,
|
||||||
b: &ty::ClosureSubsts<'tcx>)
|
a: &ty::ClosureSubsts<'tcx>,
|
||||||
-> RelateResult<'tcx, ty::ClosureSubsts<'tcx>>
|
b: &ty::ClosureSubsts<'tcx>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, ty::ClosureSubsts<'tcx>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
let substs = relate_substs(relation, None, a.substs, b.substs)?;
|
let substs = relate_substs(relation, None, a.substs, b.substs)?;
|
||||||
Ok(ty::ClosureSubsts { substs })
|
Ok(ty::ClosureSubsts { substs })
|
||||||
|
@ -669,11 +729,15 @@ impl<'tcx> Relate<'tcx> for ty::ClosureSubsts<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for ty::GeneratorSubsts<'tcx> {
|
impl<'tcx> Relate<'tcx> for ty::GeneratorSubsts<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &ty::GeneratorSubsts<'tcx>,
|
relation: &mut R,
|
||||||
b: &ty::GeneratorSubsts<'tcx>)
|
a: &ty::GeneratorSubsts<'tcx>,
|
||||||
-> RelateResult<'tcx, ty::GeneratorSubsts<'tcx>>
|
b: &ty::GeneratorSubsts<'tcx>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, ty::GeneratorSubsts<'tcx>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
let substs = relate_substs(relation, None, a.substs, b.substs)?;
|
let substs = relate_substs(relation, None, a.substs, b.substs)?;
|
||||||
Ok(ty::GeneratorSubsts { substs })
|
Ok(ty::GeneratorSubsts { substs })
|
||||||
|
@ -681,55 +745,71 @@ impl<'tcx> Relate<'tcx> for ty::GeneratorSubsts<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for SubstsRef<'tcx> {
|
impl<'tcx> Relate<'tcx> for SubstsRef<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &SubstsRef<'tcx>,
|
relation: &mut R,
|
||||||
b: &SubstsRef<'tcx>)
|
a: &SubstsRef<'tcx>,
|
||||||
-> RelateResult<'tcx, SubstsRef<'tcx>>
|
b: &SubstsRef<'tcx>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, SubstsRef<'tcx>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
relate_substs(relation, None, a, b)
|
relate_substs(relation, None, a, b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for ty::Region<'tcx> {
|
impl<'tcx> Relate<'tcx> for ty::Region<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &ty::Region<'tcx>,
|
relation: &mut R,
|
||||||
b: &ty::Region<'tcx>)
|
a: &ty::Region<'tcx>,
|
||||||
-> RelateResult<'tcx, ty::Region<'tcx>>
|
b: &ty::Region<'tcx>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, ty::Region<'tcx>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
relation.regions(*a, *b)
|
relation.regions(*a, *b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for &'tcx ty::Const<'tcx> {
|
impl<'tcx> Relate<'tcx> for &'tcx ty::Const<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &&'tcx ty::Const<'tcx>,
|
relation: &mut R,
|
||||||
b: &&'tcx ty::Const<'tcx>)
|
a: &&'tcx ty::Const<'tcx>,
|
||||||
-> RelateResult<'tcx, &'tcx ty::Const<'tcx>>
|
b: &&'tcx ty::Const<'tcx>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
relation.consts(*a, *b)
|
relation.consts(*a, *b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for ty::Binder<T> {
|
impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for ty::Binder<T> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(
|
||||||
a: &ty::Binder<T>,
|
relation: &mut R,
|
||||||
b: &ty::Binder<T>)
|
a: &ty::Binder<T>,
|
||||||
-> RelateResult<'tcx, ty::Binder<T>>
|
b: &ty::Binder<T>,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
) -> RelateResult<'tcx, ty::Binder<T>>
|
||||||
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
relation.binders(a, b)
|
relation.binders(a, b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for Rc<T> {
|
impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for Rc<T> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(relation: &mut R, a: &Rc<T>, b: &Rc<T>) -> RelateResult<'tcx, Rc<T>>
|
||||||
a: &Rc<T>,
|
where
|
||||||
b: &Rc<T>)
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
-> RelateResult<'tcx, Rc<T>>
|
'gcx: 'a + 'tcx,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
let a: &T = a;
|
let a: &T = a;
|
||||||
let b: &T = b;
|
let b: &T = b;
|
||||||
|
@ -738,11 +818,11 @@ impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for Rc<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for Box<T> {
|
impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for Box<T> {
|
||||||
fn relate<'a, 'gcx, R>(relation: &mut R,
|
fn relate<'a, 'gcx, R>(relation: &mut R, a: &Box<T>, b: &Box<T>) -> RelateResult<'tcx, Box<T>>
|
||||||
a: &Box<T>,
|
where
|
||||||
b: &Box<T>)
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
-> RelateResult<'tcx, Box<T>>
|
'gcx: 'a + 'tcx,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
let a: &T = a;
|
let a: &T = a;
|
||||||
let b: &T = b;
|
let b: &T = b;
|
||||||
|
@ -754,10 +834,12 @@ impl<'tcx> Relate<'tcx> for Kind<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(
|
fn relate<'a, 'gcx, R>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: &Kind<'tcx>,
|
a: &Kind<'tcx>,
|
||||||
b: &Kind<'tcx>
|
b: &Kind<'tcx>,
|
||||||
) -> RelateResult<'tcx, Kind<'tcx>>
|
) -> RelateResult<'tcx, Kind<'tcx>>
|
||||||
where
|
where
|
||||||
R: TypeRelation<'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a,
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
match (a.unpack(), b.unpack()) {
|
match (a.unpack(), b.unpack()) {
|
||||||
(UnpackedKind::Lifetime(a_lt), UnpackedKind::Lifetime(b_lt)) => {
|
(UnpackedKind::Lifetime(a_lt), UnpackedKind::Lifetime(b_lt)) => {
|
||||||
|
@ -786,9 +868,12 @@ impl<'tcx> Relate<'tcx> for ty::TraitPredicate<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(
|
fn relate<'a, 'gcx, R>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: &ty::TraitPredicate<'tcx>,
|
a: &ty::TraitPredicate<'tcx>,
|
||||||
b: &ty::TraitPredicate<'tcx>
|
b: &ty::TraitPredicate<'tcx>,
|
||||||
) -> RelateResult<'tcx, ty::TraitPredicate<'tcx>>
|
) -> RelateResult<'tcx, ty::TraitPredicate<'tcx>>
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
Ok(ty::TraitPredicate {
|
Ok(ty::TraitPredicate {
|
||||||
trait_ref: relation.relate(&a.trait_ref, &b.trait_ref)?,
|
trait_ref: relation.relate(&a.trait_ref, &b.trait_ref)?,
|
||||||
|
@ -802,7 +887,10 @@ impl<'tcx> Relate<'tcx> for ty::ProjectionPredicate<'tcx> {
|
||||||
a: &ty::ProjectionPredicate<'tcx>,
|
a: &ty::ProjectionPredicate<'tcx>,
|
||||||
b: &ty::ProjectionPredicate<'tcx>,
|
b: &ty::ProjectionPredicate<'tcx>,
|
||||||
) -> RelateResult<'tcx, ty::ProjectionPredicate<'tcx>>
|
) -> RelateResult<'tcx, ty::ProjectionPredicate<'tcx>>
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
Ok(ty::ProjectionPredicate {
|
Ok(ty::ProjectionPredicate {
|
||||||
projection_ty: relation.relate(&a.projection_ty, &b.projection_ty)?,
|
projection_ty: relation.relate(&a.projection_ty, &b.projection_ty)?,
|
||||||
|
@ -815,9 +903,12 @@ impl<'tcx> Relate<'tcx> for traits::WhereClause<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(
|
fn relate<'a, 'gcx, R>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: &traits::WhereClause<'tcx>,
|
a: &traits::WhereClause<'tcx>,
|
||||||
b: &traits::WhereClause<'tcx>
|
b: &traits::WhereClause<'tcx>,
|
||||||
) -> RelateResult<'tcx, traits::WhereClause<'tcx>>
|
) -> RelateResult<'tcx, traits::WhereClause<'tcx>>
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
use crate::traits::WhereClause::*;
|
use crate::traits::WhereClause::*;
|
||||||
match (a, b) {
|
match (a, b) {
|
||||||
|
@ -852,9 +943,12 @@ impl<'tcx> Relate<'tcx> for traits::WellFormed<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(
|
fn relate<'a, 'gcx, R>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: &traits::WellFormed<'tcx>,
|
a: &traits::WellFormed<'tcx>,
|
||||||
b: &traits::WellFormed<'tcx>
|
b: &traits::WellFormed<'tcx>,
|
||||||
) -> RelateResult<'tcx, traits::WellFormed<'tcx>>
|
) -> RelateResult<'tcx, traits::WellFormed<'tcx>>
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
use crate::traits::WellFormed::*;
|
use crate::traits::WellFormed::*;
|
||||||
match (a, b) {
|
match (a, b) {
|
||||||
|
@ -869,9 +963,12 @@ impl<'tcx> Relate<'tcx> for traits::FromEnv<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(
|
fn relate<'a, 'gcx, R>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: &traits::FromEnv<'tcx>,
|
a: &traits::FromEnv<'tcx>,
|
||||||
b: &traits::FromEnv<'tcx>
|
b: &traits::FromEnv<'tcx>,
|
||||||
) -> RelateResult<'tcx, traits::FromEnv<'tcx>>
|
) -> RelateResult<'tcx, traits::FromEnv<'tcx>>
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
use crate::traits::FromEnv::*;
|
use crate::traits::FromEnv::*;
|
||||||
match (a, b) {
|
match (a, b) {
|
||||||
|
@ -886,9 +983,12 @@ impl<'tcx> Relate<'tcx> for traits::DomainGoal<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(
|
fn relate<'a, 'gcx, R>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: &traits::DomainGoal<'tcx>,
|
a: &traits::DomainGoal<'tcx>,
|
||||||
b: &traits::DomainGoal<'tcx>
|
b: &traits::DomainGoal<'tcx>,
|
||||||
) -> RelateResult<'tcx, traits::DomainGoal<'tcx>>
|
) -> RelateResult<'tcx, traits::DomainGoal<'tcx>>
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
use crate::traits::DomainGoal::*;
|
use crate::traits::DomainGoal::*;
|
||||||
match (a, b) {
|
match (a, b) {
|
||||||
|
@ -909,9 +1009,12 @@ impl<'tcx> Relate<'tcx> for traits::Goal<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(
|
fn relate<'a, 'gcx, R>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: &traits::Goal<'tcx>,
|
a: &traits::Goal<'tcx>,
|
||||||
b: &traits::Goal<'tcx>
|
b: &traits::Goal<'tcx>,
|
||||||
) -> RelateResult<'tcx, traits::Goal<'tcx>>
|
) -> RelateResult<'tcx, traits::Goal<'tcx>>
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
use crate::traits::GoalKind::*;
|
use crate::traits::GoalKind::*;
|
||||||
match (a, b) {
|
match (a, b) {
|
||||||
|
@ -955,9 +1058,12 @@ impl<'tcx> Relate<'tcx> for traits::Goals<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(
|
fn relate<'a, 'gcx, R>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: &traits::Goals<'tcx>,
|
a: &traits::Goals<'tcx>,
|
||||||
b: &traits::Goals<'tcx>
|
b: &traits::Goals<'tcx>,
|
||||||
) -> RelateResult<'tcx, traits::Goals<'tcx>>
|
) -> RelateResult<'tcx, traits::Goals<'tcx>>
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
if a.len() != b.len() {
|
if a.len() != b.len() {
|
||||||
return Err(TypeError::Mismatch);
|
return Err(TypeError::Mismatch);
|
||||||
|
@ -973,9 +1079,12 @@ impl<'tcx> Relate<'tcx> for traits::Clause<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(
|
fn relate<'a, 'gcx, R>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: &traits::Clause<'tcx>,
|
a: &traits::Clause<'tcx>,
|
||||||
b: &traits::Clause<'tcx>
|
b: &traits::Clause<'tcx>,
|
||||||
) -> RelateResult<'tcx, traits::Clause<'tcx>>
|
) -> RelateResult<'tcx, traits::Clause<'tcx>>
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
use crate::traits::Clause::*;
|
use crate::traits::Clause::*;
|
||||||
match (a, b) {
|
match (a, b) {
|
||||||
|
@ -998,9 +1107,12 @@ impl<'tcx> Relate<'tcx> for traits::Clauses<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(
|
fn relate<'a, 'gcx, R>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: &traits::Clauses<'tcx>,
|
a: &traits::Clauses<'tcx>,
|
||||||
b: &traits::Clauses<'tcx>
|
b: &traits::Clauses<'tcx>,
|
||||||
) -> RelateResult<'tcx, traits::Clauses<'tcx>>
|
) -> RelateResult<'tcx, traits::Clauses<'tcx>>
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
if a.len() != b.len() {
|
if a.len() != b.len() {
|
||||||
return Err(TypeError::Mismatch);
|
return Err(TypeError::Mismatch);
|
||||||
|
@ -1016,9 +1128,12 @@ impl<'tcx> Relate<'tcx> for traits::ProgramClause<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(
|
fn relate<'a, 'gcx, R>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: &traits::ProgramClause<'tcx>,
|
a: &traits::ProgramClause<'tcx>,
|
||||||
b: &traits::ProgramClause<'tcx>
|
b: &traits::ProgramClause<'tcx>,
|
||||||
) -> RelateResult<'tcx, traits::ProgramClause<'tcx>>
|
) -> RelateResult<'tcx, traits::ProgramClause<'tcx>>
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
Ok(traits::ProgramClause {
|
Ok(traits::ProgramClause {
|
||||||
goal: relation.relate(&a.goal, &b.goal)?,
|
goal: relation.relate(&a.goal, &b.goal)?,
|
||||||
|
@ -1032,9 +1147,12 @@ impl<'tcx> Relate<'tcx> for traits::Environment<'tcx> {
|
||||||
fn relate<'a, 'gcx, R>(
|
fn relate<'a, 'gcx, R>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: &traits::Environment<'tcx>,
|
a: &traits::Environment<'tcx>,
|
||||||
b: &traits::Environment<'tcx>
|
b: &traits::Environment<'tcx>,
|
||||||
) -> RelateResult<'tcx, traits::Environment<'tcx>>
|
) -> RelateResult<'tcx, traits::Environment<'tcx>>
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
Ok(traits::Environment {
|
Ok(traits::Environment {
|
||||||
clauses: relation.relate(&a.clauses, &b.clauses)?,
|
clauses: relation.relate(&a.clauses, &b.clauses)?,
|
||||||
|
@ -1043,14 +1161,18 @@ impl<'tcx> Relate<'tcx> for traits::Environment<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, G> Relate<'tcx> for traits::InEnvironment<'tcx, G>
|
impl<'tcx, G> Relate<'tcx> for traits::InEnvironment<'tcx, G>
|
||||||
where G: Relate<'tcx>
|
where
|
||||||
|
G: Relate<'tcx>,
|
||||||
{
|
{
|
||||||
fn relate<'a, 'gcx, R>(
|
fn relate<'a, 'gcx, R>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: &traits::InEnvironment<'tcx, G>,
|
a: &traits::InEnvironment<'tcx, G>,
|
||||||
b: &traits::InEnvironment<'tcx, G>
|
b: &traits::InEnvironment<'tcx, G>,
|
||||||
) -> RelateResult<'tcx, traits::InEnvironment<'tcx, G>>
|
) -> RelateResult<'tcx, traits::InEnvironment<'tcx, G>>
|
||||||
where R: TypeRelation<'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a
|
where
|
||||||
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
|
'gcx: 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
Ok(traits::InEnvironment {
|
Ok(traits::InEnvironment {
|
||||||
environment: relation.relate(&a.environment, &b.environment)?,
|
environment: relation.relate(&a.environment, &b.environment)?,
|
||||||
|
@ -1062,11 +1184,12 @@ impl<'tcx, G> Relate<'tcx> for traits::InEnvironment<'tcx, G>
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Error handling
|
// Error handling
|
||||||
|
|
||||||
pub fn expected_found<'a, 'gcx, 'tcx, R, T>(relation: &mut R,
|
pub fn expected_found<'a, 'gcx, 'tcx, R, T>(relation: &mut R, a: &T, b: &T) -> ExpectedFound<T>
|
||||||
a: &T,
|
where
|
||||||
b: &T)
|
R: TypeRelation<'gcx, 'tcx>,
|
||||||
-> ExpectedFound<T>
|
T: Clone,
|
||||||
where R: TypeRelation<'gcx, 'tcx>, T: Clone, 'gcx: 'a+'tcx, 'tcx: 'a
|
'gcx: 'a + 'tcx,
|
||||||
|
'tcx: 'a,
|
||||||
{
|
{
|
||||||
expected_found_bool(relation.a_is_expected(), a, b)
|
expected_found_bool(relation.a_is_expected(), a, b)
|
||||||
}
|
}
|
||||||
|
|
|
@ -450,8 +450,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialPredicate<'a> {
|
||||||
|
|
||||||
impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> {
|
impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> {
|
||||||
type Lifted = ty::TraitPredicate<'tcx>;
|
type Lifted = ty::TraitPredicate<'tcx>;
|
||||||
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>)
|
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<ty::TraitPredicate<'tcx>> {
|
||||||
-> Option<ty::TraitPredicate<'tcx>> {
|
|
||||||
tcx.lift(&self.trait_ref).map(|trait_ref| ty::TraitPredicate {
|
tcx.lift(&self.trait_ref).map(|trait_ref| ty::TraitPredicate {
|
||||||
trait_ref,
|
trait_ref,
|
||||||
})
|
})
|
||||||
|
@ -460,8 +459,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> {
|
||||||
|
|
||||||
impl<'a, 'tcx> Lift<'tcx> for ty::SubtypePredicate<'a> {
|
impl<'a, 'tcx> Lift<'tcx> for ty::SubtypePredicate<'a> {
|
||||||
type Lifted = ty::SubtypePredicate<'tcx>;
|
type Lifted = ty::SubtypePredicate<'tcx>;
|
||||||
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>)
|
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<ty::SubtypePredicate<'tcx>> {
|
||||||
-> Option<ty::SubtypePredicate<'tcx>> {
|
|
||||||
tcx.lift(&(self.a, self.b)).map(|(a, b)| ty::SubtypePredicate {
|
tcx.lift(&(self.a, self.b)).map(|(a, b)| ty::SubtypePredicate {
|
||||||
a_is_expected: self.a_is_expected,
|
a_is_expected: self.a_is_expected,
|
||||||
a,
|
a,
|
||||||
|
@ -470,7 +468,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::SubtypePredicate<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, A: Copy+Lift<'tcx>, B: Copy+Lift<'tcx>> Lift<'tcx> for ty::OutlivesPredicate<A, B> {
|
impl<'tcx, A: Copy + Lift<'tcx>, B: Copy + Lift<'tcx>> Lift<'tcx> for ty::OutlivesPredicate<A, B> {
|
||||||
type Lifted = ty::OutlivesPredicate<A::Lifted, B::Lifted>;
|
type Lifted = ty::OutlivesPredicate<A::Lifted, B::Lifted>;
|
||||||
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<Self::Lifted> {
|
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<Self::Lifted> {
|
||||||
tcx.lift(&(self.0, self.1)).map(|(a, b)| ty::OutlivesPredicate(a, b))
|
tcx.lift(&(self.0, self.1)).map(|(a, b)| ty::OutlivesPredicate(a, b))
|
||||||
|
@ -479,8 +477,7 @@ impl<'tcx, A: Copy+Lift<'tcx>, B: Copy+Lift<'tcx>> Lift<'tcx> for ty::OutlivesPr
|
||||||
|
|
||||||
impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionTy<'a> {
|
impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionTy<'a> {
|
||||||
type Lifted = ty::ProjectionTy<'tcx>;
|
type Lifted = ty::ProjectionTy<'tcx>;
|
||||||
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>)
|
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<ty::ProjectionTy<'tcx>> {
|
||||||
-> Option<ty::ProjectionTy<'tcx>> {
|
|
||||||
tcx.lift(&self.substs).map(|substs| {
|
tcx.lift(&self.substs).map(|substs| {
|
||||||
ty::ProjectionTy {
|
ty::ProjectionTy {
|
||||||
item_def_id: self.item_def_id,
|
item_def_id: self.item_def_id,
|
||||||
|
@ -492,8 +489,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionTy<'a> {
|
||||||
|
|
||||||
impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionPredicate<'a> {
|
impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionPredicate<'a> {
|
||||||
type Lifted = ty::ProjectionPredicate<'tcx>;
|
type Lifted = ty::ProjectionPredicate<'tcx>;
|
||||||
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>)
|
fn lift_to_tcx<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Option<ty::ProjectionPredicate<'tcx>> {
|
||||||
-> Option<ty::ProjectionPredicate<'tcx>> {
|
|
||||||
tcx.lift(&(self.projection_ty, self.ty)).map(|(projection_ty, ty)| {
|
tcx.lift(&(self.projection_ty, self.ty)).map(|(projection_ty, ty)| {
|
||||||
ty::ProjectionPredicate {
|
ty::ProjectionPredicate {
|
||||||
projection_ty,
|
projection_ty,
|
||||||
|
|
|
@ -335,9 +335,11 @@ impl<'tcx> ClosureSubsts<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn upvar_tys(self, def_id: DefId, tcx: TyCtxt<'_, '_>) ->
|
pub fn upvar_tys(
|
||||||
impl Iterator<Item=Ty<'tcx>> + 'tcx
|
self,
|
||||||
{
|
def_id: DefId,
|
||||||
|
tcx: TyCtxt<'_, '_>,
|
||||||
|
) -> impl Iterator<Item = Ty<'tcx>> + 'tcx {
|
||||||
let SplitClosureSubsts { upvar_kinds, .. } = self.split(def_id, tcx);
|
let SplitClosureSubsts { upvar_kinds, .. } = self.split(def_id, tcx);
|
||||||
upvar_kinds.iter().map(|t| {
|
upvar_kinds.iter().map(|t| {
|
||||||
if let UnpackedKind::Type(ty) = t.unpack() {
|
if let UnpackedKind::Type(ty) = t.unpack() {
|
||||||
|
@ -422,9 +424,11 @@ impl<'tcx> GeneratorSubsts<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn upvar_tys(self, def_id: DefId, tcx: TyCtxt<'_, '_>) ->
|
pub fn upvar_tys(
|
||||||
impl Iterator<Item=Ty<'tcx>> + 'tcx
|
self,
|
||||||
{
|
def_id: DefId,
|
||||||
|
tcx: TyCtxt<'_, '_>,
|
||||||
|
) -> impl Iterator<Item = Ty<'tcx>> + 'tcx {
|
||||||
let SplitGeneratorSubsts { upvar_kinds, .. } = self.split(def_id, tcx);
|
let SplitGeneratorSubsts { upvar_kinds, .. } = self.split(def_id, tcx);
|
||||||
upvar_kinds.iter().map(|t| {
|
upvar_kinds.iter().map(|t| {
|
||||||
if let UnpackedKind::Type(ty) = t.unpack() {
|
if let UnpackedKind::Type(ty) = t.unpack() {
|
||||||
|
@ -489,7 +493,10 @@ impl<'gcx, 'tcx> GeneratorSubsts<'tcx> {
|
||||||
/// out of range.
|
/// out of range.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn discriminant_for_variant(
|
pub fn discriminant_for_variant(
|
||||||
&self, def_id: DefId, tcx: TyCtxt<'gcx, 'tcx>, variant_index: VariantIdx
|
&self,
|
||||||
|
def_id: DefId,
|
||||||
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
|
variant_index: VariantIdx,
|
||||||
) -> Discr<'tcx> {
|
) -> Discr<'tcx> {
|
||||||
// Generators don't support explicit discriminant values, so they are
|
// Generators don't support explicit discriminant values, so they are
|
||||||
// the same as the variant index.
|
// the same as the variant index.
|
||||||
|
@ -501,8 +508,10 @@ impl<'gcx, 'tcx> GeneratorSubsts<'tcx> {
|
||||||
/// variant indices.
|
/// variant indices.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn discriminants(
|
pub fn discriminants(
|
||||||
&'tcx self, def_id: DefId, tcx: TyCtxt<'gcx, 'tcx>
|
&'tcx self,
|
||||||
) -> impl Iterator<Item=(VariantIdx, Discr<'tcx>)> + Captures<'gcx> {
|
def_id: DefId,
|
||||||
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
|
) -> impl Iterator<Item = (VariantIdx, Discr<'tcx>)> + Captures<'gcx> {
|
||||||
self.variant_range(def_id, tcx).map(move |index| {
|
self.variant_range(def_id, tcx).map(move |index| {
|
||||||
(index, Discr { val: index.as_usize() as u128, ty: self.discr_ty(tcx) })
|
(index, Discr { val: index.as_usize() as u128, ty: self.discr_ty(tcx) })
|
||||||
})
|
})
|
||||||
|
@ -533,9 +542,11 @@ impl<'gcx, 'tcx> GeneratorSubsts<'tcx> {
|
||||||
/// The locals are grouped by their variant number. Note that some locals may
|
/// The locals are grouped by their variant number. Note that some locals may
|
||||||
/// be repeated in multiple variants.
|
/// be repeated in multiple variants.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn state_tys(self, def_id: DefId, tcx: TyCtxt<'gcx, 'tcx>) ->
|
pub fn state_tys(
|
||||||
impl Iterator<Item=impl Iterator<Item=Ty<'tcx>> + Captures<'gcx>>
|
self,
|
||||||
{
|
def_id: DefId,
|
||||||
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
|
) -> impl Iterator<Item = impl Iterator<Item = Ty<'tcx>> + Captures<'gcx>> {
|
||||||
let layout = tcx.generator_layout(def_id);
|
let layout = tcx.generator_layout(def_id);
|
||||||
layout.variant_fields.iter().map(move |variant| {
|
layout.variant_fields.iter().map(move |variant| {
|
||||||
variant.iter().map(move |field| {
|
variant.iter().map(move |field| {
|
||||||
|
@ -547,9 +558,11 @@ impl<'gcx, 'tcx> GeneratorSubsts<'tcx> {
|
||||||
/// This is the types of the fields of a generator which are not stored in a
|
/// This is the types of the fields of a generator which are not stored in a
|
||||||
/// variant.
|
/// variant.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn prefix_tys(self, def_id: DefId, tcx: TyCtxt<'gcx, 'tcx>) ->
|
pub fn prefix_tys(
|
||||||
impl Iterator<Item=Ty<'tcx>>
|
self,
|
||||||
{
|
def_id: DefId,
|
||||||
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
|
) -> impl Iterator<Item = Ty<'tcx>> {
|
||||||
self.upvar_tys(def_id, tcx)
|
self.upvar_tys(def_id, tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -562,9 +575,11 @@ pub enum UpvarSubsts<'tcx> {
|
||||||
|
|
||||||
impl<'tcx> UpvarSubsts<'tcx> {
|
impl<'tcx> UpvarSubsts<'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn upvar_tys(self, def_id: DefId, tcx: TyCtxt<'_, '_>) ->
|
pub fn upvar_tys(
|
||||||
impl Iterator<Item=Ty<'tcx>> + 'tcx
|
self,
|
||||||
{
|
def_id: DefId,
|
||||||
|
tcx: TyCtxt<'_, '_>,
|
||||||
|
) -> impl Iterator<Item = Ty<'tcx>> + 'tcx {
|
||||||
let upvar_kinds = match self {
|
let upvar_kinds = match self {
|
||||||
UpvarSubsts::Closure(substs) => substs.split(def_id, tcx).upvar_kinds,
|
UpvarSubsts::Closure(substs) => substs.split(def_id, tcx).upvar_kinds,
|
||||||
UpvarSubsts::Generator(substs) => substs.split(def_id, tcx).upvar_kinds,
|
UpvarSubsts::Generator(substs) => substs.split(def_id, tcx).upvar_kinds,
|
||||||
|
@ -607,12 +622,10 @@ impl<'gcx, 'tcx> ExistentialPredicate<'tcx> {
|
||||||
(AutoTrait(_), _) => Ordering::Greater,
|
(AutoTrait(_), _) => Ordering::Greater,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'gcx, 'tcx> Binder<ExistentialPredicate<'tcx>> {
|
impl<'gcx, 'tcx> Binder<ExistentialPredicate<'tcx>> {
|
||||||
pub fn with_self_ty(&self, tcx: TyCtxt<'gcx, 'tcx>, self_ty: Ty<'tcx>)
|
pub fn with_self_ty(&self, tcx: TyCtxt<'gcx, 'tcx>, self_ty: Ty<'tcx>) -> ty::Predicate<'tcx> {
|
||||||
-> ty::Predicate<'tcx> {
|
|
||||||
use crate::ty::ToPredicate;
|
use crate::ty::ToPredicate;
|
||||||
match *self.skip_binder() {
|
match *self.skip_binder() {
|
||||||
ExistentialPredicate::Trait(tr) => Binder(tr).with_self_ty(tcx, self_ty).to_predicate(),
|
ExistentialPredicate::Trait(tr) => Binder(tr).with_self_ty(tcx, self_ty).to_predicate(),
|
||||||
|
@ -764,10 +777,11 @@ impl<'tcx> TraitRef<'tcx> {
|
||||||
self.substs.types()
|
self.substs.types()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_method(tcx: TyCtxt<'_, 'tcx>,
|
pub fn from_method(
|
||||||
trait_id: DefId,
|
tcx: TyCtxt<'_, 'tcx>,
|
||||||
substs: SubstsRef<'tcx>)
|
trait_id: DefId,
|
||||||
-> ty::TraitRef<'tcx> {
|
substs: SubstsRef<'tcx>,
|
||||||
|
) -> ty::TraitRef<'tcx> {
|
||||||
let defs = tcx.generics_of(trait_id);
|
let defs = tcx.generics_of(trait_id);
|
||||||
|
|
||||||
ty::TraitRef {
|
ty::TraitRef {
|
||||||
|
@ -817,9 +831,10 @@ impl<'gcx, 'tcx> ExistentialTraitRef<'tcx> {
|
||||||
self.substs.types()
|
self.substs.types()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn erase_self_ty(tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn erase_self_ty(
|
||||||
trait_ref: ty::TraitRef<'tcx>)
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
-> ty::ExistentialTraitRef<'tcx> {
|
trait_ref: ty::TraitRef<'tcx>,
|
||||||
|
) -> ty::ExistentialTraitRef<'tcx> {
|
||||||
// Assert there is a Self.
|
// Assert there is a Self.
|
||||||
trait_ref.substs.type_at(0);
|
trait_ref.substs.type_at(0);
|
||||||
|
|
||||||
|
@ -833,8 +848,7 @@ impl<'gcx, 'tcx> ExistentialTraitRef<'tcx> {
|
||||||
/// we convert the principal trait-ref into a normal trait-ref,
|
/// we convert the principal trait-ref into a normal trait-ref,
|
||||||
/// you must give *some* self type. A common choice is `mk_err()`
|
/// you must give *some* self type. A common choice is `mk_err()`
|
||||||
/// or some placeholder type.
|
/// or some placeholder type.
|
||||||
pub fn with_self_ty(&self, tcx: TyCtxt<'gcx, 'tcx>, self_ty: Ty<'tcx>)
|
pub fn with_self_ty(&self, tcx: TyCtxt<'gcx, 'tcx>, self_ty: Ty<'tcx>) -> ty::TraitRef<'tcx> {
|
||||||
-> ty::TraitRef<'tcx> {
|
|
||||||
// otherwise the escaping vars would be captured by the binder
|
// otherwise the escaping vars would be captured by the binder
|
||||||
// debug_assert!(!self_ty.has_escaping_bound_vars());
|
// debug_assert!(!self_ty.has_escaping_bound_vars());
|
||||||
|
|
||||||
|
@ -856,9 +870,7 @@ impl<'tcx> PolyExistentialTraitRef<'tcx> {
|
||||||
/// we convert the principal trait-ref into a normal trait-ref,
|
/// we convert the principal trait-ref into a normal trait-ref,
|
||||||
/// you must give *some* self type. A common choice is `mk_err()`
|
/// you must give *some* self type. A common choice is `mk_err()`
|
||||||
/// or some placeholder type.
|
/// or some placeholder type.
|
||||||
pub fn with_self_ty(&self, tcx: TyCtxt<'_, 'tcx>,
|
pub fn with_self_ty(&self, tcx: TyCtxt<'_, 'tcx>, self_ty: Ty<'tcx>) -> ty::PolyTraitRef<'tcx> {
|
||||||
self_ty: Ty<'tcx>)
|
|
||||||
-> ty::PolyTraitRef<'tcx> {
|
|
||||||
self.map_bound(|trait_ref| trait_ref.with_self_ty(tcx, self_ty))
|
self.map_bound(|trait_ref| trait_ref.with_self_ty(tcx, self_ty))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -992,7 +1004,9 @@ impl<'tcx> ProjectionTy<'tcx> {
|
||||||
/// Construct a `ProjectionTy` by searching the trait from `trait_ref` for the
|
/// Construct a `ProjectionTy` by searching the trait from `trait_ref` for the
|
||||||
/// associated item named `item_name`.
|
/// associated item named `item_name`.
|
||||||
pub fn from_ref_and_name(
|
pub fn from_ref_and_name(
|
||||||
tcx: TyCtxt<'_, '_>, trait_ref: ty::TraitRef<'tcx>, item_name: Ident
|
tcx: TyCtxt<'_, '_>,
|
||||||
|
trait_ref: ty::TraitRef<'tcx>,
|
||||||
|
item_name: Ident,
|
||||||
) -> ProjectionTy<'tcx> {
|
) -> ProjectionTy<'tcx> {
|
||||||
let item_def_id = tcx.associated_items(trait_ref.def_id).find(|item| {
|
let item_def_id = tcx.associated_items(trait_ref.def_id).find(|item| {
|
||||||
item.kind == ty::AssocKind::Type &&
|
item.kind == ty::AssocKind::Type &&
|
||||||
|
@ -1421,10 +1435,11 @@ impl<'tcx, 'gcx> ExistentialProjection<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_self_ty(&self, tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn with_self_ty(
|
||||||
self_ty: Ty<'tcx>)
|
&self,
|
||||||
-> ty::ProjectionPredicate<'tcx>
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
{
|
self_ty: Ty<'tcx>,
|
||||||
|
) -> ty::ProjectionPredicate<'tcx> {
|
||||||
// otherwise the escaping regions would be captured by the binders
|
// otherwise the escaping regions would be captured by the binders
|
||||||
debug_assert!(!self_ty.has_escaping_bound_vars());
|
debug_assert!(!self_ty.has_escaping_bound_vars());
|
||||||
|
|
||||||
|
@ -1439,8 +1454,11 @@ impl<'tcx, 'gcx> ExistentialProjection<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, 'gcx> PolyExistentialProjection<'tcx> {
|
impl<'tcx, 'gcx> PolyExistentialProjection<'tcx> {
|
||||||
pub fn with_self_ty(&self, tcx: TyCtxt<'gcx, 'tcx>, self_ty: Ty<'tcx>)
|
pub fn with_self_ty(
|
||||||
-> ty::PolyProjectionPredicate<'tcx> {
|
&self,
|
||||||
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
|
self_ty: Ty<'tcx>,
|
||||||
|
) -> ty::PolyProjectionPredicate<'tcx> {
|
||||||
self.map_bound(|p| p.with_self_ty(tcx, self_ty))
|
self.map_bound(|p| p.with_self_ty(tcx, self_ty))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2099,7 +2117,7 @@ impl<'gcx, 'tcx> TyS<'tcx> {
|
||||||
pub fn discriminant_for_variant(
|
pub fn discriminant_for_variant(
|
||||||
&self,
|
&self,
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
variant_index: VariantIdx
|
variant_index: VariantIdx,
|
||||||
) -> Option<Discr<'tcx>> {
|
) -> Option<Discr<'tcx>> {
|
||||||
match self.sty {
|
match self.sty {
|
||||||
TyKind::Adt(adt, _) => Some(adt.discriminant_for_variant(tcx, variant_index)),
|
TyKind::Adt(adt, _) => Some(adt.discriminant_for_variant(tcx, variant_index)),
|
||||||
|
@ -2239,11 +2257,7 @@ static_assert_size!(Const<'_>, 40);
|
||||||
|
|
||||||
impl<'tcx> Const<'tcx> {
|
impl<'tcx> Const<'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_scalar(
|
pub fn from_scalar(tcx: TyCtxt<'_, 'tcx>, val: Scalar, ty: Ty<'tcx>) -> &'tcx Self {
|
||||||
tcx: TyCtxt<'_, 'tcx>,
|
|
||||||
val: Scalar,
|
|
||||||
ty: Ty<'tcx>,
|
|
||||||
) -> &'tcx Self {
|
|
||||||
tcx.mk_const(Self {
|
tcx.mk_const(Self {
|
||||||
val: ConstValue::Scalar(val),
|
val: ConstValue::Scalar(val),
|
||||||
ty,
|
ty,
|
||||||
|
@ -2279,11 +2293,7 @@ impl<'tcx> Const<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_bits(
|
pub fn to_bits(&self, tcx: TyCtxt<'_, 'tcx>, ty: ParamEnvAnd<'tcx, Ty<'tcx>>) -> Option<u128> {
|
||||||
&self,
|
|
||||||
tcx: TyCtxt<'_, 'tcx>,
|
|
||||||
ty: ParamEnvAnd<'tcx, Ty<'tcx>>,
|
|
||||||
) -> Option<u128> {
|
|
||||||
if self.ty != ty.value {
|
if self.ty != ty.value {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -2324,11 +2334,7 @@ impl<'tcx> Const<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn unwrap_bits(
|
pub fn unwrap_bits(&self, tcx: TyCtxt<'_, '_>, ty: ParamEnvAnd<'tcx, Ty<'tcx>>) -> u128 {
|
||||||
&self,
|
|
||||||
tcx: TyCtxt<'_, '_>,
|
|
||||||
ty: ParamEnvAnd<'tcx, Ty<'tcx>>,
|
|
||||||
) -> u128 {
|
|
||||||
self.assert_bits(tcx, ty).unwrap_or_else(||
|
self.assert_bits(tcx, ty).unwrap_or_else(||
|
||||||
bug!("expected bits of {}, got {:#?}", ty.value, self))
|
bug!("expected bits of {}, got {:#?}", ty.value, self))
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,10 +194,7 @@ impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> {
|
||||||
/// var bound at index `0`. For types, we use a `BoundVar` index equal to
|
/// var bound at index `0`. For types, we use a `BoundVar` index equal to
|
||||||
/// the type parameter index. For regions, we use the `BoundRegion::BrNamed`
|
/// the type parameter index. For regions, we use the `BoundRegion::BrNamed`
|
||||||
/// variant (which has a `DefId`).
|
/// variant (which has a `DefId`).
|
||||||
pub fn bound_vars_for_item(
|
pub fn bound_vars_for_item(tcx: TyCtxt<'gcx, 'tcx>, def_id: DefId) -> SubstsRef<'tcx> {
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
|
||||||
def_id: DefId
|
|
||||||
) -> SubstsRef<'tcx> {
|
|
||||||
Self::for_item(tcx, def_id, |param, _| {
|
Self::for_item(tcx, def_id, |param, _| {
|
||||||
match param.kind {
|
match param.kind {
|
||||||
ty::GenericParamDefKind::Type { .. } => {
|
ty::GenericParamDefKind::Type { .. } => {
|
||||||
|
@ -233,11 +230,9 @@ impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> {
|
||||||
/// The closures get to observe the `InternalSubsts` as they're
|
/// The closures get to observe the `InternalSubsts` as they're
|
||||||
/// being built, which can be used to correctly
|
/// being built, which can be used to correctly
|
||||||
/// substitute defaults of generic parameters.
|
/// substitute defaults of generic parameters.
|
||||||
pub fn for_item<F>(tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn for_item<F>(tcx: TyCtxt<'gcx, 'tcx>, def_id: DefId, mut mk_kind: F) -> SubstsRef<'tcx>
|
||||||
def_id: DefId,
|
where
|
||||||
mut mk_kind: F)
|
F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>,
|
||||||
-> SubstsRef<'tcx>
|
|
||||||
where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>
|
|
||||||
{
|
{
|
||||||
let defs = tcx.generics_of(def_id);
|
let defs = tcx.generics_of(def_id);
|
||||||
let count = defs.count();
|
let count = defs.count();
|
||||||
|
@ -246,12 +241,14 @@ impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> {
|
||||||
tcx.intern_substs(&substs)
|
tcx.intern_substs(&substs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn extend_to<F>(&self,
|
pub fn extend_to<F>(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
&self,
|
||||||
def_id: DefId,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
mut mk_kind: F)
|
def_id: DefId,
|
||||||
-> SubstsRef<'tcx>
|
mut mk_kind: F,
|
||||||
where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>
|
) -> SubstsRef<'tcx>
|
||||||
|
where
|
||||||
|
F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>,
|
||||||
{
|
{
|
||||||
Self::for_item(tcx, def_id, |param, substs| {
|
Self::for_item(tcx, def_id, |param, substs| {
|
||||||
self.get(param.index as usize)
|
self.get(param.index as usize)
|
||||||
|
@ -260,11 +257,13 @@ impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fill_item<F>(substs: &mut SmallVec<[Kind<'tcx>; 8]>,
|
fn fill_item<F>(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
substs: &mut SmallVec<[Kind<'tcx>; 8]>,
|
||||||
defs: &ty::Generics,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
mk_kind: &mut F)
|
defs: &ty::Generics,
|
||||||
where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>
|
mk_kind: &mut F,
|
||||||
|
) where
|
||||||
|
F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>,
|
||||||
{
|
{
|
||||||
if let Some(def_id) = defs.parent {
|
if let Some(def_id) = defs.parent {
|
||||||
let parent_defs = tcx.generics_of(def_id);
|
let parent_defs = tcx.generics_of(def_id);
|
||||||
|
@ -372,16 +371,17 @@ impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> {
|
||||||
/// in a different item, with `target_substs` as the base for
|
/// in a different item, with `target_substs` as the base for
|
||||||
/// the target impl/trait, with the source child-specific
|
/// the target impl/trait, with the source child-specific
|
||||||
/// parameters (e.g., method parameters) on top of that base.
|
/// parameters (e.g., method parameters) on top of that base.
|
||||||
pub fn rebase_onto(&self, tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn rebase_onto(
|
||||||
source_ancestor: DefId,
|
&self,
|
||||||
target_substs: SubstsRef<'tcx>)
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
-> SubstsRef<'tcx> {
|
source_ancestor: DefId,
|
||||||
|
target_substs: SubstsRef<'tcx>,
|
||||||
|
) -> SubstsRef<'tcx> {
|
||||||
let defs = tcx.generics_of(source_ancestor);
|
let defs = tcx.generics_of(source_ancestor);
|
||||||
tcx.mk_substs(target_substs.iter().chain(&self[defs.params.len()..]).cloned())
|
tcx.mk_substs(target_substs.iter().chain(&self[defs.params.len()..]).cloned())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn truncate_to(&self, tcx: TyCtxt<'gcx, 'tcx>, generics: &ty::Generics)
|
pub fn truncate_to(&self, tcx: TyCtxt<'gcx, 'tcx>, generics: &ty::Generics) -> SubstsRef<'tcx> {
|
||||||
-> SubstsRef<'tcx> {
|
|
||||||
tcx.mk_substs(self.iter().take(generics.count()).cloned())
|
tcx.mk_substs(self.iter().take(generics.count()).cloned())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -414,23 +414,25 @@ impl<'tcx> serialize::UseSpecializedDecodable for SubstsRef<'tcx> {}
|
||||||
// there is more information available (for better errors).
|
// there is more information available (for better errors).
|
||||||
|
|
||||||
pub trait Subst<'tcx>: Sized {
|
pub trait Subst<'tcx>: Sized {
|
||||||
fn subst<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>,
|
fn subst<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>, substs: &[Kind<'tcx>]) -> Self {
|
||||||
substs: &[Kind<'tcx>]) -> Self {
|
|
||||||
self.subst_spanned(tcx, substs, None)
|
self.subst_spanned(tcx, substs, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subst_spanned<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>,
|
fn subst_spanned<'gcx>(
|
||||||
substs: &[Kind<'tcx>],
|
&self,
|
||||||
span: Option<Span>)
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
-> Self;
|
substs: &[Kind<'tcx>],
|
||||||
|
span: Option<Span>,
|
||||||
|
) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, T:TypeFoldable<'tcx>> Subst<'tcx> for T {
|
impl<'tcx, T: TypeFoldable<'tcx>> Subst<'tcx> for T {
|
||||||
fn subst_spanned<'gcx>(&self, tcx: TyCtxt<'gcx, 'tcx>,
|
fn subst_spanned<'gcx>(
|
||||||
substs: &[Kind<'tcx>],
|
&self,
|
||||||
span: Option<Span>)
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
-> T
|
substs: &[Kind<'tcx>],
|
||||||
{
|
span: Option<Span>,
|
||||||
|
) -> T {
|
||||||
let mut folder = SubstFolder { tcx,
|
let mut folder = SubstFolder { tcx,
|
||||||
substs,
|
substs,
|
||||||
span,
|
span,
|
||||||
|
@ -444,7 +446,7 @@ impl<'tcx, T:TypeFoldable<'tcx>> Subst<'tcx> for T {
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// The actual substitution engine itself is a type folder.
|
// The actual substitution engine itself is a type folder.
|
||||||
|
|
||||||
struct SubstFolder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
struct SubstFolder<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
substs: &'a [Kind<'tcx>],
|
substs: &'a [Kind<'tcx>],
|
||||||
|
|
||||||
|
|
|
@ -64,9 +64,11 @@ impl<'gcx, 'tcx> TraitDef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ancestors(&self, tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn ancestors(
|
||||||
of_impl: DefId)
|
&self,
|
||||||
-> specialization_graph::Ancestors<'gcx> {
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
|
of_impl: DefId,
|
||||||
|
) -> specialization_graph::Ancestors<'gcx> {
|
||||||
specialization_graph::ancestors(tcx, self.def_id, of_impl)
|
specialization_graph::ancestors(tcx, self.def_id, of_impl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,9 +150,10 @@ impl<'gcx, 'tcx> TyCtxt<'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query provider for `trait_impls_of`.
|
// Query provider for `trait_impls_of`.
|
||||||
pub(super) fn trait_impls_of_provider<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
pub(super) fn trait_impls_of_provider<'tcx>(
|
||||||
trait_id: DefId)
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
-> &'tcx TraitImpls {
|
trait_id: DefId,
|
||||||
|
) -> &'tcx TraitImpls {
|
||||||
let mut impls = TraitImpls::default();
|
let mut impls = TraitImpls::default();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -105,8 +105,11 @@ impl<'tcx> Discr<'tcx> {
|
||||||
|
|
||||||
pub trait IntTypeExt {
|
pub trait IntTypeExt {
|
||||||
fn to_ty<'gcx, 'tcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx>;
|
fn to_ty<'gcx, 'tcx>(&self, tcx: TyCtxt<'gcx, 'tcx>) -> Ty<'tcx>;
|
||||||
fn disr_incr<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, val: Option<Discr<'tcx>>)
|
fn disr_incr<'tcx>(
|
||||||
-> Option<Discr<'tcx>>;
|
&self,
|
||||||
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
|
val: Option<Discr<'tcx>>,
|
||||||
|
) -> Option<Discr<'tcx>>;
|
||||||
fn initial_discriminant<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Discr<'tcx>;
|
fn initial_discriminant<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> Discr<'tcx>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,10 +181,11 @@ pub enum Representability {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> ty::ParamEnv<'tcx> {
|
impl<'tcx> ty::ParamEnv<'tcx> {
|
||||||
pub fn can_type_implement_copy(self,
|
pub fn can_type_implement_copy(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
self,
|
||||||
self_type: Ty<'tcx>)
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
-> Result<(), CopyImplementationError<'tcx>> {
|
self_type: Ty<'tcx>,
|
||||||
|
) -> Result<(), CopyImplementationError<'tcx>> {
|
||||||
// FIXME: (@jroesch) float this code up
|
// FIXME: (@jroesch) float this code up
|
||||||
tcx.infer_ctxt().enter(|infcx| {
|
tcx.infer_ctxt().enter(|infcx| {
|
||||||
let (adt, substs) = match self_type.sty {
|
let (adt, substs) = match self_type.sty {
|
||||||
|
@ -695,11 +699,12 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||||
/// does copies even when the type actually doesn't satisfy the
|
/// does copies even when the type actually doesn't satisfy the
|
||||||
/// full requirements for the `Copy` trait (cc #29149) -- this
|
/// full requirements for the `Copy` trait (cc #29149) -- this
|
||||||
/// winds up being reported as an error during NLL borrow check.
|
/// winds up being reported as an error during NLL borrow check.
|
||||||
pub fn is_copy_modulo_regions(&'tcx self,
|
pub fn is_copy_modulo_regions(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
&'tcx self,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
span: Span)
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
-> bool {
|
span: Span,
|
||||||
|
) -> bool {
|
||||||
tcx.at(span).is_copy_raw(param_env.and(self))
|
tcx.at(span).is_copy_raw(param_env.and(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -709,10 +714,11 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||||
/// over-approximation in generic contexts, where one can have
|
/// over-approximation in generic contexts, where one can have
|
||||||
/// strange rules like `<T as Foo<'static>>::Bar: Sized` that
|
/// strange rules like `<T as Foo<'static>>::Bar: Sized` that
|
||||||
/// actually carry lifetime requirements.
|
/// actually carry lifetime requirements.
|
||||||
pub fn is_sized(&'tcx self,
|
pub fn is_sized(
|
||||||
tcx_at: TyCtxtAt<'tcx, 'tcx>,
|
&'tcx self,
|
||||||
param_env: ty::ParamEnv<'tcx>)-> bool
|
tcx_at: TyCtxtAt<'tcx, 'tcx>,
|
||||||
{
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
|
) -> bool {
|
||||||
tcx_at.is_sized_raw(param_env.and(self))
|
tcx_at.is_sized_raw(param_env.and(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,11 +729,12 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||||
/// optimization as well as the rules around static values. Note
|
/// optimization as well as the rules around static values. Note
|
||||||
/// that the `Freeze` trait is not exposed to end users and is
|
/// that the `Freeze` trait is not exposed to end users and is
|
||||||
/// effectively an implementation detail.
|
/// effectively an implementation detail.
|
||||||
pub fn is_freeze(&'tcx self,
|
pub fn is_freeze(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
&'tcx self,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
span: Span)-> bool
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
{
|
span: Span,
|
||||||
|
) -> bool {
|
||||||
tcx.at(span).is_freeze_raw(param_env.and(self))
|
tcx.at(span).is_freeze_raw(param_env.and(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -738,10 +745,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||||
/// (Note that this implies that if `ty` has a destructor attached,
|
/// (Note that this implies that if `ty` has a destructor attached,
|
||||||
/// then `needs_drop` will definitely return `true` for `ty`.)
|
/// then `needs_drop` will definitely return `true` for `ty`.)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn needs_drop(&'tcx self,
|
pub fn needs_drop(&'tcx self, tcx: TyCtxt<'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
|
||||||
param_env: ty::ParamEnv<'tcx>)
|
|
||||||
-> bool {
|
|
||||||
tcx.needs_drop_raw(param_env.and(self)).0
|
tcx.needs_drop_raw(param_env.and(self)).0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -760,11 +764,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||||
|
|
||||||
/// Check whether a type is representable. This means it cannot contain unboxed
|
/// Check whether a type is representable. This means it cannot contain unboxed
|
||||||
/// structural recursion. This check is needed for structs and enums.
|
/// structural recursion. This check is needed for structs and enums.
|
||||||
pub fn is_representable(&'tcx self,
|
pub fn is_representable(&'tcx self, tcx: TyCtxt<'tcx, 'tcx>, sp: Span) -> Representability {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
|
||||||
sp: Span)
|
|
||||||
-> Representability
|
|
||||||
{
|
|
||||||
// Iterate until something non-representable is found
|
// Iterate until something non-representable is found
|
||||||
fn fold_repr<It: Iterator<Item=Representability>>(iter: It) -> Representability {
|
fn fold_repr<It: Iterator<Item=Representability>>(iter: It) -> Representability {
|
||||||
iter.fold(Representability::Representable, |r1, r2| {
|
iter.fold(Representability::Representable, |r1, r2| {
|
||||||
|
@ -779,12 +779,12 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn are_inner_types_recursive<'tcx>(
|
fn are_inner_types_recursive<'tcx>(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>, sp: Span,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
|
sp: Span,
|
||||||
seen: &mut Vec<Ty<'tcx>>,
|
seen: &mut Vec<Ty<'tcx>>,
|
||||||
representable_cache: &mut FxHashMap<Ty<'tcx>, Representability>,
|
representable_cache: &mut FxHashMap<Ty<'tcx>, Representability>,
|
||||||
ty: Ty<'tcx>)
|
ty: Ty<'tcx>,
|
||||||
-> Representability
|
) -> Representability {
|
||||||
{
|
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
Tuple(ref ts) => {
|
Tuple(ref ts) => {
|
||||||
// Find non representable
|
// Find non representable
|
||||||
|
@ -843,8 +843,8 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||||
sp: Span,
|
sp: Span,
|
||||||
seen: &mut Vec<Ty<'tcx>>,
|
seen: &mut Vec<Ty<'tcx>>,
|
||||||
representable_cache: &mut FxHashMap<Ty<'tcx>, Representability>,
|
representable_cache: &mut FxHashMap<Ty<'tcx>, Representability>,
|
||||||
ty: Ty<'tcx>) -> Representability
|
ty: Ty<'tcx>,
|
||||||
{
|
) -> Representability {
|
||||||
debug!("is_type_structurally_recursive: {:?} {:?}", ty, sp);
|
debug!("is_type_structurally_recursive: {:?} {:?}", ty, sp);
|
||||||
if let Some(representability) = representable_cache.get(ty) {
|
if let Some(representability) = representable_cache.get(ty) {
|
||||||
debug!("is_type_structurally_recursive: {:?} {:?} - (cached) {:?}",
|
debug!("is_type_structurally_recursive: {:?} {:?} - (cached) {:?}",
|
||||||
|
@ -864,8 +864,8 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||||
sp: Span,
|
sp: Span,
|
||||||
seen: &mut Vec<Ty<'tcx>>,
|
seen: &mut Vec<Ty<'tcx>>,
|
||||||
representable_cache: &mut FxHashMap<Ty<'tcx>, Representability>,
|
representable_cache: &mut FxHashMap<Ty<'tcx>, Representability>,
|
||||||
ty: Ty<'tcx>) -> Representability
|
ty: Ty<'tcx>,
|
||||||
{
|
) -> Representability {
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
Adt(def, _) => {
|
Adt(def, _) => {
|
||||||
{
|
{
|
||||||
|
@ -937,10 +937,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_copy_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn is_copy_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
||||||
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
|
|
||||||
-> bool
|
|
||||||
{
|
|
||||||
let (param_env, ty) = query.into_parts();
|
let (param_env, ty) = query.into_parts();
|
||||||
let trait_def_id = tcx.require_lang_item(lang_items::CopyTraitLangItem);
|
let trait_def_id = tcx.require_lang_item(lang_items::CopyTraitLangItem);
|
||||||
tcx.infer_ctxt()
|
tcx.infer_ctxt()
|
||||||
|
@ -953,10 +950,7 @@ fn is_copy_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_sized_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn is_sized_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
||||||
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
|
|
||||||
-> bool
|
|
||||||
{
|
|
||||||
let (param_env, ty) = query.into_parts();
|
let (param_env, ty) = query.into_parts();
|
||||||
let trait_def_id = tcx.require_lang_item(lang_items::SizedTraitLangItem);
|
let trait_def_id = tcx.require_lang_item(lang_items::SizedTraitLangItem);
|
||||||
tcx.infer_ctxt()
|
tcx.infer_ctxt()
|
||||||
|
@ -969,10 +963,7 @@ fn is_sized_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
||||||
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
|
|
||||||
-> bool
|
|
||||||
{
|
|
||||||
let (param_env, ty) = query.into_parts();
|
let (param_env, ty) = query.into_parts();
|
||||||
let trait_def_id = tcx.require_lang_item(lang_items::FreezeTraitLangItem);
|
let trait_def_id = tcx.require_lang_item(lang_items::FreezeTraitLangItem);
|
||||||
tcx.infer_ctxt()
|
tcx.infer_ctxt()
|
||||||
|
@ -988,10 +979,10 @@ fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
#[derive(Clone, HashStable)]
|
#[derive(Clone, HashStable)]
|
||||||
pub struct NeedsDrop(pub bool);
|
pub struct NeedsDrop(pub bool);
|
||||||
|
|
||||||
fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn needs_drop_raw<'tcx>(
|
||||||
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
-> NeedsDrop
|
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
|
||||||
{
|
) -> NeedsDrop {
|
||||||
let (param_env, ty) = query.into_parts();
|
let (param_env, ty) = query.into_parts();
|
||||||
|
|
||||||
let needs_drop = |ty: Ty<'tcx>| -> bool {
|
let needs_drop = |ty: Ty<'tcx>| -> bool {
|
||||||
|
|
|
@ -510,9 +510,8 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
|
||||||
/// `ty::required_region_bounds`, see that for more information.
|
/// `ty::required_region_bounds`, see that for more information.
|
||||||
pub fn object_region_bounds<'gcx, 'tcx>(
|
pub fn object_region_bounds<'gcx, 'tcx>(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
existential_predicates: ty::Binder<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>>)
|
existential_predicates: ty::Binder<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>>,
|
||||||
-> Vec<ty::Region<'tcx>>
|
) -> Vec<ty::Region<'tcx>> {
|
||||||
{
|
|
||||||
// Since we don't actually *know* the self type for an object,
|
// Since we don't actually *know* the self type for an object,
|
||||||
// this "open(err)" serves as a kind of dummy standin -- basically
|
// this "open(err)" serves as a kind of dummy standin -- basically
|
||||||
// a placeholder type.
|
// a placeholder type.
|
||||||
|
|
|
@ -179,11 +179,13 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
|
||||||
fn decl_without_init(&mut self, _id: hir::HirId, _span: Span) { }
|
fn decl_without_init(&mut self, _id: hir::HirId, _span: Span) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_loans<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
pub fn check_loans<'a, 'tcx>(
|
||||||
dfcx_loans: &LoanDataFlow<'tcx>,
|
bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||||
move_data: &move_data::FlowedMoveData<'tcx>,
|
dfcx_loans: &LoanDataFlow<'tcx>,
|
||||||
all_loans: &[Loan<'tcx>],
|
move_data: &move_data::FlowedMoveData<'tcx>,
|
||||||
body: &hir::Body) {
|
all_loans: &[Loan<'tcx>],
|
||||||
|
body: &hir::Body,
|
||||||
|
) {
|
||||||
debug!("check_loans(body id={})", body.value.hir_id);
|
debug!("check_loans(body id={})", body.value.hir_id);
|
||||||
|
|
||||||
let def_id = bccx.tcx.hir().body_owner_def_id(body.id());
|
let def_id = bccx.tcx.hir().body_owner_def_id(body.id());
|
||||||
|
|
|
@ -73,9 +73,7 @@ pub struct AnalysisData<'tcx> {
|
||||||
pub move_data: move_data::FlowedMoveData<'tcx>,
|
pub move_data: move_data::FlowedMoveData<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn borrowck<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, owner_def_id: DefId)
|
fn borrowck<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, owner_def_id: DefId) -> &'tcx BorrowCheckResult {
|
||||||
-> &'tcx BorrowCheckResult
|
|
||||||
{
|
|
||||||
assert!(tcx.use_ast_borrowck() || tcx.migrate_borrowck());
|
assert!(tcx.use_ast_borrowck() || tcx.migrate_borrowck());
|
||||||
|
|
||||||
debug!("borrowck(body_owner_def_id={:?})", owner_def_id);
|
debug!("borrowck(body_owner_def_id={:?})", owner_def_id);
|
||||||
|
@ -141,12 +139,14 @@ fn borrowck<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, owner_def_id: DefId)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_borrowck_dataflow_data<'a, 'c, 'tcx, F>(this: &mut BorrowckCtxt<'a, 'tcx>,
|
fn build_borrowck_dataflow_data<'a, 'c, 'tcx, F>(
|
||||||
force_analysis: bool,
|
this: &mut BorrowckCtxt<'a, 'tcx>,
|
||||||
body_id: hir::BodyId,
|
force_analysis: bool,
|
||||||
get_cfg: F)
|
body_id: hir::BodyId,
|
||||||
-> Option<AnalysisData<'tcx>>
|
get_cfg: F,
|
||||||
where F: FnOnce(&mut BorrowckCtxt<'a, 'tcx>) -> &'c cfg::CFG
|
) -> Option<AnalysisData<'tcx>>
|
||||||
|
where
|
||||||
|
F: FnOnce(&mut BorrowckCtxt<'a, 'tcx>) -> &'c cfg::CFG,
|
||||||
{
|
{
|
||||||
// Check the body of fn items.
|
// Check the body of fn items.
|
||||||
let (all_loans, move_data) =
|
let (all_loans, move_data) =
|
||||||
|
@ -195,9 +195,8 @@ fn build_borrowck_dataflow_data<'a, 'c, 'tcx, F>(this: &mut BorrowckCtxt<'a, 'tc
|
||||||
pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>(
|
pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
body_id: hir::BodyId,
|
body_id: hir::BodyId,
|
||||||
cfg: &cfg::CFG)
|
cfg: &cfg::CFG,
|
||||||
-> (BorrowckCtxt<'a, 'tcx>, AnalysisData<'tcx>)
|
) -> (BorrowckCtxt<'a, 'tcx>, AnalysisData<'tcx>) {
|
||||||
{
|
|
||||||
let owner_id = tcx.hir().body_owner(body_id);
|
let owner_id = tcx.hir().body_owner(body_id);
|
||||||
let owner_def_id = tcx.hir().local_def_id(owner_id);
|
let owner_def_id = tcx.hir().local_def_id(owner_id);
|
||||||
let tables = tcx.typeck_tables_of(owner_def_id);
|
let tables = tcx.typeck_tables_of(owner_def_id);
|
||||||
|
@ -238,7 +237,6 @@ pub struct BorrowckCtxt<'a, 'tcx> {
|
||||||
signalled_any_error: Cell<SignalledError>,
|
signalled_any_error: Cell<SignalledError>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl BorrowckCtxt<'_, 'tcx> {
|
impl BorrowckCtxt<'_, 'tcx> {
|
||||||
fn signal_error(&self) {
|
fn signal_error(&self) {
|
||||||
self.signalled_any_error.set(SignalledError::SawSomeError);
|
self.signalled_any_error.set(SignalledError::SawSomeError);
|
||||||
|
@ -390,8 +388,7 @@ pub enum LoanPathElem<'tcx> {
|
||||||
LpInterior(Option<DefId>, InteriorKind),
|
LpInterior(Option<DefId>, InteriorKind),
|
||||||
}
|
}
|
||||||
|
|
||||||
fn closure_to_block(closure_id: LocalDefId,
|
fn closure_to_block(closure_id: LocalDefId, tcx: TyCtxt<'_, '_>) -> HirId {
|
||||||
tcx: TyCtxt<'_, '_>) -> HirId {
|
|
||||||
let closure_id = tcx.hir().local_def_id_to_node_id(closure_id);
|
let closure_id = tcx.hir().local_def_id_to_node_id(closure_id);
|
||||||
match tcx.hir().get(closure_id) {
|
match tcx.hir().get(closure_id) {
|
||||||
Node::Expr(expr) => match expr.node {
|
Node::Expr(expr) => match expr.node {
|
||||||
|
|
|
@ -47,7 +47,7 @@ pub struct FlowedMoveData<'tcx> {
|
||||||
// We could (and maybe should, for efficiency) combine both move
|
// We could (and maybe should, for efficiency) combine both move
|
||||||
// and assign data flow into one, but this way it's easier to
|
// and assign data flow into one, but this way it's easier to
|
||||||
// distinguish the bits that correspond to moves and assignments.
|
// distinguish the bits that correspond to moves and assignments.
|
||||||
pub dfcx_assign: AssignDataFlow<'tcx>
|
pub dfcx_assign: AssignDataFlow<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Index into `MoveData.paths`, used like a pointer
|
/// Index into `MoveData.paths`, used like a pointer
|
||||||
|
@ -223,8 +223,7 @@ impl MoveData<'tcx> {
|
||||||
|
|
||||||
/// Returns the existing move path index for `lp`, if any, and otherwise adds a new index for
|
/// Returns the existing move path index for `lp`, if any, and otherwise adds a new index for
|
||||||
/// `lp` and any of its base paths that do not yet have an index.
|
/// `lp` and any of its base paths that do not yet have an index.
|
||||||
pub fn move_path(&self, tcx: TyCtxt<'tcx, 'tcx>,
|
pub fn move_path(&self, tcx: TyCtxt<'tcx, 'tcx>, lp: Rc<LoanPath<'tcx>>) -> MovePathIndex {
|
||||||
lp: Rc<LoanPath<'tcx>>) -> MovePathIndex {
|
|
||||||
if let Some(&index) = self.path_map.borrow().get(&lp) {
|
if let Some(&index) = self.path_map.borrow().get(&lp) {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
@ -311,10 +310,13 @@ impl MoveData<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a new move entry for a move of `lp` that occurs at location `id` with kind `kind`.
|
/// Adds a new move entry for a move of `lp` that occurs at location `id` with kind `kind`.
|
||||||
pub fn add_move(&self, tcx: TyCtxt<'tcx, 'tcx>,
|
pub fn add_move(
|
||||||
orig_lp: Rc<LoanPath<'tcx>>,
|
&self,
|
||||||
id: hir::ItemLocalId,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
kind: MoveKind) {
|
orig_lp: Rc<LoanPath<'tcx>>,
|
||||||
|
id: hir::ItemLocalId,
|
||||||
|
kind: MoveKind,
|
||||||
|
) {
|
||||||
// Moving one union field automatically moves all its fields. Also move siblings of
|
// Moving one union field automatically moves all its fields. Also move siblings of
|
||||||
// all parent union fields, moves do not propagate upwards automatically.
|
// all parent union fields, moves do not propagate upwards automatically.
|
||||||
let mut lp = orig_lp.clone();
|
let mut lp = orig_lp.clone();
|
||||||
|
@ -340,10 +342,13 @@ impl MoveData<'tcx> {
|
||||||
self.add_move_helper(tcx, orig_lp, id, kind);
|
self.add_move_helper(tcx, orig_lp, id, kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_move_helper(&self, tcx: TyCtxt<'tcx, 'tcx>,
|
fn add_move_helper(
|
||||||
lp: Rc<LoanPath<'tcx>>,
|
&self,
|
||||||
id: hir::ItemLocalId,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
kind: MoveKind) {
|
lp: Rc<LoanPath<'tcx>>,
|
||||||
|
id: hir::ItemLocalId,
|
||||||
|
kind: MoveKind,
|
||||||
|
) {
|
||||||
debug!("add_move(lp={:?}, id={:?}, kind={:?})",
|
debug!("add_move(lp={:?}, id={:?}, kind={:?})",
|
||||||
lp,
|
lp,
|
||||||
id,
|
id,
|
||||||
|
@ -365,10 +370,13 @@ impl MoveData<'tcx> {
|
||||||
|
|
||||||
/// Adds a new record for an assignment to `lp` that occurs at location `id` with the given
|
/// Adds a new record for an assignment to `lp` that occurs at location `id` with the given
|
||||||
/// `span`.
|
/// `span`.
|
||||||
pub fn add_assignment(&self, tcx: TyCtxt<'tcx, 'tcx>,
|
pub fn add_assignment(
|
||||||
lp: Rc<LoanPath<'tcx>>,
|
&self,
|
||||||
assign_id: hir::ItemLocalId,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
span: Span) {
|
lp: Rc<LoanPath<'tcx>>,
|
||||||
|
assign_id: hir::ItemLocalId,
|
||||||
|
span: Span,
|
||||||
|
) {
|
||||||
// Assigning to one union field automatically assigns to all its fields.
|
// Assigning to one union field automatically assigns to all its fields.
|
||||||
if let LpExtend(ref base_lp, mutbl, LpInterior(opt_variant_id, interior)) = lp.kind {
|
if let LpExtend(ref base_lp, mutbl, LpInterior(opt_variant_id, interior)) = lp.kind {
|
||||||
if let ty::Adt(adt_def, _) = base_lp.ty.sty {
|
if let ty::Adt(adt_def, _) = base_lp.ty.sty {
|
||||||
|
@ -395,10 +403,13 @@ impl MoveData<'tcx> {
|
||||||
self.add_assignment_helper(tcx, lp, assign_id, span);
|
self.add_assignment_helper(tcx, lp, assign_id, span);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_assignment_helper(&self, tcx: TyCtxt<'tcx, 'tcx>,
|
fn add_assignment_helper(
|
||||||
lp: Rc<LoanPath<'tcx>>,
|
&self,
|
||||||
assign_id: hir::ItemLocalId,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
span: Span) {
|
lp: Rc<LoanPath<'tcx>>,
|
||||||
|
assign_id: hir::ItemLocalId,
|
||||||
|
span: Span,
|
||||||
|
) {
|
||||||
debug!("add_assignment(lp={:?}, assign_id={:?}", lp, assign_id);
|
debug!("add_assignment(lp={:?}, assign_id={:?}", lp, assign_id);
|
||||||
|
|
||||||
let path_index = self.move_path(tcx, lp.clone());
|
let path_index = self.move_path(tcx, lp.clone());
|
||||||
|
@ -427,10 +438,12 @@ impl MoveData<'tcx> {
|
||||||
/// Moves are generated by moves and killed by assignments and
|
/// Moves are generated by moves and killed by assignments and
|
||||||
/// scoping. Assignments are generated by assignment to variables and
|
/// scoping. Assignments are generated by assignment to variables and
|
||||||
/// killed by scoping. See `README.md` for more details.
|
/// killed by scoping. See `README.md` for more details.
|
||||||
fn add_gen_kills(&self,
|
fn add_gen_kills(
|
||||||
bccx: &BorrowckCtxt<'_, 'tcx>,
|
&self,
|
||||||
dfcx_moves: &mut MoveDataFlow<'_>,
|
bccx: &BorrowckCtxt<'_, 'tcx>,
|
||||||
dfcx_assign: &mut AssignDataFlow<'_>) {
|
dfcx_moves: &mut MoveDataFlow<'_>,
|
||||||
|
dfcx_assign: &mut AssignDataFlow<'_>,
|
||||||
|
) {
|
||||||
for (i, the_move) in self.moves.borrow().iter().enumerate() {
|
for (i, the_move) in self.moves.borrow().iter().enumerate() {
|
||||||
dfcx_moves.add_gen(the_move.id, i);
|
dfcx_moves.add_gen(the_move.id, i);
|
||||||
}
|
}
|
||||||
|
@ -534,11 +547,13 @@ impl MoveData<'tcx> {
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
fn kill_moves(&self,
|
fn kill_moves(
|
||||||
path: MovePathIndex,
|
&self,
|
||||||
kill_id: hir::ItemLocalId,
|
path: MovePathIndex,
|
||||||
kill_kind: KillFrom,
|
kill_id: hir::ItemLocalId,
|
||||||
dfcx_moves: &mut MoveDataFlow<'_>) {
|
kill_kind: KillFrom,
|
||||||
|
dfcx_moves: &mut MoveDataFlow<'_>,
|
||||||
|
) {
|
||||||
// We can only perform kills for paths that refer to a unique location,
|
// We can only perform kills for paths that refer to a unique location,
|
||||||
// since otherwise we may kill a move from one location with an
|
// since otherwise we may kill a move from one location with an
|
||||||
// assignment referring to another location.
|
// assignment referring to another location.
|
||||||
|
@ -556,11 +571,12 @@ impl MoveData<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> FlowedMoveData<'tcx> {
|
impl<'tcx> FlowedMoveData<'tcx> {
|
||||||
pub fn new(move_data: MoveData<'tcx>,
|
pub fn new(
|
||||||
bccx: &BorrowckCtxt<'_, 'tcx>,
|
move_data: MoveData<'tcx>,
|
||||||
cfg: &cfg::CFG,
|
bccx: &BorrowckCtxt<'_, 'tcx>,
|
||||||
body: &hir::Body)
|
cfg: &cfg::CFG,
|
||||||
-> FlowedMoveData<'tcx> {
|
body: &hir::Body,
|
||||||
|
) -> FlowedMoveData<'tcx> {
|
||||||
let tcx = bccx.tcx;
|
let tcx = bccx.tcx;
|
||||||
|
|
||||||
let mut dfcx_moves =
|
let mut dfcx_moves =
|
||||||
|
|
|
@ -51,7 +51,6 @@ pub struct DataFlowContext<'tcx, O> {
|
||||||
// `id_range`, there is a range of words equal to `words_per_id`.
|
// `id_range`, there is a range of words equal to `words_per_id`.
|
||||||
// So, to access the bits for any given id, you take a slice of
|
// So, to access the bits for any given id, you take a slice of
|
||||||
// the full vector (see the method `compute_id_range()`).
|
// the full vector (see the method `compute_id_range()`).
|
||||||
|
|
||||||
/// bits generated as we exit the cfg node. Updated by `add_gen()`.
|
/// bits generated as we exit the cfg node. Updated by `add_gen()`.
|
||||||
gens: Vec<usize>,
|
gens: Vec<usize>,
|
||||||
|
|
||||||
|
@ -82,7 +81,7 @@ pub trait DataFlowOperator : BitwiseOperator {
|
||||||
|
|
||||||
struct PropagationContext<'a, 'tcx, O> {
|
struct PropagationContext<'a, 'tcx, O> {
|
||||||
dfcx: &'a mut DataFlowContext<'tcx, O>,
|
dfcx: &'a mut DataFlowContext<'tcx, O>,
|
||||||
changed: bool
|
changed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_cfg_indices<'a>(id: hir::ItemLocalId,
|
fn get_cfg_indices<'a>(id: hir::ItemLocalId,
|
||||||
|
@ -98,7 +97,7 @@ impl<'tcx, O: DataFlowOperator> DataFlowContext<'tcx, O> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'tcx, O> {
|
impl<'tcx, O: DataFlowOperator> pprust::PpAnn for DataFlowContext<'tcx, O> {
|
||||||
fn nested(&self, state: &mut pprust::State<'_>, nested: pprust::Nested) -> io::Result<()> {
|
fn nested(&self, state: &mut pprust::State<'_>, nested: pprust::Nested) -> io::Result<()> {
|
||||||
pprust::PpAnn::nested(self.tcx.hir(), state, nested)
|
pprust::PpAnn::nested(self.tcx.hir(), state, nested)
|
||||||
}
|
}
|
||||||
|
@ -225,12 +224,14 @@ pub enum KillFrom {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, O: DataFlowOperator> DataFlowContext<'tcx, O> {
|
impl<'tcx, O: DataFlowOperator> DataFlowContext<'tcx, O> {
|
||||||
pub fn new(tcx: TyCtxt<'tcx, 'tcx>,
|
pub fn new(
|
||||||
analysis_name: &'static str,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
body: Option<&hir::Body>,
|
analysis_name: &'static str,
|
||||||
cfg: &cfg::CFG,
|
body: Option<&hir::Body>,
|
||||||
oper: O,
|
cfg: &cfg::CFG,
|
||||||
bits_per_id: usize) -> DataFlowContext<'tcx, O> {
|
oper: O,
|
||||||
|
bits_per_id: usize,
|
||||||
|
) -> DataFlowContext<'tcx, O> {
|
||||||
let usize_bits = mem::size_of::<usize>() * 8;
|
let usize_bits = mem::size_of::<usize>() * 8;
|
||||||
let words_per_id = (bits_per_id + usize_bits - 1) / usize_bits;
|
let words_per_id = (bits_per_id + usize_bits - 1) / usize_bits;
|
||||||
let num_nodes = cfg.graph.all_nodes().len();
|
let num_nodes = cfg.graph.all_nodes().len();
|
||||||
|
|
|
@ -61,11 +61,14 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_set<O:DataFlowOperator, F>(&self,
|
fn build_set<O: DataFlowOperator, F>(
|
||||||
e: EntryOrExit,
|
&self,
|
||||||
cfgidx: CFGIndex,
|
e: EntryOrExit,
|
||||||
dfcx: &DataFlowContext<'tcx, O>,
|
cfgidx: CFGIndex,
|
||||||
mut to_lp: F) -> String where
|
dfcx: &DataFlowContext<'tcx, O>,
|
||||||
|
mut to_lp: F,
|
||||||
|
) -> String
|
||||||
|
where
|
||||||
F: FnMut(usize) -> Rc<LoanPath<'tcx>>,
|
F: FnMut(usize) -> Rc<LoanPath<'tcx>>,
|
||||||
{
|
{
|
||||||
let mut saw_some = false;
|
let mut saw_some = false;
|
||||||
|
|
|
@ -44,7 +44,7 @@ use crate::value::Value;
|
||||||
pub fn write_compressed_metadata<'a, 'gcx>(
|
pub fn write_compressed_metadata<'a, 'gcx>(
|
||||||
tcx: TyCtxt<'gcx, 'gcx>,
|
tcx: TyCtxt<'gcx, 'gcx>,
|
||||||
metadata: &EncodedMetadata,
|
metadata: &EncodedMetadata,
|
||||||
llvm_module: &mut ModuleLlvm
|
llvm_module: &mut ModuleLlvm,
|
||||||
) {
|
) {
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use flate2::Compression;
|
use flate2::Compression;
|
||||||
|
|
|
@ -47,8 +47,8 @@ pub struct CodegenCx<'ll, 'tcx: 'll> {
|
||||||
/// Cache instances of monomorphic and polymorphic items
|
/// Cache instances of monomorphic and polymorphic items
|
||||||
pub instances: RefCell<FxHashMap<Instance<'tcx>, &'ll Value>>,
|
pub instances: RefCell<FxHashMap<Instance<'tcx>, &'ll Value>>,
|
||||||
/// Cache generated vtables
|
/// Cache generated vtables
|
||||||
pub vtables: RefCell<FxHashMap<
|
pub vtables:
|
||||||
(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), &'ll Value>>,
|
RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), &'ll Value>>,
|
||||||
/// Cache of constant strings,
|
/// Cache of constant strings,
|
||||||
pub const_cstr_cache: RefCell<FxHashMap<LocalInternedString, &'ll Value>>,
|
pub const_cstr_cache: RefCell<FxHashMap<LocalInternedString, &'ll Value>>,
|
||||||
|
|
||||||
|
@ -207,10 +207,11 @@ pub unsafe fn create_module(
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
||||||
crate fn new(tcx: TyCtxt<'tcx, 'tcx>,
|
crate fn new(
|
||||||
codegen_unit: Arc<CodegenUnit<'tcx>>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
llvm_module: &'ll crate::ModuleLlvm)
|
codegen_unit: Arc<CodegenUnit<'tcx>>,
|
||||||
-> Self {
|
llvm_module: &'ll crate::ModuleLlvm,
|
||||||
|
) -> Self {
|
||||||
// An interesting part of Windows which MSVC forces our hand on (and
|
// An interesting part of Windows which MSVC forces our hand on (and
|
||||||
// apparently MinGW didn't) is the usage of `dllimport` and `dllexport`
|
// apparently MinGW didn't) is the usage of `dllimport` and `dllexport`
|
||||||
// attributes in LLVM IR as well as native dependencies (in C these
|
// attributes in LLVM IR as well as native dependencies (in C these
|
||||||
|
|
|
@ -894,10 +894,11 @@ fn pointer_type_metadata(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compile_unit_metadata(tcx: TyCtxt<'_, '_>,
|
pub fn compile_unit_metadata(
|
||||||
codegen_unit_name: &str,
|
tcx: TyCtxt<'_, '_>,
|
||||||
debug_context: &CrateDebugContext<'ll, '_>)
|
codegen_unit_name: &str,
|
||||||
-> &'ll DIDescriptor {
|
debug_context: &CrateDebugContext<'ll, '_>,
|
||||||
|
) -> &'ll DIDescriptor {
|
||||||
let mut name_in_debuginfo = match tcx.sess.local_crate_source_file {
|
let mut name_in_debuginfo = match tcx.sess.local_crate_source_file {
|
||||||
Some(ref path) => path.clone(),
|
Some(ref path) => path.clone(),
|
||||||
None => PathBuf::from(&*tcx.crate_name(LOCAL_CRATE).as_str()),
|
None => PathBuf::from(&*tcx.crate_name(LOCAL_CRATE).as_str()),
|
||||||
|
|
|
@ -111,7 +111,7 @@ impl ExtraBackendMethods for LlvmCodegenBackend {
|
||||||
&self,
|
&self,
|
||||||
tcx: TyCtxt<'gcx, 'gcx>,
|
tcx: TyCtxt<'gcx, 'gcx>,
|
||||||
metadata: &EncodedMetadata,
|
metadata: &EncodedMetadata,
|
||||||
llvm_module: &mut ModuleLlvm
|
llvm_module: &mut ModuleLlvm,
|
||||||
) {
|
) {
|
||||||
base::write_compressed_metadata(tcx, metadata, llvm_module)
|
base::write_compressed_metadata(tcx, metadata, llvm_module)
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ impl ExtraBackendMethods for LlvmCodegenBackend {
|
||||||
&self,
|
&self,
|
||||||
tcx: TyCtxt<'gcx, 'gcx>,
|
tcx: TyCtxt<'gcx, 'gcx>,
|
||||||
mods: &mut ModuleLlvm,
|
mods: &mut ModuleLlvm,
|
||||||
kind: AllocatorKind
|
kind: AllocatorKind,
|
||||||
) {
|
) {
|
||||||
unsafe { allocator::codegen(tcx, mods, kind) }
|
unsafe { allocator::codegen(tcx, mods, kind) }
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ impl CodegenBackend for LlvmCodegenBackend {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
metadata: EncodedMetadata,
|
metadata: EncodedMetadata,
|
||||||
need_metadata_module: bool,
|
need_metadata_module: bool,
|
||||||
rx: mpsc::Receiver<Box<dyn Any + Send>>
|
rx: mpsc::Receiver<Box<dyn Any + Send>>,
|
||||||
) -> Box<dyn Any> {
|
) -> Box<dyn Any> {
|
||||||
box rustc_codegen_ssa::base::codegen_crate(
|
box rustc_codegen_ssa::base::codegen_crate(
|
||||||
LlvmCodegenBackend(()), tcx, metadata, need_metadata_module, rx)
|
LlvmCodegenBackend(()), tcx, metadata, need_metadata_module, rx)
|
||||||
|
|
|
@ -46,10 +46,10 @@ pub fn crates_export_threshold(crate_types: &[config::CrateType]) -> SymbolExpor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reachable_non_generics_provider<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn reachable_non_generics_provider<'tcx>(
|
||||||
cnum: CrateNum)
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
-> &'tcx DefIdMap<SymbolExportLevel>
|
cnum: CrateNum,
|
||||||
{
|
) -> &'tcx DefIdMap<SymbolExportLevel> {
|
||||||
assert_eq!(cnum, LOCAL_CRATE);
|
assert_eq!(cnum, LOCAL_CRATE);
|
||||||
|
|
||||||
if !tcx.sess.opts.output_types.should_codegen() {
|
if !tcx.sess.opts.output_types.should_codegen() {
|
||||||
|
@ -157,9 +157,7 @@ fn reachable_non_generics_provider<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
tcx.arena.alloc(reachable_non_generics)
|
tcx.arena.alloc(reachable_non_generics)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_reachable_non_generic_provider_local<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn is_reachable_non_generic_provider_local<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool {
|
||||||
def_id: DefId)
|
|
||||||
-> bool {
|
|
||||||
let export_threshold = threshold(tcx);
|
let export_threshold = threshold(tcx);
|
||||||
|
|
||||||
if let Some(&level) = tcx.reachable_non_generics(def_id.krate).get(&def_id) {
|
if let Some(&level) = tcx.reachable_non_generics(def_id.krate).get(&def_id) {
|
||||||
|
@ -169,17 +167,14 @@ fn is_reachable_non_generic_provider_local<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_reachable_non_generic_provider_extern<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn is_reachable_non_generic_provider_extern<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> bool {
|
||||||
def_id: DefId)
|
|
||||||
-> bool {
|
|
||||||
tcx.reachable_non_generics(def_id.krate).contains_key(&def_id)
|
tcx.reachable_non_generics(def_id.krate).contains_key(&def_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exported_symbols_provider_local<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn exported_symbols_provider_local<'tcx>(
|
||||||
cnum: CrateNum)
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
-> Arc<Vec<(ExportedSymbol<'tcx>,
|
cnum: CrateNum,
|
||||||
SymbolExportLevel)>>
|
) -> Arc<Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)>> {
|
||||||
{
|
|
||||||
assert_eq!(cnum, LOCAL_CRATE);
|
assert_eq!(cnum, LOCAL_CRATE);
|
||||||
|
|
||||||
if !tcx.sess.opts.output_types.should_codegen() {
|
if !tcx.sess.opts.output_types.should_codegen() {
|
||||||
|
@ -280,9 +275,8 @@ fn exported_symbols_provider_local<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
|
|
||||||
fn upstream_monomorphizations_provider<'tcx>(
|
fn upstream_monomorphizations_provider<'tcx>(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
cnum: CrateNum)
|
cnum: CrateNum,
|
||||||
-> &'tcx DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>>
|
) -> &'tcx DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
|
||||||
{
|
|
||||||
debug_assert!(cnum == LOCAL_CRATE);
|
debug_assert!(cnum == LOCAL_CRATE);
|
||||||
|
|
||||||
let cnums = tcx.all_crate_nums(LOCAL_CRATE);
|
let cnums = tcx.all_crate_nums(LOCAL_CRATE);
|
||||||
|
@ -330,9 +324,8 @@ fn upstream_monomorphizations_provider<'tcx>(
|
||||||
|
|
||||||
fn upstream_monomorphizations_for_provider<'tcx>(
|
fn upstream_monomorphizations_for_provider<'tcx>(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
def_id: DefId)
|
def_id: DefId,
|
||||||
-> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>>
|
) -> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>> {
|
||||||
{
|
|
||||||
debug_assert!(!def_id.is_local());
|
debug_assert!(!def_id.is_local());
|
||||||
tcx.upstream_monomorphizations(LOCAL_CRATE).get(&def_id)
|
tcx.upstream_monomorphizations(LOCAL_CRATE).get(&def_id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -378,7 +378,7 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
|
||||||
tcx: TyCtxt<'_, '_>,
|
tcx: TyCtxt<'_, '_>,
|
||||||
metadata: EncodedMetadata,
|
metadata: EncodedMetadata,
|
||||||
coordinator_receive: Receiver<Box<dyn Any + Send>>,
|
coordinator_receive: Receiver<Box<dyn Any + Send>>,
|
||||||
total_cgus: usize
|
total_cgus: usize,
|
||||||
) -> OngoingCodegen<B> {
|
) -> OngoingCodegen<B> {
|
||||||
let sess = tcx.sess;
|
let sess = tcx.sess;
|
||||||
let crate_name = tcx.crate_name(LOCAL_CRATE);
|
let crate_name = tcx.crate_name(LOCAL_CRATE);
|
||||||
|
@ -1005,7 +1005,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
||||||
jobserver: Client,
|
jobserver: Client,
|
||||||
modules_config: Arc<ModuleConfig>,
|
modules_config: Arc<ModuleConfig>,
|
||||||
metadata_config: Arc<ModuleConfig>,
|
metadata_config: Arc<ModuleConfig>,
|
||||||
allocator_config: Arc<ModuleConfig>
|
allocator_config: Arc<ModuleConfig>,
|
||||||
) -> thread::JoinHandle<Result<CompiledModules, ()>> {
|
) -> thread::JoinHandle<Result<CompiledModules, ()>> {
|
||||||
let coordinator_send = tcx.tx_to_llvm_workers.lock().clone();
|
let coordinator_send = tcx.tx_to_llvm_workers.lock().clone();
|
||||||
let sess = tcx.sess;
|
let sess = tcx.sess;
|
||||||
|
@ -1861,9 +1861,11 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
|
||||||
}, work_products)
|
}, work_products)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn submit_pre_codegened_module_to_llvm(&self,
|
pub fn submit_pre_codegened_module_to_llvm(
|
||||||
tcx: TyCtxt<'_, '_>,
|
&self,
|
||||||
module: ModuleCodegen<B::Module>) {
|
tcx: TyCtxt<'_, '_>,
|
||||||
|
module: ModuleCodegen<B::Module>,
|
||||||
|
) {
|
||||||
self.wait_for_signal_to_codegen_item();
|
self.wait_for_signal_to_codegen_item();
|
||||||
self.check_for_errors(tcx.sess);
|
self.check_for_errors(tcx.sess);
|
||||||
|
|
||||||
|
@ -1913,7 +1915,7 @@ pub fn submit_codegened_module_to_llvm<B: ExtraBackendMethods>(
|
||||||
_backend: &B,
|
_backend: &B,
|
||||||
tcx: TyCtxt<'_, '_>,
|
tcx: TyCtxt<'_, '_>,
|
||||||
module: ModuleCodegen<B::Module>,
|
module: ModuleCodegen<B::Module>,
|
||||||
cost: u64
|
cost: u64,
|
||||||
) {
|
) {
|
||||||
let llvm_work_item = WorkItem::Optimize(module);
|
let llvm_work_item = WorkItem::Optimize(module);
|
||||||
drop(tcx.tx_to_llvm_workers.lock().send(Box::new(Message::CodegenDone::<B> {
|
drop(tcx.tx_to_llvm_workers.lock().send(Box::new(Message::CodegenDone::<B> {
|
||||||
|
@ -1925,7 +1927,7 @@ pub fn submit_codegened_module_to_llvm<B: ExtraBackendMethods>(
|
||||||
pub fn submit_post_lto_module_to_llvm<B: ExtraBackendMethods>(
|
pub fn submit_post_lto_module_to_llvm<B: ExtraBackendMethods>(
|
||||||
_backend: &B,
|
_backend: &B,
|
||||||
tcx: TyCtxt<'_, '_>,
|
tcx: TyCtxt<'_, '_>,
|
||||||
module: CachedModuleCodegen
|
module: CachedModuleCodegen,
|
||||||
) {
|
) {
|
||||||
let llvm_work_item = WorkItem::CopyPostLtoArtifacts(module);
|
let llvm_work_item = WorkItem::CopyPostLtoArtifacts(module);
|
||||||
drop(tcx.tx_to_llvm_workers.lock().send(Box::new(Message::CodegenDone::<B> {
|
drop(tcx.tx_to_llvm_workers.lock().send(Box::new(Message::CodegenDone::<B> {
|
||||||
|
@ -1937,7 +1939,7 @@ pub fn submit_post_lto_module_to_llvm<B: ExtraBackendMethods>(
|
||||||
pub fn submit_pre_lto_module_to_llvm<B: ExtraBackendMethods>(
|
pub fn submit_pre_lto_module_to_llvm<B: ExtraBackendMethods>(
|
||||||
_backend: &B,
|
_backend: &B,
|
||||||
tcx: TyCtxt<'_, '_>,
|
tcx: TyCtxt<'_, '_>,
|
||||||
module: CachedModuleCodegen
|
module: CachedModuleCodegen,
|
||||||
) {
|
) {
|
||||||
let filename = pre_lto_bitcode_filename(&module.name);
|
let filename = pre_lto_bitcode_filename(&module.name);
|
||||||
let bc_path = in_incr_comp_dir_sess(tcx.sess, &filename);
|
let bc_path = in_incr_comp_dir_sess(tcx.sess, &filename);
|
||||||
|
|
|
@ -483,9 +483,8 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
metadata: EncodedMetadata,
|
metadata: EncodedMetadata,
|
||||||
need_metadata_module: bool,
|
need_metadata_module: bool,
|
||||||
rx: mpsc::Receiver<Box<dyn Any + Send>>
|
rx: mpsc::Receiver<Box<dyn Any + Send>>,
|
||||||
) -> OngoingCodegen<B> {
|
) -> OngoingCodegen<B> {
|
||||||
|
|
||||||
check_for_rustc_errors_attr(tcx);
|
check_for_rustc_errors_attr(tcx);
|
||||||
|
|
||||||
// Skip crate items and just output metadata in -Z no-codegen mode.
|
// Skip crate items and just output metadata in -Z no-codegen mode.
|
||||||
|
@ -776,7 +775,7 @@ impl CrateInfo {
|
||||||
info.missing_lang_items.insert(cnum, missing);
|
info.missing_lang_items.insert(cnum, missing);
|
||||||
}
|
}
|
||||||
|
|
||||||
return info
|
return info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -850,9 +849,7 @@ pub fn provide_both(providers: &mut Providers<'_>) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cgu: &CodegenUnit<'tcx>) -> CguReuse {
|
||||||
cgu: &CodegenUnit<'tcx>)
|
|
||||||
-> CguReuse {
|
|
||||||
if !tcx.dep_graph.is_fully_enabled() {
|
if !tcx.dep_graph.is_fully_enabled() {
|
||||||
return CguReuse::No
|
return CguReuse::No
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,11 +122,7 @@ mod temp_stable_hash_impls {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn langcall(tcx: TyCtxt<'_, '_>,
|
pub fn langcall(tcx: TyCtxt<'_, '_>, span: Option<Span>, msg: &str, li: LangItem) -> DefId {
|
||||||
span: Option<Span>,
|
|
||||||
msg: &str,
|
|
||||||
li: LangItem)
|
|
||||||
-> DefId {
|
|
||||||
tcx.lang_items().require(li).unwrap_or_else(|s| {
|
tcx.lang_items().require(li).unwrap_or_else(|s| {
|
||||||
let msg = format!("{} {}", msg, s);
|
let msg = format!("{} {}", msg, s);
|
||||||
match span {
|
match span {
|
||||||
|
|
|
@ -8,10 +8,11 @@ use rustc_data_structures::fx::FxHashSet;
|
||||||
// any caching, i.e., calling the function twice with the same type will also do
|
// any caching, i.e., calling the function twice with the same type will also do
|
||||||
// the work twice. The `qualified` parameter only affects the first level of the
|
// the work twice. The `qualified` parameter only affects the first level of the
|
||||||
// type name, further levels (i.e., type parameters) are always fully qualified.
|
// type name, further levels (i.e., type parameters) are always fully qualified.
|
||||||
pub fn compute_debuginfo_type_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
pub fn compute_debuginfo_type_name<'tcx>(
|
||||||
t: Ty<'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
qualified: bool)
|
t: Ty<'tcx>,
|
||||||
-> String {
|
qualified: bool,
|
||||||
|
) -> String {
|
||||||
let mut result = String::with_capacity(64);
|
let mut result = String::with_capacity(64);
|
||||||
let mut visited = FxHashSet::default();
|
let mut visited = FxHashSet::default();
|
||||||
push_debuginfo_type_name(tcx, t, qualified, &mut result, &mut visited);
|
push_debuginfo_type_name(tcx, t, qualified, &mut result, &mut visited);
|
||||||
|
@ -20,12 +21,13 @@ pub fn compute_debuginfo_type_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
|
|
||||||
// Pushes the name of the type as it should be stored in debuginfo on the
|
// Pushes the name of the type as it should be stored in debuginfo on the
|
||||||
// `output` String. See also compute_debuginfo_type_name().
|
// `output` String. See also compute_debuginfo_type_name().
|
||||||
pub fn push_debuginfo_type_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
pub fn push_debuginfo_type_name<'tcx>(
|
||||||
t: Ty<'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
qualified: bool,
|
t: Ty<'tcx>,
|
||||||
output: &mut String,
|
qualified: bool,
|
||||||
visited: &mut FxHashSet<Ty<'tcx>>) {
|
output: &mut String,
|
||||||
|
visited: &mut FxHashSet<Ty<'tcx>>,
|
||||||
|
) {
|
||||||
// When targeting MSVC, emit C++ style type names for compatibility with
|
// When targeting MSVC, emit C++ style type names for compatibility with
|
||||||
// .natvis visualizers (and perhaps other existing native debuggers?)
|
// .natvis visualizers (and perhaps other existing native debuggers?)
|
||||||
let cpp_like_names = tcx.sess.target.target.options.is_like_msvc;
|
let cpp_like_names = tcx.sess.target.target.options.is_like_msvc;
|
||||||
|
@ -208,10 +210,12 @@ pub fn push_debuginfo_type_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_item_name(tcx: TyCtxt<'tcx, 'tcx>,
|
fn push_item_name(
|
||||||
def_id: DefId,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
qualified: bool,
|
def_id: DefId,
|
||||||
output: &mut String) {
|
qualified: bool,
|
||||||
|
output: &mut String,
|
||||||
|
) {
|
||||||
if qualified {
|
if qualified {
|
||||||
output.push_str(&tcx.crate_name(def_id.krate).as_str());
|
output.push_str(&tcx.crate_name(def_id.krate).as_str());
|
||||||
for path_element in tcx.def_path(def_id).data {
|
for path_element in tcx.def_path(def_id).data {
|
||||||
|
@ -228,10 +232,12 @@ pub fn push_debuginfo_type_name<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
// reconstructed for items from non-local crates. For local crates, this
|
// reconstructed for items from non-local crates. For local crates, this
|
||||||
// would be possible but with inlining and LTO we have to use the least
|
// would be possible but with inlining and LTO we have to use the least
|
||||||
// common denominator - otherwise we would run into conflicts.
|
// common denominator - otherwise we would run into conflicts.
|
||||||
fn push_type_params<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn push_type_params<'tcx>(
|
||||||
substs: SubstsRef<'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
output: &mut String,
|
substs: SubstsRef<'tcx>,
|
||||||
visited: &mut FxHashSet<Ty<'tcx>>) {
|
output: &mut String,
|
||||||
|
visited: &mut FxHashSet<Ty<'tcx>>,
|
||||||
|
) {
|
||||||
if substs.types().next().is_none() {
|
if substs.types().next().is_none() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,13 +42,9 @@ pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Se
|
||||||
&self,
|
&self,
|
||||||
tcx: TyCtxt<'gcx, 'gcx>,
|
tcx: TyCtxt<'gcx, 'gcx>,
|
||||||
mods: &mut Self::Module,
|
mods: &mut Self::Module,
|
||||||
kind: AllocatorKind
|
kind: AllocatorKind,
|
||||||
);
|
|
||||||
fn compile_codegen_unit<'a, 'tcx: 'a>(
|
|
||||||
&self,
|
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
|
||||||
cgu_name: InternedString,
|
|
||||||
);
|
);
|
||||||
|
fn compile_codegen_unit<'a, 'tcx: 'a>(&self, tcx: TyCtxt<'tcx, 'tcx>, cgu_name: InternedString);
|
||||||
// If find_features is true this won't access `sess.crate_types` by assuming
|
// If find_features is true this won't access `sess.crate_types` by assuming
|
||||||
// that `is_pie_binary` is false. When we discover LLVM target features
|
// that `is_pie_binary` is false. When we discover LLVM target features
|
||||||
// `sess.crate_types` is uninitialized so we cannot access it.
|
// `sess.crate_types` is uninitialized so we cannot access it.
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
|
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
|
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
@ -39,7 +38,7 @@ pub trait CodegenBackend {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
metadata: EncodedMetadata,
|
metadata: EncodedMetadata,
|
||||||
need_metadata_module: bool,
|
need_metadata_module: bool,
|
||||||
rx: mpsc::Receiver<Box<dyn Any + Send>>
|
rx: mpsc::Receiver<Box<dyn Any + Send>>,
|
||||||
) -> Box<dyn Any>;
|
) -> Box<dyn Any>;
|
||||||
|
|
||||||
/// This is called on the returned `Box<dyn Any>` from `codegen_backend`
|
/// This is called on the returned `Box<dyn Any>` from `codegen_backend`
|
||||||
|
|
|
@ -154,12 +154,14 @@ pub fn parse_pretty(sess: &Session,
|
||||||
|
|
||||||
impl PpSourceMode {
|
impl PpSourceMode {
|
||||||
/// Constructs a `PrinterSupport` object and passes it to `f`.
|
/// Constructs a `PrinterSupport` object and passes it to `f`.
|
||||||
fn call_with_pp_support<'tcx, A, F>(&self,
|
fn call_with_pp_support<'tcx, A, F>(
|
||||||
sess: &'tcx Session,
|
&self,
|
||||||
tcx: Option<TyCtxt<'tcx, 'tcx>>,
|
sess: &'tcx Session,
|
||||||
f: F)
|
tcx: Option<TyCtxt<'tcx, 'tcx>>,
|
||||||
-> A
|
f: F,
|
||||||
where F: FnOnce(&dyn PrinterSupport) -> A
|
) -> A
|
||||||
|
where
|
||||||
|
F: FnOnce(&dyn PrinterSupport) -> A,
|
||||||
{
|
{
|
||||||
match *self {
|
match *self {
|
||||||
PpmNormal | PpmEveryBodyLoops | PpmExpanded => {
|
PpmNormal | PpmEveryBodyLoops | PpmExpanded => {
|
||||||
|
@ -186,12 +188,9 @@ impl PpSourceMode {
|
||||||
_ => panic!("Should use call_with_pp_support_hir"),
|
_ => panic!("Should use call_with_pp_support_hir"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn call_with_pp_support_hir<'tcx, A, F>(
|
fn call_with_pp_support_hir<'tcx, A, F>(&self, tcx: TyCtxt<'tcx, 'tcx>, f: F) -> A
|
||||||
&self,
|
where
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
F: FnOnce(&dyn HirPrinterSupport<'_>, &hir::Crate) -> A,
|
||||||
f: F
|
|
||||||
) -> A
|
|
||||||
where F: FnOnce(&dyn HirPrinterSupport<'_>, &hir::Crate) -> A
|
|
||||||
{
|
{
|
||||||
match *self {
|
match *self {
|
||||||
PpmNormal => {
|
PpmNormal => {
|
||||||
|
@ -454,7 +453,6 @@ impl<'a> pprust::PpAnn for HygieneAnnotation<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct TypedAnnotation<'a, 'tcx: 'a> {
|
struct TypedAnnotation<'a, 'tcx: 'a> {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
tables: Cell<&'a ty::TypeckTables<'tcx>>,
|
tables: Cell<&'a ty::TypeckTables<'tcx>>,
|
||||||
|
@ -617,12 +615,13 @@ impl UserIdentifiedItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_flowgraph<'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
|
fn print_flowgraph<'tcx, W: Write>(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
variants: Vec<borrowck_dot::Variant>,
|
||||||
code: blocks::Code<'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
mode: PpFlowGraphMode,
|
code: blocks::Code<'tcx>,
|
||||||
mut out: W)
|
mode: PpFlowGraphMode,
|
||||||
-> io::Result<()> {
|
mut out: W,
|
||||||
|
) -> io::Result<()> {
|
||||||
let body_id = match code {
|
let body_id = match code {
|
||||||
blocks::Code::Expr(expr) => {
|
blocks::Code::Expr(expr) => {
|
||||||
// Find the function this expression is from.
|
// Find the function this expression is from.
|
||||||
|
@ -760,7 +759,8 @@ pub fn print_after_hir_lowering<'tcx>(
|
||||||
krate: &ast::Crate,
|
krate: &ast::Crate,
|
||||||
ppm: PpMode,
|
ppm: PpMode,
|
||||||
opt_uii: Option<UserIdentifiedItem>,
|
opt_uii: Option<UserIdentifiedItem>,
|
||||||
ofile: Option<&Path>) {
|
ofile: Option<&Path>,
|
||||||
|
) {
|
||||||
if ppm.needs_analysis() {
|
if ppm.needs_analysis() {
|
||||||
abort_on_err(print_with_analysis(
|
abort_on_err(print_with_analysis(
|
||||||
tcx,
|
tcx,
|
||||||
|
@ -869,7 +869,7 @@ fn print_with_analysis<'tcx>(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
ppm: PpMode,
|
ppm: PpMode,
|
||||||
uii: Option<UserIdentifiedItem>,
|
uii: Option<UserIdentifiedItem>,
|
||||||
ofile: Option<&Path>
|
ofile: Option<&Path>,
|
||||||
) -> Result<(), ErrorReported> {
|
) -> Result<(), ErrorReported> {
|
||||||
let nodeid = if let Some(uii) = uii {
|
let nodeid = if let Some(uii) = uii {
|
||||||
debug!("pretty printing for {:?}", uii);
|
debug!("pretty printing for {:?}", uii);
|
||||||
|
|
|
@ -184,10 +184,11 @@ impl Visitor<'tcx> for IfThisChanged<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_paths<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn check_paths<'tcx>(
|
||||||
if_this_changed: &Sources,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
then_this_would_need: &Targets)
|
if_this_changed: &Sources,
|
||||||
{
|
then_this_would_need: &Targets,
|
||||||
|
) {
|
||||||
// Return early here so as not to construct the query, which is not cheap.
|
// Return early here so as not to construct the query, which is not cheap.
|
||||||
if if_this_changed.is_empty() {
|
if if_this_changed.is_empty() {
|
||||||
for &(target_span, _, _, _) in then_this_would_need {
|
for &(target_span, _, _, _) in then_this_would_need {
|
||||||
|
|
|
@ -129,8 +129,7 @@ fn save_in<F>(sess: &Session, path_buf: PathBuf, encode: F)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_dep_graph(tcx: TyCtxt<'_, '_>,
|
fn encode_dep_graph(tcx: TyCtxt<'_, '_>, encoder: &mut Encoder) {
|
||||||
encoder: &mut Encoder) {
|
|
||||||
// First encode the commandline arguments hash
|
// First encode the commandline arguments hash
|
||||||
tcx.sess.opts.dep_tracking_hash().encode(encoder).unwrap();
|
tcx.sess.opts.dep_tracking_hash().encode(encoder).unwrap();
|
||||||
|
|
||||||
|
@ -234,8 +233,7 @@ fn encode_work_product_index(work_products: &FxHashMap<WorkProductId, WorkProduc
|
||||||
serialized_products.encode(encoder).unwrap();
|
serialized_products.encode(encoder).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_query_cache(tcx: TyCtxt<'_, '_>,
|
fn encode_query_cache(tcx: TyCtxt<'_, '_>, encoder: &mut Encoder) {
|
||||||
encoder: &mut Encoder) {
|
|
||||||
time(tcx.sess, "serialize query result cache", || {
|
time(tcx.sess, "serialize query result cache", || {
|
||||||
tcx.serialize_query_result_cache(encoder).unwrap();
|
tcx.serialize_query_result_cache(encoder).unwrap();
|
||||||
})
|
})
|
||||||
|
|
|
@ -798,7 +798,7 @@ declare_box_region_type!(
|
||||||
impl BoxedGlobalCtxt {
|
impl BoxedGlobalCtxt {
|
||||||
pub fn enter<F, R>(&mut self, f: F) -> R
|
pub fn enter<F, R>(&mut self, f: F) -> R
|
||||||
where
|
where
|
||||||
F: for<'tcx> FnOnce(TyCtxt<'tcx, 'tcx>) -> R
|
F: for<'tcx> FnOnce(TyCtxt<'tcx, 'tcx>) -> R,
|
||||||
{
|
{
|
||||||
self.access(|gcx| ty::tls::enter_global(gcx, |tcx| f(tcx)))
|
self.access(|gcx| ty::tls::enter_global(gcx, |tcx| f(tcx)))
|
||||||
}
|
}
|
||||||
|
@ -878,10 +878,7 @@ pub fn create_global_ctxt(
|
||||||
|
|
||||||
/// Runs the resolution, type-checking, region checking and other
|
/// Runs the resolution, type-checking, region checking and other
|
||||||
/// miscellaneous analysis passes on the crate.
|
/// miscellaneous analysis passes on the crate.
|
||||||
fn analysis<'tcx>(
|
fn analysis<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum) -> Result<()> {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
|
||||||
cnum: CrateNum,
|
|
||||||
) -> Result<()> {
|
|
||||||
assert_eq!(cnum, LOCAL_CRATE);
|
assert_eq!(cnum, LOCAL_CRATE);
|
||||||
|
|
||||||
let sess = tcx.sess;
|
let sess = tcx.sess;
|
||||||
|
|
|
@ -10,10 +10,7 @@ pub fn find<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Option<DefId> {
|
||||||
tcx.proc_macro_decls_static(LOCAL_CRATE)
|
tcx.proc_macro_decls_static(LOCAL_CRATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn proc_macro_decls_static<'tcx>(
|
fn proc_macro_decls_static<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, cnum: CrateNum) -> Option<DefId> {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
|
||||||
cnum: CrateNum,
|
|
||||||
) -> Option<DefId> {
|
|
||||||
assert_eq!(cnum, LOCAL_CRATE);
|
assert_eq!(cnum, LOCAL_CRATE);
|
||||||
|
|
||||||
let mut finder = Finder { decls: None };
|
let mut finder = Finder { decls: None };
|
||||||
|
|
|
@ -555,11 +555,12 @@ fn ty_is_known_nonnull<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||||
/// to function pointers, references, core::num::NonZero*,
|
/// to function pointers, references, core::num::NonZero*,
|
||||||
/// core::ptr::NonNull, and #[repr(transparent)] newtypes.
|
/// core::ptr::NonNull, and #[repr(transparent)] newtypes.
|
||||||
/// FIXME: This duplicates code in codegen.
|
/// FIXME: This duplicates code in codegen.
|
||||||
fn is_repr_nullable_ptr<'tcx>(tcx: TyCtxt<'tcx, 'tcx>,
|
fn is_repr_nullable_ptr<'tcx>(
|
||||||
ty: Ty<'tcx>,
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
ty_def: &'tcx ty::AdtDef,
|
ty: Ty<'tcx>,
|
||||||
substs: SubstsRef<'tcx>)
|
ty_def: &'tcx ty::AdtDef,
|
||||||
-> bool {
|
substs: SubstsRef<'tcx>,
|
||||||
|
) -> bool {
|
||||||
if ty_def.variants.len() != 2 {
|
if ty_def.variants.len() != 2 {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,7 +314,7 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
|
||||||
fn add_query_description_impl(
|
fn add_query_description_impl(
|
||||||
query: &Query,
|
query: &Query,
|
||||||
modifiers: QueryModifiers,
|
modifiers: QueryModifiers,
|
||||||
impls: &mut proc_macro2::TokenStream
|
impls: &mut proc_macro2::TokenStream,
|
||||||
) {
|
) {
|
||||||
let name = &query.name;
|
let name = &query.name;
|
||||||
let arg = &query.arg;
|
let arg = &query.arg;
|
||||||
|
|
|
@ -550,10 +550,7 @@ impl CrateStore for cstore::CStore {
|
||||||
self.do_postorder_cnums_untracked()
|
self.do_postorder_cnums_untracked()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_metadata<'tcx>(&self,
|
fn encode_metadata<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>) -> EncodedMetadata {
|
||||||
tcx: TyCtxt<'tcx, 'tcx>)
|
|
||||||
-> EncodedMetadata
|
|
||||||
{
|
|
||||||
encoder::encode_metadata(tcx)
|
encoder::encode_metadata(tcx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,9 @@ pub trait Metadata<'a, 'tcx>: Copy {
|
||||||
fn raw_bytes(self) -> &'a [u8];
|
fn raw_bytes(self) -> &'a [u8];
|
||||||
fn cdata(self) -> Option<&'a CrateMetadata> { None }
|
fn cdata(self) -> Option<&'a CrateMetadata> { None }
|
||||||
fn sess(self) -> Option<&'a Session> { None }
|
fn sess(self) -> Option<&'a Session> { None }
|
||||||
fn tcx(self) -> Option<TyCtxt<'tcx, 'tcx>> { None }
|
fn tcx(self) -> Option<TyCtxt<'tcx, 'tcx>> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
fn decoder(self, pos: usize) -> DecodeContext<'a, 'tcx> {
|
fn decoder(self, pos: usize) -> DecodeContext<'a, 'tcx> {
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
|
@ -170,7 +172,6 @@ impl<'a, 'tcx> DecodeContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> TyDecoder<'tcx> for DecodeContext<'a, 'tcx> {
|
impl<'a, 'tcx> TyDecoder<'tcx> for DecodeContext<'a, 'tcx> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
|
fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
|
||||||
self.tcx.expect("missing TyCtxt in DecodeContext")
|
self.tcx.expect("missing TyCtxt in DecodeContext")
|
||||||
|
@ -551,7 +552,7 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
item: &Entry<'_>,
|
item: &Entry<'_>,
|
||||||
index: DefIndex,
|
index: DefIndex,
|
||||||
parent_did: DefId,
|
parent_did: DefId,
|
||||||
adt_kind: ty::AdtKind
|
adt_kind: ty::AdtKind,
|
||||||
) -> ty::VariantDef {
|
) -> ty::VariantDef {
|
||||||
let data = match item.kind {
|
let data = match item.kind {
|
||||||
EntryKind::Variant(data) |
|
EntryKind::Variant(data) |
|
||||||
|
@ -588,10 +589,7 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_adt_def(&self,
|
pub fn get_adt_def(&self, item_id: DefIndex, tcx: TyCtxt<'tcx, 'tcx>) -> &'tcx ty::AdtDef {
|
||||||
item_id: DefIndex,
|
|
||||||
tcx: TyCtxt<'tcx, 'tcx>)
|
|
||||||
-> &'tcx ty::AdtDef {
|
|
||||||
let item = self.entry(item_id);
|
let item = self.entry(item_id);
|
||||||
let did = self.local_def_id(item_id);
|
let did = self.local_def_id(item_id);
|
||||||
|
|
||||||
|
@ -616,24 +614,27 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
tcx.alloc_adt_def(did, kind, variants, repr)
|
tcx.alloc_adt_def(did, kind, variants, repr)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_predicates(&self,
|
pub fn get_predicates(
|
||||||
item_id: DefIndex,
|
&self,
|
||||||
tcx: TyCtxt<'tcx, 'tcx>)
|
item_id: DefIndex,
|
||||||
-> ty::GenericPredicates<'tcx> {
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
|
) -> ty::GenericPredicates<'tcx> {
|
||||||
self.entry(item_id).predicates.unwrap().decode((self, tcx))
|
self.entry(item_id).predicates.unwrap().decode((self, tcx))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_predicates_defined_on(&self,
|
pub fn get_predicates_defined_on(
|
||||||
item_id: DefIndex,
|
&self,
|
||||||
tcx: TyCtxt<'tcx, 'tcx>)
|
item_id: DefIndex,
|
||||||
-> ty::GenericPredicates<'tcx> {
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
|
) -> ty::GenericPredicates<'tcx> {
|
||||||
self.entry(item_id).predicates_defined_on.unwrap().decode((self, tcx))
|
self.entry(item_id).predicates_defined_on.unwrap().decode((self, tcx))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_super_predicates(&self,
|
pub fn get_super_predicates(
|
||||||
item_id: DefIndex,
|
&self,
|
||||||
tcx: TyCtxt<'tcx, 'tcx>)
|
item_id: DefIndex,
|
||||||
-> ty::GenericPredicates<'tcx> {
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
|
) -> ty::GenericPredicates<'tcx> {
|
||||||
let super_predicates = match self.entry(item_id).kind {
|
let super_predicates = match self.entry(item_id).kind {
|
||||||
EntryKind::Trait(data) => data.decode(self).super_predicates,
|
EntryKind::Trait(data) => data.decode(self).super_predicates,
|
||||||
EntryKind::TraitAlias(data) => data.decode(self).super_predicates,
|
EntryKind::TraitAlias(data) => data.decode(self).super_predicates,
|
||||||
|
@ -700,10 +701,11 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
self.get_impl_data(id).coerce_unsized_info
|
self.get_impl_data(id).coerce_unsized_info
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_impl_trait(&self,
|
pub fn get_impl_trait(
|
||||||
id: DefIndex,
|
&self,
|
||||||
tcx: TyCtxt<'tcx, 'tcx>)
|
id: DefIndex,
|
||||||
-> Option<ty::TraitRef<'tcx>> {
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
|
) -> Option<ty::TraitRef<'tcx>> {
|
||||||
self.get_impl_data(id).trait_ref.map(|tr| tr.decode((self, tcx)))
|
self.get_impl_data(id).trait_ref.map(|tr| tr.decode((self, tcx)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -720,10 +722,7 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterates over the language items in the given crate.
|
/// Iterates over the language items in the given crate.
|
||||||
pub fn get_lang_items(
|
pub fn get_lang_items(&self, tcx: TyCtxt<'tcx, '_>) -> &'tcx [(DefId, usize)] {
|
||||||
&self,
|
|
||||||
tcx: TyCtxt<'tcx, '_>,
|
|
||||||
) -> &'tcx [(DefId, usize)] {
|
|
||||||
if self.proc_macros.is_some() {
|
if self.proc_macros.is_some() {
|
||||||
// Proc macro crates do not export any lang-items to the target.
|
// Proc macro crates do not export any lang-items to the target.
|
||||||
&[]
|
&[]
|
||||||
|
@ -884,10 +883,11 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
self.maybe_entry(id).and_then(|item| item.decode(self).mir).is_some()
|
self.maybe_entry(id).and_then(|item| item.decode(self).mir).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn maybe_get_optimized_mir(&self,
|
pub fn maybe_get_optimized_mir(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>,
|
&self,
|
||||||
id: DefIndex)
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
-> Option<Body<'tcx>> {
|
id: DefIndex,
|
||||||
|
) -> Option<Body<'tcx>> {
|
||||||
match self.is_proc_macro(id) {
|
match self.is_proc_macro(id) {
|
||||||
true => None,
|
true => None,
|
||||||
false => self.entry(id).mir.map(|mir| mir.decode((self, tcx))),
|
false => self.entry(id).mir.map(|mir| mir.decode((self, tcx))),
|
||||||
|
@ -1020,7 +1020,7 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
pub fn get_inherent_implementations_for_type(
|
pub fn get_inherent_implementations_for_type(
|
||||||
&self,
|
&self,
|
||||||
tcx: TyCtxt<'tcx, '_>,
|
tcx: TyCtxt<'tcx, '_>,
|
||||||
id: DefIndex
|
id: DefIndex,
|
||||||
) -> &'tcx [DefId] {
|
) -> &'tcx [DefId] {
|
||||||
tcx.arena.alloc_from_iter(self.entry(id)
|
tcx.arena.alloc_from_iter(self.entry(id)
|
||||||
.inherent_impls
|
.inherent_impls
|
||||||
|
@ -1085,10 +1085,7 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_foreign_modules(
|
pub fn get_foreign_modules(&self, tcx: TyCtxt<'tcx, '_>) -> &'tcx [ForeignModule] {
|
||||||
&self,
|
|
||||||
tcx: TyCtxt<'tcx, '_>,
|
|
||||||
) -> &'tcx [ForeignModule] {
|
|
||||||
if self.proc_macros.is_some() {
|
if self.proc_macros.is_some() {
|
||||||
// Proc macro crates do not have any *target* foreign modules.
|
// Proc macro crates do not have any *target* foreign modules.
|
||||||
&[]
|
&[]
|
||||||
|
@ -1111,10 +1108,7 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_missing_lang_items(
|
pub fn get_missing_lang_items(&self, tcx: TyCtxt<'tcx, '_>) -> &'tcx [lang_items::LangItem] {
|
||||||
&self,
|
|
||||||
tcx: TyCtxt<'tcx, '_>,
|
|
||||||
) -> &'tcx [lang_items::LangItem] {
|
|
||||||
if self.proc_macros.is_some() {
|
if self.proc_macros.is_some() {
|
||||||
// Proc macro crates do not depend on any target weak lang-items.
|
// Proc macro crates do not depend on any target weak lang-items.
|
||||||
&[]
|
&[]
|
||||||
|
@ -1135,9 +1129,10 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
arg_names.decode(self).collect()
|
arg_names.decode(self).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exported_symbols(&self,
|
pub fn exported_symbols(
|
||||||
tcx: TyCtxt<'tcx, 'tcx>)
|
&self,
|
||||||
-> Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)> {
|
tcx: TyCtxt<'tcx, 'tcx>,
|
||||||
|
) -> Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)> {
|
||||||
if self.proc_macros.is_some() {
|
if self.proc_macros.is_some() {
|
||||||
// If this crate is a custom derive crate, then we're not even going to
|
// If this crate is a custom derive crate, then we're not even going to
|
||||||
// link those in so we skip those crates.
|
// link those in so we skip those crates.
|
||||||
|
@ -1192,10 +1187,7 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fn_sig(&self,
|
pub fn fn_sig(&self, id: DefIndex, tcx: TyCtxt<'tcx, 'tcx>) -> ty::PolyFnSig<'tcx> {
|
||||||
id: DefIndex,
|
|
||||||
tcx: TyCtxt<'tcx, 'tcx>)
|
|
||||||
-> ty::PolyFnSig<'tcx> {
|
|
||||||
let sig = match self.entry(id).kind {
|
let sig = match self.entry(id).kind {
|
||||||
EntryKind::Fn(data) |
|
EntryKind::Fn(data) |
|
||||||
EntryKind::ForeignFn(data) => data.decode(self).sig,
|
EntryKind::ForeignFn(data) => data.decode(self).sig,
|
||||||
|
|
|
@ -217,8 +217,7 @@ impl<'tcx> SpecializedEncoder<Fingerprint> for EncodeContext<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, T: Encodable> SpecializedEncoder<mir::ClearCrossCrate<T>>
|
impl<'tcx, T: Encodable> SpecializedEncoder<mir::ClearCrossCrate<T>> for EncodeContext<'tcx> {
|
||||||
for EncodeContext<'tcx> {
|
|
||||||
fn specialized_encode(&mut self,
|
fn specialized_encode(&mut self,
|
||||||
_: &mir::ClearCrossCrate<T>)
|
_: &mir::ClearCrossCrate<T>)
|
||||||
-> Result<(), Self::Error> {
|
-> Result<(), Self::Error> {
|
||||||
|
@ -233,7 +232,6 @@ impl<'tcx> TyEncoder for EncodeContext<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> EncodeContext<'tcx> {
|
impl<'tcx> EncodeContext<'tcx> {
|
||||||
|
|
||||||
fn emit_node<F: FnOnce(&mut Self, usize) -> R, R>(&mut self, f: F) -> R {
|
fn emit_node<F: FnOnce(&mut Self, usize) -> R, R>(&mut self, f: F) -> R {
|
||||||
assert_eq!(self.lazy_state, LazyState::NoNode);
|
assert_eq!(self.lazy_state, LazyState::NoNode);
|
||||||
let pos = self.position();
|
let pos = self.position();
|
||||||
|
@ -1865,9 +1863,7 @@ impl<'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'tcx> {
|
||||||
// will allow us to slice the metadata to the precise length that we just
|
// will allow us to slice the metadata to the precise length that we just
|
||||||
// generated regardless of trailing bytes that end up in it.
|
// generated regardless of trailing bytes that end up in it.
|
||||||
|
|
||||||
pub fn encode_metadata<'tcx>(tcx: TyCtxt<'tcx, 'tcx>)
|
pub fn encode_metadata<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> EncodedMetadata {
|
||||||
-> EncodedMetadata
|
|
||||||
{
|
|
||||||
let mut encoder = opaque::Encoder::new(vec![]);
|
let mut encoder = opaque::Encoder::new(vec![]);
|
||||||
encoder.emit_raw_bytes(METADATA_HEADER);
|
encoder.emit_raw_bytes(METADATA_HEADER);
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Vec<ForeignModule> {
|
||||||
modules: Vec::new(),
|
modules: Vec::new(),
|
||||||
};
|
};
|
||||||
tcx.hir().krate().visit_all_item_likes(&mut collector);
|
tcx.hir().krate().visit_all_item_likes(&mut collector);
|
||||||
return collector.modules
|
return collector.modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Collector<'tcx> {
|
struct Collector<'tcx> {
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Vec<String> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return collector.args
|
return collector.args;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Collector {
|
struct Collector {
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub fn collect<'tcx>(tcx: TyCtxt<'tcx, 'tcx>) -> Vec<NativeLibrary> {
|
||||||
};
|
};
|
||||||
tcx.hir().krate().visit_all_item_likes(&mut collector);
|
tcx.hir().krate().visit_all_item_likes(&mut collector);
|
||||||
collector.process_command_line();
|
collector.process_command_line();
|
||||||
return collector.libs
|
return collector.libs;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool {
|
pub fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool {
|
||||||
|
|
|
@ -125,9 +125,8 @@ impl<'tcx> BorrowSet<'tcx> {
|
||||||
tcx: TyCtxt<'_, 'tcx>,
|
tcx: TyCtxt<'_, 'tcx>,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
locals_are_invalidated_at_exit: bool,
|
locals_are_invalidated_at_exit: bool,
|
||||||
move_data: &MoveData<'tcx>
|
move_data: &MoveData<'tcx>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
|
||||||
let mut visitor = GatherBorrows {
|
let mut visitor = GatherBorrows {
|
||||||
tcx,
|
tcx,
|
||||||
body,
|
body,
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub(super) enum Control {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Encapsulates the idea of iterating over every borrow that involves a particular path
|
/// Encapsulates the idea of iterating over every borrow that involves a particular path
|
||||||
pub(super) fn each_borrow_involving_path<'tcx, 'gcx: 'tcx, F, I, S> (
|
pub(super) fn each_borrow_involving_path<'tcx, 'gcx: 'tcx, F, I, S>(
|
||||||
s: &mut S,
|
s: &mut S,
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
|
@ -33,7 +33,7 @@ pub(super) fn each_borrow_involving_path<'tcx, 'gcx: 'tcx, F, I, S> (
|
||||||
mut op: F,
|
mut op: F,
|
||||||
) where
|
) where
|
||||||
F: FnMut(&mut S, BorrowIndex, &BorrowData<'tcx>) -> Control,
|
F: FnMut(&mut S, BorrowIndex, &BorrowData<'tcx>) -> Control,
|
||||||
I: Iterator<Item=BorrowIndex>
|
I: Iterator<Item = BorrowIndex>,
|
||||||
{
|
{
|
||||||
let (access, place) = access_place;
|
let (access, place) = access_place;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ crate trait PlaceExt<'tcx> {
|
||||||
tcx: TyCtxt<'_, 'tcx>,
|
tcx: TyCtxt<'_, 'tcx>,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
locals_state_at_exit: &LocalsStateAtExit,
|
locals_state_at_exit: &LocalsStateAtExit,
|
||||||
) -> bool;
|
) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> PlaceExt<'tcx> for Place<'tcx> {
|
impl<'tcx> PlaceExt<'tcx> for Place<'tcx> {
|
||||||
|
|
|
@ -186,7 +186,7 @@ pub fn mir_build<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, def_id: DefId) -> Body<'tcx> {
|
||||||
/// can change `'tcx` so we have to transmute afterwards.
|
/// can change `'tcx` so we have to transmute afterwards.
|
||||||
struct GlobalizeMir<'gcx> {
|
struct GlobalizeMir<'gcx> {
|
||||||
tcx: TyCtxt<'gcx, 'gcx>,
|
tcx: TyCtxt<'gcx, 'gcx>,
|
||||||
span: Span
|
span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'gcx: 'tcx, 'tcx> MutVisitor<'tcx> for GlobalizeMir<'gcx> {
|
impl<'gcx: 'tcx, 'tcx> MutVisitor<'tcx> for GlobalizeMir<'gcx> {
|
||||||
|
@ -234,10 +234,11 @@ impl<'gcx: 'tcx, 'tcx> MutVisitor<'tcx> for GlobalizeMir<'gcx> {
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// BuildMir -- walks a crate, looking for fn items and methods to build MIR from
|
// BuildMir -- walks a crate, looking for fn items and methods to build MIR from
|
||||||
|
|
||||||
fn liberated_closure_env_ty<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
|
fn liberated_closure_env_ty<'gcx, 'tcx>(
|
||||||
closure_expr_id: hir::HirId,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
body_id: hir::BodyId)
|
closure_expr_id: hir::HirId,
|
||||||
-> Ty<'tcx> {
|
body_id: hir::BodyId,
|
||||||
|
) -> Ty<'tcx> {
|
||||||
let closure_ty = tcx.body_tables(body_id).node_type(closure_expr_id);
|
let closure_ty = tcx.body_tables(body_id).node_type(closure_expr_id);
|
||||||
|
|
||||||
let (closure_def_id, closure_substs) = match closure_ty.sty {
|
let (closure_def_id, closure_substs) = match closure_ty.sty {
|
||||||
|
@ -551,10 +552,7 @@ macro_rules! unpack {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn should_abort_on_panic<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
|
fn should_abort_on_panic<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>, fn_def_id: DefId, abi: Abi) -> bool {
|
||||||
fn_def_id: DefId,
|
|
||||||
abi: Abi)
|
|
||||||
-> bool {
|
|
||||||
// Not callable from C, so we can safely unwind through these
|
// Not callable from C, so we can safely unwind through these
|
||||||
if abi == Abi::Rust || abi == Abi::RustCall { return false; }
|
if abi == Abi::Rust || abi == Abi::RustCall { return false; }
|
||||||
|
|
||||||
|
|
|
@ -308,9 +308,7 @@ impl interpret::MayLeak for ! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx>
|
impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, 'tcx> {
|
||||||
for CompileTimeInterpreter<'mir, 'tcx>
|
|
||||||
{
|
|
||||||
type MemoryKinds = !;
|
type MemoryKinds = !;
|
||||||
type PointerTag = ();
|
type PointerTag = ();
|
||||||
|
|
||||||
|
@ -454,18 +452,13 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn stack_push(
|
fn stack_push(_ecx: &mut InterpretCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
|
||||||
_ecx: &mut InterpretCx<'mir, 'tcx, Self>,
|
|
||||||
) -> InterpResult<'tcx> {
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called immediately before a stack frame gets popped.
|
/// Called immediately before a stack frame gets popped.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn stack_pop(
|
fn stack_pop(_ecx: &mut InterpretCx<'mir, 'tcx, Self>, _extra: ()) -> InterpResult<'tcx> {
|
||||||
_ecx: &mut InterpretCx<'mir, 'tcx, Self>,
|
|
||||||
_extra: (),
|
|
||||||
) -> InterpResult<'tcx> {
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -511,7 +504,7 @@ pub fn const_variant_index<'tcx>(
|
||||||
|
|
||||||
pub fn error_to_const_error<'mir, 'tcx>(
|
pub fn error_to_const_error<'mir, 'tcx>(
|
||||||
ecx: &InterpretCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
|
ecx: &InterpretCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
|
||||||
mut error: InterpErrorInfo<'tcx>
|
mut error: InterpErrorInfo<'tcx>,
|
||||||
) -> ConstEvalErr<'tcx> {
|
) -> ConstEvalErr<'tcx> {
|
||||||
error.print_backtrace();
|
error.print_backtrace();
|
||||||
let stacktrace = ecx.generate_stacktrace(None);
|
let stacktrace = ecx.generate_stacktrace(None);
|
||||||
|
|
|
@ -46,9 +46,11 @@ pub fn move_path_children_matching<'tcx, F>(move_data: &MoveData<'tcx>,
|
||||||
/// is no need to maintain separate drop flags to track such state.
|
/// is no need to maintain separate drop flags to track such state.
|
||||||
//
|
//
|
||||||
// FIXME: we have to do something for moving slice patterns.
|
// FIXME: we have to do something for moving slice patterns.
|
||||||
fn place_contents_drop_state_cannot_differ<'gcx, 'tcx>(tcx: TyCtxt<'gcx, 'tcx>,
|
fn place_contents_drop_state_cannot_differ<'gcx, 'tcx>(
|
||||||
body: &Body<'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
place: &mir::Place<'tcx>) -> bool {
|
body: &Body<'tcx>,
|
||||||
|
place: &mir::Place<'tcx>,
|
||||||
|
) -> bool {
|
||||||
let ty = place.ty(body, tcx).ty;
|
let ty = place.ty(body, tcx).ty;
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
ty::Array(..) => {
|
ty::Array(..) => {
|
||||||
|
@ -77,8 +79,9 @@ pub(crate) fn on_lookup_result_bits<'gcx, 'tcx, F>(
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
move_data: &MoveData<'tcx>,
|
move_data: &MoveData<'tcx>,
|
||||||
lookup_result: LookupResult,
|
lookup_result: LookupResult,
|
||||||
each_child: F)
|
each_child: F,
|
||||||
where F: FnMut(MovePathIndex)
|
) where
|
||||||
|
F: FnMut(MovePathIndex),
|
||||||
{
|
{
|
||||||
match lookup_result {
|
match lookup_result {
|
||||||
LookupResult::Parent(..) => {
|
LookupResult::Parent(..) => {
|
||||||
|
@ -95,15 +98,16 @@ pub(crate) fn on_all_children_bits<'gcx, 'tcx, F>(
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
move_data: &MoveData<'tcx>,
|
move_data: &MoveData<'tcx>,
|
||||||
move_path_index: MovePathIndex,
|
move_path_index: MovePathIndex,
|
||||||
mut each_child: F)
|
mut each_child: F,
|
||||||
where F: FnMut(MovePathIndex)
|
) where
|
||||||
|
F: FnMut(MovePathIndex),
|
||||||
{
|
{
|
||||||
fn is_terminal_path<'gcx, 'tcx>(
|
fn is_terminal_path<'gcx, 'tcx>(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
move_data: &MoveData<'tcx>,
|
move_data: &MoveData<'tcx>,
|
||||||
path: MovePathIndex) -> bool
|
path: MovePathIndex,
|
||||||
{
|
) -> bool {
|
||||||
place_contents_drop_state_cannot_differ(
|
place_contents_drop_state_cannot_differ(
|
||||||
tcx, body, &move_data.move_paths[path].place)
|
tcx, body, &move_data.move_paths[path].place)
|
||||||
}
|
}
|
||||||
|
@ -113,8 +117,9 @@ pub(crate) fn on_all_children_bits<'gcx, 'tcx, F>(
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
move_data: &MoveData<'tcx>,
|
move_data: &MoveData<'tcx>,
|
||||||
move_path_index: MovePathIndex,
|
move_path_index: MovePathIndex,
|
||||||
each_child: &mut F)
|
each_child: &mut F,
|
||||||
where F: FnMut(MovePathIndex)
|
) where
|
||||||
|
F: FnMut(MovePathIndex),
|
||||||
{
|
{
|
||||||
each_child(move_path_index);
|
each_child(move_path_index);
|
||||||
|
|
||||||
|
@ -136,8 +141,9 @@ pub(crate) fn on_all_drop_children_bits<'gcx, 'tcx, F>(
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
ctxt: &MoveDataParamEnv<'gcx, 'tcx>,
|
ctxt: &MoveDataParamEnv<'gcx, 'tcx>,
|
||||||
path: MovePathIndex,
|
path: MovePathIndex,
|
||||||
mut each_child: F)
|
mut each_child: F,
|
||||||
where F: FnMut(MovePathIndex)
|
) where
|
||||||
|
F: FnMut(MovePathIndex),
|
||||||
{
|
{
|
||||||
on_all_children_bits(tcx, body, &ctxt.move_data, path, |child| {
|
on_all_children_bits(tcx, body, &ctxt.move_data, path, |child| {
|
||||||
let place = &ctxt.move_data.move_paths[path].place;
|
let place = &ctxt.move_data.move_paths[path].place;
|
||||||
|
@ -158,8 +164,9 @@ pub(crate) fn drop_flag_effects_for_function_entry<'gcx, 'tcx, F>(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
ctxt: &MoveDataParamEnv<'gcx, 'tcx>,
|
ctxt: &MoveDataParamEnv<'gcx, 'tcx>,
|
||||||
mut callback: F)
|
mut callback: F,
|
||||||
where F: FnMut(MovePathIndex, DropFlagState)
|
) where
|
||||||
|
F: FnMut(MovePathIndex, DropFlagState),
|
||||||
{
|
{
|
||||||
let move_data = &ctxt.move_data;
|
let move_data = &ctxt.move_data;
|
||||||
for arg in body.args_iter() {
|
for arg in body.args_iter() {
|
||||||
|
@ -176,8 +183,9 @@ pub(crate) fn drop_flag_effects_for_location<'gcx, 'tcx, F>(
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
ctxt: &MoveDataParamEnv<'gcx, 'tcx>,
|
ctxt: &MoveDataParamEnv<'gcx, 'tcx>,
|
||||||
loc: Location,
|
loc: Location,
|
||||||
mut callback: F)
|
mut callback: F,
|
||||||
where F: FnMut(MovePathIndex, DropFlagState)
|
) where
|
||||||
|
F: FnMut(MovePathIndex, DropFlagState),
|
||||||
{
|
{
|
||||||
let move_data = &ctxt.move_data;
|
let move_data = &ctxt.move_data;
|
||||||
debug!("drop_flag_effects_for_location({:?})", loc);
|
debug!("drop_flag_effects_for_location({:?})", loc);
|
||||||
|
@ -208,8 +216,9 @@ pub(crate) fn for_location_inits<'gcx, 'tcx, F>(
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
move_data: &MoveData<'tcx>,
|
move_data: &MoveData<'tcx>,
|
||||||
loc: Location,
|
loc: Location,
|
||||||
mut callback: F)
|
mut callback: F,
|
||||||
where F: FnMut(MovePathIndex)
|
) where
|
||||||
|
F: FnMut(MovePathIndex),
|
||||||
{
|
{
|
||||||
for ii in &move_data.init_loc_map[loc] {
|
for ii in &move_data.init_loc_map[loc] {
|
||||||
let init = move_data.inits[*ii];
|
let init = move_data.inits[*ii];
|
||||||
|
|
|
@ -70,11 +70,11 @@ pub struct MaybeInitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx: 'tcx, 'tcx> MaybeInitializedPlaces<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx: 'tcx, 'tcx> MaybeInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
pub fn new(tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn new(
|
||||||
body: &'a Body<'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
|
body: &'a Body<'tcx>,
|
||||||
-> Self
|
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
|
||||||
{
|
) -> Self {
|
||||||
MaybeInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe }
|
MaybeInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,11 +125,11 @@ pub struct MaybeUninitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> MaybeUninitializedPlaces<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> MaybeUninitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
pub fn new(tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn new(
|
||||||
body: &'a Body<'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
|
body: &'a Body<'tcx>,
|
||||||
-> Self
|
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
|
||||||
{
|
) -> Self {
|
||||||
MaybeUninitializedPlaces { tcx: tcx, body: body, mdpe: mdpe }
|
MaybeUninitializedPlaces { tcx: tcx, body: body, mdpe: mdpe }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,11 +179,11 @@ pub struct DefinitelyInitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx: 'a> DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx: 'a> DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
pub fn new(tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn new(
|
||||||
body: &'a Body<'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
|
body: &'a Body<'tcx>,
|
||||||
-> Self
|
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
|
||||||
{
|
) -> Self {
|
||||||
DefinitelyInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe }
|
DefinitelyInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,11 +228,11 @@ pub struct EverInitializedPlaces<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx: 'tcx, 'tcx: 'a> EverInitializedPlaces<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx: 'tcx, 'tcx: 'a> EverInitializedPlaces<'a, 'gcx, 'tcx> {
|
||||||
pub fn new(tcx: TyCtxt<'gcx, 'tcx>,
|
pub fn new(
|
||||||
body: &'a Body<'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>)
|
body: &'a Body<'tcx>,
|
||||||
-> Self
|
mdpe: &'a MoveDataParamEnv<'gcx, 'tcx>,
|
||||||
{
|
) -> Self {
|
||||||
EverInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe }
|
EverInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,29 +121,36 @@ pub struct MoveDataParamEnv<'gcx, 'tcx> {
|
||||||
pub(crate) param_env: ty::ParamEnv<'gcx>,
|
pub(crate) param_env: ty::ParamEnv<'gcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn do_dataflow<'a, 'gcx, 'tcx, BD, P>(tcx: TyCtxt<'gcx, 'tcx>,
|
pub(crate) fn do_dataflow<'a, 'gcx, 'tcx, BD, P>(
|
||||||
body: &'a Body<'tcx>,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
def_id: DefId,
|
body: &'a Body<'tcx>,
|
||||||
attributes: &[ast::Attribute],
|
def_id: DefId,
|
||||||
dead_unwinds: &BitSet<BasicBlock>,
|
attributes: &[ast::Attribute],
|
||||||
bd: BD,
|
dead_unwinds: &BitSet<BasicBlock>,
|
||||||
p: P)
|
bd: BD,
|
||||||
-> DataflowResults<'tcx, BD>
|
p: P,
|
||||||
where BD: BitDenotation<'tcx> + InitialFlow,
|
) -> DataflowResults<'tcx, BD>
|
||||||
P: Fn(&BD, BD::Idx) -> DebugFormatted
|
where
|
||||||
|
BD: BitDenotation<'tcx> + InitialFlow,
|
||||||
|
P: Fn(&BD, BD::Idx) -> DebugFormatted,
|
||||||
{
|
{
|
||||||
let flow_state = DataflowAnalysis::new(body, dead_unwinds, bd);
|
let flow_state = DataflowAnalysis::new(body, dead_unwinds, bd);
|
||||||
flow_state.run(tcx, def_id, attributes, p)
|
flow_state.run(tcx, def_id, attributes, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx: 'tcx, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitDenotation<'tcx>
|
impl<'a, 'gcx: 'tcx, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD>
|
||||||
|
where
|
||||||
|
BD: BitDenotation<'tcx>,
|
||||||
{
|
{
|
||||||
pub(crate) fn run<P>(self,
|
pub(crate) fn run<P>(
|
||||||
tcx: TyCtxt<'gcx, 'tcx>,
|
self,
|
||||||
def_id: DefId,
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
attributes: &[ast::Attribute],
|
def_id: DefId,
|
||||||
p: P) -> DataflowResults<'tcx, BD>
|
attributes: &[ast::Attribute],
|
||||||
where P: Fn(&BD, BD::Idx) -> DebugFormatted
|
p: P,
|
||||||
|
) -> DataflowResults<'tcx, BD>
|
||||||
|
where
|
||||||
|
P: Fn(&BD, BD::Idx) -> DebugFormatted,
|
||||||
{
|
{
|
||||||
let name_found = |sess: &Session, attrs: &[ast::Attribute], name| -> Option<String> {
|
let name_found = |sess: &Session, attrs: &[ast::Attribute], name| -> Option<String> {
|
||||||
if let Some(item) = has_rustc_mir_with(attrs, name) {
|
if let Some(item) = has_rustc_mir_with(attrs, name) {
|
||||||
|
|
|
@ -204,7 +204,7 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
pub(super) fn gather_moves<'gcx, 'tcx>(
|
pub(super) fn gather_moves<'gcx, 'tcx>(
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
tcx: TyCtxt<'gcx, 'tcx>
|
tcx: TyCtxt<'gcx, 'tcx>,
|
||||||
) -> Result<MoveData<'tcx>, (MoveData<'tcx>, Vec<(Place<'tcx>, MoveError<'tcx>)>)> {
|
) -> Result<MoveData<'tcx>, (MoveData<'tcx>, Vec<(Place<'tcx>, MoveError<'tcx>)>)> {
|
||||||
let mut builder = MoveDataBuilder::new(body, tcx);
|
let mut builder = MoveDataBuilder::new(body, tcx);
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue