Skip to content

Commit 444bc3c

Browse files
committed
Use span label instead of note for cause in E0631
1 parent 2d851b3 commit 444bc3c

File tree

187 files changed

+1177
-2058
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+1177
-2058
lines changed

src/librustc/traits/error_reporting.rs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -657,19 +657,22 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
657657
span,
658658
E0277,
659659
"{}",
660-
message.unwrap_or_else(||
661-
format!("the trait bound `{}` is not satisfied{}",
662-
trait_ref.to_predicate(), post_message)
663-
));
660+
message.unwrap_or_else(|| format!(
661+
"the trait bound `{}` is not satisfied{}",
662+
trait_ref.to_predicate(),
663+
post_message,
664+
)));
664665

665666
let explanation =
666667
if obligation.cause.code == ObligationCauseCode::MainFunctionType {
667668
"consider using `()`, or a `Result`".to_owned()
668669
} else {
669-
format!("{}the trait `{}` is not implemented for `{}`",
670+
format!(
671+
"{}the trait `{}` is not implemented for `{}`",
670672
pre_message,
671673
trait_ref,
672-
trait_ref.self_ty())
674+
trait_ref.self_ty(),
675+
)
673676
};
674677

675678
if let Some(ref s) = label {
@@ -1535,25 +1538,31 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15351538
err.note("only the last element of a tuple may have a dynamically sized type");
15361539
}
15371540
ObligationCauseCode::ProjectionWf(data) => {
1538-
err.note(&format!("required so that the projection `{}` is well-formed",
1539-
data));
1541+
err.note(&format!(
1542+
"required so that the projection `{}` is well-formed",
1543+
data,
1544+
));
15401545
}
15411546
ObligationCauseCode::ReferenceOutlivesReferent(ref_ty) => {
1542-
err.note(&format!("required so that reference `{}` does not outlive its referent",
1543-
ref_ty));
1547+
err.note(&format!(
1548+
"required so that reference `{}` does not outlive its referent",
1549+
ref_ty,
1550+
));
15441551
}
15451552
ObligationCauseCode::ObjectTypeBound(object_ty, region) => {
1546-
err.note(&format!("required so that the lifetime bound of `{}` for `{}` \
1547-
is satisfied",
1548-
region, object_ty));
1553+
err.note(&format!(
1554+
"required so that the lifetime bound of `{}` for `{}` is satisfied",
1555+
region,
1556+
object_ty,
1557+
));
15491558
}
15501559
ObligationCauseCode::ItemObligation(item_def_id) => {
15511560
let item_name = tcx.def_path_str(item_def_id);
15521561
let msg = format!("required by `{}`", item_name);
15531562

15541563
if let Some(sp) = tcx.hir().span_if_local(item_def_id) {
15551564
let sp = tcx.sess.source_map().def_span(sp);
1556-
err.span_note(sp, &msg);
1565+
err.span_label(sp, &msg);
15571566
} else {
15581567
err.note(&msg);
15591568
}

src/test/ui/anonymous-higher-ranked-lifetime.stderr

Lines changed: 44 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ LL | f1(|_: (), _: ()| {});
55
| ^^ -------------- found signature of `fn((), ()) -> _`
66
| |
77
| expected signature of `for<'r, 's> fn(&'r (), &'s ()) -> _`
8-
|
9-
note: required by `f1`
10-
--> $DIR/anonymous-higher-ranked-lifetime.rs:27:1
11-
|
8+
...
129
LL | fn f1<F>(_: F) where F: Fn(&(), &()) {}
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
| ------------------------------------ required by `f1`
1411

1512
error[E0631]: type mismatch in closure arguments
1613
--> $DIR/anonymous-higher-ranked-lifetime.rs:2:5
@@ -19,12 +16,9 @@ LL | f1(|_: (), _: ()| {});
1916
| ^^ -------------- found signature of `fn((), ()) -> _`
2017
| |
2118
| expected signature of `fn(&(), &()) -> _`
22-
|
23-
note: required by `f1`
24-
--> $DIR/anonymous-higher-ranked-lifetime.rs:27:1
25-
|
19+
...
2620
LL | fn f1<F>(_: F) where F: Fn(&(), &()) {}
27-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21+
| ------------------------------------ required by `f1`
2822

2923
error[E0631]: type mismatch in closure arguments
3024
--> $DIR/anonymous-higher-ranked-lifetime.rs:4:5
@@ -33,12 +27,9 @@ LL | f2(|_: (), _: ()| {});
3327
| ^^ -------------- found signature of `fn((), ()) -> _`
3428
| |
3529
| expected signature of `for<'a, 'r> fn(&'a (), &'r ()) -> _`
36-
|
37-
note: required by `f2`
38-
--> $DIR/anonymous-higher-ranked-lifetime.rs:28:1
39-
|
30+
...
4031
LL | fn f2<F>(_: F) where F: for<'a> Fn(&'a (), &()) {}
41-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32+
| ----------------------------------------------- required by `f2`
4233

4334
error[E0631]: type mismatch in closure arguments
4435
--> $DIR/anonymous-higher-ranked-lifetime.rs:4:5
@@ -47,12 +38,9 @@ LL | f2(|_: (), _: ()| {});
4738
| ^^ -------------- found signature of `fn((), ()) -> _`
4839
| |
4940
| expected signature of `fn(&'a (), &()) -> _`
50-
|
51-
note: required by `f2`
52-
--> $DIR/anonymous-higher-ranked-lifetime.rs:28:1
53-
|
41+
...
5442
LL | fn f2<F>(_: F) where F: for<'a> Fn(&'a (), &()) {}
55-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43+
| ----------------------------------------------- required by `f2`
5644

5745
error[E0631]: type mismatch in closure arguments
5846
--> $DIR/anonymous-higher-ranked-lifetime.rs:6:5
@@ -61,12 +49,9 @@ LL | f3(|_: (), _: ()| {});
6149
| ^^ -------------- found signature of `fn((), ()) -> _`
6250
| |
6351
| expected signature of `for<'r> fn(&(), &'r ()) -> _`
64-
|
65-
note: required by `f3`
66-
--> $DIR/anonymous-higher-ranked-lifetime.rs:29:1
67-
|
52+
...
6853
LL | fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {}
69-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54+
| ------------------------------------------- required by `f3`
7055

7156
error[E0631]: type mismatch in closure arguments
7257
--> $DIR/anonymous-higher-ranked-lifetime.rs:6:5
@@ -75,12 +60,9 @@ LL | f3(|_: (), _: ()| {});
7560
| ^^ -------------- found signature of `fn((), ()) -> _`
7661
| |
7762
| expected signature of `fn(&(), &()) -> _`
78-
|
79-
note: required by `f3`
80-
--> $DIR/anonymous-higher-ranked-lifetime.rs:29:1
81-
|
63+
...
8264
LL | fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {}
83-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
65+
| ------------------------------------------- required by `f3`
8466

8567
error[E0631]: type mismatch in closure arguments
8668
--> $DIR/anonymous-higher-ranked-lifetime.rs:8:5
@@ -89,12 +71,9 @@ LL | f4(|_: (), _: ()| {});
8971
| ^^ -------------- found signature of `fn((), ()) -> _`
9072
| |
9173
| expected signature of `for<'s, 'r> fn(&'s (), &'r ()) -> _`
92-
|
93-
note: required by `f4`
94-
--> $DIR/anonymous-higher-ranked-lifetime.rs:30:1
95-
|
74+
...
9675
LL | fn f4<F>(_: F) where F: for<'r> Fn(&(), &'r ()) {}
97-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76+
| ----------------------------------------------- required by `f4`
9877

9978
error[E0631]: type mismatch in closure arguments
10079
--> $DIR/anonymous-higher-ranked-lifetime.rs:8:5
@@ -103,12 +82,9 @@ LL | f4(|_: (), _: ()| {});
10382
| ^^ -------------- found signature of `fn((), ()) -> _`
10483
| |
10584
| expected signature of `fn(&(), &'r ()) -> _`
106-
|
107-
note: required by `f4`
108-
--> $DIR/anonymous-higher-ranked-lifetime.rs:30:1
109-
|
85+
...
11086
LL | fn f4<F>(_: F) where F: for<'r> Fn(&(), &'r ()) {}
111-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87+
| ----------------------------------------------- required by `f4`
11288

11389
error[E0631]: type mismatch in closure arguments
11490
--> $DIR/anonymous-higher-ranked-lifetime.rs:10:5
@@ -117,12 +93,9 @@ LL | f5(|_: (), _: ()| {});
11793
| ^^ -------------- found signature of `fn((), ()) -> _`
11894
| |
11995
| expected signature of `for<'r> fn(&'r (), &'r ()) -> _`
120-
|
121-
note: required by `f5`
122-
--> $DIR/anonymous-higher-ranked-lifetime.rs:31:1
123-
|
96+
...
12497
LL | fn f5<F>(_: F) where F: for<'r> Fn(&'r (), &'r ()) {}
125-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
98+
| -------------------------------------------------- required by `f5`
12699

127100
error[E0631]: type mismatch in closure arguments
128101
--> $DIR/anonymous-higher-ranked-lifetime.rs:10:5
@@ -131,12 +104,9 @@ LL | f5(|_: (), _: ()| {});
131104
| ^^ -------------- found signature of `fn((), ()) -> _`
132105
| |
133106
| expected signature of `fn(&'r (), &'r ()) -> _`
134-
|
135-
note: required by `f5`
136-
--> $DIR/anonymous-higher-ranked-lifetime.rs:31:1
137-
|
107+
...
138108
LL | fn f5<F>(_: F) where F: for<'r> Fn(&'r (), &'r ()) {}
139-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
109+
| -------------------------------------------------- required by `f5`
140110

141111
error[E0631]: type mismatch in closure arguments
142112
--> $DIR/anonymous-higher-ranked-lifetime.rs:12:5
@@ -145,12 +115,9 @@ LL | g1(|_: (), _: ()| {});
145115
| ^^ -------------- found signature of `fn((), ()) -> _`
146116
| |
147117
| expected signature of `for<'r> fn(&'r (), std::boxed::Box<(dyn for<'s> std::ops::Fn(&'s ()) + 'static)>) -> _`
148-
|
149-
note: required by `g1`
150-
--> $DIR/anonymous-higher-ranked-lifetime.rs:34:1
151-
|
118+
...
152119
LL | fn g1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>) {}
153-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
120+
| ------------------------------------------------- required by `g1`
154121

155122
error[E0631]: type mismatch in closure arguments
156123
--> $DIR/anonymous-higher-ranked-lifetime.rs:12:5
@@ -159,12 +126,9 @@ LL | g1(|_: (), _: ()| {});
159126
| ^^ -------------- found signature of `fn((), ()) -> _`
160127
| |
161128
| expected signature of `fn(&(), std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r ()) + 'static)>) -> _`
162-
|
163-
note: required by `g1`
164-
--> $DIR/anonymous-higher-ranked-lifetime.rs:34:1
165-
|
129+
...
166130
LL | fn g1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>) {}
167-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
131+
| ------------------------------------------------- required by `g1`
168132

169133
error[E0631]: type mismatch in closure arguments
170134
--> $DIR/anonymous-higher-ranked-lifetime.rs:14:5
@@ -173,12 +137,9 @@ LL | g2(|_: (), _: ()| {});
173137
| ^^ -------------- found signature of `fn((), ()) -> _`
174138
| |
175139
| expected signature of `for<'r> fn(&'r (), for<'s> fn(&'s ())) -> _`
176-
|
177-
note: required by `g2`
178-
--> $DIR/anonymous-higher-ranked-lifetime.rs:35:1
179-
|
140+
...
180141
LL | fn g2<F>(_: F) where F: Fn(&(), fn(&())) {}
181-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
142+
| ---------------------------------------- required by `g2`
182143

183144
error[E0631]: type mismatch in closure arguments
184145
--> $DIR/anonymous-higher-ranked-lifetime.rs:14:5
@@ -187,12 +148,9 @@ LL | g2(|_: (), _: ()| {});
187148
| ^^ -------------- found signature of `fn((), ()) -> _`
188149
| |
189150
| expected signature of `fn(&(), for<'r> fn(&'r ())) -> _`
190-
|
191-
note: required by `g2`
192-
--> $DIR/anonymous-higher-ranked-lifetime.rs:35:1
193-
|
151+
...
194152
LL | fn g2<F>(_: F) where F: Fn(&(), fn(&())) {}
195-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
153+
| ---------------------------------------- required by `g2`
196154

197155
error[E0631]: type mismatch in closure arguments
198156
--> $DIR/anonymous-higher-ranked-lifetime.rs:16:5
@@ -201,12 +159,9 @@ LL | g3(|_: (), _: ()| {});
201159
| ^^ -------------- found signature of `fn((), ()) -> _`
202160
| |
203161
| expected signature of `for<'s> fn(&'s (), std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r ()) + 'static)>) -> _`
204-
|
205-
note: required by `g3`
206-
--> $DIR/anonymous-higher-ranked-lifetime.rs:36:1
207-
|
162+
...
208163
LL | fn g3<F>(_: F) where F: for<'s> Fn(&'s (), Box<dyn Fn(&())>) {}
209-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
164+
| ------------------------------------------------------------ required by `g3`
210165

211166
error[E0631]: type mismatch in closure arguments
212167
--> $DIR/anonymous-higher-ranked-lifetime.rs:16:5
@@ -215,12 +170,9 @@ LL | g3(|_: (), _: ()| {});
215170
| ^^ -------------- found signature of `fn((), ()) -> _`
216171
| |
217172
| expected signature of `fn(&'s (), std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r ()) + 'static)>) -> _`
218-
|
219-
note: required by `g3`
220-
--> $DIR/anonymous-higher-ranked-lifetime.rs:36:1
221-
|
173+
...
222174
LL | fn g3<F>(_: F) where F: for<'s> Fn(&'s (), Box<dyn Fn(&())>) {}
223-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
175+
| ------------------------------------------------------------ required by `g3`
224176

225177
error[E0631]: type mismatch in closure arguments
226178
--> $DIR/anonymous-higher-ranked-lifetime.rs:18:5
@@ -229,12 +181,9 @@ LL | g4(|_: (), _: ()| {});
229181
| ^^ -------------- found signature of `fn((), ()) -> _`
230182
| |
231183
| expected signature of `for<'s> fn(&'s (), for<'r> fn(&'r ())) -> _`
232-
|
233-
note: required by `g4`
234-
--> $DIR/anonymous-higher-ranked-lifetime.rs:37:1
235-
|
184+
...
236185
LL | fn g4<F>(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {}
237-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
186+
| --------------------------------------------------- required by `g4`
238187

239188
error[E0631]: type mismatch in closure arguments
240189
--> $DIR/anonymous-higher-ranked-lifetime.rs:18:5
@@ -243,12 +192,9 @@ LL | g4(|_: (), _: ()| {});
243192
| ^^ -------------- found signature of `fn((), ()) -> _`
244193
| |
245194
| expected signature of `fn(&(), for<'r> fn(&'r ())) -> _`
246-
|
247-
note: required by `g4`
248-
--> $DIR/anonymous-higher-ranked-lifetime.rs:37:1
249-
|
195+
...
250196
LL | fn g4<F>(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {}
251-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
197+
| --------------------------------------------------- required by `g4`
252198

253199
error[E0631]: type mismatch in closure arguments
254200
--> $DIR/anonymous-higher-ranked-lifetime.rs:20:5
@@ -257,12 +203,9 @@ LL | h1(|_: (), _: (), _: (), _: ()| {});
257203
| ^^ ---------------------------- found signature of `fn((), (), (), ()) -> _`
258204
| |
259205
| expected signature of `for<'r, 's> fn(&'r (), std::boxed::Box<(dyn for<'t0> std::ops::Fn(&'t0 ()) + 'static)>, &'s (), for<'t0, 't1> fn(&'t0 (), &'t1 ())) -> _`
260-
|
261-
note: required by `h1`
262-
--> $DIR/anonymous-higher-ranked-lifetime.rs:40:1
263-
|
206+
...
264207
LL | fn h1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>, &(), fn(&(), &())) {}
265-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
208+
| -------------------------------------------------------------------- required by `h1`
266209

267210
error[E0631]: type mismatch in closure arguments
268211
--> $DIR/anonymous-higher-ranked-lifetime.rs:20:5
@@ -271,12 +214,9 @@ LL | h1(|_: (), _: (), _: (), _: ()| {});
271214
| ^^ ---------------------------- found signature of `fn((), (), (), ()) -> _`
272215
| |
273216
| expected signature of `fn(&(), std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r ()) + 'static)>, &(), for<'r, 's> fn(&'r (), &'s ())) -> _`
274-
|
275-
note: required by `h1`
276-
--> $DIR/anonymous-higher-ranked-lifetime.rs:40:1
277-
|
217+
...
278218
LL | fn h1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>, &(), fn(&(), &())) {}
279-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
219+
| -------------------------------------------------------------------- required by `h1`
280220

281221
error[E0631]: type mismatch in closure arguments
282222
--> $DIR/anonymous-higher-ranked-lifetime.rs:22:5
@@ -285,12 +225,9 @@ LL | h2(|_: (), _: (), _: (), _: ()| {});
285225
| ^^ ---------------------------- found signature of `fn((), (), (), ()) -> _`
286226
| |
287227
| expected signature of `for<'r, 't0> fn(&'r (), std::boxed::Box<(dyn for<'s> std::ops::Fn(&'s ()) + 'static)>, &'t0 (), for<'s, 't1> fn(&'s (), &'t1 ())) -> _`
288-
|
289-
note: required by `h2`
290-
--> $DIR/anonymous-higher-ranked-lifetime.rs:41:1
291-
|
228+
...
292229
LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<dyn Fn(&())>, &'t0 (), fn(&(), &())) {}
293-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
230+
| --------------------------------------------------------------------------------- required by `h2`
294231

295232
error[E0631]: type mismatch in closure arguments
296233
--> $DIR/anonymous-higher-ranked-lifetime.rs:22:5
@@ -299,12 +236,9 @@ LL | h2(|_: (), _: (), _: (), _: ()| {});
299236
| ^^ ---------------------------- found signature of `fn((), (), (), ()) -> _`
300237
| |
301238
| expected signature of `fn(&(), std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r ()) + 'static)>, &'t0 (), for<'r, 's> fn(&'r (), &'s ())) -> _`
302-
|
303-
note: required by `h2`
304-
--> $DIR/anonymous-higher-ranked-lifetime.rs:41:1
305-
|
239+
...
306240
LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<dyn Fn(&())>, &'t0 (), fn(&(), &())) {}
307-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
241+
| --------------------------------------------------------------------------------- required by `h2`
308242

309243
error: aborting due to 22 previous errors
310244

0 commit comments

Comments
 (0)