infer: use derive more
Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
//! to hold.
|
||||
|
||||
use crate::errors::{note_and_explain, IntroducesStaticBecauseUnmetLifetimeReq};
|
||||
use crate::errors::{ImplNote, MismatchedStaticLifetime, TraitSubdiag};
|
||||
use crate::errors::{
|
||||
DoesNotOutliveStaticFromImpl, ImplicitStaticLifetimeSubdiag, MismatchedStaticLifetime,
|
||||
};
|
||||
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||
use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
use crate::infer::{SubregionOrigin, TypeTrace};
|
||||
@@ -56,7 +58,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
note_and_explain::SuffixKind::Continues,
|
||||
);
|
||||
let mut impl_span = None;
|
||||
let mut trait_subdiags = Vec::new();
|
||||
let mut implicit_static_lifetimes = Vec::new();
|
||||
if let Some(impl_node) = self.tcx().hir().get_if_local(*impl_def_id) {
|
||||
// If an impl is local, then maybe this isn't what they want. Try to
|
||||
// be as helpful as possible with implicit lifetimes.
|
||||
@@ -90,10 +92,12 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
// Otherwise, point at all implicit static lifetimes
|
||||
|
||||
for span in &traits {
|
||||
trait_subdiags.push(TraitSubdiag::Note { span: *span });
|
||||
implicit_static_lifetimes
|
||||
.push(ImplicitStaticLifetimeSubdiag::Note { span: *span });
|
||||
// It would be nice to put this immediately under the above note, but they get
|
||||
// pushed to the end.
|
||||
trait_subdiags.push(TraitSubdiag::Sugg { span: span.shrink_to_hi() });
|
||||
implicit_static_lifetimes
|
||||
.push(ImplicitStaticLifetimeSubdiag::Sugg { span: span.shrink_to_hi() });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -105,8 +109,10 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
cause_span: cause.span,
|
||||
unmet_lifetime_reqs: multispan_subdiag,
|
||||
expl,
|
||||
impl_note: ImplNote { impl_span },
|
||||
trait_subdiags,
|
||||
does_not_outlive_static_from_impl: impl_span
|
||||
.map(|span| DoesNotOutliveStaticFromImpl::Spanned { span })
|
||||
.unwrap_or(DoesNotOutliveStaticFromImpl::Unspanned),
|
||||
implicit_static_lifetimes,
|
||||
};
|
||||
let reported = self.tcx().sess.emit_err(err);
|
||||
Some(reported)
|
||||
|
||||
Reference in New Issue
Block a user