mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
use more accurate spans for user type ascriptions
This commit is contained in:
parent
b52dea8230
commit
d1e82d438f
@ -453,12 +453,14 @@ pub enum ExprKind<'tcx> {
|
|||||||
source: ExprId,
|
source: ExprId,
|
||||||
/// Type that the user gave to this expression
|
/// Type that the user gave to this expression
|
||||||
user_ty: UserTy<'tcx>,
|
user_ty: UserTy<'tcx>,
|
||||||
|
user_ty_span: Span,
|
||||||
},
|
},
|
||||||
/// A type ascription on a value, e.g. `42: i32`.
|
/// A type ascription on a value, e.g. `type_ascribe!(42, i32)` or `42 as i32`.
|
||||||
ValueTypeAscription {
|
ValueTypeAscription {
|
||||||
source: ExprId,
|
source: ExprId,
|
||||||
/// Type that the user gave to this expression
|
/// Type that the user gave to this expression
|
||||||
user_ty: UserTy<'tcx>,
|
user_ty: UserTy<'tcx>,
|
||||||
|
user_ty_span: Span,
|
||||||
},
|
},
|
||||||
/// A closure definition.
|
/// A closure definition.
|
||||||
Closure(Box<ClosureExpr<'tcx>>),
|
Closure(Box<ClosureExpr<'tcx>>),
|
||||||
|
@ -129,7 +129,8 @@ pub fn walk_expr<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>(
|
|||||||
visitor.visit_expr(&visitor.thir()[base.base]);
|
visitor.visit_expr(&visitor.thir()[base.base]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlaceTypeAscription { source, user_ty: _ } | ValueTypeAscription { source, user_ty: _ } => {
|
PlaceTypeAscription { source, user_ty: _, user_ty_span: _ }
|
||||||
|
| ValueTypeAscription { source, user_ty: _, user_ty_span: _ } => {
|
||||||
visitor.visit_expr(&visitor.thir()[source])
|
visitor.visit_expr(&visitor.thir()[source])
|
||||||
}
|
}
|
||||||
Closure(box ClosureExpr {
|
Closure(box ClosureExpr {
|
||||||
|
@ -470,21 +470,22 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
block.and(place_builder)
|
block.and(place_builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprKind::PlaceTypeAscription { source, ref user_ty } => {
|
ExprKind::PlaceTypeAscription { source, ref user_ty, user_ty_span } => {
|
||||||
let place_builder = unpack!(
|
let place_builder = unpack!(
|
||||||
block = this.expr_as_place(block, source, mutability, fake_borrow_temps,)
|
block = this.expr_as_place(block, source, mutability, fake_borrow_temps,)
|
||||||
);
|
);
|
||||||
if let Some(user_ty) = user_ty {
|
if let Some(user_ty) = user_ty {
|
||||||
|
let ty_source_info = this.source_info(user_ty_span);
|
||||||
let annotation_index =
|
let annotation_index =
|
||||||
this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
|
this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
|
||||||
span: source_info.span,
|
span: user_ty_span,
|
||||||
user_ty: user_ty.clone(),
|
user_ty: user_ty.clone(),
|
||||||
inferred_ty: expr.ty,
|
inferred_ty: expr.ty,
|
||||||
});
|
});
|
||||||
|
|
||||||
let place = place_builder.to_place(this);
|
let place = place_builder.to_place(this);
|
||||||
this.cfg.push(block, Statement {
|
this.cfg.push(block, Statement {
|
||||||
source_info,
|
source_info: ty_source_info,
|
||||||
kind: StatementKind::AscribeUserType(
|
kind: StatementKind::AscribeUserType(
|
||||||
Box::new((place, UserTypeProjection {
|
Box::new((place, UserTypeProjection {
|
||||||
base: annotation_index,
|
base: annotation_index,
|
||||||
@ -496,20 +497,21 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
block.and(place_builder)
|
block.and(place_builder)
|
||||||
}
|
}
|
||||||
ExprKind::ValueTypeAscription { source, ref user_ty } => {
|
ExprKind::ValueTypeAscription { source, ref user_ty, user_ty_span } => {
|
||||||
let source_expr = &this.thir[source];
|
let source_expr = &this.thir[source];
|
||||||
let temp = unpack!(
|
let temp = unpack!(
|
||||||
block = this.as_temp(block, source_expr.temp_lifetime, source, mutability)
|
block = this.as_temp(block, source_expr.temp_lifetime, source, mutability)
|
||||||
);
|
);
|
||||||
if let Some(user_ty) = user_ty {
|
if let Some(user_ty) = user_ty {
|
||||||
|
let ty_source_info = this.source_info(user_ty_span);
|
||||||
let annotation_index =
|
let annotation_index =
|
||||||
this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
|
this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
|
||||||
span: source_info.span,
|
span: user_ty_span,
|
||||||
user_ty: user_ty.clone(),
|
user_ty: user_ty.clone(),
|
||||||
inferred_ty: expr.ty,
|
inferred_ty: expr.ty,
|
||||||
});
|
});
|
||||||
this.cfg.push(block, Statement {
|
this.cfg.push(block, Statement {
|
||||||
source_info,
|
source_info: ty_source_info,
|
||||||
kind: StatementKind::AscribeUserType(
|
kind: StatementKind::AscribeUserType(
|
||||||
Box::new((Place::from(temp), UserTypeProjection {
|
Box::new((Place::from(temp), UserTypeProjection {
|
||||||
base: annotation_index,
|
base: annotation_index,
|
||||||
|
@ -840,6 +840,7 @@ impl<'tcx> Cx<'tcx> {
|
|||||||
ExprKind::ValueTypeAscription {
|
ExprKind::ValueTypeAscription {
|
||||||
source: cast_expr,
|
source: cast_expr,
|
||||||
user_ty: Some(Box::new(*user_ty)),
|
user_ty: Some(Box::new(*user_ty)),
|
||||||
|
user_ty_span: cast_ty.span,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cast
|
cast
|
||||||
@ -851,9 +852,17 @@ impl<'tcx> Cx<'tcx> {
|
|||||||
debug!("make_mirror_unadjusted: (type) user_ty={:?}", user_ty);
|
debug!("make_mirror_unadjusted: (type) user_ty={:?}", user_ty);
|
||||||
let mirrored = self.mirror_expr(source);
|
let mirrored = self.mirror_expr(source);
|
||||||
if source.is_syntactic_place_expr() {
|
if source.is_syntactic_place_expr() {
|
||||||
ExprKind::PlaceTypeAscription { source: mirrored, user_ty }
|
ExprKind::PlaceTypeAscription {
|
||||||
|
source: mirrored,
|
||||||
|
user_ty,
|
||||||
|
user_ty_span: ty.span,
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ExprKind::ValueTypeAscription { source: mirrored, user_ty }
|
ExprKind::ValueTypeAscription {
|
||||||
|
source: mirrored,
|
||||||
|
user_ty,
|
||||||
|
user_ty_span: ty.span,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ExprKind::DropTemps(source) => ExprKind::Use { source: self.mirror_expr(source) },
|
hir::ExprKind::DropTemps(source) => ExprKind::Use { source: self.mirror_expr(source) },
|
||||||
|
@ -454,16 +454,18 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
|
|||||||
self.print_adt_expr(&**adt_expr, depth_lvl + 1);
|
self.print_adt_expr(&**adt_expr, depth_lvl + 1);
|
||||||
print_indented!(self, "}", depth_lvl);
|
print_indented!(self, "}", depth_lvl);
|
||||||
}
|
}
|
||||||
PlaceTypeAscription { source, user_ty } => {
|
PlaceTypeAscription { source, user_ty, user_ty_span } => {
|
||||||
print_indented!(self, "PlaceTypeAscription {", depth_lvl);
|
print_indented!(self, "PlaceTypeAscription {", depth_lvl);
|
||||||
print_indented!(self, format!("user_ty: {:?}", user_ty), depth_lvl + 1);
|
print_indented!(self, format!("user_ty: {:?}", user_ty), depth_lvl + 1);
|
||||||
|
print_indented!(self, format!("user_ty_span: {:?}", user_ty_span), depth_lvl + 1);
|
||||||
print_indented!(self, "source:", depth_lvl + 1);
|
print_indented!(self, "source:", depth_lvl + 1);
|
||||||
self.print_expr(*source, depth_lvl + 2);
|
self.print_expr(*source, depth_lvl + 2);
|
||||||
print_indented!(self, "}", depth_lvl);
|
print_indented!(self, "}", depth_lvl);
|
||||||
}
|
}
|
||||||
ValueTypeAscription { source, user_ty } => {
|
ValueTypeAscription { source, user_ty, user_ty_span } => {
|
||||||
print_indented!(self, "ValueTypeAscription {", depth_lvl);
|
print_indented!(self, "ValueTypeAscription {", depth_lvl);
|
||||||
print_indented!(self, format!("user_ty: {:?}", user_ty), depth_lvl + 1);
|
print_indented!(self, format!("user_ty: {:?}", user_ty), depth_lvl + 1);
|
||||||
|
print_indented!(self, format!("user_ty_span: {:?}", user_ty_span), depth_lvl + 1);
|
||||||
print_indented!(self, "source:", depth_lvl + 1);
|
print_indented!(self, "source:", depth_lvl + 1);
|
||||||
self.print_expr(*source, depth_lvl + 2);
|
self.print_expr(*source, depth_lvl + 2);
|
||||||
print_indented!(self, "}", depth_lvl);
|
print_indented!(self, "}", depth_lvl);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// MIR for `address_of_reborrow` after SimplifyCfg-initial
|
// MIR for `address_of_reborrow` after SimplifyCfg-initial
|
||||||
|
|
||||||
| User Type Annotations
|
| User Type Annotations
|
||||||
| 0: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:8:5: 8:18, inferred_ty: *const [i32; 10]
|
| 0: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:8:10: 8:18, inferred_ty: *const [i32; 10]
|
||||||
| 1: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:10:5: 10:25, inferred_ty: *const dyn std::marker::Send
|
| 1: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:10:10: 10:25, inferred_ty: *const dyn std::marker::Send
|
||||||
| 2: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:14:12: 14:20, inferred_ty: *const [i32; 10]
|
| 2: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:14:12: 14:20, inferred_ty: *const [i32; 10]
|
||||||
| 3: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:14:12: 14:20, inferred_ty: *const [i32; 10]
|
| 3: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:14:12: 14:20, inferred_ty: *const [i32; 10]
|
||||||
| 4: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:15:12: 15:28, inferred_ty: *const [i32; 10]
|
| 4: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:15:12: 15:28, inferred_ty: *const [i32; 10]
|
||||||
@ -11,8 +11,8 @@
|
|||||||
| 7: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:16:12: 16:27, inferred_ty: *const dyn std::marker::Send
|
| 7: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:16:12: 16:27, inferred_ty: *const dyn std::marker::Send
|
||||||
| 8: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:17:12: 17:24, inferred_ty: *const [i32]
|
| 8: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:17:12: 17:24, inferred_ty: *const [i32]
|
||||||
| 9: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:17:12: 17:24, inferred_ty: *const [i32]
|
| 9: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:17:12: 17:24, inferred_ty: *const [i32]
|
||||||
| 10: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:19:5: 19:18, inferred_ty: *const [i32; 10]
|
| 10: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:19:10: 19:18, inferred_ty: *const [i32; 10]
|
||||||
| 11: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:21:5: 21:25, inferred_ty: *const dyn std::marker::Send
|
| 11: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:21:10: 21:25, inferred_ty: *const dyn std::marker::Send
|
||||||
| 12: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:24:12: 24:20, inferred_ty: *const [i32; 10]
|
| 12: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:24:12: 24:20, inferred_ty: *const [i32; 10]
|
||||||
| 13: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:24:12: 24:20, inferred_ty: *const [i32; 10]
|
| 13: user_ty: Canonical { value: Ty(*const ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:24:12: 24:20, inferred_ty: *const [i32; 10]
|
||||||
| 14: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:25:12: 25:28, inferred_ty: *const [i32; 10]
|
| 14: user_ty: Canonical { value: Ty(*const [i32; 10]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:25:12: 25:28, inferred_ty: *const [i32; 10]
|
||||||
@ -21,8 +21,8 @@
|
|||||||
| 17: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:26:12: 26:27, inferred_ty: *const dyn std::marker::Send
|
| 17: user_ty: Canonical { value: Ty(*const dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:26:12: 26:27, inferred_ty: *const dyn std::marker::Send
|
||||||
| 18: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:27:12: 27:24, inferred_ty: *const [i32]
|
| 18: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:27:12: 27:24, inferred_ty: *const [i32]
|
||||||
| 19: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:27:12: 27:24, inferred_ty: *const [i32]
|
| 19: user_ty: Canonical { value: Ty(*const [i32]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:27:12: 27:24, inferred_ty: *const [i32]
|
||||||
| 20: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:29:5: 29:16, inferred_ty: *mut [i32; 10]
|
| 20: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:29:10: 29:16, inferred_ty: *mut [i32; 10]
|
||||||
| 21: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:31:5: 31:23, inferred_ty: *mut dyn std::marker::Send
|
| 21: user_ty: Canonical { value: Ty(*mut dyn std::marker::Send), max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:31:10: 31:23, inferred_ty: *mut dyn std::marker::Send
|
||||||
| 22: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:34:12: 34:18, inferred_ty: *mut [i32; 10]
|
| 22: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:34:12: 34:18, inferred_ty: *mut [i32; 10]
|
||||||
| 23: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:34:12: 34:18, inferred_ty: *mut [i32; 10]
|
| 23: user_ty: Canonical { value: Ty(*mut ^0), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], defining_opaque_types: [] }, span: $DIR/address_of.rs:34:12: 34:18, inferred_ty: *mut [i32; 10]
|
||||||
| 24: user_ty: Canonical { value: Ty(*mut [i32; 10]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:35:12: 35:26, inferred_ty: *mut [i32; 10]
|
| 24: user_ty: Canonical { value: Ty(*mut [i32; 10]), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/address_of.rs:35:12: 35:26, inferred_ty: *mut [i32; 10]
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ptr-to-trait-obj-different-regions-id-trait.rs:24:17
|
--> $DIR/ptr-to-trait-obj-different-regions-id-trait.rs:24:27
|
||||||
|
|
|
|
||||||
LL | fn m<'a>() {
|
LL | fn m<'a>() {
|
||||||
| -- lifetime `'a` defined here
|
| -- lifetime `'a` defined here
|
||||||
LL | let unsend: *const dyn Cat<'a> = &();
|
LL | let unsend: *const dyn Cat<'a> = &();
|
||||||
LL | let _send = unsend as *const S<dyn Cat<'static>>;
|
LL | let _send = unsend as *const S<dyn Cat<'static>>;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
|
||||||
|
|
|
|
||||||
= note: requirement occurs because of the type `S<dyn Cat<'_>>`, which makes the generic argument `dyn Cat<'_>` invariant
|
= note: requirement occurs because of the type `S<dyn Cat<'_>>`, which makes the generic argument `dyn Cat<'_>` invariant
|
||||||
= note: the struct `S<T>` is invariant over the parameter `T`
|
= note: the struct `S<T>` is invariant over the parameter `T`
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/ptr-to-trait-obj-different-regions-id-trait.rs:24:17
|
--> $DIR/ptr-to-trait-obj-different-regions-id-trait.rs:24:27
|
||||||
|
|
|
|
||||||
LL | fn m<'a>() {
|
LL | fn m<'a>() {
|
||||||
| -- lifetime `'a` defined here
|
| -- lifetime `'a` defined here
|
||||||
LL | let unsend: *const dyn Cat<'a> = &();
|
LL | let unsend: *const dyn Cat<'a> = &();
|
||||||
LL | let _send = unsend as *const S<dyn Cat<'static>>;
|
LL | let _send = unsend as *const S<dyn Cat<'static>>;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
|
||||||
|
|
|
|
||||||
= note: requirement occurs because of the type `S<dyn Cat<'_>>`, which makes the generic argument `dyn Cat<'_>` invariant
|
= note: requirement occurs because of the type `S<dyn Cat<'_>>`, which makes the generic argument `dyn Cat<'_>` invariant
|
||||||
= note: the struct `S<T>` is invariant over the parameter `T`
|
= note: the struct `S<T>` is invariant over the parameter `T`
|
||||||
|
@ -112,13 +112,13 @@ LL | struct Foo; // does not impl Copy
|
|||||||
|
|
|
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/kindck-impl-type-params.rs:30:13
|
--> $DIR/kindck-impl-type-params.rs:30:19
|
||||||
|
|
|
|
||||||
LL | fn foo<'a>() {
|
LL | fn foo<'a>() {
|
||||||
| -- lifetime `'a` defined here
|
| -- lifetime `'a` defined here
|
||||||
LL | let t: S<&'a isize> = S(marker::PhantomData);
|
LL | let t: S<&'a isize> = S(marker::PhantomData);
|
||||||
LL | let a = &t as &dyn Gettable<&'a isize>;
|
LL | let a = &t as &dyn Gettable<&'a isize>;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
|
||||||
|
|
||||||
error: aborting due to 7 previous errors
|
error: aborting due to 7 previous errors
|
||||||
|
|
||||||
|
@ -4,10 +4,9 @@ error[E0597]: `x` does not live long enough
|
|||||||
LL | let x = 22_u32;
|
LL | let x = 22_u32;
|
||||||
| - binding `x` declared here
|
| - binding `x` declared here
|
||||||
LL | let y: &u32 = (&x) as &'static u32;
|
LL | let y: &u32 = (&x) as &'static u32;
|
||||||
| ^^^^----------------
|
| ^^^^ ------------ type annotation requires that `x` is borrowed for `'static`
|
||||||
| |
|
| |
|
||||||
| borrowed value does not live long enough
|
| borrowed value does not live long enough
|
||||||
| type annotation requires that `x` is borrowed for `'static`
|
|
||||||
LL | }
|
LL | }
|
||||||
| - `x` dropped here while still borrowed
|
| - `x` dropped here while still borrowed
|
||||||
|
|
||||||
|
@ -4,10 +4,9 @@ error[E0597]: `x` does not live long enough
|
|||||||
LL | let x = 22_u32;
|
LL | let x = 22_u32;
|
||||||
| - binding `x` declared here
|
| - binding `x` declared here
|
||||||
LL | let y: &u32 = type_ascribe!(&x, &'static u32);
|
LL | let y: &u32 = type_ascribe!(&x, &'static u32);
|
||||||
| --------------^^---------------
|
| ^^ ------------ type annotation requires that `x` is borrowed for `'static`
|
||||||
| | |
|
| |
|
||||||
| | borrowed value does not live long enough
|
| borrowed value does not live long enough
|
||||||
| type annotation requires that `x` is borrowed for `'static`
|
|
||||||
LL | }
|
LL | }
|
||||||
| - `x` dropped here while still borrowed
|
| - `x` dropped here while still borrowed
|
||||||
|
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/type-checking-test-3.rs:11:13
|
--> $DIR/type-checking-test-3.rs:11:18
|
||||||
|
|
|
|
||||||
LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
|
LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
|
||||||
| -- lifetime `'a` defined here
|
| -- lifetime `'a` defined here
|
||||||
LL | let _ = x as &dyn Bar<'a>; // Error
|
LL | let _ = x as &dyn Bar<'a>; // Error
|
||||||
| ^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
|
| ^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/type-checking-test-3.rs:16:13
|
--> $DIR/type-checking-test-3.rs:16:18
|
||||||
|
|
|
|
||||||
LL | fn test_wrong2<'a>(x: &dyn Foo<'a>) {
|
LL | fn test_wrong2<'a>(x: &dyn Foo<'a>) {
|
||||||
| -- lifetime `'a` defined here
|
| -- lifetime `'a` defined here
|
||||||
LL | let _ = x as &dyn Bar<'static>; // Error
|
LL | let _ = x as &dyn Bar<'static>; // Error
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
|
| ^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/type-checking-test-4.rs:19:13
|
--> $DIR/type-checking-test-4.rs:19:18
|
||||||
|
|
|
|
||||||
LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
|
LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
|
||||||
| -- lifetime `'a` defined here
|
| -- lifetime `'a` defined here
|
||||||
LL | let _ = x as &dyn Bar<'static, 'a>; // Error
|
LL | let _ = x as &dyn Bar<'static, 'a>; // Error
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
|
| ^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/type-checking-test-4.rs:24:13
|
--> $DIR/type-checking-test-4.rs:24:18
|
||||||
|
|
|
|
||||||
LL | fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) {
|
LL | fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) {
|
||||||
| -- lifetime `'a` defined here
|
| -- lifetime `'a` defined here
|
||||||
LL | let _ = x as &dyn Bar<'a, 'static>; // Error
|
LL | let _ = x as &dyn Bar<'a, 'static>; // Error
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
|
| ^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/type-checking-test-4.rs:30:5
|
--> $DIR/type-checking-test-4.rs:30:5
|
||||||
|
Loading…
Reference in New Issue
Block a user