1
Fork 0

Auto merge of #97284 - b-naber:constraint-dyn-impl-suggestion, r=estebank

Add suggestion for relaxing static lifetime bounds on dyn trait impls in NLL

This PR introduces suggestions for relaxing static lifetime bounds on impls of dyn trait items for NLL similar to what is already available in lexical region diagnostics.

Fixes https://github.com/rust-lang/rust/issues/95701

r? `@estebank`
This commit is contained in:
bors 2022-05-28 04:04:29 +00:00
commit ed76b773b5
23 changed files with 368 additions and 104 deletions

View file

@ -338,11 +338,12 @@ pub struct ClosureOutlivesRequirement<'tcx> {
pub blame_span: Span,
// ... due to this reason.
pub category: ConstraintCategory,
pub category: ConstraintCategory<'tcx>,
}
// Make sure this enum doesn't unintentionally grow
rustc_data_structures::static_assert_size!(ConstraintCategory, 12);
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(ConstraintCategory<'_>, 16);
/// Outlives-constraints can be categorized to determine whether and why they
/// are interesting (for error reporting). Order of variants indicates sort
@ -351,7 +352,7 @@ rustc_data_structures::static_assert_size!(ConstraintCategory, 12);
/// See also `rustc_const_eval::borrow_check::constraints`.
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)]
#[derive(TyEncodable, TyDecodable, HashStable)]
pub enum ConstraintCategory {
pub enum ConstraintCategory<'tcx> {
Return(ReturnConstraint),
Yield,
UseAsConst,
@ -363,7 +364,9 @@ pub enum ConstraintCategory {
///
/// We try to get the category that the closure used when reporting this.
ClosureBounds,
CallArgument,
/// Contains the function type if available.
CallArgument(Option<Ty<'tcx>>),
CopyBound,
SizedBound,
Assignment,

View file

@ -135,8 +135,8 @@ impl<'a> HashStable<StableHashingContext<'a>> for ty::RegionKind {
ty::RePlaceholder(p) => {
p.hash_stable(hcx, hasher);
}
ty::ReVar(..) => {
bug!("StableHasher: unexpected region {:?}", *self)
ty::ReVar(reg) => {
reg.hash_stable(hcx, hasher);
}
}
}