Skip to content

Commit 5a92236

Browse files
committed
Move subst_and_normalize_erasing_regions into normalize_erasing_regions.rs so that it's not
weirdly on it's own within the codegen module.
1 parent fe87b6a commit 5a92236

File tree

3 files changed

+24
-34
lines changed

3 files changed

+24
-34
lines changed

src/librustc/traits/codegen/mod.rs

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/librustc/traits/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#[allow(dead_code)]
66
pub mod auto_trait;
77
mod chalk_fulfill;
8-
pub mod codegen;
98
mod coherence;
109
mod engine;
1110
pub mod error_reporting;

src/librustc/traits/query/normalize_erasing_regions.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//! within. (This underlying query is what is cached.)
99
1010
use crate::ty::fold::{TypeFoldable, TypeFolder};
11+
use crate::ty::subst::{Subst, SubstsRef};
1112
use crate::ty::{self, Ty, TyCtxt};
1213

1314
impl<'tcx> TyCtxt<'tcx> {
@@ -40,6 +41,29 @@ impl<'tcx> TyCtxt<'tcx> {
4041
}
4142
}
4243

44+
/// Monomorphizes a type from the AST by first applying the
45+
/// in-scope substitutions and then normalizing any associated
46+
/// types.
47+
pub fn subst_and_normalize_erasing_regions<T>(
48+
self,
49+
param_substs: SubstsRef<'tcx>,
50+
param_env: ty::ParamEnv<'tcx>,
51+
value: &T,
52+
) -> T
53+
where
54+
T: TypeFoldable<'tcx>,
55+
{
56+
debug!(
57+
"subst_and_normalize_erasing_regions(\
58+
param_substs={:?}, \
59+
value={:?}, \
60+
param_env={:?})",
61+
param_substs, value, param_env,
62+
);
63+
let substituted = value.subst(self, param_substs);
64+
self.normalize_erasing_regions(param_env, substituted)
65+
}
66+
4367
/// If you have a `Binder<T>`, you can do this to strip out the
4468
/// late-bound regions and then normalize the result, yielding up
4569
/// a `T` (with regions erased). This is appropriate when the

0 commit comments

Comments
 (0)