提交 297546e6 编写于 作者: E Eduard-Mihai Burtescu

rustc: add a 'tcx parameter to Print.

上级 382d24e7
......@@ -57,7 +57,7 @@ pub(crate) fn prepare_late_bound_region_info<'tcx, T>(&mut self, value: &ty::Bin
}
}
pub trait Print {
pub trait Print<'tcx> {
fn print<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintContext) -> fmt::Result;
fn print_to_string(&self, cx: &mut PrintContext) -> String {
let mut result = String::new();
......
......@@ -212,7 +212,7 @@ impl fmt::Debug for $target {
}
macro_rules! gen_print_impl {
( ($($x:tt)+) $target:ty, ($self:ident, $f:ident, $cx:ident) $disp:block $dbg:block ) => {
impl<$($x)+> Print for $target {
impl<$($x)+> Print<'tcx> for $target {
fn print<F: fmt::Write>(&$self, $f: &mut F, $cx: &mut PrintContext) -> fmt::Result {
if $cx.is_debug $dbg
else $disp
......@@ -220,7 +220,7 @@ fn print<F: fmt::Write>(&$self, $f: &mut F, $cx: &mut PrintContext) -> fmt::Resu
}
};
( () $target:ty, ($self:ident, $f:ident, $cx:ident) $disp:block $dbg:block ) => {
impl Print for $target {
impl Print<'tcx> for $target {
fn print<F: fmt::Write>(&$self, $f: &mut F, $cx: &mut PrintContext) -> fmt::Result {
if $cx.is_debug $dbg
else $disp
......@@ -527,12 +527,15 @@ fn parameterized<F: fmt::Write>(&mut self,
Ok(())
}
fn in_binder<'a, 'gcx, 'tcx, T, U, F>(&mut self,
f: &mut F,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
original: &ty::Binder<T>,
lifted: Option<ty::Binder<U>>) -> fmt::Result
where T: Print, U: Print + TypeFoldable<'tcx>, F: fmt::Write
// FIXME(eddyb) replace `'almost_tcx` with `'tcx` when possible/needed.
fn in_binder<'a, 'gcx, 'tcx, 'almost_tcx, T, U, F>(
&mut self,
f: &mut F,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
original: &ty::Binder<T>,
lifted: Option<ty::Binder<U>>,
) -> fmt::Result
where T: Print<'almost_tcx>, U: Print<'tcx> + TypeFoldable<'tcx>, F: fmt::Write
{
fn name_by_region_index(index: usize) -> InternedString {
match index {
......@@ -627,7 +630,7 @@ pub fn parameterized<F: fmt::Write>(f: &mut F,
PrintContext::new().parameterized(f, substs, did, projections)
}
impl<'a, T: Print> Print for &'a T {
impl<'a, 'tcx, T: Print<'tcx>> Print<'tcx> for &'a T {
fn print<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintContext) -> fmt::Result {
(*self).print(f, cx)
}
......@@ -1466,7 +1469,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
define_print! {
('tcx, T: Print + fmt::Debug, U: Print + fmt::Debug) ty::OutlivesPredicate<T, U>,
('tcx, T: Print<'tcx> + fmt::Debug, U: Print<'tcx> + fmt::Debug) ty::OutlivesPredicate<T, U>,
(self, f, cx) {
display {
print!(f, cx, print(self.0), write(" : "), print(self.1))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册