mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Port another diagnostic
This commit is contained in:
parent
cb8ea01096
commit
35dbec338a
@ -146,8 +146,10 @@ infer_region_explanation = {$pref_kind ->
|
||||
[source_pointer_valid_for] source pointer is only valid for
|
||||
[type_satisfy] type must satisfy
|
||||
[type_outlive] type must outlive
|
||||
[lf_instantiated_with] lifetime parameter instantiated with
|
||||
[lf_must_outlive] but lifetime parameter must outlive
|
||||
[lf_param_instantiated_with] lifetime parameter instantiated with
|
||||
[lf_param_must_outlive] but lifetime parameter must outlive
|
||||
[lf_instantiated_with] lifetime instantiated with
|
||||
[lf_must_outlive] but lifetime must outlive
|
||||
[type_valid_for] the type is valid for
|
||||
[borrow_lasts_for] but the borrow lasts for
|
||||
[pointer_valid_for] the pointer is valid for
|
||||
|
@ -127,6 +127,8 @@ pub enum PrefixKind {
|
||||
SourcePointerValidFor,
|
||||
TypeSatisfy,
|
||||
TypeOutlive,
|
||||
LfParamInstantiatedWith,
|
||||
LfParamMustOutlive,
|
||||
LfInstantiatedWith,
|
||||
LfMustOutlive,
|
||||
TypeValidFor,
|
||||
@ -151,6 +153,8 @@ impl IntoDiagnosticArg for PrefixKind {
|
||||
Self::SourcePointerValidFor => "source_pointer_valid_for",
|
||||
Self::TypeSatisfy => "type_satisfy",
|
||||
Self::TypeOutlive => "type_outlive",
|
||||
Self::LfParamInstantiatedWith => "lf_param_instantiated_with",
|
||||
Self::LfParamMustOutlive => "lf_param_must_outlive",
|
||||
Self::LfInstantiatedWith => "lf_instantiated_with",
|
||||
Self::LfMustOutlive => "lf_must_outlive",
|
||||
Self::TypeValidFor => "type_valid_for",
|
||||
|
@ -5,8 +5,8 @@ use crate::errors::{
|
||||
use crate::infer::error_reporting::{note_and_explain_region, TypeErrCtxt};
|
||||
use crate::infer::{self, SubregionOrigin};
|
||||
use rustc_errors::{
|
||||
fluent, struct_span_err, AddToDiagnostic, Applicability, Diagnostic, DiagnosticBuilder,
|
||||
ErrorGuaranteed, IntoDiagnostic,
|
||||
fluent, AddToDiagnostic, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
|
||||
IntoDiagnostic,
|
||||
};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_middle::traits::ObligationCauseCode;
|
||||
@ -184,14 +184,14 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
self.tcx,
|
||||
sup,
|
||||
None,
|
||||
note_and_explain::PrefixKind::LfInstantiatedWith,
|
||||
note_and_explain::PrefixKind::LfParamInstantiatedWith,
|
||||
note_and_explain::SuffixKind::Empty,
|
||||
);
|
||||
let param_must_outlive = note_and_explain::RegionExplanation::new(
|
||||
self.tcx,
|
||||
sub,
|
||||
None,
|
||||
note_and_explain::PrefixKind::LfMustOutlive,
|
||||
note_and_explain::PrefixKind::LfParamMustOutlive,
|
||||
note_and_explain::SuffixKind::Empty,
|
||||
);
|
||||
LfBoundNotSatisfied {
|
||||
@ -279,25 +279,25 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
err
|
||||
}
|
||||
infer::AscribeUserTypeProvePredicate(span) => {
|
||||
let mut err =
|
||||
struct_span_err!(self.tcx.sess, span, E0478, "lifetime bound not satisfied");
|
||||
note_and_explain_region(
|
||||
let instantiated = note_and_explain::RegionExplanation::new(
|
||||
self.tcx,
|
||||
&mut err,
|
||||
"lifetime instantiated with ",
|
||||
sup,
|
||||
"",
|
||||
None,
|
||||
note_and_explain::PrefixKind::LfInstantiatedWith,
|
||||
note_and_explain::SuffixKind::Empty,
|
||||
);
|
||||
note_and_explain_region(
|
||||
let must_outlive = note_and_explain::RegionExplanation::new(
|
||||
self.tcx,
|
||||
&mut err,
|
||||
"but lifetime must outlive ",
|
||||
sub,
|
||||
"",
|
||||
None,
|
||||
note_and_explain::PrefixKind::LfMustOutlive,
|
||||
note_and_explain::SuffixKind::Empty,
|
||||
);
|
||||
err
|
||||
LfBoundNotSatisfied {
|
||||
span,
|
||||
notes: instantiated.into_iter().chain(must_outlive).collect(),
|
||||
}
|
||||
.into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic)
|
||||
}
|
||||
};
|
||||
if sub.is_error() || sup.is_error() {
|
||||
|
Loading…
Reference in New Issue
Block a user