Use real opaque type instead of just saying impl Trait

This commit is contained in:
Michael Goulet 2022-07-26 06:19:58 +00:00
parent daaae25022
commit d3492ca852
27 changed files with 52 additions and 50 deletions

View file

@ -78,6 +78,8 @@ pub(crate) enum RegionErrorKind<'tcx> {
span: Span, span: Span,
/// The hidden type. /// The hidden type.
hidden_ty: Ty<'tcx>, hidden_ty: Ty<'tcx>,
/// The opaque type.
key: ty::OpaqueTypeKey<'tcx>,
/// The unexpected region. /// The unexpected region.
member_region: ty::Region<'tcx>, member_region: ty::Region<'tcx>,
}, },
@ -205,14 +207,16 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
} }
} }
RegionErrorKind::UnexpectedHiddenRegion { span, hidden_ty, member_region } => { RegionErrorKind::UnexpectedHiddenRegion { span, hidden_ty, key, member_region } => {
let named_ty = self.regioncx.name_regions(self.infcx.tcx, hidden_ty); let named_ty = self.regioncx.name_regions(self.infcx.tcx, hidden_ty);
let named_key = self.regioncx.name_regions(self.infcx.tcx, key);
let named_region = self.regioncx.name_regions(self.infcx.tcx, member_region); let named_region = self.regioncx.name_regions(self.infcx.tcx, member_region);
self.buffer_error(unexpected_hidden_region_diagnostic( self.buffer_error(unexpected_hidden_region_diagnostic(
self.infcx.tcx, self.infcx.tcx,
span, span,
named_ty, named_ty,
named_region, named_region,
named_key,
)); ));
} }

View file

@ -38,6 +38,8 @@ pub(crate) struct NllMemberConstraint<'tcx> {
/// The hidden type in which `R0` appears. (Used in error reporting.) /// The hidden type in which `R0` appears. (Used in error reporting.)
pub(crate) hidden_ty: Ty<'tcx>, pub(crate) hidden_ty: Ty<'tcx>,
pub(crate) key: ty::OpaqueTypeKey<'tcx>,
/// The region `R0`. /// The region `R0`.
pub(crate) member_region_vid: ty::RegionVid, pub(crate) member_region_vid: ty::RegionVid,
@ -90,6 +92,7 @@ impl<'tcx> MemberConstraintSet<'tcx, ty::RegionVid> {
member_region_vid, member_region_vid,
definition_span: m_c.definition_span, definition_span: m_c.definition_span,
hidden_ty: m_c.hidden_ty, hidden_ty: m_c.hidden_ty,
key: m_c.key,
start_index, start_index,
end_index, end_index,
}); });

View file

@ -1763,6 +1763,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
errors_buffer.push(RegionErrorKind::UnexpectedHiddenRegion { errors_buffer.push(RegionErrorKind::UnexpectedHiddenRegion {
span: m_c.definition_span, span: m_c.definition_span,
hidden_ty: m_c.hidden_ty, hidden_ty: m_c.hidden_ty,
key: m_c.key,
member_region, member_region,
}); });
} }

View file

