summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_middle/src/ty/visit.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_middle/src/ty/visit.rs')
-rw-r--r--compiler/rustc_middle/src/ty/visit.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/ty/visit.rs b/compiler/rustc_middle/src/ty/visit.rs
index c09f71f9a..4cdfd9e59 100644
--- a/compiler/rustc_middle/src/ty/visit.rs
+++ b/compiler/rustc_middle/src/ty/visit.rs
@@ -72,12 +72,18 @@ pub trait TypeVisitable<'tcx>: fmt::Debug + Clone {
self.visit_with(&mut HasEscapingVarsVisitor { outer_index: binder }).is_break()
}
- /// Returns `true` if this `self` has any regions that escape `binder` (and
+ /// Returns `true` if this type has any regions that escape `binder` (and
/// hence are not bound by it).
fn has_vars_bound_above(&self, binder: ty::DebruijnIndex) -> bool {
self.has_vars_bound_at_or_above(binder.shifted_in(1))
}
+ /// Return `true` if this type has regions that are not a part of the type.
+ /// For example, `for<'a> fn(&'a i32)` return `false`, while `fn(&'a i32)`
+ /// would return `true`. The latter can occur when traversing through the
+ /// former.
+ ///
+ /// See [`HasEscapingVarsVisitor`] for more information.
fn has_escaping_bound_vars(&self) -> bool {
self.has_vars_bound_at_or_above(ty::INNERMOST)
}
@@ -95,11 +101,15 @@ pub trait TypeVisitable<'tcx>: fmt::Debug + Clone {
fn references_error(&self) -> bool {
self.has_type_flags(TypeFlags::HAS_ERROR)
}
- fn error_reported(&self) -> Option<ErrorGuaranteed> {
+ fn error_reported(&self) -> Result<(), ErrorGuaranteed> {
if self.references_error() {
- Some(ErrorGuaranteed::unchecked_claim_error_was_emitted())
+ if let Some(reported) = ty::tls::with(|tcx| tcx.sess.is_compilation_going_to_fail()) {
+ Err(reported)
+ } else {
+ bug!("expect tcx.sess.is_compilation_going_to_fail return `Some`");
+ }
} else {
- None
+ Ok(())
}
}
fn has_non_region_param(&self) -> bool {