Skip to content

Commit 7580826

Browse files
committed
Avoid printing overwhelming info on -Znll-dump-cause
1 parent a17a2e3 commit 7580826

File tree

2 files changed

+2
-70
lines changed
  • src/librustc_mir/borrow_check/nll

2 files changed

+2
-70
lines changed

src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
7171
}
7272

7373
_ => {
74-
cause.label_diagnostic(mir, err);
7574
}
7675
}
7776
}

src/librustc_mir/borrow_check/nll/region_infer/mod.rs

Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use rustc::ty::{self, RegionVid, Ty, TypeFoldable};
2626
use rustc::util::common::ErrorReported;
2727
use rustc_data_structures::bitvec::BitVector;
2828
use rustc_data_structures::indexed_vec::IndexVec;
29-
use rustc_errors::DiagnosticBuilder;
3029
use std::fmt;
3130
use std::rc::Rc;
3231
use syntax::ast;
@@ -435,7 +434,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
435434

436435
self.check_type_tests(infcx, mir, mir_def_id, outlives_requirements.as_mut());
437436

438-
self.check_universal_regions(infcx, mir, mir_def_id, outlives_requirements.as_mut());
437+
self.check_universal_regions(infcx, mir_def_id, outlives_requirements.as_mut());
439438

440439
let outlives_requirements = outlives_requirements.unwrap_or(vec![]);
441440

@@ -897,7 +896,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
897896
fn check_universal_regions<'gcx>(
898897
&self,
899898
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
900-
mir: &Mir<'tcx>,
901899
mir_def_id: DefId,
902900
mut propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'gcx>>>,
903901
) {
@@ -913,7 +911,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
913911
for (fr, _) in universal_definitions {
914912
self.check_universal_region(
915913
infcx,
916-
mir,
917914
mir_def_id,
918915
fr,
919916
&mut propagated_outlives_requirements,
@@ -932,7 +929,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
932929
fn check_universal_region<'gcx>(
933930
&self,
934931
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
935-
mir: &Mir<'tcx>,
936932
mir_def_id: DefId,
937933
longer_fr: RegionVid,
938934
propagated_outlives_requirements: &mut Option<&mut Vec<ClosureOutlivesRequirement<'gcx>>>,
@@ -990,7 +986,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
990986
// Note: in this case, we use the unapproximated regions
991987
// to report the error. This gives better error messages
992988
// in some cases.
993-
self.report_error(infcx, mir, mir_def_id, longer_fr, shorter_fr, blame_span);
989+
self.report_error(infcx, mir_def_id, longer_fr, shorter_fr, blame_span);
994990
}
995991
}
996992

@@ -1005,7 +1001,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
10051001
fn report_error(
10061002
&self,
10071003
infcx: &InferCtxt<'_, '_, 'tcx>,
1008-
mir: &Mir<'tcx>,
10091004
mir_def_id: DefId,
10101005
fr: RegionVid,
10111006
outlived_fr: RegionVid,
@@ -1039,12 +1034,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
10391034
&format!("{} does not outlive {}", fr_string, outlived_fr_string,),
10401035
);
10411036

1042-
// Find out why `fr` had to outlive `outlived_fr`...
1043-
let inferred_values = self.inferred_values.as_ref().unwrap();
1044-
if let Some(cause) = inferred_values.cause(fr, outlived_fr) {
1045-
cause.label_diagnostic(mir, &mut diag);
1046-
}
1047-
10481037
diag.emit();
10491038
}
10501039

@@ -1285,62 +1274,6 @@ impl CauseExt for Rc<Cause> {
12851274
}
12861275

12871276
impl Cause {
1288-
pub(crate) fn label_diagnostic(&self, mir: &Mir<'_>, diag: &mut DiagnosticBuilder<'_>) {
1289-
// The cause information is pretty messy. Only dump it as an
1290-
// internal debugging aid if -Znll-dump-cause is given.
1291-
let nll_dump_cause = ty::tls::with(|tcx| tcx.sess.nll_dump_cause());
1292-
if !nll_dump_cause {
1293-
return;
1294-
}
1295-
1296-
let mut string = String::new();
1297-
self.push_diagnostic_string(mir, &mut string);
1298-
diag.note(&string);
1299-
}
1300-
1301-
fn push_diagnostic_string(&self, mir: &Mir<'_>, string: &mut String) {
1302-
match self {
1303-
Cause::LiveVar(local, location) => {
1304-
string.push_str(&format!("because `{:?}` is live at {:?}", local, location));
1305-
}
1306-
1307-
Cause::DropVar(local, location) => {
1308-
string.push_str(&format!(
1309-
"because `{:?}` is dropped at {:?}",
1310-
local,
1311-
location
1312-
));
1313-
}
1314-
1315-
Cause::LiveOther(location) => {
1316-
string.push_str(&format!(
1317-
"because of a general liveness constraint at {:?}",
1318-
location
1319-
));
1320-
}
1321-
1322-
Cause::UniversalRegion(region_vid) => {
1323-
string.push_str(&format!(
1324-
"because `{:?}` is universally quantified",
1325-
region_vid
1326-
));
1327-
}
1328-
1329-
Cause::Outlives {
1330-
original_cause,
1331-
constraint_location,
1332-
constraint_span: _,
1333-
} => {
1334-
string.push_str(&format!(
1335-
"because of an outlives relation created at `{:?}`\n",
1336-
constraint_location
1337-
));
1338-
1339-
original_cause.push_diagnostic_string(mir, string);
1340-
}
1341-
}
1342-
}
1343-
13441277
pub(crate) fn root_cause(&self) -> &Cause {
13451278
match self {
13461279
Cause::LiveVar(..) |

0 commit comments

Comments
 (0)