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 b8d85a3

Browse files
authoredMar 14, 2020
Rollup merge of rust-lang#69942 - estebank:sized-verbose-sugg, r=matthewjasper
Increase verbosity when suggesting subtle code changes Do not suggest changes that are actually quite small inline, to minimize the likelihood of confusion. Fix rust-lang#69243.
2 parents af0cdbf + 7995a08 commit b8d85a3

32 files changed

+361
-240
lines changed
 

‎src/librustc_infer/infer/error_reporting/need_type_info.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::infer::InferCtxt;
33
use rustc::hir::map::Map;
44
use rustc::ty::print::Print;
55
use rustc::ty::{self, DefIdTree, Infer, Ty, TyVar};
6-
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
6+
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder};
77
use rustc_hir as hir;
88
use rustc_hir::def::{DefKind, Namespace};
99
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
@@ -462,24 +462,19 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
462462
e: &Expr<'_>,
463463
err: &mut DiagnosticBuilder<'_>,
464464
) {
465-
if let (Ok(snippet), Some(tables), None) = (
466-
self.tcx.sess.source_map().span_to_snippet(segment.ident.span),
467-
self.in_progress_tables,
468-
&segment.args,
469-
) {
465+
if let (Some(tables), None) = (self.in_progress_tables, &segment.args) {
470466
let borrow = tables.borrow();
471467
if let Some((DefKind::AssocFn, did)) = borrow.type_dependent_def(e.hir_id) {
472468
let generics = self.tcx.generics_of(did);
473469
if !generics.params.is_empty() {
474-
err.span_suggestion(
475-
segment.ident.span,
470+
err.span_suggestion_verbose(
471+
segment.ident.span.shrink_to_hi(),
476472
&format!(
477473
"consider specifying the type argument{} in the method call",
478-
if generics.params.len() > 1 { "s" } else { "" },
474+
pluralize!(generics.params.len()),
479475
),
480476
format!(
481-
"{}::<{}>",
482-
snippet,
477+
"::<{}>",
483478
generics
484479
.params
485480
.iter()

‎src/librustc_infer/traits/error_reporting/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc::ty::{
2323
};
2424
use rustc_ast::ast;
2525
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
26-
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
26+
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder};
2727
use rustc_hir as hir;
2828
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
2929
use rustc_hir::{QPath, TyKind, WhereBoundPredicate, WherePredicate};
@@ -1186,15 +1186,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11861186
// |
11871187
// = note: cannot resolve `_: Tt`
11881188

1189-
err.span_suggestion(
1190-
span,
1189+
err.span_suggestion_verbose(
1190+
span.shrink_to_hi(),
11911191
&format!(
11921192
"consider specifying the type argument{} in the function call",
1193-
if generics.params.len() > 1 { "s" } else { "" },
1193+
pluralize!(generics.params.len()),
11941194
),
11951195
format!(
1196-
"{}::<{}>",
1197-
snippet,
1196+
"::<{}>",
11981197
generics
11991198
.params
12001199
.iter()
@@ -1356,7 +1355,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
13561355
[] => (span.shrink_to_hi(), ":"),
13571356
[.., bound] => (bound.span().shrink_to_hi(), " + "),
13581357
};
1359-
err.span_suggestion(
1358+
err.span_suggestion_verbose(
13601359
span,
13611360
"consider relaxing the implicit `Sized` restriction",
13621361
format!("{} ?Sized", separator),

‎src/librustc_infer/traits/error_reporting/suggestions.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
265265
}
266266
let hir = self.tcx.hir();
267267
// Get the name of the callable and the arguments to be used in the suggestion.
268-
let snippet = match hir.get_if_local(def_id) {
268+
let (snippet, sugg) = match hir.get_if_local(def_id) {
269269
Some(hir::Node::Expr(hir::Expr {
270270
kind: hir::ExprKind::Closure(_, decl, _, span, ..),
271271
..
@@ -276,7 +276,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
276276
None => return,
277277
};
278278
let args = decl.inputs.iter().map(|_| "_").collect::<Vec<_>>().join(", ");
279-
format!("{}({})", name, args)
279+
let sugg = format!("({})", args);
280+
(format!("{}{}", name, sugg), sugg)
280281
}
281282
Some(hir::Node::Item(hir::Item {
282283
ident,
@@ -297,7 +298,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
297298
})
298299
.collect::<Vec<_>>()
299300
.join(", ");
300-
format!("{}({})", ident, args)
301+
let sugg = format!("({})", args);
302+
(format!("{}{}", ident, sugg), sugg)
301303
}
302304
_ => return,
303305
};
@@ -306,10 +308,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
306308
// an argument, the `obligation.cause.span` points at the expression
307309
// of the argument, so we can provide a suggestion. This is signaled
308310
// by `points_at_arg`. Otherwise, we give a more general note.
309-
err.span_suggestion(
310-
obligation.cause.span,
311+
err.span_suggestion_verbose(
312+
obligation.cause.span.shrink_to_hi(),
311313
&msg,
312-
snippet,
314+
sugg,
313315
Applicability::HasPlaceholders,
314316
);
315317
} else {
@@ -494,7 +496,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
494496
.source_map()
495497
.span_take_while(span, |c| c.is_whitespace() || *c == '&');
496498
if points_at_arg && mutability == hir::Mutability::Not && refs_number > 0 {
497-
err.span_suggestion(
499+
err.span_suggestion_verbose(
498500
sp,
499501
"consider changing this borrow's mutability",
500502
"&mut ".to_string(),
@@ -898,11 +900,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
898900
// For example, if `expected_args_length` is 2, suggest `|_, _|`.
899901
if found_args.is_empty() && is_closure {
900902
let underscores = vec!["_"; expected_args.len()].join(", ");
901-
err.span_suggestion(
903+
err.span_suggestion_verbose(
902904
pipe_span,
903905
&format!(
904906
"consider changing the closure to take and ignore the expected argument{}",
905-
if expected_args.len() < 2 { "" } else { "s" }
907+
pluralize!(expected_args.len())
906908
),
907909
format!("|{}|", underscores),
908910
Applicability::MachineApplicable,
@@ -916,7 +918,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
916918
.map(|(name, _)| name.to_owned())
917919
.collect::<Vec<String>>()
918920
.join(", ");
919-
err.span_suggestion(
921+
err.span_suggestion_verbose(
920922
found_span,
921923
"change the closure to take multiple arguments instead of a single tuple",
922924
format!("|{}|", sugg),
@@ -953,7 +955,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
953955
String::new()
954956
},
955957
);
956-
err.span_suggestion(
958+
err.span_suggestion_verbose(
957959
found_span,
958960
"change the closure to accept a tuple instead of individual arguments",
959961
sugg,

‎src/librustc_typeck/check/method/mod.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
136136
self_ty: Ty<'tcx>,
137137
call_expr: &hir::Expr<'_>,
138138
) {
139-
let has_params = self
139+
let params = self
140140
.probe_for_name(
141141
method_name.span,
142142
probe::Mode::MethodCall,
@@ -146,26 +146,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
146146
call_expr.hir_id,
147147
ProbeScope::TraitsInScope,
148148
)
149-
.and_then(|pick| {
149+
.map(|pick| {
150150
let sig = self.tcx.fn_sig(pick.item.def_id);
151-
Ok(sig.inputs().skip_binder().len() > 1)
152-
});
151+
sig.inputs().skip_binder().len().saturating_sub(1)
152+
})
153+
.unwrap_or(0);
153154

154155
// Account for `foo.bar<T>`;
155-
let sugg_span = method_name.span.with_hi(call_expr.span.hi());
156-
let snippet = self
157-
.tcx
158-
.sess
159-
.source_map()
160-
.span_to_snippet(sugg_span)
161-
.unwrap_or_else(|_| method_name.to_string());
162-
let (suggestion, applicability) = if has_params.unwrap_or_default() {
163-
(format!("{}(...)", snippet), Applicability::HasPlaceholders)
164-
} else {
165-
(format!("{}()", snippet), Applicability::MaybeIncorrect)
166-
};
156+
let sugg_span = call_expr.span.shrink_to_hi();
157+
let (suggestion, applicability) = (
158+
format!("({})", (0..params).map(|_| "_").collect::<Vec<_>>().join(", ")),
159+
if params > 0 { Applicability::HasPlaceholders } else { Applicability::MaybeIncorrect },
160+
);
167161

168-
err.span_suggestion(sugg_span, msg, suggestion, applicability);
162+
err.span_suggestion_verbose(sugg_span, msg, suggestion, applicability);
169163
}
170164

171165
/// Performs method lookup. If lookup is successful, it will return the callee

‎src/librustc_typeck/check/mod.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4951,15 +4951,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
49514951
}
49524952
_ => {}
49534953
}
4954-
if let Ok(code) = self.sess().source_map().span_to_snippet(expr.span) {
4955-
err.span_suggestion(
4956-
expr.span,
4957-
&format!("use parentheses to {}", msg),
4958-
format!("{}({})", code, sugg_call),
4959-
applicability,
4960-
);
4961-
return true;
4962-
}
4954+
err.span_suggestion_verbose(
4955+
expr.span.shrink_to_hi(),
4956+
&format!("use parentheses to {}", msg),
4957+
format!("({})", sugg_call),
4958+
applicability,
4959+
);
4960+
return true;
49634961
}
49644962
false
49654963
}

‎src/librustc_typeck/check/pat.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -752,17 +752,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
752752
res.descr(),
753753
),
754754
);
755-
let (msg, sugg) = match parent_pat {
756-
Some(Pat { kind: hir::PatKind::Struct(..), .. }) => (
757-
"bind the struct field to a different name instead",
758-
format!("{}: other_{}", ident, ident.as_str().to_lowercase()),
759-
),
760-
_ => (
761-
"introduce a new binding instead",
762-
format!("other_{}", ident.as_str().to_lowercase()),
763-
),
755+
match parent_pat {
756+
Some(Pat { kind: hir::PatKind::Struct(..), .. }) => {
757+
e.span_suggestion_verbose(
758+
ident.span.shrink_to_hi(),
759+
"bind the struct field to a different name instead",
760+
format!(": other_{}", ident.as_str().to_lowercase()),
761+
Applicability::HasPlaceholders,
762+
);
763+
}
764+
_ => {
765+
let msg = "introduce a new binding instead";
766+
let sugg = format!("other_{}", ident.as_str().to_lowercase());
767+
e.span_suggestion(ident.span, msg, sugg, Applicability::HasPlaceholders);
768+
}
764769
};
765-
e.span_suggestion(ident.span, msg, sugg, Applicability::HasPlaceholders);
766770
}
767771
}
768772
e.emit();

‎src/test/ui/error-codes/E0615.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ error[E0615]: attempted to take value of method `method` on type `Foo`
22
--> $DIR/E0615.rs:11:7
33
|
44
LL | f.method;
5-
| ^^^^^^ help: use parentheses to call the method: `method()`
5+
| ^^^^^^
6+
|
7+
help: use parentheses to call the method
8+
|
9+
LL | f.method();
10+
| ^^
611

712
error: aborting due to previous error
813

‎src/test/ui/extern/extern-types-unsized.stderr

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim
22
--> $DIR/extern-types-unsized.rs:22:20
33
|
44
LL | fn assert_sized<T>() { }
5-
| ------------ -- help: consider relaxing the implicit `Sized` restriction: `: ?Sized`
6-
| |
7-
| required by this bound in `assert_sized`
5+
| ------------ - required by this bound in `assert_sized`
86
...
97
LL | assert_sized::<A>();
108
| ^ doesn't have a size known at compile-time
119
|
1210
= help: the trait `std::marker::Sized` is not implemented for `A`
1311
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
12+
help: consider relaxing the implicit `Sized` restriction
13+
|
14+
LL | fn assert_sized<T: ?Sized>() { }
15+
| ^^^^^^^^
1416

1517
error[E0277]: the size for values of type `A` cannot be known at compilation time
1618
--> $DIR/extern-types-unsized.rs:25:5

‎src/test/ui/implicit-method-bind.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ error[E0615]: attempted to take value of method `abs` on type `i32`
22
--> $DIR/implicit-method-bind.rs:2:20
33
|
44
LL | let _f = 10i32.abs;
5-
| ^^^ help: use parentheses to call the method: `abs()`
5+
| ^^^
6+
|
7+
help: use parentheses to call the method
8+
|
9+
LL | let _f = 10i32.abs();
10+
| ^^
611

712
error: aborting due to previous error
813

‎src/test/ui/issues/issue-13853-2.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ error[E0615]: attempted to take value of method `get` on type `std::boxed::Box<(
22
--> $DIR/issue-13853-2.rs:5:43
33
|
44
LL | fn foo(res : Box<dyn ResponseHook>) { res.get }
5-
| ^^^ help: use parentheses to call the method: `get()`
5+
| ^^^
6+
|
7+
help: use parentheses to call the method
8+
|
9+
LL | fn foo(res : Box<dyn ResponseHook>) { res.get() }
10+
| ^^
611

712
error: aborting due to previous error
813

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ error[E0616]: field `len` of struct `sub::S` is private
22
--> $DIR/issue-26472.rs:11:13
33
|
44
LL | let v = s.len;
5-
| ^^---
6-
| |
7-
| help: a method `len` also exists, call it with parentheses: `len()`
5+
| ^^^^^
6+
|
7+
help: a method `len` also exists, call it with parentheses
8+
|
9+
LL | let v = s.len();
10+
| ^^
811

912
error[E0616]: field `len` of struct `sub::S` is private
1013
--> $DIR/issue-26472.rs:12:5

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ LL | struct Foo(u32);
55
| ---------------- fn(u32) -> Foo {Foo} defined here
66
LL |
77
LL | fn test() -> Foo { Foo }
8-
| --- ^^^
9-
| | |
10-
| | expected struct `Foo`, found fn item
11-
| | help: use parentheses to instantiate this tuple struct: `Foo(_)`
8+
| --- ^^^ expected struct `Foo`, found fn item
9+
| |
1210
| expected `Foo` because of return type
1311
|
1412
= note: expected struct `Foo`
1513
found fn item `fn(u32) -> Foo {Foo}`
14+
help: use parentheses to instantiate this tuple struct
15+
|
16+
LL | fn test() -> Foo { Foo(_) }
17+
| ^^^
1618

1719
error: aborting due to previous error
1820

‎src/test/ui/methods/method-missing-call.stderr

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,23 @@ error[E0615]: attempted to take value of method `get_x` on type `Point`
22
--> $DIR/method-missing-call.rs:22:26
33
|
44
LL | .get_x;
5-
| ^^^^^ help: use parentheses to call the method: `get_x()`
5+
| ^^^^^
6+
|
7+
help: use parentheses to call the method
8+
|
9+
LL | .get_x();
10+
| ^^
611

712
error[E0615]: attempted to take value of method `filter_map` on type `std::iter::Filter<std::iter::Map<std::slice::Iter<'_, {integer}>, [closure@$DIR/method-missing-call.rs:27:20: 27:25]>, [closure@$DIR/method-missing-call.rs:28:23: 28:35]>`
813
--> $DIR/method-missing-call.rs:29:16
914
|
1015
LL | .filter_map;
11-
| ^^^^^^^^^^ help: use parentheses to call the method: `filter_map(...)`
16+
| ^^^^^^^^^^
17+
|
18+
help: use parentheses to call the method
19+
|
20+
LL | .filter_map(_);
21+
| ^^^
1222

1323
error: aborting due to 2 previous errors
1424

‎src/test/ui/question-mark-type-infer.stderr

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ error[E0284]: type annotations needed
22
--> $DIR/question-mark-type-infer.rs:12:21
33
|
44
LL | l.iter().map(f).collect()?
5-
| ^^^^^^^
6-
| |
7-
| cannot infer type
8-
| help: consider specifying the type argument in the method call: `collect::<B>`
5+
| ^^^^^^^ cannot infer type
96
|
107
= note: cannot resolve `<_ as std::ops::Try>::Ok == _`
8+
help: consider specifying the type argument in the method call
9+
|
10+
LL | l.iter().map(f).collect::<B>()?
11+
| ^^^^^
1112

1213
error: aborting due to previous error
1314

‎src/test/ui/reify-intrinsic.stderr

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ error[E0308]: cannot coerce intrinsics to function pointers
22
--> $DIR/reify-intrinsic.rs:6:64
33
|
44
LL | let _: unsafe extern "rust-intrinsic" fn(isize) -> usize = std::mem::transmute;
5-
| ------------------------------------------------- ^^^^^^^^^^^^^^^^^^^
6-
| | |
7-
| | cannot coerce intrinsics to function pointers
8-
| | help: use parentheses to call this function: `std::mem::transmute(...)`
5+
| ------------------------------------------------- ^^^^^^^^^^^^^^^^^^^ cannot coerce intrinsics to function pointers
6+
| |
97
| expected due to this
108
|
119
= note: expected fn pointer `unsafe extern "rust-intrinsic" fn(isize) -> usize`
1210
found fn item `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}`
11+
help: use parentheses to call this function
12+
|
13+
LL | let _: unsafe extern "rust-intrinsic" fn(isize) -> usize = std::mem::transmute(...);
14+
| ^^^^^
1315

1416
error[E0606]: casting `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}` as `unsafe extern "rust-intrinsic" fn(isize) -> usize` is invalid
1517
--> $DIR/reify-intrinsic.rs:11:13

‎src/test/ui/resolve/privacy-enum-ctor.stderr

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,16 @@ LL | Fn(u8),
304304
| ------ fn(u8) -> m::n::Z {m::n::Z::Fn} defined here
305305
...
306306
LL | let _: Z = Z::Fn;
307-
| - ^^^^^
308-
| | |
309-
| | expected enum `m::n::Z`, found fn item
310-
| | help: use parentheses to instantiate this tuple variant: `Z::Fn(_)`
307+
| - ^^^^^ expected enum `m::n::Z`, found fn item
308+
| |
311309
| expected due to this
312310
|
313311
= note: expected enum `m::n::Z`
314312
found fn item `fn(u8) -> m::n::Z {m::n::Z::Fn}`
313+
help: use parentheses to instantiate this tuple variant
314+
|
315+
LL | let _: Z = Z::Fn(_);
316+
| ^^^
315317

316318
error[E0618]: expected function, found enum variant `Z::Unit`
317319
--> $DIR/privacy-enum-ctor.rs:31:17
@@ -336,14 +338,16 @@ LL | Fn(u8),
336338
| ------ fn(u8) -> m::E {m::E::Fn} defined here
337339
...
338340
LL | let _: E = m::E::Fn;
339-
| - ^^^^^^^^
340-
| | |
341-
| | expected enum `m::E`, found fn item
342-
| | help: use parentheses to instantiate this tuple variant: `m::E::Fn(_)`
341+
| - ^^^^^^^^ expected enum `m::E`, found fn item
342+
| |
343343
| expected due to this
344344
|
345345
= note: expected enum `m::E`
346346
found fn item `fn(u8) -> m::E {m::E::Fn}`
347+
help: use parentheses to instantiate this tuple variant
348+
|
349+
LL | let _: E = m::E::Fn(_);
350+
| ^^^
347351

348352
error[E0618]: expected function, found enum variant `m::E::Unit`
349353
--> $DIR/privacy-enum-ctor.rs:47:16
@@ -368,14 +372,16 @@ LL | Fn(u8),
368372
| ------ fn(u8) -> m::E {m::E::Fn} defined here
369373
...
370374
LL | let _: E = E::Fn;
371-
| - ^^^^^
372-
| | |
373-
| | expected enum `m::E`, found fn item
374-
| | help: use parentheses to instantiate this tuple variant: `E::Fn(_)`
375+
| - ^^^^^ expected enum `m::E`, found fn item
376+
| |
375377
| expected due to this
376378
|
377379
= note: expected enum `m::E`
378380
found fn item `fn(u8) -> m::E {m::E::Fn}`
381+
help: use parentheses to instantiate this tuple variant
382+
|
383+
LL | let _: E = E::Fn(_);
384+
| ^^^
379385

380386
error[E0618]: expected function, found enum variant `E::Unit`
381387
--> $DIR/privacy-enum-ctor.rs:55:16

‎src/test/ui/span/type-annotations-needed-expr.stderr

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ error[E0282]: type annotations needed
22
--> $DIR/type-annotations-needed-expr.rs:2:39
33
|
44
LL | let _ = (vec![1,2,3]).into_iter().sum() as f64;
5-
| ^^^
6-
| |
7-
| cannot infer type for type parameter `S` declared on the method `sum`
8-
| help: consider specifying the type argument in the method call: `sum::<S>`
5+
| ^^^ cannot infer type for type parameter `S` declared on the method `sum`
96
|
107
= note: type must be known at this point
8+
help: consider specifying the type argument in the method call
9+
|
10+
LL | let _ = (vec![1,2,3]).into_iter().sum::<S>() as f64;
11+
| ^^^^^
1112

1213
error: aborting due to previous error
1314

‎src/test/ui/str/str-mut-idx.stderr

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t
22
--> $DIR/str-mut-idx.rs:4:15
33
|
44
LL | fn bot<T>() -> T { loop {} }
5-
| --- -- help: consider relaxing the implicit `Sized` restriction: `: ?Sized`
6-
| |
7-
| required by this bound in `bot`
5+
| --- - required by this bound in `bot`
86
...
97
LL | s[1..2] = bot();
108
| ^^^ doesn't have a size known at compile-time
119
|
1210
= help: the trait `std::marker::Sized` is not implemented for `str`
1311
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
12+
help: consider relaxing the implicit `Sized` restriction
13+
|
14+
LL | fn bot<T: ?Sized>() -> T { loop {} }
15+
| ^^^^^^^^
1416

1517
error[E0277]: the size for values of type `str` cannot be known at compilation time
1618
--> $DIR/str-mut-idx.rs:4:5

‎src/test/ui/substs-ppaux.normal.stderr

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ LL | fn bar<'a, T>() where T: 'a {}
55
| --------------------------- fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>} defined here
66
...
77
LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>;
8-
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9-
| | |
10-
| | expected `()`, found fn item
11-
| | help: use parentheses to call this function: `<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>()`
8+
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
9+
| |
1210
| expected due to this
1311
|
1412
= note: expected unit type `()`
1513
found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>}`
14+
help: use parentheses to call this function
15+
|
16+
LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>();
17+
| ^^
1618

1719
error[E0308]: mismatched types
1820
--> $DIR/substs-ppaux.rs:25:17
@@ -21,14 +23,16 @@ LL | fn bar<'a, T>() where T: 'a {}
2123
| --------------------------- fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>} defined here
2224
...
2325
LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>;
24-
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
25-
| | |
26-
| | expected `()`, found fn item
27-
| | help: use parentheses to call this function: `<i8 as Foo<'static, 'static, u32>>::bar::<'static, char>()`
26+
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
27+
| |
2828
| expected due to this
2929
|
3030
= note: expected unit type `()`
3131
found fn item `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}`
32+
help: use parentheses to call this function
33+
|
34+
LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>();
35+
| ^^
3236

3337
error[E0308]: mismatched types
3438
--> $DIR/substs-ppaux.rs:33:17
@@ -37,14 +41,16 @@ LL | fn baz() {}
3741
| -------- fn() {<i8 as Foo<'static, 'static, u8>>::baz} defined here
3842
...
3943
LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz;
40-
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41-
| | |
42-
| | expected `()`, found fn item
43-
| | help: use parentheses to call this function: `<i8 as Foo<'static, 'static, u8>>::baz()`
44+
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
45+
| |
4446
| expected due to this
4547
|
4648
= note: expected unit type `()`
4749
found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::baz}`
50+
help: use parentheses to call this function
51+
|
52+
LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz();
53+
| ^^
4854

4955
error[E0308]: mismatched types
5056
--> $DIR/substs-ppaux.rs:41:17
@@ -53,14 +59,16 @@ LL | fn foo<'z>() where &'z (): Sized {
5359
| -------------------------------- fn() {foo::<'static>} defined here
5460
...
5561
LL | let x: () = foo::<'static>;
56-
| -- ^^^^^^^^^^^^^^
57-
| | |
58-
| | expected `()`, found fn item
59-
| | help: use parentheses to call this function: `foo::<'static>()`
62+
| -- ^^^^^^^^^^^^^^ expected `()`, found fn item
63+
| |
6064
| expected due to this
6165
|
6266
= note: expected unit type `()`
6367
found fn item `fn() {foo::<'static>}`
68+
help: use parentheses to call this function
69+
|
70+
LL | let x: () = foo::<'static>();
71+
| ^^
6472

6573
error[E0277]: the size for values of type `str` cannot be known at compilation time
6674
--> $DIR/substs-ppaux.rs:49:5

‎src/test/ui/substs-ppaux.verbose.stderr

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ LL | fn bar<'a, T>() where T: 'a {}
55
| --------------------------- fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::bar::<ReStatic, char>} defined here
66
...
77
LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>;
8-
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9-
| | |
10-
| | expected `()`, found fn item
11-
| | help: use parentheses to call this function: `<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>()`
8+
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
9+
| |
1210
| expected due to this
1311
|
1412
= note: expected unit type `()`
1513
found fn item `fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::bar::<ReStatic, char>}`
14+
help: use parentheses to call this function
15+
|
16+
LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>();
17+
| ^^
1618

1719
error[E0308]: mismatched types
1820
--> $DIR/substs-ppaux.rs:25:17
@@ -21,14 +23,16 @@ LL | fn bar<'a, T>() where T: 'a {}
2123
| --------------------------- fn() {<i8 as Foo<ReStatic, ReStatic>>::bar::<ReStatic, char>} defined here
2224
...
2325
LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>;
24-
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
25-
| | |
26-
| | expected `()`, found fn item
27-
| | help: use parentheses to call this function: `<i8 as Foo<'static, 'static, u32>>::bar::<'static, char>()`
26+
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
27+
| |
2828
| expected due to this
2929
|
3030
= note: expected unit type `()`
3131
found fn item `fn() {<i8 as Foo<ReStatic, ReStatic>>::bar::<ReStatic, char>}`
32+
help: use parentheses to call this function
33+
|
34+
LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>();
35+
| ^^
3236

3337
error[E0308]: mismatched types
3438
--> $DIR/substs-ppaux.rs:33:17
@@ -37,14 +41,16 @@ LL | fn baz() {}
3741
| -------- fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::baz} defined here
3842
...
3943
LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz;
40-
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41-
| | |
42-
| | expected `()`, found fn item
43-
| | help: use parentheses to call this function: `<i8 as Foo<'static, 'static, u8>>::baz()`
44+
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
45+
| |
4446
| expected due to this
4547
|
4648
= note: expected unit type `()`
4749
found fn item `fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::baz}`
50+
help: use parentheses to call this function
51+
|
52+
LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz();
53+
| ^^
4854

4955
error[E0308]: mismatched types
5056
--> $DIR/substs-ppaux.rs:41:17
@@ -53,14 +59,16 @@ LL | fn foo<'z>() where &'z (): Sized {
5359
| -------------------------------- fn() {foo::<ReStatic>} defined here
5460
...
5561
LL | let x: () = foo::<'static>;
56-
| -- ^^^^^^^^^^^^^^
57-
| | |
58-
| | expected `()`, found fn item
59-
| | help: use parentheses to call this function: `foo::<'static>()`
62+
| -- ^^^^^^^^^^^^^^ expected `()`, found fn item
63+
| |
6064
| expected due to this
6165
|
6266
= note: expected unit type `()`
6367
found fn item `fn() {foo::<ReStatic>}`
68+
help: use parentheses to call this function
69+
|
70+
LL | let x: () = foo::<'static>();
71+
| ^^
6472

6573
error[E0277]: the size for values of type `str` cannot be known at compilation time
6674
--> $DIR/substs-ppaux.rs:49:5

‎src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ LL | fn bar(f: impl Future<Output=()>) {}
88
| --- ----------------- required by this bound in `bar`
99
...
1010
LL | bar(foo);
11-
| ^^^
12-
| |
13-
| the trait `std::future::Future` is not implemented for `fn() -> impl std::future::Future {foo}`
14-
| help: use parentheses to call the function: `foo()`
11+
| ^^^ the trait `std::future::Future` is not implemented for `fn() -> impl std::future::Future {foo}`
12+
|
13+
help: use parentheses to call the function
14+
|
15+
LL | bar(foo());
16+
| ^^
1517

1618
error[E0277]: the trait bound `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]: std::future::Future` is not satisfied
1719
--> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:12:9
@@ -22,10 +24,12 @@ LL | fn bar(f: impl Future<Output=()>) {}
2224
LL | let async_closure = async || ();
2325
| -------- consider calling this closure
2426
LL | bar(async_closure);
25-
| ^^^^^^^^^^^^^
26-
| |
27-
| the trait `std::future::Future` is not implemented for `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]`
28-
| help: use parentheses to call the closure: `async_closure()`
27+
| ^^^^^^^^^^^^^ the trait `std::future::Future` is not implemented for `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]`
28+
|
29+
help: use parentheses to call the closure
30+
|
31+
LL | bar(async_closure());
32+
| ^^
2933

3034
error: aborting due to 2 previous errors
3135

‎src/test/ui/suggestions/const-in-struct-pat.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ LL | let Thing { foo } = t;
99
| |
1010
| expected struct `std::string::String`, found struct `foo`
1111
| `foo` is interpreted as a unit struct, not a new binding
12-
| help: bind the struct field to a different name instead: `foo: other_foo`
12+
|
13+
help: bind the struct field to a different name instead
14+
|
15+
LL | let Thing { foo: other_foo } = t;
16+
| ^^^^^^^^^^^
1317

1418
error: aborting due to previous error
1519

‎src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ LL | fn bar(f: impl T<O=()>) {}
88
| --- ------- required by this bound in `bar`
99
...
1010
LL | bar(foo);
11-
| ^^^
12-
| |
13-
| the trait `T` is not implemented for `fn() -> impl T {foo}`
14-
| help: use parentheses to call the function: `foo()`
11+
| ^^^ the trait `T` is not implemented for `fn() -> impl T {foo}`
12+
|
13+
help: use parentheses to call the function
14+
|
15+
LL | bar(foo());
16+
| ^^
1517

1618
error[E0277]: the trait bound `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:23]: T` is not satisfied
1719
--> $DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:19:9
@@ -22,10 +24,12 @@ LL | fn bar(f: impl T<O=()>) {}
2224
LL | let closure = || S;
2325
| -- consider calling this closure
2426
LL | bar(closure);
25-
| ^^^^^^^
26-
| |
27-
| the trait `T` is not implemented for `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:23]`
28-
| help: use parentheses to call the closure: `closure()`
27+
| ^^^^^^^ the trait `T` is not implemented for `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:23]`
28+
|
29+
help: use parentheses to call the closure
30+
|
31+
LL | bar(closure());
32+
| ^^
2933

3034
error: aborting due to 2 previous errors
3135

‎src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr

Lines changed: 96 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ LL | fn foo(a: usize, b: usize) -> usize { a }
1919
| ----------------------------------- fn(usize, usize) -> usize {foo} defined here
2020
...
2121
LL | let _: usize = foo;
22-
| ----- ^^^
23-
| | |
24-
| | expected `usize`, found fn item
25-
| | help: use parentheses to call this function: `foo(a, b)`
22+
| ----- ^^^ expected `usize`, found fn item
23+
| |
2624
| expected due to this
2725
|
2826
= note: expected type `usize`
2927
found fn item `fn(usize, usize) -> usize {foo}`
28+
help: use parentheses to call this function
29+
|
30+
LL | let _: usize = foo(a, b);
31+
| ^^^^^^
3032

3133
error[E0308]: mismatched types
3234
--> $DIR/fn-or-tuple-struct-without-args.rs:30:16
@@ -35,14 +37,16 @@ LL | struct S(usize, usize);
3537
| ----------------------- fn(usize, usize) -> S {S} defined here
3638
...
3739
LL | let _: S = S;
38-
| - ^
39-
| | |
40-
| | expected struct `S`, found fn item
41-
| | help: use parentheses to instantiate this tuple struct: `S(_, _)`
40+
| - ^ expected struct `S`, found fn item
41+
| |
4242
| expected due to this
4343
|
4444
= note: expected struct `S`
4545
found fn item `fn(usize, usize) -> S {S}`
46+
help: use parentheses to instantiate this tuple struct
47+
|
48+
LL | let _: S = S(_, _);
49+
| ^^^^^^
4650

4751
error[E0308]: mismatched types
4852
--> $DIR/fn-or-tuple-struct-without-args.rs:31:20
@@ -51,14 +55,16 @@ LL | fn bar() -> usize { 42 }
5155
| ----------------- fn() -> usize {bar} defined here
5256
...
5357
LL | let _: usize = bar;
54-
| ----- ^^^
55-
| | |
56-
| | expected `usize`, found fn item
57-
| | help: use parentheses to call this function: `bar()`
58+
| ----- ^^^ expected `usize`, found fn item
59+
| |
5860
| expected due to this
5961
|
6062
= note: expected type `usize`
6163
found fn item `fn() -> usize {bar}`
64+
help: use parentheses to call this function
65+
|
66+
LL | let _: usize = bar();
67+
| ^^
6268

6369
error[E0308]: mismatched types
6470
--> $DIR/fn-or-tuple-struct-without-args.rs:32:16
@@ -67,14 +73,16 @@ LL | struct V();
6773
| ----------- fn() -> V {V} defined here
6874
...
6975
LL | let _: V = V;
70-
| - ^
71-
| | |
72-
| | expected struct `V`, found fn item
73-
| | help: use parentheses to instantiate this tuple struct: `V()`
76+
| - ^ expected struct `V`, found fn item
77+
| |
7478
| expected due to this
7579
|
7680
= note: expected struct `V`
7781
found fn item `fn() -> V {V}`
82+
help: use parentheses to instantiate this tuple struct
83+
|
84+
LL | let _: V = V();
85+
| ^^
7886

7987
error[E0308]: mismatched types
8088
--> $DIR/fn-or-tuple-struct-without-args.rs:33:20
@@ -83,14 +91,16 @@ LL | fn baz(x: usize, y: usize) -> usize { x }
8391
| ----------------------------------- fn(usize, usize) -> usize {<_ as T>::baz} defined here
8492
...
8593
LL | let _: usize = T::baz;
86-
| ----- ^^^^^^
87-
| | |
88-
| | expected `usize`, found fn item
89-
| | help: use parentheses to call this function: `T::baz(x, y)`
94+
| ----- ^^^^^^ expected `usize`, found fn item
95+
| |
9096
| expected due to this
9197
|
9298
= note: expected type `usize`
9399
found fn item `fn(usize, usize) -> usize {<_ as T>::baz}`
100+
help: use parentheses to call this function
101+
|
102+
LL | let _: usize = T::baz(x, y);
103+
| ^^^^^^
94104

95105
error[E0308]: mismatched types
96106
--> $DIR/fn-or-tuple-struct-without-args.rs:34:20
@@ -99,14 +109,16 @@ LL | fn bat(x: usize) -> usize { 42 }
99109
| ------------------------- fn(usize) -> usize {<_ as T>::bat} defined here
100110
...
101111
LL | let _: usize = T::bat;
102-
| ----- ^^^^^^
103-
| | |
104-
| | expected `usize`, found fn item
105-
| | help: use parentheses to call this function: `T::bat(x)`
112+
| ----- ^^^^^^ expected `usize`, found fn item
113+
| |
106114
| expected due to this
107115
|
108116
= note: expected type `usize`
109117
found fn item `fn(usize) -> usize {<_ as T>::bat}`
118+
help: use parentheses to call this function
119+
|
120+
LL | let _: usize = T::bat(x);
121+
| ^^^
110122

111123
error[E0308]: mismatched types
112124
--> $DIR/fn-or-tuple-struct-without-args.rs:35:16
@@ -115,14 +127,16 @@ LL | A(usize),
115127
| -------- fn(usize) -> E {E::A} defined here
116128
...
117129
LL | let _: E = E::A;
118-
| - ^^^^
119-
| | |
120-
| | expected enum `E`, found fn item
121-
| | help: use parentheses to instantiate this tuple variant: `E::A(_)`
130+
| - ^^^^ expected enum `E`, found fn item
131+
| |
122132
| expected due to this
123133
|
124134
= note: expected enum `E`
125135
found fn item `fn(usize) -> E {E::A}`
136+
help: use parentheses to instantiate this tuple variant
137+
|
138+
LL | let _: E = E::A(_);
139+
| ^^^
126140

127141
error[E0308]: mismatched types
128142
--> $DIR/fn-or-tuple-struct-without-args.rs:37:20
@@ -131,14 +145,16 @@ LL | fn baz(x: usize, y: usize) -> usize { x }
131145
| ----------------------------------- fn(usize, usize) -> usize {<X as T>::baz} defined here
132146
...
133147
LL | let _: usize = X::baz;
134-
| ----- ^^^^^^
135-
| | |
136-
| | expected `usize`, found fn item
137-
| | help: use parentheses to call this function: `X::baz(x, y)`
148+
| ----- ^^^^^^ expected `usize`, found fn item
149+
| |
138150
| expected due to this
139151
|
140152
= note: expected type `usize`
141153
found fn item `fn(usize, usize) -> usize {<X as T>::baz}`
154+
help: use parentheses to call this function
155+
|
156+
LL | let _: usize = X::baz(x, y);
157+
| ^^^^^^
142158

143159
error[E0308]: mismatched types
144160
--> $DIR/fn-or-tuple-struct-without-args.rs:38:20
@@ -147,14 +163,16 @@ LL | fn bat(x: usize) -> usize { 42 }
147163
| ------------------------- fn(usize) -> usize {<X as T>::bat} defined here
148164
...
149165
LL | let _: usize = X::bat;
150-
| ----- ^^^^^^
151-
| | |
152-
| | expected `usize`, found fn item
153-
| | help: use parentheses to call this function: `X::bat(x)`
166+
| ----- ^^^^^^ expected `usize`, found fn item
167+
| |
154168
| expected due to this
155169
|
156170
= note: expected type `usize`
157171
found fn item `fn(usize) -> usize {<X as T>::bat}`
172+
help: use parentheses to call this function
173+
|
174+
LL | let _: usize = X::bat(x);
175+
| ^^^
158176

159177
error[E0308]: mismatched types
160178
--> $DIR/fn-or-tuple-struct-without-args.rs:39:20
@@ -163,14 +181,16 @@ LL | fn bax(x: usize) -> usize { 42 }
163181
| ------------------------- fn(usize) -> usize {<X as T>::bax} defined here
164182
...
165183
LL | let _: usize = X::bax;
166-
| ----- ^^^^^^
167-
| | |
168-
| | expected `usize`, found fn item
169-
| | help: use parentheses to call this function: `X::bax(x)`
184+
| ----- ^^^^^^ expected `usize`, found fn item
185+
| |
170186
| expected due to this
171187
|
172188
= note: expected type `usize`
173189
found fn item `fn(usize) -> usize {<X as T>::bax}`
190+
help: use parentheses to call this function
191+
|
192+
LL | let _: usize = X::bax(x);
193+
| ^^^
174194

175195
error[E0308]: mismatched types
176196
--> $DIR/fn-or-tuple-struct-without-args.rs:40:20
@@ -179,14 +199,16 @@ LL | fn bach(x: usize) -> usize;
179199
| --------------------------- fn(usize) -> usize {<X as T>::bach} defined here
180200
...
181201
LL | let _: usize = X::bach;
182-
| ----- ^^^^^^^
183-
| | |
184-
| | expected `usize`, found fn item
185-
| | help: use parentheses to call this function: `X::bach(x)`
202+
| ----- ^^^^^^^ expected `usize`, found fn item
203+
| |
186204
| expected due to this
187205
|
188206
= note: expected type `usize`
189207
found fn item `fn(usize) -> usize {<X as T>::bach}`
208+
help: use parentheses to call this function
209+
|
210+
LL | let _: usize = X::bach(x);
211+
| ^^^
190212

191213
error[E0308]: mismatched types
192214
--> $DIR/fn-or-tuple-struct-without-args.rs:41:20
@@ -195,14 +217,16 @@ LL | fn ban(&self) -> usize { 42 }
195217
| ---------------------- for<'r> fn(&'r X) -> usize {<X as T>::ban} defined here
196218
...
197219
LL | let _: usize = X::ban;
198-
| ----- ^^^^^^
199-
| | |
200-
| | expected `usize`, found fn item
201-
| | help: use parentheses to call this function: `X::ban(_)`
220+
| ----- ^^^^^^ expected `usize`, found fn item
221+
| |
202222
| expected due to this
203223
|
204224
= note: expected type `usize`
205225
found fn item `for<'r> fn(&'r X) -> usize {<X as T>::ban}`
226+
help: use parentheses to call this function
227+
|
228+
LL | let _: usize = X::ban(_);
229+
| ^^^
206230

207231
error[E0308]: mismatched types
208232
--> $DIR/fn-or-tuple-struct-without-args.rs:42:20
@@ -211,41 +235,55 @@ LL | fn bal(&self) -> usize;
211235
| ----------------------- for<'r> fn(&'r X) -> usize {<X as T>::bal} defined here
212236
...
213237
LL | let _: usize = X::bal;
214-
| ----- ^^^^^^
215-
| | |
216-
| | expected `usize`, found fn item
217-
| | help: use parentheses to call this function: `X::bal(_)`
238+
| ----- ^^^^^^ expected `usize`, found fn item
239+
| |
218240
| expected due to this
219241
|
220242
= note: expected type `usize`
221243
found fn item `for<'r> fn(&'r X) -> usize {<X as T>::bal}`
244+
help: use parentheses to call this function
245+
|
246+
LL | let _: usize = X::bal(_);
247+
| ^^^
222248

223249
error[E0615]: attempted to take value of method `ban` on type `X`
224250
--> $DIR/fn-or-tuple-struct-without-args.rs:43:22
225251
|
226252
LL | let _: usize = X.ban;
227-
| ^^^ help: use parentheses to call the method: `ban()`
253+
| ^^^
254+
|
255+
help: use parentheses to call the method
256+
|
257+
LL | let _: usize = X.ban();
258+
| ^^
228259

229260
error[E0615]: attempted to take value of method `bal` on type `X`
230261
--> $DIR/fn-or-tuple-struct-without-args.rs:44:22
231262
|
232263
LL | let _: usize = X.bal;
233-
| ^^^ help: use parentheses to call the method: `bal()`
264+
| ^^^
265+
|
266+
help: use parentheses to call the method
267+
|
268+
LL | let _: usize = X.bal();
269+
| ^^
234270

235271
error[E0308]: mismatched types
236272
--> $DIR/fn-or-tuple-struct-without-args.rs:46:20
237273
|
238274
LL | let closure = || 42;
239275
| ----- the found closure
240276
LL | let _: usize = closure;
241-
| ----- ^^^^^^^
242-
| | |
243-
| | expected `usize`, found closure
244-
| | help: use parentheses to call this closure: `closure()`
277+
| ----- ^^^^^^^ expected `usize`, found closure
278+
| |
245279
| expected due to this
246280
|
247281
= note: expected type `usize`
248282
found closure `[closure@$DIR/fn-or-tuple-struct-without-args.rs:45:19: 45:24]`
283+
help: use parentheses to call this closure
284+
|
285+
LL | let _: usize = closure();
286+
| ^^
249287

250288
error: aborting due to 17 previous errors
251289

‎src/test/ui/suggestions/imm-ref-trait-object-literal.stderr

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ LL | fn foo<X: Trait>(_: X) {}
55
| --- ----- required by this bound in `foo`
66
...
77
LL | foo(&s);
8-
| -^
9-
| |
10-
| the trait `Trait` is not implemented for `&S`
11-
| help: consider changing this borrow's mutability: `&mut`
8+
| ^^ the trait `Trait` is not implemented for `&S`
129
|
1310
= help: the following implementations were found:
1411
<&'a mut S as Trait>
12+
help: consider changing this borrow's mutability
13+
|
14+
LL | foo(&mut s);
15+
| ^^^^
1516

1617
error[E0277]: the trait bound `S: Trait` is not satisfied
1718
--> $DIR/imm-ref-trait-object-literal.rs:13:7

‎src/test/ui/suggestions/method-missing-parentheses.stderr

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ error[E0615]: attempted to take value of method `collect` on type `std::vec::Int
88
--> $DIR/method-missing-parentheses.rs:2:32
99
|
1010
LL | let _ = vec![].into_iter().collect::<usize>;
11-
| ^^^^^^^---------
12-
| |
13-
| help: use parentheses to call the method: `collect::<usize>()`
11+
| ^^^^^^^
12+
|
13+
help: use parentheses to call the method
14+
|
15+
LL | let _ = vec![].into_iter().collect::<usize>();
16+
| ^^
1417

1518
error: aborting due to 2 previous errors
1619

‎src/test/ui/type-inference/or_else-multiple-type-params.stderr

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ error[E0282]: type annotations needed
22
--> $DIR/or_else-multiple-type-params.rs:7:10
33
|
44
LL | .or_else(|err| {
5-
| ^^^^^^^
6-
| |
7-
| cannot infer type for type parameter `F` declared on the method `or_else`
8-
| help: consider specifying the type arguments in the method call: `or_else::<F, O>`
5+
| ^^^^^^^ cannot infer type for type parameter `F` declared on the method `or_else`
6+
|
7+
help: consider specifying the type arguments in the method call
8+
|
9+
LL | .or_else::<F, O>(|err| {
10+
| ^^^^^^^^
911

1012
error: aborting due to previous error
1113

‎src/test/ui/type-inference/sort_by_key.stderr

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ error[E0282]: type annotations needed
22
--> $DIR/sort_by_key.rs:3:9
33
|
44
LL | lst.sort_by_key(|&(v, _)| v.iter().sum());
5-
| ^^^^^^^^^^^ --- help: consider specifying the type argument in the method call: `sum::<S>`
6-
| |
7-
| cannot infer type for type parameter `K` declared on the method `sort_by_key`
5+
| ^^^^^^^^^^^ cannot infer type for type parameter `K` declared on the method `sort_by_key`
6+
|
7+
help: consider specifying the type argument in the method call
8+
|
9+
LL | lst.sort_by_key(|&(v, _)| v.iter().sum::<S>());
10+
| ^^^^^
811

912
error: aborting due to previous error
1013

‎src/test/ui/type/type-annotation-needed.stderr

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ LL | fn foo<T: Into<String>>(x: i32) {}
55
| --- ------------ required by this bound in `foo`
66
...
77
LL | foo(42);
8-
| ^^^
9-
| |
10-
| cannot infer type for type parameter `T` declared on the function `foo`
11-
| help: consider specifying the type argument in the function call: `foo::<T>`
8+
| ^^^ cannot infer type for type parameter `T` declared on the function `foo`
129
|
1310
= note: cannot resolve `_: std::convert::Into<std::string::String>`
11+
help: consider specifying the type argument in the function call
12+
|
13+
LL | foo::<T>(42);
14+
| ^^^^^
1415

1516
error: aborting due to previous error
1617

‎src/test/ui/union/union-suggest-field.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ fn main() {
1717

1818
let y = u.calculate; //~ ERROR attempted to take value of method `calculate` on type `U`
1919
//~| HELP use parentheses to call the method
20-
//~| SUGGESTION calculate()
20+
//~| SUGGESTION ()
2121
}

‎src/test/ui/union/union-suggest-field.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ error[E0615]: attempted to take value of method `calculate` on type `U`
1414
--> $DIR/union-suggest-field.rs:18:15
1515
|
1616
LL | let y = u.calculate;
17-
| ^^^^^^^^^ help: use parentheses to call the method: `calculate()`
17+
| ^^^^^^^^^
18+
|
19+
help: use parentheses to call the method
20+
|
21+
LL | let y = u.calculate();
22+
| ^^
1823

1924
error: aborting due to 3 previous errors
2025

‎src/test/ui/unsized3.stderr

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ LL | f2::<X>(x);
77
| ^ doesn't have a size known at compile-time
88
...
99
LL | fn f2<X>(x: &X) {
10-
| -- -- help: consider relaxing the implicit `Sized` restriction: `: ?Sized`
11-
| |
12-
| required by this bound in `f2`
10+
| -- - required by this bound in `f2`
1311
|
1412
= help: the trait `std::marker::Sized` is not implemented for `X`
1513
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
14+
help: consider relaxing the implicit `Sized` restriction
15+
|
16+
LL | fn f2<X: ?Sized>(x: &X) {
17+
| ^^^^^^^^
1618

1719
error[E0277]: the size for values of type `X` cannot be known at compilation time
1820
--> $DIR/unsized3.rs:18:13
@@ -23,12 +25,14 @@ LL | f4::<X>(x);
2325
| ^ doesn't have a size known at compile-time
2426
...
2527
LL | fn f4<X: T>(x: &X) {
26-
| -- - - help: consider relaxing the implicit `Sized` restriction: `+ ?Sized`
27-
| |
28-
| required by this bound in `f4`
28+
| -- - required by this bound in `f4`
2929
|
3030
= help: the trait `std::marker::Sized` is not implemented for `X`
3131
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
32+
help: consider relaxing the implicit `Sized` restriction
33+
|
34+
LL | fn f4<X: T + ?Sized>(x: &X) {
35+
| ^^^^^^^^^
3236

3337
error[E0277]: the size for values of type `X` cannot be known at compilation time
3438
--> $DIR/unsized3.rs:33:8

0 commit comments

Comments
 (0)
Please sign in to comment.