rustc: rename PrintContext to PrintCx.
This commit is contained in:
parent
c684814102
commit
5f3841ca2f
3 changed files with 17 additions and 17 deletions
|
|
@ -683,7 +683,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
/// For generic types with parameters with defaults, remove the parameters corresponding to
|
||||
/// the defaults. This repeats a lot of the logic found in `PrintContext::parameterized`.
|
||||
/// the defaults. This repeats a lot of the logic found in `PrintCx::parameterized`.
|
||||
fn strip_generic_default_params(
|
||||
&self,
|
||||
def_id: DefId,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ impl<'tcx> ty::fold::TypeVisitor<'tcx> for LateBoundRegionNameCollector {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PrintContext {
|
||||
pub struct PrintCx {
|
||||
pub(crate) is_debug: bool,
|
||||
pub(crate) is_verbose: bool,
|
||||
pub(crate) identify_regions: bool,
|
||||
|
|
@ -31,12 +31,12 @@ pub struct PrintContext {
|
|||
pub(crate) binder_depth: usize,
|
||||
}
|
||||
|
||||
impl PrintContext {
|
||||
impl PrintCx {
|
||||
pub(crate) fn new() -> Self {
|
||||
ty::tls::with(|tcx| {
|
||||
let (is_verbose, identify_regions) =
|
||||
(tcx.sess.verbose(), tcx.sess.opts.debugging_opts.identify_regions);
|
||||
PrintContext {
|
||||
PrintCx {
|
||||
is_debug: false,
|
||||
is_verbose: is_verbose,
|
||||
identify_regions: identify_regions,
|
||||
|
|
@ -57,32 +57,32 @@ impl PrintContext {
|
|||
}
|
||||
|
||||
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 {
|
||||
fn print<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintCx) -> fmt::Result;
|
||||
fn print_to_string(&self, cx: &mut PrintCx) -> String {
|
||||
let mut result = String::new();
|
||||
let _ = self.print(&mut result, cx);
|
||||
result
|
||||
}
|
||||
fn print_display<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintContext) -> fmt::Result {
|
||||
fn print_display<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintCx) -> fmt::Result {
|
||||
let old_debug = cx.is_debug;
|
||||
cx.is_debug = false;
|
||||
let result = self.print(f, cx);
|
||||
cx.is_debug = old_debug;
|
||||
result
|
||||
}
|
||||
fn print_display_to_string(&self, cx: &mut PrintContext) -> String {
|
||||
fn print_display_to_string(&self, cx: &mut PrintCx) -> String {
|
||||
let mut result = String::new();
|
||||
let _ = self.print_display(&mut result, cx);
|
||||
result
|
||||
}
|
||||
fn print_debug<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintContext) -> fmt::Result {
|
||||
fn print_debug<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintCx) -> fmt::Result {
|
||||
let old_debug = cx.is_debug;
|
||||
cx.is_debug = true;
|
||||
let result = self.print(f, cx);
|
||||
cx.is_debug = old_debug;
|
||||
result
|
||||
}
|
||||
fn print_debug_to_string(&self, cx: &mut PrintContext) -> String {
|
||||
fn print_debug_to_string(&self, cx: &mut PrintCx) -> String {
|
||||
let mut result = String::new();
|
||||
let _ = self.print_debug(&mut result, cx);
|
||||
result
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use crate::ty::{Param, Bound, RawPtr, Ref, Never, Tuple};
|
|||
use crate::ty::{Closure, Generator, GeneratorWitness, Foreign, Projection, Opaque};
|
||||
use crate::ty::{Placeholder, UnnormalizedProjection, Dynamic, Int, Uint, Infer};
|
||||
use crate::ty::{self, Ty, TyCtxt, TypeFoldable, GenericParamCount, GenericParamDefKind, ParamConst};
|
||||
use crate::ty::print::{PrintContext, Print};
|
||||
use crate::ty::print::{PrintCx, Print};
|
||||
use crate::mir::interpret::ConstValue;
|
||||
|
||||
use std::cell::Cell;
|
||||
|
|
@ -182,7 +182,7 @@ impl RegionHighlightMode {
|
|||
macro_rules! gen_display_debug_body {
|
||||
( $with:path ) => {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let mut cx = PrintContext::new();
|
||||
let mut cx = PrintCx::new();
|
||||
$with(self, f, &mut cx)
|
||||
}
|
||||
};
|
||||
|
|
@ -213,7 +213,7 @@ macro_rules! gen_display_debug {
|
|||
macro_rules! gen_print_impl {
|
||||
( ($($x:tt)+) $target:ty, ($self:ident, $f:ident, $cx:ident) $disp:block $dbg:block ) => {
|
||||
impl<$($x)+> Print<'tcx> for $target {
|
||||
fn print<F: fmt::Write>(&$self, $f: &mut F, $cx: &mut PrintContext) -> fmt::Result {
|
||||
fn print<F: fmt::Write>(&$self, $f: &mut F, $cx: &mut PrintCx) -> fmt::Result {
|
||||
if $cx.is_debug $dbg
|
||||
else $disp
|
||||
}
|
||||
|
|
@ -221,7 +221,7 @@ macro_rules! gen_print_impl {
|
|||
};
|
||||
( () $target:ty, ($self:ident, $f:ident, $cx:ident) $disp:block $dbg:block ) => {
|
||||
impl Print<'tcx> for $target {
|
||||
fn print<F: fmt::Write>(&$self, $f: &mut F, $cx: &mut PrintContext) -> fmt::Result {
|
||||
fn print<F: fmt::Write>(&$self, $f: &mut F, $cx: &mut PrintCx) -> fmt::Result {
|
||||
if $cx.is_debug $dbg
|
||||
else $disp
|
||||
}
|
||||
|
|
@ -275,7 +275,7 @@ macro_rules! print {
|
|||
};
|
||||
}
|
||||
|
||||
impl PrintContext {
|
||||
impl PrintCx {
|
||||
fn fn_sig<F: fmt::Write>(&mut self,
|
||||
f: &mut F,
|
||||
inputs: &[Ty<'_>],
|
||||
|
|
@ -618,11 +618,11 @@ pub fn parameterized<F: fmt::Write>(f: &mut F,
|
|||
did: DefId,
|
||||
projections: &[ty::ProjectionPredicate<'_>])
|
||||
-> fmt::Result {
|
||||
PrintContext::new().parameterized(f, substs, did, projections)
|
||||
PrintCx::new().parameterized(f, substs, did, projections)
|
||||
}
|
||||
|
||||
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 {
|
||||
fn print<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintCx) -> fmt::Result {
|
||||
(*self).print(f, cx)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue