generics: &[hir::GenericParam<'_>],
placeholder_types: Vec<Span>,
suggest: bool,
+ is_fn: bool,
) {
if placeholder_types.is_empty() {
return;
}
let mut err = bad_placeholder_type(tcx, placeholder_types);
- if suggest {
+
+ // Suggest, but only if it is not a function
+ if suggest && !is_fn {
err.multipart_suggestion(
"use type parameters instead",
sugg,
let mut visitor = PlaceholderHirTyCollector::default();
visitor.visit_item(item);
- placeholder_type_error(tcx, Some(generics.span), &generics.params[..], visitor.0, suggest);
+ placeholder_type_error(
+ tcx,
+ Some(generics.span),
+ &generics.params[..],
+ visitor.0,
+ suggest,
+ false
+ );
}
impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
// Account for `const C: _;`.
let mut visitor = PlaceholderHirTyCollector::default();
visitor.visit_trait_item(trait_item);
- placeholder_type_error(tcx, None, &[], visitor.0, false);
+ placeholder_type_error(tcx, None, &[], visitor.0, false, false);
}
hir::TraitItemKind::Type(_, Some(_)) => {
// Account for `type T = _;`.
let mut visitor = PlaceholderHirTyCollector::default();
visitor.visit_trait_item(trait_item);
- placeholder_type_error(tcx, None, &[], visitor.0, false);
+ placeholder_type_error(tcx, None, &[], visitor.0, false, false);
}
hir::TraitItemKind::Type(_, None) => {
// even if there is no concrete type.
let mut visitor = PlaceholderHirTyCollector::default();
visitor.visit_trait_item(trait_item);
- placeholder_type_error(tcx, None, &[], visitor.0, false);
+ placeholder_type_error(tcx, None, &[], visitor.0, false, false);
}
};
// Account for `type T = _;`
let mut visitor = PlaceholderHirTyCollector::default();
visitor.visit_impl_item(impl_item);
- placeholder_type_error(tcx, None, &[], visitor.0, false);
+ placeholder_type_error(tcx, None, &[], visitor.0, false, false);
}
hir::ImplItemKind::Const(..) => {}
}
|
LL | fn test6(_: _) { }
| ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn test6<T>(_: T) { }
- | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:24:18
|
LL | fn test6_b<T>(_: _, _: T) { }
| ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn test6_b<T, U>(_: U, _: T) { }
- | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:27:30
|
LL | fn test6_c<T, K, L, A, B>(_: _, _: (T, K, L, A, B)) { }
| ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn test6_c<T, K, L, A, B, U>(_: U, _: (T, K, L, A, B)) { }
- | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:30:13
|
LL | fn test7(x: _) { let _x: usize = x; }
| ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn test7<T>(x: T) { let _x: usize = x; }
- | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:33:22
|
LL | fn test8(_f: fn() -> _) { }
- | ^
- | |
- | not allowed in type signatures
- | help: use type parameters instead: `T`
+ | ^ not allowed in type signatures
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:33:22
|
LL | fn test8(_f: fn() -> _) { }
| ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn test8<T>(_f: fn() -> T) { }
- | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:47:26
|
LL | fn fn_test6(_: _) { }
| ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn fn_test6<T>(_: T) { }
- | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:97:20
|
LL | fn fn_test7(x: _) { let _x: usize = x; }
| ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn fn_test7<T>(x: T) { let _x: usize = x; }
- | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:100:29
|
LL | fn fn_test8(_f: fn() -> _) { }
- | ^
- | |
- | not allowed in type signatures
- | help: use type parameters instead: `T`
+ | ^ not allowed in type signatures
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:100:29
|
LL | fn fn_test8(_f: fn() -> _) { }
| ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn fn_test8<T>(_f: fn() -> T) { }
- | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:123:12
|
LL | fn method_test1(&self, x: _);
| ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn method_test1<T>(&self, x: T);
- | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:142:31
| ^ ^ not allowed in type signatures
| |
| not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn method_test2<T>(&self, x: T) -> T;
- | ^^^ ^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:144:31
|
LL | fn method_test3(&self) -> _;
| ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn method_test3<T>(&self) -> T;
- | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:146:26
|
LL | fn assoc_fn_test1(x: _);
| ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn assoc_fn_test1<T>(x: T);
- | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:148:26
| ^ ^ not allowed in type signatures
| |
| not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn assoc_fn_test2<T>(x: T) -> T;
- | ^^^ ^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:150:28
|
LL | fn assoc_fn_test3() -> _;
| ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn assoc_fn_test3<T>() -> T;
- | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:190:14
|
LL | fn test10(&self, _x : _) { }
| ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn test10<T>(&self, _x : T) { }
- | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:58:24
|
LL | fn clone_from(&mut self, other: _) { *self = Test9; }
| ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn clone_from<T>(&mut self, other: T) { *self = Test9; }
- | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:107:31
|
LL | fn fn_test10(&self, _x : _) { }
| ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn fn_test10<T>(&self, _x : T) { }
- | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:115:28
|
LL | fn clone_from(&mut self, other: _) { *self = FnTest9; }
| ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn clone_from<T>(&mut self, other: T) { *self = FnTest9; }
- | ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:201:14