Skip to content

Commit

Permalink
Move ty::wf to traits.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Jan 7, 2020
1 parent 787cd54 commit 73667af
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/librustc/traits/fulfill.rs
Expand Up @@ -9,6 +9,7 @@ use std::marker::PhantomData;
use super::engine::{TraitEngine, TraitEngineExt};
use super::project;
use super::select::SelectionContext;
use super::wf;
use super::CodeAmbiguity;
use super::CodeProjectionError;
use super::CodeSelectionError;
Expand Down Expand Up @@ -461,7 +462,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
}

ty::Predicate::WellFormed(ty) => {
match ty::wf::obligations(
match wf::obligations(
self.selcx.infcx(),
obligation.param_env,
obligation.cause.body_id,
Expand Down
1 change: 1 addition & 0 deletions src/librustc/traits/mod.rs
Expand Up @@ -18,6 +18,7 @@ mod select;
mod specialize;
mod structural_impls;
mod util;
pub mod wf;

use crate::infer::outlives::env::OutlivesEnvironment;
use crate::infer::{InferCtxt, SuppressRegionErrors};
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/traits/select.rs
Expand Up @@ -12,6 +12,7 @@ use super::project;
use super::project::{normalize_with_depth, Normalized, ProjectionCacheKey};
use super::util;
use super::util::{closure_trait_ref_and_return_type, predicate_for_trait_def};
use super::wf;
use super::DerivedObligationCause;
use super::Selection;
use super::SelectionResult;
Expand Down Expand Up @@ -738,7 +739,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}

ty::Predicate::WellFormed(ty) => match ty::wf::obligations(
ty::Predicate::WellFormed(ty) => match wf::obligations(
self.infcx,
obligation.param_env,
obligation.cause.body_id,
Expand Down Expand Up @@ -1154,7 +1155,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
/// to have a *lower* recursion_depth than the obligation used to create it.
/// Projection sub-obligations may be returned from the projection cache,
/// which results in obligations with an 'old' `recursion_depth`.
/// Additionally, methods like `ty::wf::obligations` and
/// Additionally, methods like `wf::obligations` and
/// `InferCtxt.subtype_predicate` produce subobligations without
/// taking in a 'parent' depth, causing the generated subobligations
/// to have a `recursion_depth` of `0`.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/wf.rs → src/librustc/traits/wf.rs
Expand Up @@ -514,7 +514,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
// of whatever returned this exact `impl Trait`.

// for named opaque `impl Trait` types we still need to check them
if super::is_impl_trait_defn(self.infcx.tcx, did).is_none() {
if ty::is_impl_trait_defn(self.infcx.tcx, did).is_none() {
let obligations = self.nominal_obligations(did, substs);
self.out.extend(obligations);
}
Expand Down
1 change: 0 additions & 1 deletion src/librustc/ty/mod.rs
Expand Up @@ -119,7 +119,6 @@ pub mod subst;
pub mod trait_def;
pub mod util;
pub mod walk;
pub mod wf;

mod context;
mod diagnostics;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_traits/implied_outlives_bounds.rs
Expand Up @@ -5,11 +5,11 @@ use rustc::infer::canonical::{self, Canonical};
use rustc::infer::InferCtxt;
use rustc::traits::query::outlives_bounds::OutlivesBound;
use rustc::traits::query::{CanonicalTyGoal, Fallible, NoSolution};
use rustc::traits::wf;
use rustc::traits::FulfillmentContext;
use rustc::traits::{TraitEngine, TraitEngineExt};
use rustc::ty::outlives::Component;
use rustc::ty::query::Providers;
use rustc::ty::wf;
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
use rustc_hir as hir;
use rustc_span::source_map::DUMMY_SP;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/astconv.rs
Expand Up @@ -15,8 +15,8 @@ use rustc::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS;
use rustc::traits;
use rustc::traits::astconv_object_safety_violations;
use rustc::traits::error_reporting::report_object_safety_error;
use rustc::traits::wf::object_region_bounds;
use rustc::ty::subst::{self, InternalSubsts, Subst, SubstsRef};
use rustc::ty::wf::object_region_bounds;
use rustc::ty::{self, Const, DefIdTree, ToPredicate, Ty, TyCtxt, TypeFoldable};
use rustc::ty::{GenericParamDef, GenericParamDefKind};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/check/wfcheck.rs
Expand Up @@ -417,7 +417,7 @@ fn check_impl<'tcx>(
let trait_ref = fcx.tcx.impl_trait_ref(item_def_id).unwrap();
let trait_ref =
fcx.normalize_associated_types_in(ast_trait_ref.path.span, &trait_ref);
let obligations = ty::wf::trait_obligations(
let obligations = traits::wf::trait_obligations(
fcx,
fcx.param_env,
fcx.body_id,
Expand Down Expand Up @@ -596,7 +596,7 @@ fn check_where_clauses<'tcx, 'fcx>(
let wf_obligations = predicates
.predicates
.iter()
.flat_map(|p| ty::wf::predicate_obligations(fcx, fcx.param_env, fcx.body_id, p, span));
.flat_map(|p| traits::wf::predicate_obligations(fcx, fcx.param_env, fcx.body_id, p, span));

for obligation in wf_obligations.chain(default_obligations) {
debug!("next obligation cause: {:?}", obligation.cause);
Expand Down

0 comments on commit 73667af

Please sign in to comment.