diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2019-01-18 21:45:13 +0200 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2019-03-15 13:25:10 +0200 |
| commit | 800ddb367e4a56a77ab940ce95023e82b64f3bd2 (patch) | |
| tree | b04bef1b145faf2646a1d8ef38aeab14521bcb15 /src/librustc/ty | |
| parent | 55871aad9a9c621e245c2b238f04f9fab55da759 (diff) | |
| download | rust-800ddb367e4a56a77ab940ce95023e82b64f3bd2.tar.gz rust-800ddb367e4a56a77ab940ce95023e82b64f3bd2.zip | |
rustc: remove fields from ty::print::PrintConfig available from tcx.
Diffstat (limited to 'src/librustc/ty')
| -rw-r--r-- | src/librustc/ty/print/mod.rs | 18 | ||||
| -rw-r--r-- | src/librustc/ty/print/pretty.rs | 18 |
2 files changed, 13 insertions, 23 deletions
diff --git a/src/librustc/ty/print/mod.rs b/src/librustc/ty/print/mod.rs index 9d93d1a34a1..ccd2a702c9f 100644 --- a/src/librustc/ty/print/mod.rs +++ b/src/librustc/ty/print/mod.rs @@ -29,28 +29,14 @@ impl<'tcx> ty::fold::TypeVisitor<'tcx> for LateBoundRegionNameCollector { } } +#[derive(Default)] pub(crate) struct PrintConfig { pub(crate) is_debug: bool, - pub(crate) is_verbose: bool, - pub(crate) identify_regions: bool, used_region_names: Option<FxHashSet<InternedString>>, region_index: usize, binder_depth: usize, } -impl PrintConfig { - fn new(tcx: TyCtxt<'_, '_, '_>) -> Self { - PrintConfig { - is_debug: false, - is_verbose: tcx.sess.verbose(), - identify_regions: tcx.sess.opts.debugging_opts.identify_regions, - used_region_names: None, - region_index: 0, - binder_depth: 0, - } - } -} - pub struct PrintCx<'a, 'gcx, 'tcx, P> { pub tcx: TyCtxt<'a, 'gcx, 'tcx>, pub printer: P, @@ -75,7 +61,7 @@ impl<'a, 'gcx, 'tcx, P> PrintCx<'a, 'gcx, 'tcx, P> { f(PrintCx { tcx, printer, - config: &mut PrintConfig::new(tcx), + config: &mut PrintConfig::default(), }) } diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index caa4090625d..325897dc042 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -515,7 +515,7 @@ impl<'gcx, 'tcx, P: PrettyPrinter> PrintCx<'_, 'gcx, 'tcx, P> { }); // Don't print args that are the defaults of their respective parameters. - let num_supplied_defaults = if self.config.is_verbose { + let num_supplied_defaults = if self.tcx.sess.verbose() { 0 } else { params.iter().rev().take_while(|param| { @@ -818,10 +818,12 @@ impl<F: fmt::Write> PrettyPrinter for FmtPrinter<F> { return true; } - if self.config.is_verbose { + if self.tcx.sess.verbose() { return true; } + let identify_regions = self.tcx.sess.opts.debugging_opts.identify_regions; + match *region { ty::ReEarlyBound(ref data) => { data.name != "" && data.name != "'_" @@ -846,7 +848,7 @@ impl<F: fmt::Write> PrettyPrinter for FmtPrinter<F> { } ty::ReScope(_) | - ty::ReVar(_) if self.config.identify_regions => true, + ty::ReVar(_) if identify_regions => true, ty::ReVar(_) | ty::ReScope(_) | @@ -874,10 +876,12 @@ impl<F: fmt::Write> FmtPrinter<F> { return Ok(self.printer); } - if self.config.is_verbose { + if self.tcx.sess.verbose() { return region.print_debug(self); } + let identify_regions = self.tcx.sess.opts.debugging_opts.identify_regions; + // These printouts are concise. They do not contain all the information // the user might want to diagnose an error, but there is basically no way // to fit that into a short string. Hence the recommendation to use @@ -904,7 +908,7 @@ impl<F: fmt::Write> FmtPrinter<F> { } } } - ty::ReScope(scope) if self.config.identify_regions => { + ty::ReScope(scope) if identify_regions => { match scope.data { region::ScopeData::Node => p!(write("'{}s", scope.item_local_id().as_usize())), @@ -921,7 +925,7 @@ impl<F: fmt::Write> FmtPrinter<F> { )), } } - ty::ReVar(region_vid) if self.config.identify_regions => { + ty::ReVar(region_vid) if identify_regions => { p!(write("{:?}", region_vid)); } ty::ReVar(_) => {} @@ -1029,7 +1033,7 @@ impl<'gcx, 'tcx, P: PrettyPrinter> PrintCx<'_, 'gcx, 'tcx, P> { p!(write("Placeholder({:?})", placeholder)) } ty::Opaque(def_id, substs) => { - if self.config.is_verbose { + if self.tcx.sess.verbose() { p!(write("Opaque({:?}, {:?})", def_id, substs)); return Ok(self.printer); } |
