mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
Use a label instead of a note for member constraint errors
This commit is contained in:
parent
15f93473f1
commit
d435101537
@ -116,7 +116,7 @@ pub(super) fn note_and_explain_region(
|
||||
emit_msg_span(err, prefix, description, span, suffix);
|
||||
}
|
||||
|
||||
pub(super) fn note_and_explain_free_region(
|
||||
fn explain_free_region(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
prefix: &str,
|
||||
@ -125,7 +125,7 @@ pub(super) fn note_and_explain_free_region(
|
||||
) {
|
||||
let (description, span) = msg_span_from_free_region(tcx, region, None);
|
||||
|
||||
emit_msg_span(err, prefix, description, span, suffix);
|
||||
label_msg_span(err, prefix, description, span, suffix);
|
||||
}
|
||||
|
||||
fn msg_span_from_free_region(
|
||||
@ -210,6 +210,22 @@ fn emit_msg_span(
|
||||
}
|
||||
}
|
||||
|
||||
fn label_msg_span(
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
prefix: &str,
|
||||
description: String,
|
||||
span: Option<Span>,
|
||||
suffix: &str,
|
||||
) {
|
||||
let message = format!("{}{}{}", prefix, description, suffix);
|
||||
|
||||
if let Some(span) = span {
|
||||
err.span_label(span, &message);
|
||||
} else {
|
||||
err.note(&message);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unexpected_hidden_region_diagnostic(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
span: Span,
|
||||
@ -244,7 +260,7 @@ pub fn unexpected_hidden_region_diagnostic(
|
||||
//
|
||||
// (*) if not, the `tainted_by_errors` field would be set to
|
||||
// `Some(ErrorReported)` in any case, so we wouldn't be here at all.
|
||||
note_and_explain_free_region(
|
||||
explain_free_region(
|
||||
tcx,
|
||||
&mut err,
|
||||
&format!("hidden type `{}` captures ", hidden_ty),
|
||||
|
@ -2,25 +2,17 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea
|
||||
--> $DIR/hidden-lifetimes.rs:28:54
|
||||
|
|
||||
LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
note: hidden type `&'a mut &'b T` captures the lifetime `'b` as defined here
|
||||
--> $DIR/hidden-lifetimes.rs:28:17
|
||||
|
|
||||
LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a {
|
||||
| ^^
|
||||
| -- ^^^^^^^^^^^^^^
|
||||
| |
|
||||
| hidden type `&'a mut &'b T` captures the lifetime `'b` as defined here
|
||||
|
||||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
--> $DIR/hidden-lifetimes.rs:45:70
|
||||
|
|
||||
LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
note: hidden type `Rc<RefCell<&'b T>>` captures the lifetime `'b` as defined here
|
||||
--> $DIR/hidden-lifetimes.rs:45:24
|
||||
|
|
||||
LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a {
|
||||
| ^^
|
||||
| -- ^^^^^^^^^^^^^^
|
||||
| |
|
||||
| hidden type `Rc<RefCell<&'b T>>` captures the lifetime `'b` as defined here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -2,13 +2,9 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea
|
||||
--> $DIR/error-handling-2.rs:13:60
|
||||
|
|
||||
LL | fn foo<'a: 'b, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> {
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: hidden type `*mut &'a i32` captures the lifetime `'a` as defined here
|
||||
--> $DIR/error-handling-2.rs:13:8
|
||||
|
|
||||
LL | fn foo<'a: 'b, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> {
|
||||
| ^^
|
||||
| -- ^^^^^^^^^
|
||||
| |
|
||||
| hidden type `*mut &'a i32` captures the lifetime `'a` as defined here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -3,12 +3,9 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea
|
||||
|
|
||||
LL | fn foo(x: Cell<&'x u32>) -> impl Trait<'y>
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
note: hidden type `Cell<&'x u32>` captures the lifetime `'x` as defined here
|
||||
--> $DIR/region-escape-via-bound.rs:17:7
|
||||
|
|
||||
LL |
|
||||
LL | where 'x: 'y
|
||||
| ^^
|
||||
| -- hidden type `Cell<&'x u32>` captures the lifetime `'x` as defined here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user