Make error message less awkward
This commit is contained in:
parent
23ab0f2cdc
commit
0d907c17a8
16 changed files with 32 additions and 32 deletions
|
|
@ -117,17 +117,17 @@ pub(super) fn check_fn<'a, 'tcx>(
|
|||
|
||||
fcx.typeck_results.borrow_mut().liberated_fn_sigs_mut().insert(fn_id, fn_sig);
|
||||
|
||||
let return_or_body_span = match decl.output {
|
||||
hir::FnRetTy::DefaultReturn(_) => body.value.span,
|
||||
hir::FnRetTy::Return(ty) => ty.span,
|
||||
};
|
||||
|
||||
// We checked the root's ret ty during wfcheck, but not the child.
|
||||
if fcx.tcx.is_typeck_child(fn_def_id.to_def_id()) {
|
||||
let return_or_body_span = match decl.output {
|
||||
hir::FnRetTy::DefaultReturn(_) => body.value.span,
|
||||
hir::FnRetTy::Return(ty) => ty.span,
|
||||
};
|
||||
|
||||
fcx.require_type_is_sized(
|
||||
declared_ret_ty,
|
||||
return_or_body_span,
|
||||
ObligationCauseCode::WellFormed(None),
|
||||
ObligationCauseCode::SizedReturnType,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1765,7 +1765,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
};
|
||||
|
||||
err.code(E0746);
|
||||
err.primary_message("return type cannot have an unboxed trait object");
|
||||
err.primary_message("return type cannot be a trait object without pointer indirection");
|
||||
err.children.clear();
|
||||
|
||||
let span = obligation.cause.span;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/E0746.rs:8:13
|
||||
|
|
||||
LL | fn foo() -> dyn Trait { Struct }
|
||||
|
|
@ -13,7 +13,7 @@ help: alternatively, box the return type, and wrap all of the returned values in
|
|||
LL | fn foo() -> Box<dyn Trait> { Box::new(Struct) }
|
||||
| ++++ + +++++++++ +
|
||||
|
||||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/E0746.rs:11:13
|
||||
|
|
||||
LL | fn bar() -> dyn Trait {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ impl DynIncompatible for B {
|
|||
}
|
||||
|
||||
fn car() -> dyn DynIncompatible { //~ ERROR the trait `DynIncompatible` is not dyn compatible
|
||||
//~^ ERROR return type cannot have an unboxed trait object
|
||||
//~^ ERROR return type cannot be a trait object without pointer indirection
|
||||
if true {
|
||||
return A;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ help: alternatively, consider constraining `foo` so it does not apply to trait o
|
|||
LL | fn foo() -> Self where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:22:13
|
||||
|
|
||||
LL | fn car() -> dyn DynIncompatible {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ LL | fn bar() -> (usize, dyn Trait) { (42, Struct) }
|
|||
= note: required because it appears within the type `(usize, (dyn Trait + 'static))`
|
||||
= note: the return type of a function must have a statically known size
|
||||
|
||||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:13
|
||||
|
|
||||
LL | fn bap() -> Trait { Struct }
|
||||
|
|
@ -33,7 +33,7 @@ help: alternatively, box the return type, and wrap all of the returned values in
|
|||
LL | fn bap() -> Box<dyn Trait> { Box::new(Struct) }
|
||||
| +++++++ + +++++++++ +
|
||||
|
||||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:17:13
|
||||
|
|
||||
LL | fn ban() -> dyn Trait { Struct }
|
||||
|
|
@ -48,7 +48,7 @@ help: alternatively, box the return type, and wrap all of the returned values in
|
|||
LL | fn ban() -> Box<dyn Trait> { Box::new(Struct) }
|
||||
| ++++ + +++++++++ +
|
||||
|
||||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:19:13
|
||||
|
|
||||
LL | fn bak() -> dyn Trait { unimplemented!() }
|
||||
|
|
@ -63,7 +63,7 @@ help: alternatively, box the return type, and wrap all of the returned values in
|
|||
LL | fn bak() -> Box<dyn Trait> { Box::new(unimplemented!()) }
|
||||
| ++++ + +++++++++ +
|
||||
|
||||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:21:13
|
||||
|
|
||||
LL | fn bal() -> dyn Trait {
|
||||
|
|
@ -82,7 +82,7 @@ LL | }
|
|||
LL ~ Box::new(42)
|
||||
|
|
||||
|
||||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:27:13
|
||||
|
|
||||
LL | fn bax() -> dyn Trait {
|
||||
|
|
@ -101,7 +101,7 @@ LL | } else {
|
|||
LL ~ Box::new(42)
|
||||
|
|
||||
|
||||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:62:13
|
||||
|
|
||||
LL | fn bat() -> dyn Trait {
|
||||
|
|
@ -120,7 +120,7 @@ LL | }
|
|||
LL ~ Box::new(42)
|
||||
|
|
||||
|
||||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:68:13
|
||||
|
|
||||
LL | fn bay() -> dyn Trait {
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ fn dog() -> impl std::fmt::Display {
|
|||
}
|
||||
}
|
||||
|
||||
fn hat() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed trait object
|
||||
fn hat() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
|
||||
match 13 {
|
||||
0 => {
|
||||
return 0i32;
|
||||
|
|
@ -74,7 +74,7 @@ fn hat() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed
|
|||
}
|
||||
}
|
||||
|
||||
fn pug() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed trait object
|
||||
fn pug() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
|
||||
match 13 {
|
||||
0 => 0i32,
|
||||
1 => 1u32,
|
||||
|
|
@ -82,7 +82,7 @@ fn pug() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed
|
|||
}
|
||||
}
|
||||
|
||||
fn man() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed trait object
|
||||
fn man() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection
|
||||
if false {
|
||||
0i32
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:66:13
|
||||
|
|
||||
LL | fn hat() -> dyn std::fmt::Display {
|
||||
|
|
@ -19,7 +19,7 @@ LL | _ => {
|
|||
LL ~ Box::new(1u32)
|
||||
|
|
||||
|
||||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:77:13
|
||||
|
|
||||
LL | fn pug() -> dyn std::fmt::Display {
|
||||
|
|
@ -38,7 +38,7 @@ LL ~ 1 => Box::new(1u32),
|
|||
LL ~ _ => Box::new(2u32),
|
||||
|
|
||||
|
||||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:85:13
|
||||
|
|
||||
LL | fn man() -> dyn std::fmt::Display {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ pub trait AbstractRenderer {}
|
|||
|
||||
fn _create_render(_: &()) ->
|
||||
dyn AbstractRenderer
|
||||
//~^ ERROR return type cannot have an unboxed trait object
|
||||
//~^ ERROR return type cannot be a trait object without pointer indirection
|
||||
{
|
||||
match 0 {
|
||||
_ => unimplemented!()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/issue-18107.rs:4:5
|
||||
|
|
||||
LL | dyn AbstractRenderer
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::fmt::Debug;
|
|||
// Test to suggest boxing the return type, and the closure branch of the `if`
|
||||
|
||||
fn print_on_or_the_other<'a>(a: i32, b: &'a String) -> dyn Fn() + 'a {
|
||||
//~^ ERROR return type cannot have an unboxed trait object
|
||||
//~^ ERROR return type cannot be a trait object without pointer indirection
|
||||
if a % 2 == 0 {
|
||||
move || println!("{a}")
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/box-instead-of-dyn-fn.rs:5:56
|
||||
|
|
||||
LL | fn print_on_or_the_other<'a>(a: i32, b: &'a String) -> dyn Fn() + 'a {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ pub static ALL_VALIDATORS: &[(&'static str, &'static Validator)] =
|
|||
&[("validate that credits and debits balance", &validate_something)];
|
||||
|
||||
fn or<'a>(first: &'static Validator<'a>, second: &'static Validator<'a>) -> Validator<'a> {
|
||||
//~^ ERROR return type cannot have an unboxed trait object
|
||||
//~^ ERROR return type cannot be a trait object without pointer indirection
|
||||
return Box::new(move |something: &'_ Something| -> Result<(), ()> {
|
||||
first(something).or_else(|_| second(something))
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/issue-91801.rs:8:77
|
||||
|
|
||||
LL | fn or<'a>(first: &'static Validator<'a>, second: &'static Validator<'a>) -> Validator<'a> {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
trait Foo<'a> {}
|
||||
|
||||
fn or<'a>(first: &'static dyn Foo<'a>) -> dyn Foo<'a> {
|
||||
//~^ ERROR return type cannot have an unboxed trait object
|
||||
//~^ ERROR return type cannot be a trait object without pointer indirection
|
||||
return Box::new(panic!());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0746]: return type cannot have an unboxed trait object
|
||||
error[E0746]: return type cannot be a trait object without pointer indirection
|
||||
--> $DIR/issue-91803.rs:3:43
|
||||
|
|
||||
LL | fn or<'a>(first: &'static dyn Foo<'a>) -> dyn Foo<'a> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue