mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Increase verbosity when suggesting subtle code changes
This commit is contained in:
parent
5ae85f43f4
commit
52fbd3e569
@ -3,7 +3,7 @@ use crate::infer::InferCtxt;
|
||||
use rustc::hir::map::Map;
|
||||
use rustc::ty::print::Print;
|
||||
use rustc::ty::{self, DefIdTree, Infer, Ty, TyVar};
|
||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Namespace};
|
||||
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
@ -462,24 +462,19 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
e: &Expr<'_>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
) {
|
||||
if let (Ok(snippet), Some(tables), None) = (
|
||||
self.tcx.sess.source_map().span_to_snippet(segment.ident.span),
|
||||
self.in_progress_tables,
|
||||
&segment.args,
|
||||
) {
|
||||
if let (Some(tables), None) = (self.in_progress_tables, &segment.args) {
|
||||
let borrow = tables.borrow();
|
||||
if let Some((DefKind::AssocFn, did)) = borrow.type_dependent_def(e.hir_id) {
|
||||
let generics = self.tcx.generics_of(did);
|
||||
if !generics.params.is_empty() {
|
||||
err.span_suggestion(
|
||||
segment.ident.span,
|
||||
err.span_suggestion_verbose(
|
||||
segment.ident.span.shrink_to_hi(),
|
||||
&format!(
|
||||
"consider specifying the type argument{} in the method call",
|
||||
if generics.params.len() > 1 { "s" } else { "" },
|
||||
pluralize!(generics.params.len()),
|
||||
),
|
||||
format!(
|
||||
"{}::<{}>",
|
||||
snippet,
|
||||
"::<{}>",
|
||||
generics
|
||||
.params
|
||||
.iter()
|
||||
|
@ -815,11 +815,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
// For example, if `expected_args_length` is 2, suggest `|_, _|`.
|
||||
if found_args.is_empty() && is_closure {
|
||||
let underscores = vec!["_"; expected_args.len()].join(", ");
|
||||
err.span_suggestion(
|
||||
err.span_suggestion_verbose(
|
||||
pipe_span,
|
||||
&format!(
|
||||
"consider changing the closure to take and ignore the expected argument{}",
|
||||
if expected_args.len() < 2 { "" } else { "s" }
|
||||
pluralize!(expected_args.len())
|
||||
),
|
||||
format!("|{}|", underscores),
|
||||
Applicability::MachineApplicable,
|
||||
@ -833,7 +833,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
.map(|(name, _)| name.to_owned())
|
||||
.collect::<Vec<String>>()
|
||||
.join(", ");
|
||||
err.span_suggestion(
|
||||
err.span_suggestion_verbose(
|
||||
found_span,
|
||||
"change the closure to take multiple arguments instead of a single tuple",
|
||||
format!("|{}|", sugg),
|
||||
@ -870,7 +870,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
String::new()
|
||||
},
|
||||
);
|
||||
err.span_suggestion(
|
||||
err.span_suggestion_verbose(
|
||||
found_span,
|
||||
"change the closure to accept a tuple instead of individual arguments",
|
||||
sugg,
|
||||
@ -1420,15 +1420,14 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
// |
|
||||
// = note: cannot resolve `_: Tt`
|
||||
|
||||
err.span_suggestion(
|
||||
span,
|
||||
err.span_suggestion_verbose(
|
||||
span.shrink_to_hi(),
|
||||
&format!(
|
||||
"consider specifying the type argument{} in the function call",
|
||||
if generics.params.len() > 1 { "s" } else { "" },
|
||||
pluralize!(generics.params.len()),
|
||||
),
|
||||
format!(
|
||||
"{}::<{}>",
|
||||
snippet,
|
||||
"::<{}>",
|
||||
generics
|
||||
.params
|
||||
.iter()
|
||||
@ -1590,7 +1589,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
[] => (span.shrink_to_hi(), ":"),
|
||||
[.., bound] => (bound.span().shrink_to_hi(), " + "),
|
||||
};
|
||||
err.span_suggestion(
|
||||
err.span_suggestion_verbose(
|
||||
span,
|
||||
"consider relaxing the implicit `Sized` restriction",
|
||||
format!("{} ?Sized", separator),
|
||||
|
@ -390,7 +390,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
}
|
||||
let hir = self.tcx.hir();
|
||||
// Get the name of the callable and the arguments to be used in the suggestion.
|
||||
let snippet = match hir.get_if_local(def_id) {
|
||||
let (snippet, sugg) = match hir.get_if_local(def_id) {
|
||||
Some(hir::Node::Expr(hir::Expr {
|
||||
kind: hir::ExprKind::Closure(_, decl, _, span, ..),
|
||||
..
|
||||
@ -401,7 +401,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
None => return,
|
||||
};
|
||||
let args = decl.inputs.iter().map(|_| "_").collect::<Vec<_>>().join(", ");
|
||||
format!("{}({})", name, args)
|
||||
let sugg = format!("({})", args);
|
||||
(format!("{}{}", name, sugg), sugg)
|
||||
}
|
||||
Some(hir::Node::Item(hir::Item {
|
||||
ident,
|
||||
@ -422,7 +423,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
format!("{}({})", ident, args)
|
||||
let sugg = format!("({})", args);
|
||||
(format!("{}{}", ident, sugg), sugg)
|
||||
}
|
||||
_ => return,
|
||||
};
|
||||
@ -431,10 +433,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
// an argument, the `obligation.cause.span` points at the expression
|
||||
// of the argument, so we can provide a suggestion. This is signaled
|
||||
// by `points_at_arg`. Otherwise, we give a more general note.
|
||||
err.span_suggestion(
|
||||
obligation.cause.span,
|
||||
err.span_suggestion_verbose(
|
||||
obligation.cause.span.shrink_to_hi(),
|
||||
&msg,
|
||||
snippet,
|
||||
sugg,
|
||||
Applicability::HasPlaceholders,
|
||||
);
|
||||
} else {
|
||||
@ -619,7 +621,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
.source_map()
|
||||
.span_take_while(span, |c| c.is_whitespace() || *c == '&');
|
||||
if points_at_arg && mutability == hir::Mutability::Not && refs_number > 0 {
|
||||
err.span_suggestion(
|
||||
err.span_suggestion_verbose(
|
||||
sp,
|
||||
"consider changing this borrow's mutability",
|
||||
"&mut ".to_string(),
|
||||
|
@ -137,7 +137,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
self_ty: Ty<'tcx>,
|
||||
call_expr: &hir::Expr<'_>,
|
||||
) {
|
||||
let has_params = self
|
||||
let params = self
|
||||
.probe_for_name(
|
||||
method_name.span,
|
||||
probe::Mode::MethodCall,
|
||||
@ -147,26 +147,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
call_expr.hir_id,
|
||||
ProbeScope::TraitsInScope,
|
||||
)
|
||||
.and_then(|pick| {
|
||||
.map(|pick| {
|
||||
let sig = self.tcx.fn_sig(pick.item.def_id);
|
||||
Ok(sig.inputs().skip_binder().len() > 1)
|
||||
});
|
||||
sig.inputs().skip_binder().len().saturating_sub(1)
|
||||
})
|
||||
.unwrap_or(0);
|
||||
|
||||
// Account for `foo.bar<T>`;
|
||||
let sugg_span = method_name.span.with_hi(call_expr.span.hi());
|
||||
let snippet = self
|
||||
.tcx
|
||||
.sess
|
||||
.source_map()
|
||||
.span_to_snippet(sugg_span)
|
||||
.unwrap_or_else(|_| method_name.to_string());
|
||||
let (suggestion, applicability) = if has_params.unwrap_or_default() {
|
||||
(format!("{}(...)", snippet), Applicability::HasPlaceholders)
|
||||
} else {
|
||||
(format!("{}()", snippet), Applicability::MaybeIncorrect)
|
||||
};
|
||||
let sugg_span = call_expr.span.shrink_to_hi();
|
||||
let (suggestion, applicability) = (
|
||||
format!("({})", (0..params).map(|_| "_").collect::<Vec<_>>().join(", ")),
|
||||
if params > 0 { Applicability::HasPlaceholders } else { Applicability::MaybeIncorrect },
|
||||
);
|
||||
|
||||
err.span_suggestion(sugg_span, msg, suggestion, applicability);
|
||||
err.span_suggestion_verbose(sugg_span, msg, suggestion, applicability);
|
||||
}
|
||||
|
||||
/// Performs method lookup. If lookup is successful, it will return the callee
|
||||
|
@ -4941,15 +4941,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if let Ok(code) = self.sess().source_map().span_to_snippet(expr.span) {
|
||||
err.span_suggestion(
|
||||
expr.span,
|
||||
&format!("use parentheses to {}", msg),
|
||||
format!("{}({})", code, sugg_call),
|
||||
applicability,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
err.span_suggestion_verbose(
|
||||
expr.span.shrink_to_hi(),
|
||||
&format!("use parentheses to {}", msg),
|
||||
format!("({})", sugg_call),
|
||||
applicability,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
false
|
||||
}
|
||||
|
@ -753,17 +753,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
res.descr(),
|
||||
),
|
||||
);
|
||||
let (msg, sugg) = match parent_pat {
|
||||
Some(Pat { kind: hir::PatKind::Struct(..), .. }) => (
|
||||
"bind the struct field to a different name instead",
|
||||
format!("{}: other_{}", ident, ident.as_str().to_lowercase()),
|
||||
),
|
||||
_ => (
|
||||
"introduce a new binding instead",
|
||||
format!("other_{}", ident.as_str().to_lowercase()),
|
||||
),
|
||||
match parent_pat {
|
||||
Some(Pat { kind: hir::PatKind::Struct(..), .. }) => {
|
||||
e.span_suggestion_verbose(
|
||||
ident.span.shrink_to_hi(),
|
||||
"bind the struct field to a different name instead",
|
||||
format!(": other_{}", ident.as_str().to_lowercase()),
|
||||
Applicability::HasPlaceholders,
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
let msg = "introduce a new binding instead";
|
||||
let sugg = format!("other_{}", ident.as_str().to_lowercase());
|
||||
e.span_suggestion(ident.span, msg, sugg, Applicability::HasPlaceholders);
|
||||
}
|
||||
};
|
||||
e.span_suggestion(ident.span, msg, sugg, Applicability::HasPlaceholders);
|
||||
}
|
||||
}
|
||||
e.emit();
|
||||
|
@ -2,7 +2,12 @@ error[E0615]: attempted to take value of method `method` on type `Foo`
|
||||
--> $DIR/E0615.rs:11:7
|
||||
|
|
||||
LL | f.method;
|
||||
| ^^^^^^ help: use parentheses to call the method: `method()`
|
||||
| ^^^^^^
|
||||
|
|
||||
help: use parentheses to call the method
|
||||
|
|
||||
LL | f.method();
|
||||
| ^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -2,15 +2,17 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim
|
||||
--> $DIR/extern-types-unsized.rs:22:20
|
||||
|
|
||||
LL | fn assert_sized<T>() { }
|
||||
| ------------ -- help: consider relaxing the implicit `Sized` restriction: `: ?Sized`
|
||||
| |
|
||||
| required by this bound in `assert_sized`
|
||||
| ------------ - required by this bound in `assert_sized`
|
||||
...
|
||||
LL | assert_sized::<A>();
|
||||
| ^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `std::marker::Sized` is not implemented for `A`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | fn assert_sized<T: ?Sized>() { }
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0277]: the size for values of type `A` cannot be known at compilation time
|
||||
--> $DIR/extern-types-unsized.rs:25:5
|
||||
|
@ -2,7 +2,12 @@ error[E0615]: attempted to take value of method `abs` on type `i32`
|
||||
--> $DIR/implicit-method-bind.rs:2:20
|
||||
|
|
||||
LL | let _f = 10i32.abs;
|
||||
| ^^^ help: use parentheses to call the method: `abs()`
|
||||
| ^^^
|
||||
|
|
||||
help: use parentheses to call the method
|
||||
|
|
||||
LL | let _f = 10i32.abs();
|
||||
| ^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -2,7 +2,12 @@ error[E0615]: attempted to take value of method `get` on type `std::boxed::Box<(
|
||||
--> $DIR/issue-13853-2.rs:5:43
|
||||
|
|
||||
LL | fn foo(res : Box<dyn ResponseHook>) { res.get }
|
||||
| ^^^ help: use parentheses to call the method: `get()`
|
||||
| ^^^
|
||||
|
|
||||
help: use parentheses to call the method
|
||||
|
|
||||
LL | fn foo(res : Box<dyn ResponseHook>) { res.get() }
|
||||
| ^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -2,9 +2,12 @@ error[E0616]: field `len` of struct `sub::S` is private
|
||||
--> $DIR/issue-26472.rs:11:13
|
||||
|
|
||||
LL | let v = s.len;
|
||||
| ^^---
|
||||
| |
|
||||
| help: a method `len` also exists, call it with parentheses: `len()`
|
||||
| ^^^^^
|
||||
|
|
||||
help: a method `len` also exists, call it with parentheses
|
||||
|
|
||||
LL | let v = s.len();
|
||||
| ^^
|
||||
|
||||
error[E0616]: field `len` of struct `sub::S` is private
|
||||
--> $DIR/issue-26472.rs:12:5
|
||||
|
@ -5,14 +5,16 @@ LL | struct Foo(u32);
|
||||
| ---------------- fn(u32) -> Foo {Foo} defined here
|
||||
LL |
|
||||
LL | fn test() -> Foo { Foo }
|
||||
| --- ^^^
|
||||
| | |
|
||||
| | expected struct `Foo`, found fn item
|
||||
| | help: use parentheses to instantiate this tuple struct: `Foo(_)`
|
||||
| --- ^^^ expected struct `Foo`, found fn item
|
||||
| |
|
||||
| expected `Foo` because of return type
|
||||
|
|
||||
= note: expected struct `Foo`
|
||||
found fn item `fn(u32) -> Foo {Foo}`
|
||||
help: use parentheses to instantiate this tuple struct
|
||||
|
|
||||
LL | fn test() -> Foo { Foo(_) }
|
||||
| ^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -2,13 +2,23 @@ error[E0615]: attempted to take value of method `get_x` on type `Point`
|
||||
--> $DIR/method-missing-call.rs:22:26
|
||||
|
|
||||
LL | .get_x;
|
||||
| ^^^^^ help: use parentheses to call the method: `get_x()`
|
||||
| ^^^^^
|
||||
|
|
||||
help: use parentheses to call the method
|
||||
|
|
||||
LL | .get_x();
|
||||
| ^^
|
||||
|
||||
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]>`
|
||||
--> $DIR/method-missing-call.rs:29:16
|
||||
|
|
||||
LL | .filter_map;
|
||||
| ^^^^^^^^^^ help: use parentheses to call the method: `filter_map(...)`
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
help: use parentheses to call the method
|
||||
|
|
||||
LL | .filter_map(_);
|
||||
| ^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -2,12 +2,13 @@ error[E0284]: type annotations needed
|
||||
--> $DIR/question-mark-type-infer.rs:12:21
|
||||
|
|
||||
LL | l.iter().map(f).collect()?
|
||||
| ^^^^^^^
|
||||
| |
|
||||
| cannot infer type
|
||||
| help: consider specifying the type argument in the method call: `collect::<B>`
|
||||
| ^^^^^^^ cannot infer type
|
||||
|
|
||||
= note: cannot resolve `<_ as std::ops::Try>::Ok == _`
|
||||
help: consider specifying the type argument in the method call
|
||||
|
|
||||
LL | l.iter().map(f).collect::<B>()?
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -2,14 +2,16 @@ error[E0308]: cannot coerce intrinsics to function pointers
|
||||
--> $DIR/reify-intrinsic.rs:6:64
|
||||
|
|
||||
LL | let _: unsafe extern "rust-intrinsic" fn(isize) -> usize = std::mem::transmute;
|
||||
| ------------------------------------------------- ^^^^^^^^^^^^^^^^^^^
|
||||
| | |
|
||||
| | cannot coerce intrinsics to function pointers
|
||||
| | help: use parentheses to call this function: `std::mem::transmute(...)`
|
||||
| ------------------------------------------------- ^^^^^^^^^^^^^^^^^^^ cannot coerce intrinsics to function pointers
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected fn pointer `unsafe extern "rust-intrinsic" fn(isize) -> usize`
|
||||
found fn item `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let _: unsafe extern "rust-intrinsic" fn(isize) -> usize = std::mem::transmute(...);
|
||||
| ^^^^^
|
||||
|
||||
error[E0606]: casting `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}` as `unsafe extern "rust-intrinsic" fn(isize) -> usize` is invalid
|
||||
--> $DIR/reify-intrinsic.rs:11:13
|
||||
|
@ -304,14 +304,16 @@ LL | Fn(u8),
|
||||
| ------ fn(u8) -> m::n::Z {m::n::Z::Fn} defined here
|
||||
...
|
||||
LL | let _: Z = Z::Fn;
|
||||
| - ^^^^^
|
||||
| | |
|
||||
| | expected enum `m::n::Z`, found fn item
|
||||
| | help: use parentheses to instantiate this tuple variant: `Z::Fn(_)`
|
||||
| - ^^^^^ expected enum `m::n::Z`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected enum `m::n::Z`
|
||||
found fn item `fn(u8) -> m::n::Z {m::n::Z::Fn}`
|
||||
help: use parentheses to instantiate this tuple variant
|
||||
|
|
||||
LL | let _: Z = Z::Fn(_);
|
||||
| ^^^
|
||||
|
||||
error[E0618]: expected function, found enum variant `Z::Unit`
|
||||
--> $DIR/privacy-enum-ctor.rs:31:17
|
||||
@ -336,14 +338,16 @@ LL | Fn(u8),
|
||||
| ------ fn(u8) -> m::E {m::E::Fn} defined here
|
||||
...
|
||||
LL | let _: E = m::E::Fn;
|
||||
| - ^^^^^^^^
|
||||
| | |
|
||||
| | expected enum `m::E`, found fn item
|
||||
| | help: use parentheses to instantiate this tuple variant: `m::E::Fn(_)`
|
||||
| - ^^^^^^^^ expected enum `m::E`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected enum `m::E`
|
||||
found fn item `fn(u8) -> m::E {m::E::Fn}`
|
||||
help: use parentheses to instantiate this tuple variant
|
||||
|
|
||||
LL | let _: E = m::E::Fn(_);
|
||||
| ^^^
|
||||
|
||||
error[E0618]: expected function, found enum variant `m::E::Unit`
|
||||
--> $DIR/privacy-enum-ctor.rs:47:16
|
||||
@ -368,14 +372,16 @@ LL | Fn(u8),
|
||||
| ------ fn(u8) -> m::E {m::E::Fn} defined here
|
||||
...
|
||||
LL | let _: E = E::Fn;
|
||||
| - ^^^^^
|
||||
| | |
|
||||
| | expected enum `m::E`, found fn item
|
||||
| | help: use parentheses to instantiate this tuple variant: `E::Fn(_)`
|
||||
| - ^^^^^ expected enum `m::E`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected enum `m::E`
|
||||
found fn item `fn(u8) -> m::E {m::E::Fn}`
|
||||
help: use parentheses to instantiate this tuple variant
|
||||
|
|
||||
LL | let _: E = E::Fn(_);
|
||||
| ^^^
|
||||
|
||||
error[E0618]: expected function, found enum variant `E::Unit`
|
||||
--> $DIR/privacy-enum-ctor.rs:55:16
|
||||
|
@ -2,12 +2,13 @@ error[E0282]: type annotations needed
|
||||
--> $DIR/type-annotations-needed-expr.rs:2:39
|
||||
|
|
||||
LL | let _ = (vec![1,2,3]).into_iter().sum() as f64;
|
||||
| ^^^
|
||||
| |
|
||||
| cannot infer type for type parameter `S` declared on the associated function `sum`
|
||||
| help: consider specifying the type argument in the method call: `sum::<S>`
|
||||
| ^^^ cannot infer type for type parameter `S` declared on the associated function `sum`
|
||||
|
|
||||
= note: type must be known at this point
|
||||
help: consider specifying the type argument in the method call
|
||||
|
|
||||
LL | let _ = (vec![1,2,3]).into_iter().sum::<S>() as f64;
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -2,15 +2,17 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t
|
||||
--> $DIR/str-mut-idx.rs:4:15
|
||||
|
|
||||
LL | fn bot<T>() -> T { loop {} }
|
||||
| --- -- help: consider relaxing the implicit `Sized` restriction: `: ?Sized`
|
||||
| |
|
||||
| required by this bound in `bot`
|
||||
| --- - required by this bound in `bot`
|
||||
...
|
||||
LL | s[1..2] = bot();
|
||||
| ^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `std::marker::Sized` is not implemented for `str`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | fn bot<T: ?Sized>() -> T { loop {} }
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
||||
--> $DIR/str-mut-idx.rs:4:5
|
||||
|
@ -5,14 +5,16 @@ LL | fn bar<'a, T>() where T: 'a {}
|
||||
| --------------------------- fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>} defined here
|
||||
...
|
||||
LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>;
|
||||
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| | |
|
||||
| | expected `()`, found fn item
|
||||
| | help: use parentheses to call this function: `<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>()`
|
||||
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected unit type `()`
|
||||
found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>();
|
||||
| ^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/substs-ppaux.rs:25:17
|
||||
@ -21,14 +23,16 @@ LL | fn bar<'a, T>() where T: 'a {}
|
||||
| --------------------------- fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>} defined here
|
||||
...
|
||||
LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>;
|
||||
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| | |
|
||||
| | expected `()`, found fn item
|
||||
| | help: use parentheses to call this function: `<i8 as Foo<'static, 'static, u32>>::bar::<'static, char>()`
|
||||
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected unit type `()`
|
||||
found fn item `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>();
|
||||
| ^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/substs-ppaux.rs:33:17
|
||||
@ -37,14 +41,16 @@ LL | fn baz() {}
|
||||
| -------- fn() {<i8 as Foo<'static, 'static, u8>>::baz} defined here
|
||||
...
|
||||
LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz;
|
||||
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| | |
|
||||
| | expected `()`, found fn item
|
||||
| | help: use parentheses to call this function: `<i8 as Foo<'static, 'static, u8>>::baz()`
|
||||
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected unit type `()`
|
||||
found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::baz}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz();
|
||||
| ^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/substs-ppaux.rs:41:17
|
||||
@ -53,14 +59,16 @@ LL | fn foo<'z>() where &'z (): Sized {
|
||||
| -------------------------------- fn() {foo::<'static>} defined here
|
||||
...
|
||||
LL | let x: () = foo::<'static>;
|
||||
| -- ^^^^^^^^^^^^^^
|
||||
| | |
|
||||
| | expected `()`, found fn item
|
||||
| | help: use parentheses to call this function: `foo::<'static>()`
|
||||
| -- ^^^^^^^^^^^^^^ expected `()`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected unit type `()`
|
||||
found fn item `fn() {foo::<'static>}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let x: () = foo::<'static>();
|
||||
| ^^
|
||||
|
||||
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
||||
--> $DIR/substs-ppaux.rs:49:5
|
||||
|
@ -5,14 +5,16 @@ LL | fn bar<'a, T>() where T: 'a {}
|
||||
| --------------------------- fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::bar::<ReStatic, char>} defined here
|
||||
...
|
||||
LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>;
|
||||
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| | |
|
||||
| | expected `()`, found fn item
|
||||
| | help: use parentheses to call this function: `<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>()`
|
||||
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected unit type `()`
|
||||
found fn item `fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::bar::<ReStatic, char>}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>();
|
||||
| ^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/substs-ppaux.rs:25:17
|
||||
@ -21,14 +23,16 @@ LL | fn bar<'a, T>() where T: 'a {}
|
||||
| --------------------------- fn() {<i8 as Foo<ReStatic, ReStatic>>::bar::<ReStatic, char>} defined here
|
||||
...
|
||||
LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>;
|
||||
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| | |
|
||||
| | expected `()`, found fn item
|
||||
| | help: use parentheses to call this function: `<i8 as Foo<'static, 'static, u32>>::bar::<'static, char>()`
|
||||
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected unit type `()`
|
||||
found fn item `fn() {<i8 as Foo<ReStatic, ReStatic>>::bar::<ReStatic, char>}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>();
|
||||
| ^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/substs-ppaux.rs:33:17
|
||||
@ -37,14 +41,16 @@ LL | fn baz() {}
|
||||
| -------- fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::baz} defined here
|
||||
...
|
||||
LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz;
|
||||
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| | |
|
||||
| | expected `()`, found fn item
|
||||
| | help: use parentheses to call this function: `<i8 as Foo<'static, 'static, u8>>::baz()`
|
||||
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected unit type `()`
|
||||
found fn item `fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::baz}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz();
|
||||
| ^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/substs-ppaux.rs:41:17
|
||||
@ -53,14 +59,16 @@ LL | fn foo<'z>() where &'z (): Sized {
|
||||
| -------------------------------- fn() {foo::<ReStatic>} defined here
|
||||
...
|
||||
LL | let x: () = foo::<'static>;
|
||||
| -- ^^^^^^^^^^^^^^
|
||||
| | |
|
||||
| | expected `()`, found fn item
|
||||
| | help: use parentheses to call this function: `foo::<'static>()`
|
||||
| -- ^^^^^^^^^^^^^^ expected `()`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected unit type `()`
|
||||
found fn item `fn() {foo::<ReStatic>}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let x: () = foo::<'static>();
|
||||
| ^^
|
||||
|
||||
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
||||
--> $DIR/substs-ppaux.rs:49:5
|
||||
|
@ -8,10 +8,12 @@ LL | fn bar(f: impl Future<Output=()>) {}
|
||||
| --- ----------------- required by this bound in `bar`
|
||||
...
|
||||
LL | bar(foo);
|
||||
| ^^^
|
||||
| |
|
||||
| the trait `std::future::Future` is not implemented for `fn() -> impl std::future::Future {foo}`
|
||||
| help: use parentheses to call the function: `foo()`
|
||||
| ^^^ the trait `std::future::Future` is not implemented for `fn() -> impl std::future::Future {foo}`
|
||||
|
|
||||
help: use parentheses to call the function
|
||||
|
|
||||
LL | bar(foo());
|
||||
| ^^
|
||||
|
||||
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
|
||||
--> $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=()>) {}
|
||||
LL | let async_closure = async || ();
|
||||
| -------- consider calling this closure
|
||||
LL | bar(async_closure);
|
||||
| ^^^^^^^^^^^^^
|
||||
| |
|
||||
| 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]`
|
||||
| help: use parentheses to call the closure: `async_closure()`
|
||||
| ^^^^^^^^^^^^^ 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]`
|
||||
|
|
||||
help: use parentheses to call the closure
|
||||
|
|
||||
LL | bar(async_closure());
|
||||
| ^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -9,7 +9,11 @@ LL | let Thing { foo } = t;
|
||||
| |
|
||||
| expected struct `std::string::String`, found struct `foo`
|
||||
| `foo` is interpreted as a unit struct, not a new binding
|
||||
| help: bind the struct field to a different name instead: `foo: other_foo`
|
||||
|
|
||||
help: bind the struct field to a different name instead
|
||||
|
|
||||
LL | let Thing { foo: other_foo } = t;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -8,10 +8,12 @@ LL | fn bar(f: impl T<O=()>) {}
|
||||
| --- ------- required by this bound in `bar`
|
||||
...
|
||||
LL | bar(foo);
|
||||
| ^^^
|
||||
| |
|
||||
| the trait `T` is not implemented for `fn() -> impl T {foo}`
|
||||
| help: use parentheses to call the function: `foo()`
|
||||
| ^^^ the trait `T` is not implemented for `fn() -> impl T {foo}`
|
||||
|
|
||||
help: use parentheses to call the function
|
||||
|
|
||||
LL | bar(foo());
|
||||
| ^^
|
||||
|
||||
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
|
||||
--> $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=()>) {}
|
||||
LL | let closure = || S;
|
||||
| -- consider calling this closure
|
||||
LL | bar(closure);
|
||||
| ^^^^^^^
|
||||
| |
|
||||
| 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]`
|
||||
| help: use parentheses to call the closure: `closure()`
|
||||
| ^^^^^^^ 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]`
|
||||
|
|
||||
help: use parentheses to call the closure
|
||||
|
|
||||
LL | bar(closure());
|
||||
| ^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -19,14 +19,16 @@ LL | fn foo(a: usize, b: usize) -> usize { a }
|
||||
| ----------------------------------- fn(usize, usize) -> usize {foo} defined here
|
||||
...
|
||||
LL | let _: usize = foo;
|
||||
| ----- ^^^
|
||||
| | |
|
||||
| | expected `usize`, found fn item
|
||||
| | help: use parentheses to call this function: `foo(a, b)`
|
||||
| ----- ^^^ expected `usize`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected type `usize`
|
||||
found fn item `fn(usize, usize) -> usize {foo}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let _: usize = foo(a, b);
|
||||
| ^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/fn-or-tuple-struct-without-args.rs:30:16
|
||||
@ -35,14 +37,16 @@ LL | struct S(usize, usize);
|
||||
| ----------------------- fn(usize, usize) -> S {S} defined here
|
||||
...
|
||||
LL | let _: S = S;
|
||||
| - ^
|
||||
| | |
|
||||
| | expected struct `S`, found fn item
|
||||
| | help: use parentheses to instantiate this tuple struct: `S(_, _)`
|
||||
| - ^ expected struct `S`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected struct `S`
|
||||
found fn item `fn(usize, usize) -> S {S}`
|
||||
help: use parentheses to instantiate this tuple struct
|
||||
|
|
||||
LL | let _: S = S(_, _);
|
||||
| ^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/fn-or-tuple-struct-without-args.rs:31:20
|
||||
@ -51,14 +55,16 @@ LL | fn bar() -> usize { 42 }
|
||||
| ----------------- fn() -> usize {bar} defined here
|
||||
...
|
||||
LL | let _: usize = bar;
|
||||
| ----- ^^^
|
||||
| | |
|
||||
| | expected `usize`, found fn item
|
||||
| | help: use parentheses to call this function: `bar()`
|
||||
| ----- ^^^ expected `usize`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected type `usize`
|
||||
found fn item `fn() -> usize {bar}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let _: usize = bar();
|
||||
| ^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/fn-or-tuple-struct-without-args.rs:32:16
|
||||
@ -67,14 +73,16 @@ LL | struct V();
|
||||
| ----------- fn() -> V {V} defined here
|
||||
...
|
||||
LL | let _: V = V;
|
||||
| - ^
|
||||
| | |
|
||||
| | expected struct `V`, found fn item
|
||||
| | help: use parentheses to instantiate this tuple struct: `V()`
|
||||
| - ^ expected struct `V`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected struct `V`
|
||||
found fn item `fn() -> V {V}`
|
||||
help: use parentheses to instantiate this tuple struct
|
||||
|
|
||||
LL | let _: V = V();
|
||||
| ^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/fn-or-tuple-struct-without-args.rs:33:20
|
||||
@ -83,14 +91,16 @@ LL | fn baz(x: usize, y: usize) -> usize { x }
|
||||
| ----------------------------------- fn(usize, usize) -> usize {<_ as T>::baz} defined here
|
||||
...
|
||||
LL | let _: usize = T::baz;
|
||||
| ----- ^^^^^^
|
||||
| | |
|
||||
| | expected `usize`, found fn item
|
||||
| | help: use parentheses to call this function: `T::baz(x, y)`
|
||||
| ----- ^^^^^^ expected `usize`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected type `usize`
|
||||
found fn item `fn(usize, usize) -> usize {<_ as T>::baz}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let _: usize = T::baz(x, y);
|
||||
| ^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/fn-or-tuple-struct-without-args.rs:34:20
|
||||
@ -99,14 +109,16 @@ LL | fn bat(x: usize) -> usize { 42 }
|
||||
| ------------------------- fn(usize) -> usize {<_ as T>::bat} defined here
|
||||
...
|
||||
LL | let _: usize = T::bat;
|
||||
| ----- ^^^^^^
|
||||
| | |
|
||||
| | expected `usize`, found fn item
|
||||
| | help: use parentheses to call this function: `T::bat(x)`
|
||||
| ----- ^^^^^^ expected `usize`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected type `usize`
|
||||
found fn item `fn(usize) -> usize {<_ as T>::bat}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let _: usize = T::bat(x);
|
||||
| ^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/fn-or-tuple-struct-without-args.rs:35:16
|
||||
@ -115,14 +127,16 @@ LL | A(usize),
|
||||
| -------- fn(usize) -> E {E::A} defined here
|
||||
...
|
||||
LL | let _: E = E::A;
|
||||
| - ^^^^
|
||||
| | |
|
||||
| | expected enum `E`, found fn item
|
||||
| | help: use parentheses to instantiate this tuple variant: `E::A(_)`
|
||||
| - ^^^^ expected enum `E`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected enum `E`
|
||||
found fn item `fn(usize) -> E {E::A}`
|
||||
help: use parentheses to instantiate this tuple variant
|
||||
|
|
||||
LL | let _: E = E::A(_);
|
||||
| ^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/fn-or-tuple-struct-without-args.rs:37:20
|
||||
@ -131,14 +145,16 @@ LL | fn baz(x: usize, y: usize) -> usize { x }
|
||||
| ----------------------------------- fn(usize, usize) -> usize {<X as T>::baz} defined here
|
||||
...
|
||||
LL | let _: usize = X::baz;
|
||||
| ----- ^^^^^^
|
||||
| | |
|
||||
| | expected `usize`, found fn item
|
||||
| | help: use parentheses to call this function: `X::baz(x, y)`
|
||||
| ----- ^^^^^^ expected `usize`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected type `usize`
|
||||
found fn item `fn(usize, usize) -> usize {<X as T>::baz}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let _: usize = X::baz(x, y);
|
||||
| ^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/fn-or-tuple-struct-without-args.rs:38:20
|
||||
@ -147,14 +163,16 @@ LL | fn bat(x: usize) -> usize { 42 }
|
||||
| ------------------------- fn(usize) -> usize {<X as T>::bat} defined here
|
||||
...
|
||||
LL | let _: usize = X::bat;
|
||||
| ----- ^^^^^^
|
||||
| | |
|
||||
| | expected `usize`, found fn item
|
||||
| | help: use parentheses to call this function: `X::bat(x)`
|
||||
| ----- ^^^^^^ expected `usize`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected type `usize`
|
||||
found fn item `fn(usize) -> usize {<X as T>::bat}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let _: usize = X::bat(x);
|
||||
| ^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/fn-or-tuple-struct-without-args.rs:39:20
|
||||
@ -163,14 +181,16 @@ LL | fn bax(x: usize) -> usize { 42 }
|
||||
| ------------------------- fn(usize) -> usize {<X as T>::bax} defined here
|
||||
...
|
||||
LL | let _: usize = X::bax;
|
||||
| ----- ^^^^^^
|
||||
| | |
|
||||
| | expected `usize`, found fn item
|
||||
| | help: use parentheses to call this function: `X::bax(x)`
|
||||
| ----- ^^^^^^ expected `usize`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected type `usize`
|
||||
found fn item `fn(usize) -> usize {<X as T>::bax}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let _: usize = X::bax(x);
|
||||
| ^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/fn-or-tuple-struct-without-args.rs:40:20
|
||||
@ -179,14 +199,16 @@ LL | fn bach(x: usize) -> usize;
|
||||
| --------------------------- fn(usize) -> usize {<X as T>::bach} defined here
|
||||
...
|
||||
LL | let _: usize = X::bach;
|
||||
| ----- ^^^^^^^
|
||||
| | |
|
||||
| | expected `usize`, found fn item
|
||||
| | help: use parentheses to call this function: `X::bach(x)`
|
||||
| ----- ^^^^^^^ expected `usize`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected type `usize`
|
||||
found fn item `fn(usize) -> usize {<X as T>::bach}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let _: usize = X::bach(x);
|
||||
| ^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/fn-or-tuple-struct-without-args.rs:41:20
|
||||
@ -195,14 +217,16 @@ LL | fn ban(&self) -> usize { 42 }
|
||||
| ---------------------- for<'r> fn(&'r X) -> usize {<X as T>::ban} defined here
|
||||
...
|
||||
LL | let _: usize = X::ban;
|
||||
| ----- ^^^^^^
|
||||
| | |
|
||||
| | expected `usize`, found fn item
|
||||
| | help: use parentheses to call this function: `X::ban(_)`
|
||||
| ----- ^^^^^^ expected `usize`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected type `usize`
|
||||
found fn item `for<'r> fn(&'r X) -> usize {<X as T>::ban}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let _: usize = X::ban(_);
|
||||
| ^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/fn-or-tuple-struct-without-args.rs:42:20
|
||||
@ -211,26 +235,38 @@ LL | fn bal(&self) -> usize;
|
||||
| ----------------------- for<'r> fn(&'r X) -> usize {<X as T>::bal} defined here
|
||||
...
|
||||
LL | let _: usize = X::bal;
|
||||
| ----- ^^^^^^
|
||||
| | |
|
||||
| | expected `usize`, found fn item
|
||||
| | help: use parentheses to call this function: `X::bal(_)`
|
||||
| ----- ^^^^^^ expected `usize`, found fn item
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected type `usize`
|
||||
found fn item `for<'r> fn(&'r X) -> usize {<X as T>::bal}`
|
||||
help: use parentheses to call this function
|
||||
|
|
||||
LL | let _: usize = X::bal(_);
|
||||
| ^^^
|
||||
|
||||
error[E0615]: attempted to take value of method `ban` on type `X`
|
||||
--> $DIR/fn-or-tuple-struct-without-args.rs:43:22
|
||||
|
|
||||
LL | let _: usize = X.ban;
|
||||
| ^^^ help: use parentheses to call the method: `ban()`
|
||||
| ^^^
|
||||
|
|
||||
help: use parentheses to call the method
|
||||
|
|
||||
LL | let _: usize = X.ban();
|
||||
| ^^
|
||||
|
||||
error[E0615]: attempted to take value of method `bal` on type `X`
|
||||
--> $DIR/fn-or-tuple-struct-without-args.rs:44:22
|
||||
|
|
||||
LL | let _: usize = X.bal;
|
||||
| ^^^ help: use parentheses to call the method: `bal()`
|
||||
| ^^^
|
||||
|
|
||||
help: use parentheses to call the method
|
||||
|
|
||||
LL | let _: usize = X.bal();
|
||||
| ^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/fn-or-tuple-struct-without-args.rs:46:20
|
||||
@ -238,14 +274,16 @@ error[E0308]: mismatched types
|
||||
LL | let closure = || 42;
|
||||
| ----- the found closure
|
||||
LL | let _: usize = closure;
|
||||
| ----- ^^^^^^^
|
||||
| | |
|
||||
| | expected `usize`, found closure
|
||||
| | help: use parentheses to call this closure: `closure()`
|
||||
| ----- ^^^^^^^ expected `usize`, found closure
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected type `usize`
|
||||
found closure `[closure@$DIR/fn-or-tuple-struct-without-args.rs:45:19: 45:24]`
|
||||
help: use parentheses to call this closure
|
||||
|
|
||||
LL | let _: usize = closure();
|
||||
| ^^
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
|
||||
|
@ -5,13 +5,14 @@ LL | fn foo<X: Trait>(_: X) {}
|
||||
| --- ----- required by this bound in `foo`
|
||||
...
|
||||
LL | foo(&s);
|
||||
| -^
|
||||
| |
|
||||
| the trait `Trait` is not implemented for `&S`
|
||||
| help: consider changing this borrow's mutability: `&mut`
|
||||
| ^^ the trait `Trait` is not implemented for `&S`
|
||||
|
|
||||
= help: the following implementations were found:
|
||||
<&'a mut S as Trait>
|
||||
help: consider changing this borrow's mutability
|
||||
|
|
||||
LL | foo(&mut s);
|
||||
| ^^^^
|
||||
|
||||
error[E0277]: the trait bound `S: Trait` is not satisfied
|
||||
--> $DIR/imm-ref-trait-object-literal.rs:13:7
|
||||
|
@ -8,9 +8,12 @@ error[E0615]: attempted to take value of method `collect` on type `std::vec::Int
|
||||
--> $DIR/method-missing-parentheses.rs:2:32
|
||||
|
|
||||
LL | let _ = vec![].into_iter().collect::<usize>;
|
||||
| ^^^^^^^---------
|
||||
| |
|
||||
| help: use parentheses to call the method: `collect::<usize>()`
|
||||
| ^^^^^^^
|
||||
|
|
||||
help: use parentheses to call the method
|
||||
|
|
||||
LL | let _ = vec![].into_iter().collect::<usize>();
|
||||
| ^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -2,10 +2,12 @@ error[E0282]: type annotations needed
|
||||
--> $DIR/or_else-multiple-type-params.rs:7:10
|
||||
|
|
||||
LL | .or_else(|err| {
|
||||
| ^^^^^^^
|
||||
| |
|
||||
| cannot infer type for type parameter `F` declared on the associated function `or_else`
|
||||
| help: consider specifying the type arguments in the method call: `or_else::<F, O>`
|
||||
| ^^^^^^^ cannot infer type for type parameter `F` declared on the associated function `or_else`
|
||||
|
|
||||
help: consider specifying the type arguments in the method call
|
||||
|
|
||||
LL | .or_else::<F, O>(|err| {
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -2,9 +2,12 @@ error[E0282]: type annotations needed
|
||||
--> $DIR/sort_by_key.rs:3:9
|
||||
|
|
||||
LL | lst.sort_by_key(|&(v, _)| v.iter().sum());
|
||||
| ^^^^^^^^^^^ --- help: consider specifying the type argument in the method call: `sum::<S>`
|
||||
| |
|
||||
| cannot infer type for type parameter `K` declared on the associated function `sort_by_key`
|
||||
| ^^^^^^^^^^^ cannot infer type for type parameter `K` declared on the associated function `sort_by_key`
|
||||
|
|
||||
help: consider specifying the type argument in the method call
|
||||
|
|
||||
LL | lst.sort_by_key(|&(v, _)| v.iter().sum::<S>());
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -5,12 +5,13 @@ LL | fn foo<T: Into<String>>(x: i32) {}
|
||||
| --- ------------ required by this bound in `foo`
|
||||
...
|
||||
LL | foo(42);
|
||||
| ^^^
|
||||
| |
|
||||
| cannot infer type for type parameter `T` declared on the function `foo`
|
||||
| help: consider specifying the type argument in the function call: `foo::<T>`
|
||||
| ^^^ cannot infer type for type parameter `T` declared on the function `foo`
|
||||
|
|
||||
= note: cannot resolve `_: std::convert::Into<std::string::String>`
|
||||
help: consider specifying the type argument in the function call
|
||||
|
|
||||
LL | foo::<T>(42);
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -17,5 +17,5 @@ fn main() {
|
||||
|
||||
let y = u.calculate; //~ ERROR attempted to take value of method `calculate` on type `U`
|
||||
//~| HELP use parentheses to call the method
|
||||
//~| SUGGESTION calculate()
|
||||
//~| SUGGESTION ()
|
||||
}
|
||||
|
@ -14,7 +14,12 @@ error[E0615]: attempted to take value of method `calculate` on type `U`
|
||||
--> $DIR/union-suggest-field.rs:18:15
|
||||
|
|
||||
LL | let y = u.calculate;
|
||||
| ^^^^^^^^^ help: use parentheses to call the method: `calculate()`
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
help: use parentheses to call the method
|
||||
|
|
||||
LL | let y = u.calculate();
|
||||
| ^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
@ -7,12 +7,14 @@ LL | f2::<X>(x);
|
||||
| ^ doesn't have a size known at compile-time
|
||||
...
|
||||
LL | fn f2<X>(x: &X) {
|
||||
| -- -- help: consider relaxing the implicit `Sized` restriction: `: ?Sized`
|
||||
| |
|
||||
| required by this bound in `f2`
|
||||
| -- - required by this bound in `f2`
|
||||
|
|
||||
= help: the trait `std::marker::Sized` is not implemented for `X`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | fn f2<X: ?Sized>(x: &X) {
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0277]: the size for values of type `X` cannot be known at compilation time
|
||||
--> $DIR/unsized3.rs:18:13
|
||||
@ -23,12 +25,14 @@ LL | f4::<X>(x);
|
||||
| ^ doesn't have a size known at compile-time
|
||||
...
|
||||
LL | fn f4<X: T>(x: &X) {
|
||||
| -- - - help: consider relaxing the implicit `Sized` restriction: `+ ?Sized`
|
||||
| |
|
||||
| required by this bound in `f4`
|
||||
| -- - required by this bound in `f4`
|
||||
|
|
||||
= help: the trait `std::marker::Sized` is not implemented for `X`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
LL | fn f4<X: T + ?Sized>(x: &X) {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error[E0277]: the size for values of type `X` cannot be known at compilation time
|
||||
--> $DIR/unsized3.rs:33:8
|
||||
|
Loading…
Reference in New Issue
Block a user