Format note.rs with rustfmt
This commit is contained in:
parent
2f8ef50f7d
commit
e136bf6a4c
1 changed files with 220 additions and 253 deletions
|
@ -14,184 +14,150 @@ use ty::error::TypeError;
|
||||||
use errors::DiagnosticBuilder;
|
use errors::DiagnosticBuilder;
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
pub(super) fn note_region_origin(&self, err: &mut DiagnosticBuilder, origin: &SubregionOrigin<'tcx>) {
|
pub(super) fn note_region_origin(&self,
|
||||||
|
err: &mut DiagnosticBuilder,
|
||||||
|
origin: &SubregionOrigin<'tcx>) {
|
||||||
match *origin {
|
match *origin {
|
||||||
infer::Subtype(ref trace) => {
|
infer::Subtype(ref trace) => {
|
||||||
if let Some((expected, found)) = self.values_str(&trace.values) {
|
if let Some((expected, found)) = self.values_str(&trace.values) {
|
||||||
// FIXME: do we want a "the" here?
|
// FIXME: do we want a "the" here?
|
||||||
err.span_note(
|
err.span_note(trace.cause.span,
|
||||||
trace.cause.span,
|
&format!("...so that {} (expected {}, found {})",
|
||||||
&format!("...so that {} (expected {}, found {})",
|
trace.cause.as_requirement_str(),
|
||||||
trace.cause.as_requirement_str(), expected, found));
|
expected,
|
||||||
|
found));
|
||||||
} else {
|
} else {
|
||||||
// FIXME: this really should be handled at some earlier stage. Our
|
// FIXME: this really should be handled at some earlier stage. Our
|
||||||
// handling of region checking when type errors are present is
|
// handling of region checking when type errors are present is
|
||||||
// *terrible*.
|
// *terrible*.
|
||||||
|
|
||||||
err.span_note(
|
err.span_note(trace.cause.span,
|
||||||
trace.cause.span,
|
&format!("...so that {}", trace.cause.as_requirement_str()));
|
||||||
&format!("...so that {}",
|
|
||||||
trace.cause.as_requirement_str()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
infer::Reborrow(span) => {
|
infer::Reborrow(span) => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
"...so that reference does not outlive borrowed content");
|
||||||
"...so that reference does not outlive \
|
|
||||||
borrowed content");
|
|
||||||
}
|
}
|
||||||
infer::ReborrowUpvar(span, ref upvar_id) => {
|
infer::ReborrowUpvar(span, ref upvar_id) => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
&format!("...so that closure can access `{}`",
|
||||||
&format!(
|
self.tcx
|
||||||
"...so that closure can access `{}`",
|
.local_var_name_str(upvar_id.var_id)
|
||||||
self.tcx.local_var_name_str(upvar_id.var_id)
|
.to_string()));
|
||||||
.to_string()));
|
|
||||||
}
|
}
|
||||||
infer::InfStackClosure(span) => {
|
infer::InfStackClosure(span) => {
|
||||||
err.span_note(
|
err.span_note(span, "...so that closure does not outlive its stack frame");
|
||||||
span,
|
|
||||||
"...so that closure does not outlive its stack frame");
|
|
||||||
}
|
}
|
||||||
infer::InvokeClosure(span) => {
|
infer::InvokeClosure(span) => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
"...so that closure is not invoked outside its lifetime");
|
||||||
"...so that closure is not invoked outside its lifetime");
|
|
||||||
}
|
}
|
||||||
infer::DerefPointer(span) => {
|
infer::DerefPointer(span) => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
"...so that pointer is not dereferenced outside its lifetime");
|
||||||
"...so that pointer is not dereferenced \
|
|
||||||
outside its lifetime");
|
|
||||||
}
|
}
|
||||||
infer::FreeVariable(span, id) => {
|
infer::FreeVariable(span, id) => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
&format!("...so that captured variable `{}` does not outlive the \
|
||||||
&format!("...so that captured variable `{}` \
|
enclosing closure",
|
||||||
does not outlive the enclosing closure",
|
self.tcx.local_var_name_str(id)));
|
||||||
self.tcx.local_var_name_str(id)));
|
|
||||||
}
|
}
|
||||||
infer::IndexSlice(span) => {
|
infer::IndexSlice(span) => {
|
||||||
err.span_note(
|
err.span_note(span, "...so that slice is not indexed outside the lifetime");
|
||||||
span,
|
|
||||||
"...so that slice is not indexed outside the lifetime");
|
|
||||||
}
|
}
|
||||||
infer::RelateObjectBound(span) => {
|
infer::RelateObjectBound(span) => {
|
||||||
err.span_note(
|
err.span_note(span, "...so that it can be closed over into an object");
|
||||||
span,
|
|
||||||
"...so that it can be closed over into an object");
|
|
||||||
}
|
}
|
||||||
infer::CallRcvr(span) => {
|
infer::CallRcvr(span) => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
"...so that method receiver is valid for the method call");
|
||||||
"...so that method receiver is valid for the method call");
|
|
||||||
}
|
}
|
||||||
infer::CallArg(span) => {
|
infer::CallArg(span) => {
|
||||||
err.span_note(
|
err.span_note(span, "...so that argument is valid for the call");
|
||||||
span,
|
|
||||||
"...so that argument is valid for the call");
|
|
||||||
}
|
}
|
||||||
infer::CallReturn(span) => {
|
infer::CallReturn(span) => {
|
||||||
err.span_note(
|
err.span_note(span, "...so that return value is valid for the call");
|
||||||
span,
|
|
||||||
"...so that return value is valid for the call");
|
|
||||||
}
|
}
|
||||||
infer::Operand(span) => {
|
infer::Operand(span) => {
|
||||||
err.span_note(
|
err.span_note(span, "...so that operand is valid for operation");
|
||||||
span,
|
|
||||||
"...so that operand is valid for operation");
|
|
||||||
}
|
}
|
||||||
infer::AddrOf(span) => {
|
infer::AddrOf(span) => {
|
||||||
err.span_note(
|
err.span_note(span, "...so that reference is valid at the time of borrow");
|
||||||
span,
|
|
||||||
"...so that reference is valid \
|
|
||||||
at the time of borrow");
|
|
||||||
}
|
}
|
||||||
infer::AutoBorrow(span) => {
|
infer::AutoBorrow(span) => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
"...so that auto-reference is valid at the time of borrow");
|
||||||
"...so that auto-reference is valid \
|
|
||||||
at the time of borrow");
|
|
||||||
}
|
}
|
||||||
infer::ExprTypeIsNotInScope(t, span) => {
|
infer::ExprTypeIsNotInScope(t, span) => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
&format!("...so type `{}` of expression is valid during the \
|
||||||
&format!("...so type `{}` of expression is valid during the \
|
expression",
|
||||||
expression",
|
self.ty_to_string(t)));
|
||||||
self.ty_to_string(t)));
|
|
||||||
}
|
}
|
||||||
infer::BindingTypeIsNotValidAtDecl(span) => {
|
infer::BindingTypeIsNotValidAtDecl(span) => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
"...so that variable is valid at time of its declaration");
|
||||||
"...so that variable is valid at time of its declaration");
|
|
||||||
}
|
}
|
||||||
infer::ParameterInScope(_, span) => {
|
infer::ParameterInScope(_, span) => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
"...so that a type/lifetime parameter is in scope here");
|
||||||
"...so that a type/lifetime parameter is in scope here");
|
|
||||||
}
|
}
|
||||||
infer::DataBorrowed(ty, span) => {
|
infer::DataBorrowed(ty, span) => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
&format!("...so that the type `{}` is not borrowed for too long",
|
||||||
&format!("...so that the type `{}` is not borrowed for too long",
|
self.ty_to_string(ty)));
|
||||||
self.ty_to_string(ty)));
|
|
||||||
}
|
}
|
||||||
infer::ReferenceOutlivesReferent(ty, span) => {
|
infer::ReferenceOutlivesReferent(ty, span) => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
&format!("...so that the reference type `{}` does not outlive the \
|
||||||
&format!("...so that the reference type `{}` \
|
data it points at",
|
||||||
does not outlive the data it points at",
|
self.ty_to_string(ty)));
|
||||||
self.ty_to_string(ty)));
|
|
||||||
}
|
}
|
||||||
infer::RelateParamBound(span, t) => {
|
infer::RelateParamBound(span, t) => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
&format!("...so that the type `{}` will meet its required \
|
||||||
&format!("...so that the type `{}` \
|
lifetime bounds",
|
||||||
will meet its required lifetime bounds",
|
self.ty_to_string(t)));
|
||||||
self.ty_to_string(t)));
|
|
||||||
}
|
}
|
||||||
infer::RelateDefaultParamBound(span, t) => {
|
infer::RelateDefaultParamBound(span, t) => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
&format!("...so that type parameter instantiated with `{}`, will \
|
||||||
&format!("...so that type parameter \
|
meet its declared lifetime bounds",
|
||||||
instantiated with `{}`, \
|
self.ty_to_string(t)));
|
||||||
will meet its declared lifetime bounds",
|
|
||||||
self.ty_to_string(t)));
|
|
||||||
}
|
}
|
||||||
infer::RelateRegionParamBound(span) => {
|
infer::RelateRegionParamBound(span) => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
"...so that the declared lifetime parameter bounds are satisfied");
|
||||||
"...so that the declared lifetime parameter bounds \
|
|
||||||
are satisfied");
|
|
||||||
}
|
}
|
||||||
infer::SafeDestructor(span) => {
|
infer::SafeDestructor(span) => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
"...so that references are valid when the destructor runs");
|
||||||
"...so that references are valid when the destructor \
|
|
||||||
runs");
|
|
||||||
}
|
}
|
||||||
infer::CompareImplMethodObligation { span, .. } => {
|
infer::CompareImplMethodObligation { span, .. } => {
|
||||||
err.span_note(
|
err.span_note(span,
|
||||||
span,
|
"...so that the definition in impl matches the definition from the \
|
||||||
"...so that the definition in impl matches the definition from the trait");
|
trait");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn report_concrete_failure(&self,
|
pub(super) fn report_concrete_failure(&self,
|
||||||
origin: SubregionOrigin<'tcx>,
|
origin: SubregionOrigin<'tcx>,
|
||||||
sub: &'tcx Region,
|
sub: &'tcx Region,
|
||||||
sup: &'tcx Region)
|
sup: &'tcx Region)
|
||||||
-> DiagnosticBuilder<'tcx> {
|
-> DiagnosticBuilder<'tcx> {
|
||||||
match origin {
|
match origin {
|
||||||
infer::Subtype(trace) => {
|
infer::Subtype(trace) => {
|
||||||
let terr = TypeError::RegionsDoesNotOutlive(sup, sub);
|
let terr = TypeError::RegionsDoesNotOutlive(sup, sub);
|
||||||
self.report_and_explain_type_error(trace, &terr)
|
self.report_and_explain_type_error(trace, &terr)
|
||||||
}
|
}
|
||||||
infer::Reborrow(span) => {
|
infer::Reborrow(span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0312,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"lifetime of reference outlives \
|
span,
|
||||||
lifetime of borrowed content...");
|
E0312,
|
||||||
|
"lifetime of reference outlives lifetime of \
|
||||||
|
borrowed content...");
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
self.tcx.note_and_explain_region(&mut err,
|
||||||
"...the reference is valid for ",
|
"...the reference is valid for ",
|
||||||
sub,
|
sub,
|
||||||
|
@ -203,83 +169,84 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::ReborrowUpvar(span, ref upvar_id) => {
|
infer::ReborrowUpvar(span, ref upvar_id) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0313,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"lifetime of borrowed pointer outlives \
|
span,
|
||||||
lifetime of captured variable `{}`...",
|
E0313,
|
||||||
self.tcx.local_var_name_str(upvar_id.var_id));
|
"lifetime of borrowed pointer outlives lifetime \
|
||||||
|
of captured variable `{}`...",
|
||||||
|
self.tcx.local_var_name_str(upvar_id.var_id));
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
self.tcx.note_and_explain_region(&mut err,
|
||||||
"...the borrowed pointer is valid for ",
|
"...the borrowed pointer is valid for ",
|
||||||
sub,
|
sub,
|
||||||
"...");
|
"...");
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
self.tcx
|
||||||
&format!("...but `{}` is only valid for ",
|
.note_and_explain_region(&mut err,
|
||||||
self.tcx.local_var_name_str(upvar_id.var_id)),
|
&format!("...but `{}` is only valid for ",
|
||||||
sup,
|
self.tcx
|
||||||
"");
|
.local_var_name_str(upvar_id.var_id)),
|
||||||
|
sup,
|
||||||
|
"");
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::InfStackClosure(span) => {
|
infer::InfStackClosure(span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0314,
|
let mut err =
|
||||||
"closure outlives stack frame");
|
struct_span_err!(self.tcx.sess, span, E0314, "closure outlives stack frame");
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
self.tcx.note_and_explain_region(&mut err,
|
||||||
"...the closure must be valid for ",
|
"...the closure must be valid for ",
|
||||||
sub,
|
sub,
|
||||||
"...");
|
"...");
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
self.tcx.note_and_explain_region(&mut err,
|
||||||
"...but the closure's stack frame is only valid for ",
|
"...but the closure's stack frame is only valid \
|
||||||
|
for ",
|
||||||
sup,
|
sup,
|
||||||
"");
|
"");
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::InvokeClosure(span) => {
|
infer::InvokeClosure(span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0315,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"cannot invoke closure outside of its lifetime");
|
span,
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
E0315,
|
||||||
"the closure is only valid for ",
|
"cannot invoke closure outside of its lifetime");
|
||||||
sup,
|
self.tcx
|
||||||
"");
|
.note_and_explain_region(&mut err, "the closure is only valid for ", sup, "");
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::DerefPointer(span) => {
|
infer::DerefPointer(span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0473,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"dereference of reference outside its lifetime");
|
span,
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
E0473,
|
||||||
"the reference is only valid for ",
|
"dereference of reference outside its lifetime");
|
||||||
sup,
|
self.tcx
|
||||||
"");
|
.note_and_explain_region(&mut err, "the reference is only valid for ", sup, "");
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::FreeVariable(span, id) => {
|
infer::FreeVariable(span, id) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0474,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"captured variable `{}` does not outlive the enclosing closure",
|
span,
|
||||||
self.tcx.local_var_name_str(id));
|
E0474,
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
"captured variable `{}` does not outlive the \
|
||||||
"captured variable is valid for ",
|
enclosing closure",
|
||||||
sup,
|
self.tcx.local_var_name_str(id));
|
||||||
"");
|
self.tcx
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
.note_and_explain_region(&mut err, "captured variable is valid for ", sup, "");
|
||||||
"closure is valid for ",
|
self.tcx.note_and_explain_region(&mut err, "closure is valid for ", sub, "");
|
||||||
sub,
|
|
||||||
"");
|
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::IndexSlice(span) => {
|
infer::IndexSlice(span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0475,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"index of slice outside its lifetime");
|
span,
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
E0475,
|
||||||
"the slice is only valid for ",
|
"index of slice outside its lifetime");
|
||||||
sup,
|
self.tcx.note_and_explain_region(&mut err, "the slice is only valid for ", sup, "");
|
||||||
"");
|
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::RelateObjectBound(span) => {
|
infer::RelateObjectBound(span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0476,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"lifetime of the source pointer does not outlive \
|
span,
|
||||||
lifetime bound of the object type");
|
E0476,
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
"lifetime of the source pointer does not outlive \
|
||||||
"object type is valid for ",
|
lifetime bound of the object type");
|
||||||
sub,
|
self.tcx.note_and_explain_region(&mut err, "object type is valid for ", sub, "");
|
||||||
"");
|
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
self.tcx.note_and_explain_region(&mut err,
|
||||||
"source pointer is only valid for ",
|
"source pointer is only valid for ",
|
||||||
sup,
|
sup,
|
||||||
|
@ -287,18 +254,18 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::RelateParamBound(span, ty) => {
|
infer::RelateParamBound(span, ty) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0477,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"the type `{}` does not fulfill the required lifetime",
|
span,
|
||||||
self.ty_to_string(ty));
|
E0477,
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
"the type `{}` does not fulfill the required \
|
||||||
"type must outlive ",
|
lifetime",
|
||||||
sub,
|
self.ty_to_string(ty));
|
||||||
"");
|
self.tcx.note_and_explain_region(&mut err, "type must outlive ", sub, "");
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::RelateRegionParamBound(span) => {
|
infer::RelateRegionParamBound(span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0478,
|
let mut err =
|
||||||
"lifetime bound not satisfied");
|
struct_span_err!(self.tcx.sess, span, E0478, "lifetime bound not satisfied");
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
self.tcx.note_and_explain_region(&mut err,
|
||||||
"lifetime parameter instantiated with ",
|
"lifetime parameter instantiated with ",
|
||||||
sup,
|
sup,
|
||||||
|
@ -310,30 +277,31 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::RelateDefaultParamBound(span, ty) => {
|
infer::RelateDefaultParamBound(span, ty) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0479,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"the type `{}` (provided as the value of \
|
span,
|
||||||
a type parameter) is not valid at this point",
|
E0479,
|
||||||
self.ty_to_string(ty));
|
"the type `{}` (provided as the value of a type \
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
parameter) is not valid at this point",
|
||||||
"type must outlive ",
|
self.ty_to_string(ty));
|
||||||
sub,
|
self.tcx.note_and_explain_region(&mut err, "type must outlive ", sub, "");
|
||||||
"");
|
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::CallRcvr(span) => {
|
infer::CallRcvr(span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0480,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"lifetime of method receiver does not outlive \
|
span,
|
||||||
the method call");
|
E0480,
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
"lifetime of method receiver does not outlive the \
|
||||||
"the receiver is only valid for ",
|
method call");
|
||||||
sup,
|
self.tcx
|
||||||
"");
|
.note_and_explain_region(&mut err, "the receiver is only valid for ", sup, "");
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::CallArg(span) => {
|
infer::CallArg(span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0481,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"lifetime of function argument does not outlive \
|
span,
|
||||||
the function call");
|
E0481,
|
||||||
|
"lifetime of function argument does not outlive \
|
||||||
|
the function call");
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
self.tcx.note_and_explain_region(&mut err,
|
||||||
"the function argument is only valid for ",
|
"the function argument is only valid for ",
|
||||||
sup,
|
sup,
|
||||||
|
@ -341,9 +309,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::CallReturn(span) => {
|
infer::CallReturn(span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0482,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"lifetime of return value does not outlive \
|
span,
|
||||||
the function call");
|
E0482,
|
||||||
|
"lifetime of return value does not outlive the \
|
||||||
|
function call");
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
self.tcx.note_and_explain_region(&mut err,
|
||||||
"the return value is only valid for ",
|
"the return value is only valid for ",
|
||||||
sup,
|
sup,
|
||||||
|
@ -351,28 +321,30 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::Operand(span) => {
|
infer::Operand(span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0483,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"lifetime of operand does not outlive \
|
span,
|
||||||
the operation");
|
E0483,
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
"lifetime of operand does not outlive the \
|
||||||
"the operand is only valid for ",
|
operation");
|
||||||
sup,
|
self.tcx
|
||||||
"");
|
.note_and_explain_region(&mut err, "the operand is only valid for ", sup, "");
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::AddrOf(span) => {
|
infer::AddrOf(span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0484,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"reference is not valid at the time of borrow");
|
span,
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
E0484,
|
||||||
"the borrow is only valid for ",
|
"reference is not valid at the time of borrow");
|
||||||
sup,
|
self.tcx
|
||||||
"");
|
.note_and_explain_region(&mut err, "the borrow is only valid for ", sup, "");
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::AutoBorrow(span) => {
|
infer::AutoBorrow(span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0485,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"automatically reference is not valid \
|
span,
|
||||||
at the time of borrow");
|
E0485,
|
||||||
|
"automatically reference is not valid at the time \
|
||||||
|
of borrow");
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
self.tcx.note_and_explain_region(&mut err,
|
||||||
"the automatic borrow is only valid for ",
|
"the automatic borrow is only valid for ",
|
||||||
sup,
|
sup,
|
||||||
|
@ -380,79 +352,74 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::ExprTypeIsNotInScope(t, span) => {
|
infer::ExprTypeIsNotInScope(t, span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0486,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"type of expression contains references \
|
span,
|
||||||
that are not valid during the expression: `{}`",
|
E0486,
|
||||||
self.ty_to_string(t));
|
"type of expression contains references that are \
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
not valid during the expression: `{}`",
|
||||||
"type is only valid for ",
|
self.ty_to_string(t));
|
||||||
sup,
|
self.tcx.note_and_explain_region(&mut err, "type is only valid for ", sup, "");
|
||||||
"");
|
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::SafeDestructor(span) => {
|
infer::SafeDestructor(span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0487,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"unsafe use of destructor: destructor might be called \
|
span,
|
||||||
while references are dead");
|
E0487,
|
||||||
|
"unsafe use of destructor: destructor might be \
|
||||||
|
called while references are dead");
|
||||||
// FIXME (22171): terms "super/subregion" are suboptimal
|
// FIXME (22171): terms "super/subregion" are suboptimal
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
self.tcx.note_and_explain_region(&mut err, "superregion: ", sup, "");
|
||||||
"superregion: ",
|
self.tcx.note_and_explain_region(&mut err, "subregion: ", sub, "");
|
||||||
sup,
|
|
||||||
"");
|
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
|
||||||
"subregion: ",
|
|
||||||
sub,
|
|
||||||
"");
|
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::BindingTypeIsNotValidAtDecl(span) => {
|
infer::BindingTypeIsNotValidAtDecl(span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0488,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"lifetime of variable does not enclose its declaration");
|
span,
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
E0488,
|
||||||
"the variable is only valid for ",
|
"lifetime of variable does not enclose its \
|
||||||
sup,
|
declaration");
|
||||||
"");
|
self.tcx
|
||||||
|
.note_and_explain_region(&mut err, "the variable is only valid for ", sup, "");
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::ParameterInScope(_, span) => {
|
infer::ParameterInScope(_, span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0489,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"type/lifetime parameter not in scope here");
|
span,
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
E0489,
|
||||||
"the parameter is only valid for ",
|
"type/lifetime parameter not in scope here");
|
||||||
sub,
|
self.tcx
|
||||||
"");
|
.note_and_explain_region(&mut err, "the parameter is only valid for ", sub, "");
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::DataBorrowed(ty, span) => {
|
infer::DataBorrowed(ty, span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0490,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"a value of type `{}` is borrowed for too long",
|
span,
|
||||||
self.ty_to_string(ty));
|
E0490,
|
||||||
|
"a value of type `{}` is borrowed for too long",
|
||||||
|
self.ty_to_string(ty));
|
||||||
self.tcx.note_and_explain_region(&mut err, "the type is valid for ", sub, "");
|
self.tcx.note_and_explain_region(&mut err, "the type is valid for ", sub, "");
|
||||||
self.tcx.note_and_explain_region(&mut err, "but the borrow lasts for ", sup, "");
|
self.tcx.note_and_explain_region(&mut err, "but the borrow lasts for ", sup, "");
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::ReferenceOutlivesReferent(ty, span) => {
|
infer::ReferenceOutlivesReferent(ty, span) => {
|
||||||
let mut err = struct_span_err!(self.tcx.sess, span, E0491,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
"in type `{}`, reference has a longer lifetime \
|
span,
|
||||||
than the data it references",
|
E0491,
|
||||||
self.ty_to_string(ty));
|
"in type `{}`, reference has a longer lifetime \
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
than the data it references",
|
||||||
"the pointer is valid for ",
|
self.ty_to_string(ty));
|
||||||
sub,
|
self.tcx.note_and_explain_region(&mut err, "the pointer is valid for ", sub, "");
|
||||||
"");
|
|
||||||
self.tcx.note_and_explain_region(&mut err,
|
self.tcx.note_and_explain_region(&mut err,
|
||||||
"but the referenced data is only valid for ",
|
"but the referenced data is only valid for ",
|
||||||
sup,
|
sup,
|
||||||
"");
|
"");
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
infer::CompareImplMethodObligation {
|
infer::CompareImplMethodObligation { span,
|
||||||
span,
|
item_name,
|
||||||
item_name,
|
impl_item_def_id,
|
||||||
impl_item_def_id,
|
trait_item_def_id,
|
||||||
trait_item_def_id,
|
lint_id } => {
|
||||||
lint_id
|
|
||||||
} => {
|
|
||||||
self.report_extra_impl_obligation(span,
|
self.report_extra_impl_obligation(span,
|
||||||
item_name,
|
item_name,
|
||||||
impl_item_def_id,
|
impl_item_def_id,
|
||||||
|
@ -462,4 +429,4 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue