clean up logic
This commit is contained in:
parent
e843245716
commit
cfa0b07c8d
@ -398,6 +398,16 @@ rustc_queries! {
|
||||
typeck_tables.map(|tables| &*tcx.arena.alloc(tables))
|
||||
}
|
||||
}
|
||||
query diagnostic_only_typeck_tables_of(key: DefId) -> &'tcx ty::TypeckTables<'tcx> {
|
||||
cache_on_disk_if { key.is_local() }
|
||||
load_cached(tcx, id) {
|
||||
let typeck_tables: Option<ty::TypeckTables<'tcx>> = tcx
|
||||
.queries.on_disk_cache
|
||||
.try_load_query_result(tcx, id);
|
||||
|
||||
typeck_tables.map(|tables| &*tcx.arena.alloc(tables))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Other {
|
||||
|
@ -2770,30 +2770,15 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
let tcx = self.tcx();
|
||||
|
||||
// We proactively collect all the infered type params to emit a single error per fn def.
|
||||
let mut placeholder_types = vec![];
|
||||
let mut output_placeholder_types = vec![];
|
||||
|
||||
let input_tys = decl.inputs.iter().map(|a| {
|
||||
let mut visitor = PlaceholderHirTyCollector::new();
|
||||
visitor.visit_ty(&a);
|
||||
if visitor.0.is_empty() || self.allow_ty_infer() {
|
||||
self.ty_of_arg(a, None)
|
||||
} else {
|
||||
placeholder_types.extend(visitor.0);
|
||||
tcx.types.err
|
||||
}
|
||||
});
|
||||
let mut visitor = PlaceholderHirTyCollector::new();
|
||||
for ty in &decl.inputs {
|
||||
visitor.visit_ty(ty);
|
||||
}
|
||||
let input_tys = decl.inputs.iter().map(|a| self.ty_of_arg(a, None));
|
||||
let output_ty = match decl.output {
|
||||
hir::Return(ref output) => {
|
||||
let mut visitor = PlaceholderHirTyCollector::new();
|
||||
visitor.visit_ty(output);
|
||||
let is_infer = if let hir::TyKind::Infer = output.kind { true } else { false };
|
||||
if (is_infer || !visitor.0.is_empty()) && !self.allow_ty_infer() {
|
||||
output_placeholder_types.extend(visitor.0);
|
||||
tcx.types.err
|
||||
} else {
|
||||
self.ast_ty_to_ty(output)
|
||||
}
|
||||
self.ast_ty_to_ty(output)
|
||||
}
|
||||
hir::DefaultReturn(..) => tcx.mk_unit(),
|
||||
};
|
||||
@ -2803,15 +2788,15 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
let bare_fn_ty =
|
||||
ty::Binder::bind(tcx.mk_fn_sig(input_tys, output_ty, decl.c_variadic, unsafety, abi));
|
||||
|
||||
placeholder_types.extend(output_placeholder_types);
|
||||
|
||||
crate::collect::placeholder_type_error(
|
||||
tcx,
|
||||
ident_span.unwrap_or(DUMMY_SP),
|
||||
generic_params,
|
||||
placeholder_types,
|
||||
ident_span.is_some(),
|
||||
);
|
||||
if !self.allow_ty_infer() {
|
||||
crate::collect::placeholder_type_error(
|
||||
tcx,
|
||||
ident_span.unwrap_or(DUMMY_SP),
|
||||
generic_params,
|
||||
visitor.0,
|
||||
ident_span.is_some(),
|
||||
);
|
||||
}
|
||||
|
||||
// Find any late-bound regions declared in return type that do
|
||||
// not appear in the arguments. These are not well-formed.
|
||||
|
@ -756,6 +756,7 @@ pub fn provide(providers: &mut Providers<'_>) {
|
||||
*providers = Providers {
|
||||
typeck_item_bodies,
|
||||
typeck_tables_of,
|
||||
diagnostic_only_typeck_tables_of,
|
||||
has_typeck_tables,
|
||||
adt_destructor,
|
||||
used_trait_imports,
|
||||
@ -941,7 +942,26 @@ where
|
||||
val.fold_with(&mut FixupFolder { tcx })
|
||||
}
|
||||
|
||||
fn typeck_tables_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::TypeckTables<'_> {
|
||||
fn typeck_tables_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &ty::TypeckTables<'tcx> {
|
||||
let fallback = move || tcx.type_of(def_id);
|
||||
typeck_tables_of_with_fallback(tcx, def_id, fallback)
|
||||
}
|
||||
|
||||
/// Used only to get `TypeckTables` for type inference during error recovery.
|
||||
/// Currently only used for type inference of `static`s and `const`s to avoid type cycle errors.
|
||||
fn diagnostic_only_typeck_tables_of<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
def_id: DefId,
|
||||
) -> &ty::TypeckTables<'tcx> {
|
||||
let fallback = move || tcx.types.err;
|
||||
typeck_tables_of_with_fallback(tcx, def_id, fallback)
|
||||
}
|
||||
|
||||
fn typeck_tables_of_with_fallback<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
def_id: DefId,
|
||||
fallback: impl Fn() -> Ty<'tcx> + 'tcx,
|
||||
) -> &'tcx ty::TypeckTables<'tcx> {
|
||||
// Closures' tables come from their outermost function,
|
||||
// as they are part of the same "inference environment".
|
||||
let outer_def_id = tcx.closure_base_def_id(def_id);
|
||||
@ -990,7 +1010,7 @@ fn typeck_tables_of(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::TypeckTables<'_> {
|
||||
hir::TyKind::Infer => Some(AstConv::ast_ty_to_ty(&fcx, ty)),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap_or_else(|| tcx.type_of(def_id));
|
||||
.unwrap_or_else(fallback);
|
||||
let expected_type = fcx.normalize_associated_types_in(body.value.span, &expected_type);
|
||||
fcx.require_type_is_sized(expected_type, body.value.span, traits::ConstSized);
|
||||
|
||||
|
@ -160,15 +160,7 @@ crate fn placeholder_type_error(
|
||||
format!(", {}", type_name),
|
||||
));
|
||||
}
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
placeholder_types.clone(),
|
||||
E0121,
|
||||
"the type placeholder `_` is not allowed within types on item signatures",
|
||||
);
|
||||
for span in &placeholder_types {
|
||||
err.span_label(*span, "not allowed in type signatures");
|
||||
}
|
||||
let mut err = bad_placeholder_type(tcx, placeholder_types);
|
||||
if suggest {
|
||||
err.multipart_suggestion(
|
||||
"use type parameters instead",
|
||||
@ -184,14 +176,8 @@ fn reject_placeholder_type_signatures_in_item(tcx: TyCtxt<'tcx>, item: &'tcx hir
|
||||
hir::ItemKind::Union(_, generics)
|
||||
| hir::ItemKind::Enum(_, generics)
|
||||
| hir::ItemKind::Struct(_, generics) => (&generics.params[..], true),
|
||||
hir::ItemKind::Static(ty, ..) => {
|
||||
if let hir::TyKind::Infer = ty.kind {
|
||||
return; // We handle it elsewhere to attempt to suggest an appropriate type.
|
||||
} else {
|
||||
(&[][..], false)
|
||||
}
|
||||
}
|
||||
hir::ItemKind::TyAlias(_, generics) => (&generics.params[..], false),
|
||||
// hir::ItemKind::Static(ty, ..) => {
|
||||
// hir::ItemKind::Fn(..) |
|
||||
// hir::ItemKind::Const(..) => {} // We handle these elsewhere to suggest appropriate type.
|
||||
_ => return,
|
||||
@ -255,15 +241,21 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Utility types and common code for the above passes.
|
||||
|
||||
fn bad_placeholder_type(tcx: TyCtxt<'tcx>, span: Span) -> errors::DiagnosticBuilder<'tcx> {
|
||||
let mut diag = struct_span_err!(
|
||||
fn bad_placeholder_type(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
mut spans: Vec<Span>,
|
||||
) -> errors::DiagnosticBuilder<'tcx> {
|
||||
spans.sort();
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
span,
|
||||
spans.clone(),
|
||||
E0121,
|
||||
"the type placeholder `_` is not allowed within types on item signatures",
|
||||
);
|
||||
diag.span_label(span, "not allowed in type signatures");
|
||||
diag
|
||||
for span in spans {
|
||||
err.span_label(span, "not allowed in type signatures");
|
||||
}
|
||||
err
|
||||
}
|
||||
|
||||
impl ItemCtxt<'tcx> {
|
||||
@ -298,7 +290,7 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
|
||||
}
|
||||
|
||||
fn ty_infer(&self, _: Option<&ty::GenericParamDef>, span: Span) -> Ty<'tcx> {
|
||||
self.tcx().sess.delay_span_bug(span, "bad placeholder type, but no error was emitted");
|
||||
self.tcx().sess.delay_span_bug(span, "bad placeholder type");
|
||||
self.tcx().types.err
|
||||
}
|
||||
|
||||
@ -308,7 +300,7 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
|
||||
_: Option<&ty::GenericParamDef>,
|
||||
span: Span,
|
||||
) -> &'tcx Const<'tcx> {
|
||||
bad_placeholder_type(self.tcx(), span).emit();
|
||||
bad_placeholder_type(self.tcx(), vec![span]).emit();
|
||||
|
||||
self.tcx().consts.err
|
||||
}
|
||||
@ -1233,7 +1225,7 @@ fn infer_placeholder_type(
|
||||
span: Span,
|
||||
item_ident: Ident,
|
||||
) -> Ty<'_> {
|
||||
let ty = tcx.typeck_tables_of(def_id).node_type(body_id.hir_id);
|
||||
let ty = tcx.diagnostic_only_typeck_tables_of(def_id).node_type(body_id.hir_id);
|
||||
|
||||
// If this came from a free `const` or `static mut?` item,
|
||||
// then the user may have written e.g. `const A = 42;`.
|
||||
@ -1253,7 +1245,7 @@ fn infer_placeholder_type(
|
||||
.emit();
|
||||
}
|
||||
None => {
|
||||
let mut diag = bad_placeholder_type(tcx, span);
|
||||
let mut diag = bad_placeholder_type(tcx, vec![span]);
|
||||
if ty != tcx.types.err {
|
||||
diag.span_suggestion(
|
||||
span,
|
||||
@ -1284,12 +1276,8 @@ fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
|
||||
}
|
||||
TraitItemKind::Const(ref ty, body_id) => body_id
|
||||
.and_then(|body_id| {
|
||||
if let hir::TyKind::Infer = ty.kind {
|
||||
if is_infer_ty(ty) {
|
||||
Some(infer_placeholder_type(tcx, def_id, body_id, ty.span, item.ident))
|
||||
} else if is_infer_ty(ty) {
|
||||
// Infering this would cause a cycle error.
|
||||
tcx.sess.delay_span_bug(ty.span, "`_` placeholder but no error emitted");
|
||||
Some(tcx.types.err)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -1307,12 +1295,8 @@ fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
|
||||
tcx.mk_fn_def(def_id, substs)
|
||||
}
|
||||
ImplItemKind::Const(ref ty, body_id) => {
|
||||
if let hir::TyKind::Infer = ty.kind {
|
||||
if is_infer_ty(ty) {
|
||||
infer_placeholder_type(tcx, def_id, body_id, ty.span, item.ident)
|
||||
} else if is_infer_ty(ty) {
|
||||
// Infering this would cause a cycle error.
|
||||
tcx.sess.delay_span_bug(ty.span, "`_` placeholder but no error emitted");
|
||||
tcx.types.err
|
||||
} else {
|
||||
icx.to_ty(ty)
|
||||
}
|
||||
@ -1336,12 +1320,8 @@ fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
|
||||
Node::Item(item) => {
|
||||
match item.kind {
|
||||
ItemKind::Static(ref ty, .., body_id) | ItemKind::Const(ref ty, body_id) => {
|
||||
if let hir::TyKind::Infer = ty.kind {
|
||||
if is_infer_ty(ty) {
|
||||
infer_placeholder_type(tcx, def_id, body_id, ty.span, item.ident)
|
||||
} else if is_infer_ty(ty) {
|
||||
// Infering this would cause a cycle error.
|
||||
tcx.sess.delay_span_bug(ty.span, "`_` placeholder but no error emitted");
|
||||
tcx.types.err
|
||||
} else {
|
||||
icx.to_ty(ty)
|
||||
}
|
||||
@ -1818,7 +1798,7 @@ crate fn is_infer_ty(ty: &hir::Ty<'_>) -> bool {
|
||||
hir::TyKind::Slice(ty) | hir::TyKind::Array(ty, _) => is_infer_ty(ty),
|
||||
hir::TyKind::Tup(tys)
|
||||
if !tys.is_empty()
|
||||
&& tys.iter().all(|ty| match ty.kind {
|
||||
&& tys.iter().any(|ty| match ty.kind {
|
||||
hir::TyKind::Infer => true,
|
||||
_ => false,
|
||||
}) =>
|
||||
@ -1858,12 +1838,14 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
|
||||
match get_infer_ret_ty(&sig.decl.output) {
|
||||
Some(ty) => {
|
||||
let fn_sig = tcx.typeck_tables_of(def_id).liberated_fn_sigs()[hir_id];
|
||||
let mut diag = bad_placeholder_type(tcx, ty.span);
|
||||
let mut visitor = PlaceholderHirTyCollector::new();
|
||||
visitor.visit_ty(ty);
|
||||
let mut diag = bad_placeholder_type(tcx, visitor.0);
|
||||
let ret_ty = fn_sig.output();
|
||||
if ret_ty != tcx.types.err {
|
||||
diag.span_suggestion(
|
||||
ty.span,
|
||||
"replace this with the correct return type",
|
||||
"replace with the correct return type",
|
||||
ret_ty.to_string(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
|
@ -5,7 +5,7 @@ LL | fn foo() -> _ { 5 }
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace this with the correct return type: `i32`
|
||||
| help: replace with the correct return type: `i32`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/E0121.rs:3:13
|
||||
|
@ -30,6 +30,7 @@ fn test7(x: _) { let _x: usize = x; }
|
||||
|
||||
fn test8(_f: fn() -> _) { }
|
||||
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
|
||||
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
|
||||
|
||||
struct Test9;
|
||||
|
||||
@ -79,6 +80,7 @@ pub fn main() {
|
||||
|
||||
fn fn_test8(_f: fn() -> _) { }
|
||||
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
|
||||
//~| ERROR the type placeholder `_` is not allowed within types on item signatures
|
||||
|
||||
struct FnTest9;
|
||||
|
||||
@ -128,4 +130,4 @@ trait T {
|
||||
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
|
||||
fn assoc_fn_test3() -> _;
|
||||
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
|
||||
}
|
||||
}
|
||||
|
@ -5,16 +5,17 @@ LL | fn test() -> _ { 5 }
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace this with the correct return type: `i32`
|
||||
| help: replace with the correct return type: `i32`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:7:15
|
||||
--> $DIR/typeck_type_placeholder_item.rs:7:16
|
||||
|
|
||||
LL | fn test2() -> (_, _) { (5, 5) }
|
||||
| ^^^^^^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace this with the correct return type: `(i32, i32)`
|
||||
| -^--^-
|
||||
| || |
|
||||
| || not allowed in type signatures
|
||||
| |not allowed in type signatures
|
||||
| help: replace with the correct return type: `(i32, i32)`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:10:15
|
||||
@ -35,12 +36,10 @@ LL | static TEST4: _ = 145;
|
||||
| help: replace `_` with the correct type: `i32`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:16:16
|
||||
--> $DIR/typeck_type_placeholder_item.rs:16:15
|
||||
|
|
||||
LL | static TEST5: (_, _) = (1, 2);
|
||||
| ^ ^ not allowed in type signatures
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| ^^^^^^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:19:13
|
||||
@ -86,6 +85,12 @@ 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:31:22
|
||||
|
|
||||
LL | fn test8(_f: fn() -> _) { }
|
||||
| ^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:31:22
|
||||
|
|
||||
@ -98,7 +103,7 @@ 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:53:8
|
||||
--> $DIR/typeck_type_placeholder_item.rs:54:8
|
||||
|
|
||||
LL | a: _,
|
||||
| ^ not allowed in type signatures
|
||||
@ -117,25 +122,26 @@ LL | b: (T, T),
|
||||
|
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:59:21
|
||||
--> $DIR/typeck_type_placeholder_item.rs:60:21
|
||||
|
|
||||
LL | fn fn_test() -> _ { 5 }
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace this with the correct return type: `i32`
|
||||
| help: replace with the correct return type: `i32`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:62:22
|
||||
--> $DIR/typeck_type_placeholder_item.rs:63:23
|
||||
|
|
||||
LL | fn fn_test2() -> (_, _) { (5, 5) }
|
||||
| ^^^^^^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace this with the correct return type: `(i32, i32)`
|
||||
| -^--^-
|
||||
| || |
|
||||
| || not allowed in type signatures
|
||||
| |not allowed in type signatures
|
||||
| help: replace with the correct return type: `(i32, i32)`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:65:22
|
||||
--> $DIR/typeck_type_placeholder_item.rs:66:22
|
||||
|
|
||||
LL | static FN_TEST3: _ = "test";
|
||||
| ^
|
||||
@ -144,7 +150,7 @@ LL | static FN_TEST3: _ = "test";
|
||||
| help: replace `_` with the correct type: `&'static str`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:68:22
|
||||
--> $DIR/typeck_type_placeholder_item.rs:69:22
|
||||
|
|
||||
LL | static FN_TEST4: _ = 145;
|
||||
| ^
|
||||
@ -153,15 +159,13 @@ LL | static FN_TEST4: _ = 145;
|
||||
| help: replace `_` with the correct type: `i32`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:71:23
|
||||
--> $DIR/typeck_type_placeholder_item.rs:72:22
|
||||
|
|
||||
LL | static FN_TEST5: (_, _) = (1, 2);
|
||||
| ^ ^ not allowed in type signatures
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| ^^^^^^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:74:20
|
||||
--> $DIR/typeck_type_placeholder_item.rs:75:20
|
||||
|
|
||||
LL | fn fn_test6(_: _) { }
|
||||
| ^ not allowed in type signatures
|
||||
@ -172,7 +176,7 @@ 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:77:20
|
||||
--> $DIR/typeck_type_placeholder_item.rs:78:20
|
||||
|
|
||||
LL | fn fn_test7(x: _) { let _x: usize = x; }
|
||||
| ^ not allowed in type signatures
|
||||
@ -183,7 +187,13 @@ 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:80:29
|
||||
--> $DIR/typeck_type_placeholder_item.rs:81:29
|
||||
|
|
||||
LL | fn fn_test8(_f: fn() -> _) { }
|
||||
| ^ not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:81:29
|
||||
|
|
||||
LL | fn fn_test8(_f: fn() -> _) { }
|
||||
| ^ not allowed in type signatures
|
||||
@ -194,7 +204,7 @@ 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:102:12
|
||||
--> $DIR/typeck_type_placeholder_item.rs:104:12
|
||||
|
|
||||
LL | a: _,
|
||||
| ^ not allowed in type signatures
|
||||
@ -213,41 +223,40 @@ LL | b: (T, T),
|
||||
|
|
||||
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/typeck_type_placeholder_item.rs:107:27
|
||||
--> $DIR/typeck_type_placeholder_item.rs:109:27
|
||||
|
|
||||
LL | fn fn_test11(_: _) -> (_, _) { panic!() }
|
||||
| ^^^^^^ cannot infer type
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:107:27
|
||||
--> $DIR/typeck_type_placeholder_item.rs:109:28
|
||||
|
|
||||
LL | fn fn_test11(_: _) -> (_, _) { panic!() }
|
||||
| ^^^^^^ not allowed in type signatures
|
||||
| ^ ^ not allowed in type signatures
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:111:29
|
||||
--> $DIR/typeck_type_placeholder_item.rs:113:30
|
||||
|
|
||||
LL | fn fn_test12(x: i32) -> (_, _) { (x, x) }
|
||||
| ^^^^^^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace this with the correct return type: `(i32, i32)`
|
||||
| -^--^-
|
||||
| || |
|
||||
| || not allowed in type signatures
|
||||
| |not allowed in type signatures
|
||||
| help: replace with the correct return type: `(i32, i32)`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:114:21
|
||||
--> $DIR/typeck_type_placeholder_item.rs:116:33
|
||||
|
|
||||
LL | fn fn_test13(x: _) -> (i32, _) { (x, x) }
|
||||
| ^ ^ not allowed in type signatures
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
|
|
||||
help: use type parameters instead
|
||||
|
|
||||
LL | fn fn_test13<T>(x: T) -> (i32, T) { (x, x) }
|
||||
| ^^^ ^ ^
|
||||
| ------^-
|
||||
| | |
|
||||
| | not allowed in type signatures
|
||||
| help: replace with the correct return type: `(i32, i32)`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:119:31
|
||||
--> $DIR/typeck_type_placeholder_item.rs:121:31
|
||||
|
|
||||
LL | fn method_test1(&self, x: _);
|
||||
| ^ not allowed in type signatures
|
||||
@ -258,7 +267,7 @@ 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:121:31
|
||||
--> $DIR/typeck_type_placeholder_item.rs:123:31
|
||||
|
|
||||
LL | fn method_test2(&self, x: _) -> _;
|
||||
| ^ ^ not allowed in type signatures
|
||||
@ -271,7 +280,7 @@ 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:123:31
|
||||
--> $DIR/typeck_type_placeholder_item.rs:125:31
|
||||
|
|
||||
LL | fn method_test3(&self) -> _;
|
||||
| ^ not allowed in type signatures
|
||||
@ -282,7 +291,7 @@ 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:125:26
|
||||
--> $DIR/typeck_type_placeholder_item.rs:127:26
|
||||
|
|
||||
LL | fn assoc_fn_test1(x: _);
|
||||
| ^ not allowed in type signatures
|
||||
@ -293,7 +302,7 @@ 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:127:26
|
||||
--> $DIR/typeck_type_placeholder_item.rs:129:26
|
||||
|
|
||||
LL | fn assoc_fn_test2(x: _) -> _;
|
||||
| ^ ^ not allowed in type signatures
|
||||
@ -306,7 +315,7 @@ 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:129:28
|
||||
--> $DIR/typeck_type_placeholder_item.rs:131:28
|
||||
|
|
||||
LL | fn assoc_fn_test3() -> _;
|
||||
| ^ not allowed in type signatures
|
||||
@ -317,16 +326,16 @@ 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:37:24
|
||||
--> $DIR/typeck_type_placeholder_item.rs:38:24
|
||||
|
|
||||
LL | fn test9(&self) -> _ { () }
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace this with the correct return type: `()`
|
||||
| help: replace with the correct return type: `()`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:40:27
|
||||
--> $DIR/typeck_type_placeholder_item.rs:41:27
|
||||
|
|
||||
LL | fn test10(&self, _x : _) { }
|
||||
| ^ not allowed in type signatures
|
||||
@ -337,16 +346,16 @@ 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:45:24
|
||||
--> $DIR/typeck_type_placeholder_item.rs:46:24
|
||||
|
|
||||
LL | fn clone(&self) -> _ { Test9 }
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace this with the correct return type: `Test9`
|
||||
| help: replace with the correct return type: `Test9`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:48:37
|
||||
--> $DIR/typeck_type_placeholder_item.rs:49:37
|
||||
|
|
||||
LL | fn clone_from(&mut self, other: _) { *self = Test9; }
|
||||
| ^ not allowed in type signatures
|
||||
@ -357,16 +366,16 @@ 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:86:31
|
||||
--> $DIR/typeck_type_placeholder_item.rs:88:31
|
||||
|
|
||||
LL | fn fn_test9(&self) -> _ { () }
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace this with the correct return type: `()`
|
||||
| help: replace with the correct return type: `()`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:89:34
|
||||
--> $DIR/typeck_type_placeholder_item.rs:91:34
|
||||
|
|
||||
LL | fn fn_test10(&self, _x : _) { }
|
||||
| ^ not allowed in type signatures
|
||||
@ -377,16 +386,16 @@ 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:94:28
|
||||
--> $DIR/typeck_type_placeholder_item.rs:96:28
|
||||
|
|
||||
LL | fn clone(&self) -> _ { FnTest9 }
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace this with the correct return type: `main::FnTest9`
|
||||
| help: replace with the correct return type: `main::FnTest9`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item.rs:97:41
|
||||
--> $DIR/typeck_type_placeholder_item.rs:99:41
|
||||
|
|
||||
LL | fn clone_from(&mut self, other: _) { *self = FnTest9; }
|
||||
| ^ not allowed in type signatures
|
||||
@ -396,7 +405,7 @@ help: use type parameters instead
|
||||
LL | fn clone_from<T>(&mut self, other: T) { *self = FnTest9; }
|
||||
| ^^^ ^
|
||||
|
||||
error: aborting due to 38 previous errors
|
||||
error: aborting due to 40 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0121, E0282.
|
||||
For more information about an error, try `rustc --explain E0121`.
|
||||
|
@ -5,7 +5,7 @@ LL | fn test1() -> _ { Some(42) }
|
||||
| ^
|
||||
| |
|
||||
| not allowed in type signatures
|
||||
| help: replace this with the correct return type: `std::option::Option<i32>`
|
||||
| help: replace with the correct return type: `std::option::Option<i32>`
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/typeck_type_placeholder_item_help.rs:7:14
|
||||
|
Loading…
x
Reference in New Issue
Block a user