Skip to content

Commit d6c63bd

Browse files
committed
Fix up DescriptionCtx::new.
The comment mentions that `ReBound` and `ReVar` aren't expected here. Experimentation with the full test suite indicates this is true, and that `ReErased` also doesn't occur. So the commit introduces `bug!` for those cases. (If any of them show up later on, at least we'll have a test case.) The commit also remove the first sentence in the comment. `RePlaceholder` is now handled in the match arm above this comment and nothing is printed for it, so that sentence is just wrong. Furthermore, issue rust-lang#13998 was closed some time ago.
1 parent 609b9a6 commit d6c63bd

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

compiler/rustc_infer/src/errors/note_and_explain.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,8 @@ impl<'a> DescriptionCtx<'a> {
6969

7070
ty::RePlaceholder(_) | ty::ReError(_) => return None,
7171

72-
// FIXME(#13998) RePlaceholder should probably print like
73-
// ReLateParam rather than dumping Debug output on the user.
74-
//
75-
// We shouldn't really be having unification failures with ReVar
76-
// and ReBound though.
77-
//
78-
// FIXME(@lcnr): figure out why we have to handle `ReBound`
79-
// here, this feels somewhat off.
8072
ty::ReVar(_) | ty::ReBound(..) | ty::ReErased => {
81-
(alt_span, "revar", format!("{region:?}"))
73+
bug!("unexpected region for DescriptionCtx: {:?}", region);
8274
}
8375
};
8476
Some(DescriptionCtx { span, kind, arg })

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,9 @@ pub(super) fn note_and_explain_region<'tcx>(
172172

173173
ty::ReError(_) => return,
174174

175-
// We shouldn't really be having unification failures with ReVar
176-
// and ReBound though.
177-
//
178-
// FIXME(@lcnr): Figure out whether this is reachable and if so, why.
179-
ty::ReVar(_) | ty::ReBound(..) | ty::ReErased => (format!("lifetime `{region}`"), alt_span),
175+
ty::ReVar(_) | ty::ReBound(..) | ty::ReErased => {
176+
bug!("unexpected region for note_and_explain_region: {:?}", region);
177+
}
180178
};
181179

182180
emit_msg_span(err, prefix, description, span, suffix);

0 commit comments

Comments
 (0)