instantiated_ty: Ty<'tcx>,
span: Span,
) -> Ty<'tcx> {
+ if self.is_tainted_by_errors() {
+ return self.tcx.ty_error();
+ }
+
let OpaqueTypeKey { def_id, substs } = opaque_type_key;
// Use substs to build up a reverse map from regions to their
// after producing an error for each of them.
let definition_ty = instantiated_ty.fold_with(&mut ReverseMapper::new(
self.tcx,
- self.is_tainted_by_errors(),
def_id,
map,
instantiated_ty,
struct ReverseMapper<'tcx> {
tcx: TyCtxt<'tcx>,
- /// If errors have already been reported in this fn, we suppress
- /// our own errors because they are sometimes derivative.
- tainted_by_errors: bool,
-
opaque_type_def_id: DefId,
map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>,
map_missing_regions_to_empty: bool,
impl<'tcx> ReverseMapper<'tcx> {
fn new(
tcx: TyCtxt<'tcx>,
- tainted_by_errors: bool,
opaque_type_def_id: DefId,
map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>,
hidden_ty: Ty<'tcx>,
) -> Self {
Self {
tcx,
- tainted_by_errors,
opaque_type_def_id,
map,
map_missing_regions_to_empty: false,
match self.map.get(&r.into()).map(|k| k.unpack()) {
Some(GenericArgKind::Lifetime(r1)) => r1,
Some(u) => panic!("region mapped to unexpected kind: {:?}", u),
- None if self.map_missing_regions_to_empty || self.tainted_by_errors => {
- self.tcx.lifetimes.re_root_empty
- }
+ None if self.map_missing_regions_to_empty => self.tcx.lifetimes.re_root_empty,
None if generics.parent.is_some() => {
if let Some(hidden_ty) = self.hidden_ty.take() {
unexpected_hidden_region_diagnostic(
|
= help: consider adding an explicit lifetime bound `T: 'static`...
-error[E0310]: the parameter type `T` may not live long enough
- --> $DIR/generic_type_does_not_live_long_enough.rs:10:24
- |
-LL | type WrongGeneric<T> = impl 'static;
- | ^^^^^^^^^^^^
- |
- = help: consider adding an explicit lifetime bound `T: 'static`...
- = note: ...so that the type `T` will meet its required lifetime bounds
-
-error: aborting due to 4 previous errors
+error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0310`.
LL | |x| x
| ^^^^^
-error[E0308]: mismatched types
- --> $DIR/issue-57611-trait-alias.rs:17:16
- |
-LL | type Bar = impl Baz<Self, Self>;
- | ^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
- |
- = note: expected type `for<'r> Fn<(&'r X,)>`
- found type `Fn<(&'static X,)>`
-note: this closure does not fulfill the lifetime requirements
- --> $DIR/issue-57611-trait-alias.rs:20:9
- |
-LL | |x| x
- | ^^^^^
-
-error: implementation of `FnOnce` is not general enough
- --> $DIR/issue-57611-trait-alias.rs:17:16
- |
-LL | type Bar = impl Baz<Self, Self>;
- | ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough
- |
- = note: closure with signature `fn(&'static X) -> &'static X` must implement `FnOnce<(&'0 X,)>`, for any lifetime `'0`...
- = note: ...but it actually implements `FnOnce<(&'static X,)>`
-
-error: aborting due to 4 previous errors
+error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0308`.