@ -246,7 +246,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
// after producing an error for each of them. // after producing an error for each of them.
let definition_ty = instantiated_ty.ty.fold_with(&mut ReverseMapper::new( let definition_ty = instantiated_ty.ty.fold_with(&mut ReverseMapper::new(
self.tcx, self.tcx,
def_id, opaque_type_key,
map, map,
instantiated_ty.ty, instantiated_ty.ty,
instantiated_ty.span, instantiated_ty.span,
@ -429,7 +429,7 @@ fn check_opaque_type_parameter_valid(
struct ReverseMapper<'tcx> { struct ReverseMapper<'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
opaque_type_def_id: LocalDefId, key: ty::OpaqueTypeKey<'tcx>,
map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>, map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>,
map_missing_regions_to_empty: bool, map_missing_regions_to_empty: bool,
@ -443,14 +443,14 @@ struct ReverseMapper<'tcx> {
impl<'tcx> ReverseMapper<'tcx> { impl<'tcx> ReverseMapper<'tcx> {
fn new( fn new(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
opaque_type_def_id: LocalDefId, key: ty::OpaqueTypeKey<'tcx>,
map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>, map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>,
hidden_ty: Ty<'tcx>, hidden_ty: Ty<'tcx>,
span: Span, span: Span,
) -> Self { ) -> Self {
Self { Self {
tcx, tcx,
opaque_type_def_id, key,
map, map,
map_missing_regions_to_empty: false, map_missing_regions_to_empty: false,
hidden_ty: Some(hidden_ty), hidden_ty: Some(hidden_ty),
@ -504,7 +504,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
} }
} }
let generics = self.tcx().generics_of(self.opaque_type_def_id); let generics = self.tcx().generics_of(self.key.def_id);
match self.map.get(&r.into()).map(|k| k.unpack()) { match self.map.get(&r.into()).map(|k| k.unpack()) {
Some(GenericArgKind::Lifetime(r1)) => r1, Some(GenericArgKind::Lifetime(r1)) => r1,
Some(u) => panic!("region mapped to unexpected kind: {:?}", u), Some(u) => panic!("region mapped to unexpected kind: {:?}", u),
@ -513,9 +513,10 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
if let Some(hidden_ty) = self.hidden_ty.take() { if let Some(hidden_ty) = self.hidden_ty.take() {
unexpected_hidden_region_diagnostic( unexpected_hidden_region_diagnostic(
self.tcx, self.tcx,
self.tcx.def_span(self.opaque_type_def_id), self.tcx.def_span(self.key.def_id),
hidden_ty, hidden_ty,
r, r,
self.key,
) )
.emit(); .emit();
} }

View file

@ -237,12 +237,14 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>(
span: Span, span: Span,
hidden_ty: Ty<'tcx>, hidden_ty: Ty<'tcx>,
hidden_region: ty::Region<'tcx>, hidden_region: ty::Region<'tcx>,
opaque_ty: ty::OpaqueTypeKey<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let opaque_ty = tcx.mk_opaque(opaque_ty.def_id.to_def_id(), opaque_ty.substs);
let mut err = struct_span_err!( let mut err = struct_span_err!(
tcx.sess, tcx.sess,
span, span,
E0700, E0700,
"hidden type for `impl Trait` captures lifetime that does not appear in bounds", "hidden type for `{opaque_ty}` captures lifetime that does not appear in bounds",
); );
// Explain the region we are capturing. // Explain the region we are capturing.

View file

@ -974,14 +974,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
#[instrument(skip(self), level = "debug")] #[instrument(skip(self), level = "debug")]
pub fn member_constraint( pub fn member_constraint(
&self, &self,
opaque_type_def_id: LocalDefId, key: ty::OpaqueTypeKey<'tcx>,
definition_span: Span, definition_span: Span,
hidden_ty: Ty<'tcx>, hidden_ty: Ty<'tcx>,
region: ty::Region<'tcx>, region: ty::Region<'tcx>,
in_regions: &Lrc<Vec<ty::Region<'tcx>>>, in_regions: &Lrc<Vec<ty::Region<'tcx>>>,
) { ) {
self.inner.borrow_mut().unwrap_region_constraints().member_constraint( self.inner.borrow_mut().unwrap_region_constraints().member_constraint(
opaque_type_def_id, key,
definition_span, definition_span,
hidden_ty, hidden_ty,
region, region,

View file

@ -394,15 +394,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
); );
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor { concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
op: |r| { op: |r| self.member_constraint(opaque_type_key, span, concrete_ty, r, &choice_regions),
self.member_constraint(
opaque_type_key.def_id,
span,
concrete_ty,
r,
&choice_regions,
)
},
}); });
} }

View file

@ -12,7 +12,6 @@ use rustc_data_structures::intern::Interned;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_data_structures::undo_log::UndoLogs; use rustc_data_structures::undo_log::UndoLogs;
use rustc_data_structures::unify as ut; use rustc_data_structures::unify as ut;
use rustc_hir::def_id::LocalDefId;
use rustc_index::vec::IndexVec; use rustc_index::vec::IndexVec;
use rustc_middle::infer::unify_key::{RegionVidKey, UnifiedRegion}; use rustc_middle::infer::unify_key::{RegionVidKey, UnifiedRegion};
use rustc_middle::ty::ReStatic; use rustc_middle::ty::ReStatic;
@ -533,7 +532,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
pub fn member_constraint( pub fn member_constraint(
&mut self, &mut self,
opaque_type_def_id: LocalDefId, key: ty::OpaqueTypeKey<'tcx>,
definition_span: Span, definition_span: Span,
hidden_ty: Ty<'tcx>, hidden_ty: Ty<'tcx>,
member_region: ty::Region<'tcx>, member_region: ty::Region<'tcx>,
@ -546,7 +545,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
} }
self.data.member_constraints.push(MemberConstraint { self.data.member_constraints.push(MemberConstraint {
opaque_type_def_id, key,
definition_span, definition_span,
hidden_ty, hidden_ty,
member_region, member_region,

View file

@ -2,9 +2,8 @@ pub mod canonical;
pub mod unify_key; pub mod unify_key;
use crate::ty::Region; use crate::ty::Region;
use crate::ty::Ty; use crate::ty::{OpaqueTypeKey, Ty};
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_hir::def_id::LocalDefId;
use rustc_span::Span; use rustc_span::Span;
/// Requires that `region` must be equal to one of the regions in `choice_regions`. /// Requires that `region` must be equal to one of the regions in `choice_regions`.
@ -15,8 +14,9 @@ use rustc_span::Span;
/// ``` /// ```
#[derive(Debug, Clone, HashStable, TypeFoldable, TypeVisitable, Lift)] #[derive(Debug, Clone, HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct MemberConstraint<'tcx> { pub struct MemberConstraint<'tcx> {
/// The `DefId` of the opaque type causing this constraint: used for error reporting. /// The `DefId` and substs of the opaque type causing this constraint.
pub opaque_type_def_id: LocalDefId, /// Used for error reporting.
pub key: OpaqueTypeKey<'tcx>,
/// The span where the hidden type was instantiated. /// The span where the hidden type was instantiated.
pub definition_span: Span, pub definition_span: Span,

View file

@ -13,7 +13,7 @@ LL | | }
| |
= help: consider adding the following bound: `'a: 'b` = help: consider adding the following bound: `'a: 'b`
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Trait<'a>` captures lifetime that does not appear in bounds
--> $DIR/ret-impl-trait-one.rs:16:80 --> $DIR/ret-impl-trait-one.rs:16:80
| |
LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> { LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> {

View file

@ -1,4 +1,4 @@
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Swap` captures lifetime that does not appear in bounds
--> $DIR/hidden-lifetimes.rs:29:5 --> $DIR/hidden-lifetimes.rs:29:5
| |
LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a { LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a {
@ -11,7 +11,7 @@ help: to declare that the `impl Trait` captures `'b`, you can add an explicit `'
LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a + 'b { LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a + 'b {
| ++++ | ++++
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Swap` captures lifetime that does not appear in bounds
--> $DIR/hidden-lifetimes.rs:46:5 --> $DIR/hidden-lifetimes.rs:46:5
| |
LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a { LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a {

View file

@ -20,7 +20,7 @@ fn foo<'a: 'b, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> {
let _: &'b i32 = *u.0; let _: &'b i32 = *u.0;
} }
u.0 u.0
//~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds //~^ ERROR hidden type for `E<'b, 'c>` captures lifetime that does not appear in bounds
} }
fn main() {} fn main() {}

View file

@ -1,4 +1,4 @@
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `E<'b, 'c>` captures lifetime that does not appear in bounds
--> $DIR/error-handling-2.rs:22:5 --> $DIR/error-handling-2.rs:22:5
| |
LL | fn foo<'a: 'b, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> { LL | fn foo<'a: 'b, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> {

View file

@ -26,7 +26,7 @@ where
// 'a in ['d, 'e] // 'a in ['d, 'e]
// ``` // ```
if condition() { a } else { b } if condition() { a } else { b }
//~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds //~^ ERROR hidden type for `impl Trait<'d, 'e>` captures lifetime that does not appear in bounds
} }
fn condition() -> bool { fn condition() -> bool {

View file

@ -1,4 +1,4 @@
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Trait<'d, 'e>` captures lifetime that does not appear in bounds
--> $DIR/ordinary-bounds-unrelated.rs:28:33 --> $DIR/ordinary-bounds-unrelated.rs:28:33
| |
LL | fn upper_bounds<'a, 'b, 'c, 'd, 'e>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'d, 'e> LL | fn upper_bounds<'a, 'b, 'c, 'd, 'e>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'d, 'e>

View file

@ -29,7 +29,7 @@ fn upper_bounds<'a, 'b>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'a, 'b>
// //
// We are forced to pick that '0 = 'e, because only 'e is outlived by *both* 'a and 'b. // We are forced to pick that '0 = 'e, because only 'e is outlived by *both* 'a and 'b.
if condition() { a } else { b } if condition() { a } else { b }
//~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds //~^ ERROR hidden type for `impl Trait<'a, 'b>` captures lifetime that does not appear in bounds
} }
fn condition() -> bool { fn condition() -> bool {

View file

@ -1,4 +1,4 @@
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Trait<'a, 'b>` captures lifetime that does not appear in bounds
--> $DIR/ordinary-bounds-unsuited.rs:31:33 --> $DIR/ordinary-bounds-unsuited.rs:31:33
| |
LL | fn upper_bounds<'a, 'b>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'a, 'b> LL | fn upper_bounds<'a, 'b>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'a, 'b>

View file

@ -1,4 +1,4 @@
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Copy` captures lifetime that does not appear in bounds
--> $DIR/must_outlive_least_region_or_bound.rs:3:35 --> $DIR/must_outlive_least_region_or_bound.rs:3:35
| |
LL | fn elided(x: &i32) -> impl Copy { x } LL | fn elided(x: &i32) -> impl Copy { x }
@ -11,7 +11,7 @@ help: to declare that the `impl Trait` captures `'_`, you can add an explicit `'
LL | fn elided(x: &i32) -> impl Copy + '_ { x } LL | fn elided(x: &i32) -> impl Copy + '_ { x }
| ++++ | ++++
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Copy` captures lifetime that does not appear in bounds
--> $DIR/must_outlive_least_region_or_bound.rs:6:44 --> $DIR/must_outlive_least_region_or_bound.rs:6:44
| |
LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
@ -96,7 +96,7 @@ help: alternatively, add an explicit `'static` bound to this reference
LL | fn with_bound<'a>(x: &'static i32) -> impl LifetimeTrait<'a> + 'static { x } LL | fn with_bound<'a>(x: &'static i32) -> impl LifetimeTrait<'a> + 'static { x }
| ~~~~~~~~~~~~ | ~~~~~~~~~~~~
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Fn(&'a u32)` captures lifetime that does not appear in bounds
--> $DIR/must_outlive_least_region_or_bound.rs:38:5 --> $DIR/must_outlive_least_region_or_bound.rs:38:5
| |
LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) {

View file

@ -15,7 +15,7 @@ fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y>
where 'x: 'y where 'x: 'y
{ {
x x
//~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds [E0700] //~^ ERROR hidden type for `impl Trait<'y>` captures lifetime that does not appear in bounds [E0700]
} }
fn main() { } fn main() { }

View file

@ -1,4 +1,4 @@
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Trait<'y>` captures lifetime that does not appear in bounds
--> $DIR/region-escape-via-bound.rs:17:5 --> $DIR/region-escape-via-bound.rs:17:5
| |
LL | fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y> LL | fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y>

View file

@ -1,4 +1,4 @@
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Iterator<Item = u32>` captures lifetime that does not appear in bounds
--> $DIR/static-return-lifetime-infered.rs:7:9 --> $DIR/static-return-lifetime-infered.rs:7:9
| |
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> { LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
@ -11,7 +11,7 @@ help: to declare that the `impl Trait` captures `'_`, you can add an explicit `'
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ { LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ {
| ++++ | ++++
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Iterator<Item = u32>` captures lifetime that does not appear in bounds
--> $DIR/static-return-lifetime-infered.rs:7:9 --> $DIR/static-return-lifetime-infered.rs:7:9
| |
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> { LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
@ -24,7 +24,7 @@ help: to declare that the `impl Trait` captures `'_`, you can add an explicit `'
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ { LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ {
| ++++ | ++++
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Iterator<Item = u32>` captures lifetime that does not appear in bounds
--> $DIR/static-return-lifetime-infered.rs:12:9 --> $DIR/static-return-lifetime-infered.rs:12:9
| |
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> { LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
@ -37,7 +37,7 @@ help: to declare that the `impl Trait` captures `'a`, you can add an explicit `'
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> + 'a { LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> + 'a {
| ++++ | ++++
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Iterator<Item = u32>` captures lifetime that does not appear in bounds
--> $DIR/static-return-lifetime-infered.rs:12:9 --> $DIR/static-return-lifetime-infered.rs:12:9
| |
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> { LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {

View file

@ -1,4 +1,4 @@
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Iterator<Item = u8>` captures lifetime that does not appear in bounds
--> $DIR/issue-73159-rpit-static.rs:8:9 --> $DIR/issue-73159-rpit-static.rs:8:9
| |
LL | impl<'a> Foo<'a> { LL | impl<'a> Foo<'a> {

View file

@ -1,4 +1,4 @@
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `Opaque(DefId(0:11 ~ impl_trait_captures[1afc]::foo::{opaque#0}), [ReStatic, T, ReEarlyBound(0, 'a)])` captures lifetime that does not appear in bounds
--> $DIR/impl-trait-captures.rs:11:5 --> $DIR/impl-trait-captures.rs:11:5
| |
LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> { LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> {

View file

@ -1,4 +1,4 @@
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Clone` captures lifetime that does not appear in bounds
--> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:8:48 --> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:8:48
| |
LL | async fn f(self: Pin<&Self>) -> impl Clone { self } LL | async fn f(self: Pin<&Self>) -> impl Clone { self }

View file

@ -1,4 +1,4 @@
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl Clone` captures lifetime that does not appear in bounds
--> $DIR/arbitrary_self_types_pin_lifetime_impl_trait.rs:6:44 --> $DIR/arbitrary_self_types_pin_lifetime_impl_trait.rs:6:44
| |
LL | fn f(self: Pin<&Self>) -> impl Clone { self } LL | fn f(self: Pin<&Self>) -> impl Clone { self }

View file

@ -17,7 +17,7 @@ where
G: Get<T>, G: Get<T>,
{ {
move || { move || {
//~^ ERROR hidden type for `impl Trait` captures lifetime //~^ ERROR hidden type for `impl FnOnce()` captures lifetime
*dest = g.get(); *dest = g.get();
} }
} }

View file

@ -6,7 +6,7 @@ LL | fn baz<G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
| | | |
| help: consider introducing lifetime `'a` here: `'a,` | help: consider introducing lifetime `'a` here: `'a,`
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds error[E0700]: hidden type for `impl FnOnce()` captures lifetime that does not appear in bounds
--> $DIR/missing-lifetimes-in-signature.rs:19:5 --> $DIR/missing-lifetimes-in-signature.rs:19:5
| |
LL | fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce() LL | fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce()