Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1ba8b13

Browse files
authoredApr 23, 2020
Rollup merge of rust-lang#71235 - estebank:lt-sugg-2, r=ecstatic-morse
Tweak `'static` suggestion code Fix rust-lang#71196.
2 parents d8c235d + 25f8966 commit 1ba8b13

25 files changed

+572
-170
lines changed
 

‎src/librustc_ast_lowering/path.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
273273
.next();
274274
if !generic_args.parenthesized && !has_lifetimes {
275275
generic_args.args = self
276-
.elided_path_lifetimes(path_span, expected_lifetimes)
276+
.elided_path_lifetimes(
277+
first_generic_span.map(|s| s.shrink_to_lo()).unwrap_or(segment.ident.span),
278+
expected_lifetimes,
279+
)
277280
.map(GenericArg::Lifetime)
278281
.chain(generic_args.args.into_iter())
279282
.collect();

‎src/librustc_resolve/late/diagnostics.rs

Lines changed: 111 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,101 +1034,125 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
10341034
lifetime_names: &FxHashSet<ast::Ident>,
10351035
params: &[ElisionFailureInfo],
10361036
) {
1037-
if count > 1 {
1038-
err.span_label(span, format!("expected {} lifetime parameters", count));
1039-
} else {
1040-
let snippet = self.tcx.sess.source_map().span_to_snippet(span).ok();
1041-
let suggest_existing = |err: &mut DiagnosticBuilder<'_>, sugg| {
1042-
err.span_suggestion(
1043-
span,
1044-
"consider using the named lifetime",
1045-
sugg,
1046-
Applicability::MaybeIncorrect,
1047-
);
1048-
};
1049-
let suggest_new = |err: &mut DiagnosticBuilder<'_>, sugg: &str| {
1050-
err.span_label(span, "expected named lifetime parameter");
1037+
let snippet = self.tcx.sess.source_map().span_to_snippet(span).ok();
10511038

1052-
for missing in self.missing_named_lifetime_spots.iter().rev() {
1053-
let mut introduce_suggestion = vec![];
1054-
let msg;
1055-
let should_break;
1056-
introduce_suggestion.push(match missing {
1057-
MissingLifetimeSpot::Generics(generics) => {
1058-
msg = "consider introducing a named lifetime parameter".to_string();
1059-
should_break = true;
1060-
if let Some(param) = generics.params.iter().find(|p| match p.kind {
1061-
hir::GenericParamKind::Type {
1062-
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
1063-
..
1064-
} => false,
1065-
_ => true,
1066-
}) {
1067-
(param.span.shrink_to_lo(), "'a, ".to_string())
1068-
} else {
1069-
(generics.span, "<'a>".to_string())
1070-
}
1071-
}
1072-
MissingLifetimeSpot::HigherRanked { span, span_type } => {
1073-
msg = format!(
1074-
"consider making the {} lifetime-generic with a new `'a` lifetime",
1075-
span_type.descr(),
1076-
);
1077-
should_break = false;
1078-
err.note(
1079-
"for more information on higher-ranked polymorphism, visit \
1080-
https://doc.rust-lang.org/nomicon/hrtb.html",
1081-
);
1082-
(*span, span_type.suggestion("'a"))
1083-
}
1084-
});
1085-
for param in params {
1086-
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(param.span)
1087-
{
1088-
if snippet.starts_with('&') && !snippet.starts_with("&'") {
1089-
introduce_suggestion
1090-
.push((param.span, format!("&'a {}", &snippet[1..])));
1091-
} else if snippet.starts_with("&'_ ") {
1092-
introduce_suggestion
1093-
.push((param.span, format!("&'a {}", &snippet[4..])));
1094-
}
1039+
err.span_label(
1040+
span,
1041+
&format!(
1042+
"expected {} lifetime parameter{}",
1043+
if count == 1 { "named".to_string() } else { count.to_string() },
1044+
pluralize!(count)
1045+
),
1046+
);
1047+
1048+
let suggest_existing = |err: &mut DiagnosticBuilder<'_>, sugg| {
1049+
err.span_suggestion_verbose(
1050+
span,
1051+
&format!("consider using the `{}` lifetime", lifetime_names.iter().next().unwrap()),
1052+
sugg,
1053+
Applicability::MaybeIncorrect,
1054+
);
1055+
};
1056+
let suggest_new = |err: &mut DiagnosticBuilder<'_>, sugg: &str| {
1057+
for missing in self.missing_named_lifetime_spots.iter().rev() {
1058+
let mut introduce_suggestion = vec![];
1059+
let msg;
1060+
let should_break;
1061+
introduce_suggestion.push(match missing {
1062+
MissingLifetimeSpot::Generics(generics) => {
1063+
msg = "consider introducing a named lifetime parameter".to_string();
1064+
should_break = true;
1065+
if let Some(param) = generics.params.iter().find(|p| match p.kind {
1066+
hir::GenericParamKind::Type {
1067+
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
1068+
..
1069+
} => false,
1070+
_ => true,
1071+
}) {
1072+
(param.span.shrink_to_lo(), "'a, ".to_string())
1073+
} else {
1074+
(generics.span, "<'a>".to_string())
10951075
}
10961076
}
1097-
introduce_suggestion.push((span, sugg.to_string()));
1098-
err.multipart_suggestion(
1099-
&msg,
1100-
introduce_suggestion,
1101-
Applicability::MaybeIncorrect,
1102-
);
1103-
if should_break {
1104-
break;
1077+
MissingLifetimeSpot::HigherRanked { span, span_type } => {
1078+
msg = format!(
1079+
"consider making the {} lifetime-generic with a new `'a` lifetime",
1080+
span_type.descr(),
1081+
);
1082+
should_break = false;
1083+
err.note(
1084+
"for more information on higher-ranked polymorphism, visit \
1085+
https://doc.rust-lang.org/nomicon/hrtb.html",
1086+
);
1087+
(*span, span_type.suggestion("'a"))
1088+
}
1089+
});
1090+
for param in params {
1091+
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(param.span) {
1092+
if snippet.starts_with('&') && !snippet.starts_with("&'") {
1093+
introduce_suggestion
1094+
.push((param.span, format!("&'a {}", &snippet[1..])));
1095+
} else if snippet.starts_with("&'_ ") {
1096+
introduce_suggestion
1097+
.push((param.span, format!("&'a {}", &snippet[4..])));
1098+
}
11051099
}
11061100
}
1107-
};
1108-
1109-
match (lifetime_names.len(), lifetime_names.iter().next(), snippet.as_deref()) {
1110-
(1, Some(name), Some("&")) => {
1111-
suggest_existing(err, format!("&{} ", name));
1112-
}
1113-
(1, Some(name), Some("'_")) => {
1114-
suggest_existing(err, name.to_string());
1115-
}
1116-
(1, Some(name), Some(snippet)) if !snippet.ends_with('>') => {
1117-
suggest_existing(err, format!("{}<{}>", snippet, name));
1118-
}
1119-
(0, _, Some("&")) => {
1120-
suggest_new(err, "&'a ");
1121-
}
1122-
(0, _, Some("'_")) => {
1123-
suggest_new(err, "'a");
1124-
}
1125-
(0, _, Some(snippet)) if !snippet.ends_with('>') => {
1126-
suggest_new(err, &format!("{}<'a>", snippet));
1101+
introduce_suggestion.push((span, sugg.to_string()));
1102+
err.multipart_suggestion(&msg, introduce_suggestion, Applicability::MaybeIncorrect);
1103+
if should_break {
1104+
break;
11271105
}
1128-
_ => {
1129-
err.span_label(span, "expected lifetime parameter");
1106+
}
1107+
};
1108+
1109+
match (lifetime_names.len(), lifetime_names.iter().next(), snippet.as_deref()) {
1110+
(1, Some(name), Some("&")) => {
1111+
suggest_existing(err, format!("&{} ", name));
1112+
}
1113+
(1, Some(name), Some("'_")) => {
1114+
suggest_existing(err, name.to_string());
1115+
}
1116+
(1, Some(name), Some("")) => {
1117+
suggest_existing(err, format!("{}, ", name).repeat(count));
1118+
}
1119+
(1, Some(name), Some(snippet)) if !snippet.ends_with('>') => {
1120+
suggest_existing(
1121+
err,
1122+
format!(
1123+
"{}<{}>",
1124+
snippet,
1125+
std::iter::repeat(name.to_string())
1126+
.take(count)
1127+
.collect::<Vec<_>>()
1128+
.join(", ")
1129+
),
1130+
);
1131+
}
1132+
(0, _, Some("&")) if count == 1 => {
1133+
suggest_new(err, "&'a ");
1134+
}
1135+
(0, _, Some("'_")) if count == 1 => {
1136+
suggest_new(err, "'a");
1137+
}
1138+
(0, _, Some(snippet)) if !snippet.ends_with('>') && count == 1 => {
1139+
suggest_new(err, &format!("{}<'a>", snippet));
1140+
}
1141+
(n, ..) if n > 1 => {
1142+
let spans: Vec<Span> = lifetime_names.iter().map(|lt| lt.span).collect();
1143+
err.span_note(spans, "these named lifetimes are available to use");
1144+
if Some("") == snippet.as_deref() {
1145+
// This happens when we have `Foo<T>` where we point at the space before `T`,
1146+
// but this can be confusing so we give a suggestion with placeholders.
1147+
err.span_suggestion_verbose(
1148+
span,
1149+
"consider using one of the available lifetimes here",
1150+
"'lifetime, ".repeat(count),
1151+
Applicability::HasPlaceholders,
1152+
);
11301153
}
11311154
}
1155+
_ => {}
11321156
}
11331157
}
11341158
}

‎src/librustc_resolve/late/lifetimes.rs

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,52 +2388,28 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
23882388
};
23892389

23902390
let mut err = self.report_missing_lifetime_specifiers(span, lifetime_refs.len());
2391-
let mut add_label = true;
23922391

23932392
if let Some(params) = error {
2394-
if lifetime_refs.len() == 1 {
2395-
add_label = add_label && self.report_elision_failure(&mut err, params, span);
2393+
// If there's no lifetime available, suggest `'static`.
2394+
if self.report_elision_failure(&mut err, params) && lifetime_names.is_empty() {
2395+
lifetime_names.insert(ast::Ident::from_str("'static"));
23962396
}
23972397
}
2398-
if add_label {
2399-
self.add_missing_lifetime_specifiers_label(
2400-
&mut err,
2401-
span,
2402-
lifetime_refs.len(),
2403-
&lifetime_names,
2404-
error.map(|p| &p[..]).unwrap_or(&[]),
2405-
);
2406-
}
2407-
2398+
self.add_missing_lifetime_specifiers_label(
2399+
&mut err,
2400+
span,
2401+
lifetime_refs.len(),
2402+
&lifetime_names,
2403+
error.map(|p| &p[..]).unwrap_or(&[]),
2404+
);
24082405
err.emit();
24092406
}
24102407

2411-
fn suggest_lifetime(&self, db: &mut DiagnosticBuilder<'_>, span: Span, msg: &str) -> bool {
2412-
match self.tcx.sess.source_map().span_to_snippet(span) {
2413-
Ok(ref snippet) => {
2414-
let (sugg, applicability) = if snippet == "&" {
2415-
("&'static ".to_owned(), Applicability::MachineApplicable)
2416-
} else if snippet == "'_" {
2417-
("'static".to_owned(), Applicability::MachineApplicable)
2418-
} else {
2419-
(format!("{} + 'static", snippet), Applicability::MaybeIncorrect)
2420-
};
2421-
db.span_suggestion(span, msg, sugg, applicability);
2422-
false
2423-
}
2424-
Err(_) => {
2425-
db.help(msg);
2426-
true
2427-
}
2428-
}
2429-
}
2430-
24312408
fn report_elision_failure(
24322409
&mut self,
24332410
db: &mut DiagnosticBuilder<'_>,
24342411
params: &[ElisionFailureInfo],
2435-
span: Span,
2436-
) -> bool {
2412+
) -> bool /* add `'static` lifetime to lifetime list */ {
24372413
let mut m = String::new();
24382414
let len = params.len();
24392415

@@ -2482,29 +2458,28 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
24822458
"this function's return type contains a borrowed value, \
24832459
but there is no value for it to be borrowed from",
24842460
);
2485-
self.suggest_lifetime(db, span, "consider giving it a 'static lifetime")
2461+
true
24862462
} else if elided_len == 0 {
24872463
db.help(
24882464
"this function's return type contains a borrowed value with \
24892465
an elided lifetime, but the lifetime cannot be derived from \
24902466
the arguments",
24912467
);
2492-
let msg = "consider giving it an explicit bounded or 'static lifetime";
2493-
self.suggest_lifetime(db, span, msg)
2468+
true
24942469
} else if elided_len == 1 {
24952470
db.help(&format!(
24962471
"this function's return type contains a borrowed value, \
24972472
but the signature does not say which {} it is borrowed from",
24982473
m
24992474
));
2500-
true
2475+
false
25012476
} else {
25022477
db.help(&format!(
25032478
"this function's return type contains a borrowed value, \
25042479
but the signature does not say whether it is borrowed from {}",
25052480
m
25062481
));
2507-
true
2482+
false
25082483
}
25092484
}
25102485

‎src/librustc_span/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,8 @@ impl MultiSpan {
657657
MultiSpan { primary_spans: vec![primary_span], span_labels: vec![] }
658658
}
659659

660-
pub fn from_spans(vec: Vec<Span>) -> MultiSpan {
660+
pub fn from_spans(mut vec: Vec<Span>) -> MultiSpan {
661+
vec.sort();
661662
MultiSpan { primary_spans: vec, span_labels: vec![] }
662663
}
663664

‎src/librustc_typeck/astconv.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,18 +1017,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
10171017

10181018
self.prohibit_generics(trait_ref.path.segments.split_last().unwrap().1);
10191019

1020-
let path_span = if let [segment] = &trait_ref.path.segments[..] {
1021-
// FIXME: `trait_ref.path.span` can point to a full path with multiple
1022-
// segments, even though `trait_ref.path.segments` is of length `1`. Work
1023-
// around that bug here, even though it should be fixed elsewhere.
1024-
// This would otherwise cause an invalid suggestion. For an example, look at
1025-
// `src/test/ui/issues/issue-28344.rs`.
1026-
segment.ident.span
1027-
} else {
1028-
trait_ref.path.span
1029-
};
10301020
let (substs, assoc_bindings, arg_count_correct) = self.create_substs_for_ast_trait_ref(
1031-
path_span,
1021+
trait_ref.path.span,
10321022
trait_def_id,
10331023
self_ty,
10341024
trait_ref.path.segments.last().unwrap(),
@@ -1729,6 +1719,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
17291719
self.ast_region_to_region(lifetime, None)
17301720
} else {
17311721
self.re_infer(None, span).unwrap_or_else(|| {
1722+
// FIXME: these can be redundant with E0106, but not always.
17321723
struct_span_err!(
17331724
tcx.sess,
17341725
span,

‎src/test/ui/associated-types/bound-lifetime-in-binding-only.elision.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ error[E0106]: missing lifetime specifier
22
--> $DIR/bound-lifetime-in-binding-only.rs:52:23
33
|
44
LL | fn elision<T: Fn() -> &i32>() {
5-
| ^ help: consider giving it a 'static lifetime: `&'static`
5+
| ^ expected named lifetime parameter
66
|
77
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
8+
help: consider using the `'static` lifetime
9+
|
10+
LL | fn elision<T: Fn() -> &'static i32>() {
11+
| ^^^^^^^^
812

913
error: aborting due to previous error
1014

‎src/test/ui/associated-types/bound-lifetime-in-return-only.elision.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ error[E0106]: missing lifetime specifier
22
--> $DIR/bound-lifetime-in-return-only.rs:34:23
33
|
44
LL | fn elision(_: fn() -> &i32) {
5-
| ^ help: consider giving it a 'static lifetime: `&'static`
5+
| ^ expected named lifetime parameter
66
|
77
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
8+
help: consider using the `'static` lifetime
9+
|
10+
LL | fn elision(_: fn() -> &'static i32) {
11+
| ^^^^^^^^
812

913
error: aborting due to previous error
1014

‎src/test/ui/async-await/issues/issue-63388-2.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ error[E0106]: missing lifetime specifier
44
LL | foo: &dyn Foo, bar: &'a dyn Foo
55
| -------- -----------
66
LL | ) -> &dyn Foo
7-
| ^ help: consider using the named lifetime: `&'a`
7+
| ^ expected named lifetime parameter
88
|
99
= help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `foo` or `bar`
10+
help: consider using the `'a` lifetime
11+
|
12+
LL | ) -> &'a dyn Foo
13+
| ^^^
1014

1115
error: aborting due to previous error
1216

‎src/test/ui/c-variadic/variadic-ffi-6.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ error[E0106]: missing lifetime specifier
22
--> $DIR/variadic-ffi-6.rs:7:6
33
|
44
LL | ) -> &usize {
5-
| ^ help: consider giving it an explicit bounded or 'static lifetime: `&'static`
5+
| ^ expected named lifetime parameter
66
|
77
= help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments
8+
help: consider using the `'static` lifetime
9+
|
10+
LL | ) -> &'static usize {
11+
| ^^^^^^^^
812

913
error: aborting due to previous error
1014

‎src/test/ui/foreign-fn-return-lifetime.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ error[E0106]: missing lifetime specifier
22
--> $DIR/foreign-fn-return-lifetime.rs:5:19
33
|
44
LL | pub fn f() -> &u8;
5-
| ^ help: consider giving it a 'static lifetime: `&'static`
5+
| ^ expected named lifetime parameter
66
|
77
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
8+
help: consider using the `'static` lifetime
9+
|
10+
LL | pub fn f() -> &'static u8;
11+
| ^^^^^^^^
812

913
error: aborting due to previous error
1014

‎src/test/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,33 @@ LL | fn should_error<T>() where T : Into<&u32> {}
55
| ^ explicit lifetime name needed here
66

77
error[E0106]: missing lifetime specifier
8-
--> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:9:19
8+
--> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:9:21
99
|
1010
LL | fn foo<'b, L: X<&'b Nested<K>>>();
11-
| ^^^^^^^^^^^^^^^^ expected lifetime parameter
11+
| ^ expected named lifetime parameter
12+
|
13+
note: these named lifetimes are available to use
14+
--> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:8:9
15+
|
16+
LL | trait X<'a, K: 'a> {
17+
| ^^
18+
LL | fn foo<'b, L: X<&'b Nested<K>>>();
19+
| ^^
20+
help: consider using one of the available lifetimes here
21+
|
22+
LL | fn foo<'b, L: X<'lifetime, &'b Nested<K>>>();
23+
| ^^^^^^^^^^
1224

1325
error[E0106]: missing lifetime specifier
14-
--> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:13:15
26+
--> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:13:17
1527
|
1628
LL | fn bar<'b, L: X<&'b Nested<i32>>>(){}
17-
| ^^^^^^^^^^^^^^^^^^ expected lifetime parameter
29+
| ^ expected named lifetime parameter
30+
|
31+
help: consider using the `'b` lifetime
32+
|
33+
LL | fn bar<'b, L: X<'b, &'b Nested<i32>>>(){}
34+
| ^^^
1835

1936
error: aborting due to 3 previous errors
2037

‎src/test/ui/issues/issue-13497.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ error[E0106]: missing lifetime specifier
22
--> $DIR/issue-13497.rs:2:5
33
|
44
LL | &str
5-
| ^ help: consider giving it a 'static lifetime: `&'static`
5+
| ^ expected named lifetime parameter
66
|
77
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
8+
help: consider using the `'static` lifetime
9+
|
10+
LL | &'static str
11+
| ^^^^^^^^
812

913
error: aborting due to previous error
1014

‎src/test/ui/issues/issue-26638.stderr

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,25 @@ error[E0106]: missing lifetime specifier
1414
--> $DIR/issue-26638.rs:4:40
1515
|
1616
LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() }
17-
| ^ help: consider giving it an explicit bounded or 'static lifetime: `&'static`
17+
| ^ expected named lifetime parameter
1818
|
1919
= help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments
20+
help: consider using the `'static` lifetime
21+
|
22+
LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &'static str { iter() }
23+
| ^^^^^^^^
2024

2125
error[E0106]: missing lifetime specifier
2226
--> $DIR/issue-26638.rs:7:22
2327
|
2428
LL | fn parse_type_3() -> &str { unimplemented!() }
25-
| ^ help: consider giving it a 'static lifetime: `&'static`
29+
| ^ expected named lifetime parameter
2630
|
2731
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
32+
help: consider using the `'static` lifetime
33+
|
34+
LL | fn parse_type_3() -> &'static str { unimplemented!() }
35+
| ^^^^^^^^
2836

2937
error: aborting due to 3 previous errors
3038

‎src/test/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ error[E0106]: missing lifetime specifier
22
--> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:2:11
33
|
44
LL | fn f() -> &isize {
5-
| ^ help: consider giving it a 'static lifetime: `&'static`
5+
| ^ expected named lifetime parameter
66
|
77
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
8+
help: consider using the `'static` lifetime
9+
|
10+
LL | fn f() -> &'static isize {
11+
| ^^^^^^^^
812

913
error[E0106]: missing lifetime specifier
1014
--> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:7:33
@@ -34,25 +38,37 @@ error[E0106]: missing lifetime specifier
3438
--> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:21:20
3539
|
3640
LL | fn i(_x: isize) -> &isize {
37-
| ^ help: consider giving it an explicit bounded or 'static lifetime: `&'static`
41+
| ^ expected named lifetime parameter
3842
|
3943
= help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments
44+
help: consider using the `'static` lifetime
45+
|
46+
LL | fn i(_x: isize) -> &'static isize {
47+
| ^^^^^^^^
4048

4149
error[E0106]: missing lifetime specifier
4250
--> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:34:24
4351
|
4452
LL | fn j(_x: StaticStr) -> &isize {
45-
| ^ help: consider giving it an explicit bounded or 'static lifetime: `&'static`
53+
| ^ expected named lifetime parameter
4654
|
4755
= help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments
56+
help: consider using the `'static` lifetime
57+
|
58+
LL | fn j(_x: StaticStr) -> &'static isize {
59+
| ^^^^^^^^
4860

4961
error[E0106]: missing lifetime specifier
5062
--> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:40:49
5163
|
5264
LL | fn k<'a, T: WithLifetime<'a>>(_x: T::Output) -> &isize {
53-
| ^ help: consider giving it an explicit bounded or 'static lifetime: `&'static`
65+
| ^ expected named lifetime parameter
5466
|
5567
= help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments
68+
help: consider using the `'a` lifetime
69+
|
70+
LL | fn k<'a, T: WithLifetime<'a>>(_x: T::Output) -> &'a isize {
71+
| ^^^
5672

5773
error: aborting due to 6 previous errors
5874

‎src/test/ui/specialization/defaultimpl/validation.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ LL | default impl !Send for Z {}
2525
| default because of this
2626

2727
error[E0750]: negative impls cannot be default impls
28-
--> $DIR/validation.rs:10:14
28+
--> $DIR/validation.rs:10:1
2929
|
3030
LL | default impl !Send for Z {}
3131
| ^^^^^^^ ^
3232

3333
error[E0750]: negative impls cannot be default impls
34-
--> $DIR/validation.rs:14:14
34+
--> $DIR/validation.rs:14:1
3535
|
3636
LL | default impl !Tr for S {}
3737
| ^^^^^^^ ^
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#![allow(bare_trait_objects)]
2+
use std::collections::HashMap;
3+
use std::cell::RefCell;
4+
5+
pub union Foo<'t, 'k> {
6+
i: &'t i64,
7+
f: &'k f64,
8+
}
9+
trait Bar<'t, 'k> {}
10+
11+
pub union Qux<'t, 'k, I> {
12+
i: &'t I,
13+
f: &'k I,
14+
}
15+
trait Tar<'t, 'k, I> {}
16+
17+
thread_local! {
18+
static a: RefCell<HashMap<i32, Vec<Vec<Foo>>>> = RefCell::new(HashMap::new());
19+
//~^ ERROR missing lifetime specifier
20+
//~| ERROR missing lifetime specifier
21+
}
22+
thread_local! {
23+
static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
24+
//~^ ERROR missing lifetime specifier
25+
//~| ERROR missing lifetime specifier
26+
//~| ERROR missing lifetime specifier
27+
//~| ERROR missing lifetime specifier
28+
//~| ERROR the lifetime bound for this object type cannot be deduced from context
29+
//~| ERROR the lifetime bound for this object type cannot be deduced from context
30+
}
31+
thread_local! {
32+
static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new());
33+
//~^ ERROR missing lifetime specifier
34+
//~| ERROR missing lifetime specifier
35+
}
36+
thread_local! {
37+
static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
38+
//~^ ERROR missing lifetime specifier
39+
//~| ERROR missing lifetime specifier
40+
//~| ERROR missing lifetime specifier
41+
//~| ERROR missing lifetime specifier
42+
//~| ERROR the lifetime bound for this object type cannot be deduced from context
43+
//~| ERROR the lifetime bound for this object type cannot be deduced from context
44+
}
45+
46+
thread_local! {
47+
static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new());
48+
//~^ ERROR wrong number of lifetime arguments: expected 2, found 1
49+
//~| ERROR wrong number of lifetime arguments: expected 2, found 1
50+
//~| ERROR wrong number of lifetime arguments: expected 2, found 1
51+
//~| ERROR wrong number of lifetime arguments: expected 2, found 1
52+
}
53+
thread_local! {
54+
static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
55+
//~^ ERROR the lifetime bound for this object type cannot be deduced from context
56+
//~| ERROR the lifetime bound for this object type cannot be deduced from context
57+
//~| ERROR wrong number of lifetime arguments: expected 2, found 1
58+
//~| ERROR wrong number of lifetime arguments: expected 2, found 1
59+
//~| ERROR wrong number of lifetime arguments: expected 2, found 1
60+
//~| ERROR wrong number of lifetime arguments: expected 2, found 1
61+
//~| ERROR missing lifetime specifier
62+
//~| ERROR missing lifetime specifier
63+
}
64+
65+
fn main() {}
Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
error[E0106]: missing lifetime specifiers
2+
--> $DIR/missing-lifetime-specifier.rs:18:44
3+
|
4+
LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo>>>> = RefCell::new(HashMap::new());
5+
| ^^^ expected 2 lifetime parameters
6+
|
7+
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
8+
help: consider using the `'static` lifetime
9+
|
10+
LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo<'static, 'static>>>>> = RefCell::new(HashMap::new());
11+
| ^^^^^^^^^^^^^^^^^^^^^
12+
13+
error[E0106]: missing lifetime specifiers
14+
--> $DIR/missing-lifetime-specifier.rs:18:44
15+
|
16+
LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo>>>> = RefCell::new(HashMap::new());
17+
| ^^^ expected 2 lifetime parameters
18+
|
19+
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
20+
help: consider using the `'static` lifetime
21+
|
22+
LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo<'static, 'static>>>>> = RefCell::new(HashMap::new());
23+
| ^^^^^^^^^^^^^^^^^^^^^
24+
25+
error[E0106]: missing lifetime specifier
26+
--> $DIR/missing-lifetime-specifier.rs:23:44
27+
|
28+
LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
29+
| ^ expected named lifetime parameter
30+
|
31+
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
32+
help: consider using the `'static` lifetime
33+
|
34+
LL | static b: RefCell<HashMap<i32, Vec<Vec<&'static Bar>>>> = RefCell::new(HashMap::new());
35+
| ^^^^^^^^
36+
37+
error[E0106]: missing lifetime specifiers
38+
--> $DIR/missing-lifetime-specifier.rs:23:45
39+
|
40+
LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
41+
| ^^^ expected 2 lifetime parameters
42+
|
43+
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
44+
help: consider using the `'static` lifetime
45+
|
46+
LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar<'static, 'static>>>>> = RefCell::new(HashMap::new());
47+
| ^^^^^^^^^^^^^^^^^^^^^
48+
49+
error[E0106]: missing lifetime specifier
50+
--> $DIR/missing-lifetime-specifier.rs:23:44
51+
|
52+
LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
53+
| ^ expected named lifetime parameter
54+
|
55+
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
56+
help: consider using the `'static` lifetime
57+
|
58+
LL | static b: RefCell<HashMap<i32, Vec<Vec<&'static Bar>>>> = RefCell::new(HashMap::new());
59+
| ^^^^^^^^
60+
61+
error[E0106]: missing lifetime specifiers
62+
--> $DIR/missing-lifetime-specifier.rs:23:45
63+
|
64+
LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
65+
| ^^^ expected 2 lifetime parameters
66+
|
67+
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
68+
help: consider using the `'static` lifetime
69+
|
70+
LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar<'static, 'static>>>>> = RefCell::new(HashMap::new());
71+
| ^^^^^^^^^^^^^^^^^^^^^
72+
73+
error[E0106]: missing lifetime specifiers
74+
--> $DIR/missing-lifetime-specifier.rs:32:48
75+
|
76+
LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new());
77+
| ^ expected 2 lifetime parameters
78+
|
79+
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
80+
help: consider using the `'static` lifetime
81+
|
82+
LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
83+
| ^^^^^^^^^^^^^^^^^
84+
85+
error[E0106]: missing lifetime specifiers
86+
--> $DIR/missing-lifetime-specifier.rs:32:48
87+
|
88+
LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new());
89+
| ^ expected 2 lifetime parameters
90+
|
91+
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
92+
help: consider using the `'static` lifetime
93+
|
94+
LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
95+
| ^^^^^^^^^^^^^^^^^
96+
97+
error[E0106]: missing lifetime specifier
98+
--> $DIR/missing-lifetime-specifier.rs:37:44
99+
|
100+
LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
101+
| ^ expected named lifetime parameter
102+
|
103+
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
104+
help: consider using the `'static` lifetime
105+
|
106+
LL | static d: RefCell<HashMap<i32, Vec<Vec<&'static Tar<i32>>>>> = RefCell::new(HashMap::new());
107+
| ^^^^^^^^
108+
109+
error[E0106]: missing lifetime specifiers
110+
--> $DIR/missing-lifetime-specifier.rs:37:49
111+
|
112+
LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
113+
| ^ expected 2 lifetime parameters
114+
|
115+
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
116+
help: consider using the `'static` lifetime
117+
|
118+
LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
119+
| ^^^^^^^^^^^^^^^^^
120+
121+
error[E0106]: missing lifetime specifier
122+
--> $DIR/missing-lifetime-specifier.rs:37:44
123+
|
124+
LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
125+
| ^ expected named lifetime parameter
126+
|
127+
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
128+
help: consider using the `'static` lifetime
129+
|
130+
LL | static d: RefCell<HashMap<i32, Vec<Vec<&'static Tar<i32>>>>> = RefCell::new(HashMap::new());
131+
| ^^^^^^^^
132+
133+
error[E0106]: missing lifetime specifiers
134+
--> $DIR/missing-lifetime-specifier.rs:37:49
135+
|
136+
LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
137+
| ^ expected 2 lifetime parameters
138+
|
139+
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
140+
help: consider using the `'static` lifetime
141+
|
142+
LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
143+
| ^^^^^^^^^^^^^^^^^
144+
145+
error[E0106]: missing lifetime specifier
146+
--> $DIR/missing-lifetime-specifier.rs:54:44
147+
|
148+
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
149+
| ^ expected named lifetime parameter
150+
|
151+
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
152+
help: consider using the `'static` lifetime
153+
|
154+
LL | static f: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
155+
| ^^^^^^^^
156+
157+
error[E0106]: missing lifetime specifier
158+
--> $DIR/missing-lifetime-specifier.rs:54:44
159+
|
160+
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
161+
| ^ expected named lifetime parameter
162+
|
163+
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
164+
help: consider using the `'static` lifetime
165+
|
166+
LL | static f: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
167+
| ^^^^^^^^
168+
169+
error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound
170+
--> $DIR/missing-lifetime-specifier.rs:23:45
171+
|
172+
LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
173+
| ^^^
174+
175+
error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound
176+
--> $DIR/missing-lifetime-specifier.rs:23:45
177+
|
178+
LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
179+
| ^^^
180+
181+
error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound
182+
--> $DIR/missing-lifetime-specifier.rs:37:45
183+
|
184+
LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
185+
| ^^^^^^^^
186+
187+
error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound
188+
--> $DIR/missing-lifetime-specifier.rs:37:45
189+
|
190+
LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
191+
| ^^^^^^^^
192+
193+
error[E0107]: wrong number of lifetime arguments: expected 2, found 1
194+
--> $DIR/missing-lifetime-specifier.rs:47:44
195+
|
196+
LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new());
197+
| ^^^^^^^^^^^^^^^^^ expected 2 lifetime arguments
198+
199+
error[E0107]: wrong number of lifetime arguments: expected 2, found 1
200+
--> $DIR/missing-lifetime-specifier.rs:47:44
201+
|
202+
LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new());
203+
| ^^^^^^^^^^^^^^^^^ expected 2 lifetime arguments
204+
205+
error[E0107]: wrong number of lifetime arguments: expected 2, found 1
206+
--> $DIR/missing-lifetime-specifier.rs:47:44
207+
|
208+
LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new());
209+
| ^^^^^^^^^^^^^^^^^ expected 2 lifetime arguments
210+
211+
error[E0107]: wrong number of lifetime arguments: expected 2, found 1
212+
--> $DIR/missing-lifetime-specifier.rs:47:44
213+
|
214+
LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new());
215+
| ^^^^^^^^^^^^^^^^^ expected 2 lifetime arguments
216+
217+
error[E0107]: wrong number of lifetime arguments: expected 2, found 1
218+
--> $DIR/missing-lifetime-specifier.rs:54:45
219+
|
220+
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
221+
| ^^^^^^^^^^^^^^^^^ expected 2 lifetime arguments
222+
223+
error[E0107]: wrong number of lifetime arguments: expected 2, found 1
224+
--> $DIR/missing-lifetime-specifier.rs:54:45
225+
|
226+
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
227+
| ^^^^^^^^^^^^^^^^^ expected 2 lifetime arguments
228+
229+
error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound
230+
--> $DIR/missing-lifetime-specifier.rs:54:45
231+
|
232+
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
233+
| ^^^^^^^^^^^^^^^^^
234+
235+
error[E0107]: wrong number of lifetime arguments: expected 2, found 1
236+
--> $DIR/missing-lifetime-specifier.rs:54:45
237+
|
238+
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
239+
| ^^^^^^^^^^^^^^^^^ expected 2 lifetime arguments
240+
241+
error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound
242+
--> $DIR/missing-lifetime-specifier.rs:54:45
243+
|
244+
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
245+
| ^^^^^^^^^^^^^^^^^
246+
247+
error[E0107]: wrong number of lifetime arguments: expected 2, found 1
248+
--> $DIR/missing-lifetime-specifier.rs:54:45
249+
|
250+
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
251+
| ^^^^^^^^^^^^^^^^^ expected 2 lifetime arguments
252+
253+
error: aborting due to 28 previous errors
254+
255+
Some errors have detailed explanations: E0106, E0107.
256+
For more information about an error, try `rustc --explain E0106`.

‎src/test/ui/suggestions/return-without-lifetime.stderr

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,36 @@ error[E0106]: missing lifetime specifier
22
--> $DIR/return-without-lifetime.rs:2:16
33
|
44
LL | struct Foo<'a>(&usize);
5-
| ^ help: consider using the named lifetime: `&'a`
5+
| ^ expected named lifetime parameter
6+
|
7+
help: consider using the `'a` lifetime
8+
|
9+
LL | struct Foo<'a>(&'a usize);
10+
| ^^^
611

712
error[E0106]: missing lifetime specifier
813
--> $DIR/return-without-lifetime.rs:5:34
914
|
1015
LL | fn func1<'a>(_arg: &'a Thing) -> &() { unimplemented!() }
11-
| --------- ^ help: consider using the named lifetime: `&'a`
16+
| --------- ^ expected named lifetime parameter
1217
|
1318
= help: this function's return type contains a borrowed value, but the signature does not say which one of `_arg`'s 2 lifetimes it is borrowed from
19+
help: consider using the `'a` lifetime
20+
|
21+
LL | fn func1<'a>(_arg: &'a Thing) -> &'a () { unimplemented!() }
22+
| ^^^
1423

1524
error[E0106]: missing lifetime specifier
1625
--> $DIR/return-without-lifetime.rs:7:35
1726
|
1827
LL | fn func2<'a>(_arg: &Thing<'a>) -> &() { unimplemented!() }
19-
| ---------- ^ help: consider using the named lifetime: `&'a`
28+
| ---------- ^ expected named lifetime parameter
2029
|
2130
= help: this function's return type contains a borrowed value, but the signature does not say which one of `_arg`'s 2 lifetimes it is borrowed from
31+
help: consider using the `'a` lifetime
32+
|
33+
LL | fn func2<'a>(_arg: &Thing<'a>) -> &'a () { unimplemented!() }
34+
| ^^^
2235

2336
error: aborting due to 3 previous errors
2437

‎src/test/ui/traits/negative-impls/negative-default-impls.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0750]: negative impls cannot be default impls
2-
--> $DIR/negative-default-impls.rs:8:14
2+
--> $DIR/negative-default-impls.rs:8:1
33
|
44
LL | default impl !MyTrait for u32 {}
55
| ^^^^^^^ ^

‎src/test/ui/unboxed-closures/unboxed-closure-feature-gate.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0658]: parenthetical notation is only stable when used with `Fn`-family t
22
--> $DIR/unboxed-closure-feature-gate.rs:13:20
33
|
44
LL | let x: Box<dyn Foo(isize)>;
5-
| ^^^
5+
| ^^^^^^^^^^
66
|
77
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
88
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable

‎src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subje
22
--> $DIR/unboxed-closure-sugar-not-used-on-fn.rs:3:17
33
|
44
LL | fn bar1(x: &dyn Fn<(), Output=()>) {
5-
| ^^ help: use parenthetical notation instead: `Fn() -> ()`
5+
| ^^^^^^^^^^^^^^^^^ help: use parenthetical notation instead: `Fn() -> ()`
66
|
77
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
88
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
@@ -11,7 +11,7 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subje
1111
--> $DIR/unboxed-closure-sugar-not-used-on-fn.rs:7:28
1212
|
1313
LL | fn bar2<T>(x: &T) where T: Fn<()> {
14-
| ^^ help: use parenthetical notation instead: `Fn() -> ()`
14+
| ^^^^^^ help: use parenthetical notation instead: `Fn() -> ()`
1515
|
1616
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
1717
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable

‎src/test/ui/unboxed-closures/unboxed-closure-sugar-region.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0107]: wrong number of lifetime arguments: expected 1, found 0
22
--> $DIR/unboxed-closure-sugar-region.rs:30:51
33
|
44
LL | fn test2(x: &dyn Foo<(isize,),Output=()>, y: &dyn Foo(isize)) {
5-
| ^^^ expected 1 lifetime argument
5+
| ^^^^^^^^^^ expected 1 lifetime argument
66

77
error: aborting due to previous error
88

‎src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0107]: wrong number of type arguments: expected 3, found 1
22
--> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:16
33
|
44
LL | fn foo(_: &dyn Three())
5-
| ^^^^^ expected 3 type arguments
5+
| ^^^^^^^ expected 3 type arguments
66

77
error[E0220]: associated type `Output` not found for `Three<(), [type error], [type error]>`
88
--> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:16

‎src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,24 @@ error[E0106]: missing lifetime specifier
1414
--> $DIR/underscore-lifetime-binders.rs:2:17
1515
|
1616
LL | struct Baz<'a>(&'_ &'a u8);
17-
| ^^ help: consider using the named lifetime: `'a`
17+
| ^^ expected named lifetime parameter
18+
|
19+
help: consider using the `'a` lifetime
20+
|
21+
LL | struct Baz<'a>(&'a &'a u8);
22+
| ^^
1823

1924
error[E0106]: missing lifetime specifier
2025
--> $DIR/underscore-lifetime-binders.rs:10:33
2126
|
2227
LL | fn meh() -> Box<dyn for<'_> Meh<'_>>
23-
| ^^ help: consider giving it a 'static lifetime: `'static`
28+
| ^^ expected named lifetime parameter
2429
|
2530
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
31+
help: consider using the `'static` lifetime
32+
|
33+
LL | fn meh() -> Box<dyn for<'_> Meh<'static>>
34+
| ^^^^^^^
2635

2736
error[E0106]: missing lifetime specifier
2837
--> $DIR/underscore-lifetime-binders.rs:16:35

‎src/test/ui/unspecified-self-in-trait-ref.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LL | | }
3131
| |_- type parameter `A` must be specified for this
3232
...
3333
LL | let e = Bar::<usize>::lol();
34-
| ^^^ missing reference to `A`
34+
| ^^^^^^^^^^^^^^^^^ missing reference to `A`
3535
|
3636
= note: because of the default `Self` reference, type parameters must be specified on object types
3737

0 commit comments

Comments
 (0)
Please sign in to comment.