Check Sizedness of return type in WF
This commit is contained in:
parent
f2c4ccd852
commit
23ab0f2cdc
42 changed files with 564 additions and 507 deletions
|
@ -1061,6 +1061,7 @@ fn check_associated_item(
|
||||||
let ty = tcx.type_of(item.def_id).instantiate_identity();
|
let ty = tcx.type_of(item.def_id).instantiate_identity();
|
||||||
let ty = wfcx.normalize(span, Some(WellFormedLoc::Ty(item_id)), ty);
|
let ty = wfcx.normalize(span, Some(WellFormedLoc::Ty(item_id)), ty);
|
||||||
wfcx.register_wf_obligation(span, loc, ty.into());
|
wfcx.register_wf_obligation(span, loc, ty.into());
|
||||||
|
check_sized_if_body(wfcx, item.def_id.expect_local(), ty, Some(span));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
ty::AssocKind::Fn => {
|
ty::AssocKind::Fn => {
|
||||||
|
@ -1185,7 +1186,7 @@ fn check_type_defn<'tcx>(
|
||||||
),
|
),
|
||||||
wfcx.param_env,
|
wfcx.param_env,
|
||||||
ty,
|
ty,
|
||||||
tcx.require_lang_item(LangItem::Sized, None),
|
tcx.require_lang_item(LangItem::Sized, Some(hir_ty.span)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1312,7 +1313,7 @@ fn check_item_type(
|
||||||
),
|
),
|
||||||
wfcx.param_env,
|
wfcx.param_env,
|
||||||
item_ty,
|
item_ty,
|
||||||
tcx.require_lang_item(LangItem::Sized, None),
|
tcx.require_lang_item(LangItem::Sized, Some(ty_span)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1642,6 +1643,31 @@ fn check_fn_or_method<'tcx>(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the function has a body, additionally require that the return type is sized.
|
||||||
|
check_sized_if_body(wfcx, def_id, sig.output(), match hir_decl.output {
|
||||||
|
hir::FnRetTy::Return(ty) => Some(ty.span),
|
||||||
|
hir::FnRetTy::DefaultReturn(_) => None,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check_sized_if_body<'tcx>(
|
||||||
|
wfcx: &WfCheckingCtxt<'_, 'tcx>,
|
||||||
|
def_id: LocalDefId,
|
||||||
|
ty: Ty<'tcx>,
|
||||||
|
maybe_span: Option<Span>,
|
||||||
|
) {
|
||||||
|
let tcx = wfcx.tcx();
|
||||||
|
if let Some(body) = tcx.hir().maybe_body_owned_by(def_id) {
|
||||||
|
let span = maybe_span.unwrap_or(body.value.span);
|
||||||
|
|
||||||
|
wfcx.register_bound(
|
||||||
|
ObligationCause::new(span, def_id, traits::ObligationCauseCode::SizedReturnType),
|
||||||
|
wfcx.param_env,
|
||||||
|
ty,
|
||||||
|
tcx.require_lang_item(LangItem::Sized, Some(span)),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The `arbitrary_self_types_pointers` feature implies `arbitrary_self_types`.
|
/// The `arbitrary_self_types_pointers` feature implies `arbitrary_self_types`.
|
||||||
|
|
|
@ -122,12 +122,7 @@ pub(super) fn check_fn<'a, 'tcx>(
|
||||||
hir::FnRetTy::Return(ty) => ty.span,
|
hir::FnRetTy::Return(ty) => ty.span,
|
||||||
};
|
};
|
||||||
|
|
||||||
fcx.require_type_is_sized(
|
// We checked the root's ret ty during wfcheck, but not the child.
|
||||||
declared_ret_ty,
|
|
||||||
return_or_body_span,
|
|
||||||
ObligationCauseCode::SizedReturnType,
|
|
||||||
);
|
|
||||||
// We checked the root's signature during wfcheck, but not the child.
|
|
||||||
if fcx.tcx.is_typeck_child(fn_def_id.to_def_id()) {
|
if fcx.tcx.is_typeck_child(fn_def_id.to_def_id()) {
|
||||||
fcx.require_type_is_sized(
|
fcx.require_type_is_sized(
|
||||||
declared_ret_ty,
|
declared_ret_ty,
|
||||||
|
|
|
@ -186,8 +186,6 @@ fn typeck_with_inspect<'tcx>(
|
||||||
let wf_code = ObligationCauseCode::WellFormed(Some(WellFormedLoc::Ty(def_id)));
|
let wf_code = ObligationCauseCode::WellFormed(Some(WellFormedLoc::Ty(def_id)));
|
||||||
fcx.register_wf_obligation(expected_type.into(), body.value.span, wf_code);
|
fcx.register_wf_obligation(expected_type.into(), body.value.span, wf_code);
|
||||||
|
|
||||||
fcx.require_type_is_sized(expected_type, body.value.span, ObligationCauseCode::ConstSized);
|
|
||||||
|
|
||||||
// Gather locals in statics (because of block expressions).
|
// Gather locals in statics (because of block expressions).
|
||||||
GatherLocalsVisitor::new(&fcx).visit_body(body);
|
GatherLocalsVisitor::new(&fcx).visit_body(body);
|
||||||
|
|
||||||
|
|
|
@ -703,7 +703,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.note_obligation_cause(&mut err, &obligation);
|
self.note_obligation_cause(&mut err, &obligation);
|
||||||
self.point_at_returns_when_relevant(&mut err, &obligation);
|
|
||||||
err.emit()
|
err.emit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -806,7 +805,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||||
"Async",
|
"Async",
|
||||||
);
|
);
|
||||||
self.note_obligation_cause(&mut err, &obligation);
|
self.note_obligation_cause(&mut err, &obligation);
|
||||||
self.point_at_returns_when_relevant(&mut err, &obligation);
|
|
||||||
return Some(err.emit());
|
return Some(err.emit());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -852,7 +850,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||||
"",
|
"",
|
||||||
);
|
);
|
||||||
self.note_obligation_cause(&mut err, &obligation);
|
self.note_obligation_cause(&mut err, &obligation);
|
||||||
self.point_at_returns_when_relevant(&mut err, &obligation);
|
|
||||||
return Some(err.emit());
|
return Some(err.emit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -868,7 +865,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||||
kind: expected_kind.as_str(),
|
kind: expected_kind.as_str(),
|
||||||
});
|
});
|
||||||
self.note_obligation_cause(&mut err, &obligation);
|
self.note_obligation_cause(&mut err, &obligation);
|
||||||
self.point_at_returns_when_relevant(&mut err, &obligation);
|
|
||||||
return Some(err.emit());
|
return Some(err.emit());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2826,7 +2822,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||||
err.span_note(self.tcx.def_span(def_id), "opaque type is declared here");
|
err.span_note(self.tcx.def_span(def_id), "opaque type is declared here");
|
||||||
|
|
||||||
self.note_obligation_cause(&mut err, &obligation);
|
self.note_obligation_cause(&mut err, &obligation);
|
||||||
self.point_at_returns_when_relevant(&mut err, &obligation);
|
|
||||||
self.dcx().try_steal_replace_and_emit_err(self.tcx.def_span(def_id), StashKey::Cycle, err)
|
self.dcx().try_steal_replace_and_emit_err(self.tcx.def_span(def_id), StashKey::Cycle, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||||
suggest_increasing_limit,
|
suggest_increasing_limit,
|
||||||
);
|
);
|
||||||
self.note_obligation_cause(&mut err, &obligation);
|
self.note_obligation_cause(&mut err, &obligation);
|
||||||
self.point_at_returns_when_relevant(&mut err, &obligation);
|
|
||||||
err.emit()
|
err.emit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1781,25 +1781,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
("dyn ", span.shrink_to_lo())
|
("dyn ", span.shrink_to_lo())
|
||||||
};
|
};
|
||||||
let alternatively = if visitor
|
|
||||||
.returns
|
err.span_suggestion_verbose(
|
||||||
.iter()
|
impl_span,
|
||||||
.map(|expr| self.typeck_results.as_ref().unwrap().expr_ty_adjusted_opt(expr))
|
"consider returning an `impl Trait` instead of a `dyn Trait`",
|
||||||
.collect::<FxHashSet<_>>()
|
"impl ",
|
||||||
.len()
|
Applicability::MaybeIncorrect,
|
||||||
<= 1
|
);
|
||||||
{
|
|
||||||
err.span_suggestion_verbose(
|
|
||||||
impl_span,
|
|
||||||
"consider returning an `impl Trait` instead of a `dyn Trait`",
|
|
||||||
"impl ",
|
|
||||||
Applicability::MaybeIncorrect,
|
|
||||||
);
|
|
||||||
"alternatively, "
|
|
||||||
} else {
|
|
||||||
err.help("if there were a single returned type, you could use `impl Trait` instead");
|
|
||||||
""
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut sugg = vec![
|
let mut sugg = vec![
|
||||||
(span.shrink_to_lo(), format!("Box<{pre}")),
|
(span.shrink_to_lo(), format!("Box<{pre}")),
|
||||||
|
@ -1831,7 +1819,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
err.multipart_suggestion(
|
err.multipart_suggestion(
|
||||||
format!(
|
format!(
|
||||||
"{alternatively}box the return type, and wrap all of the returned values in \
|
"alternatively, box the return type, and wrap all of the returned values in \
|
||||||
`Box::new`",
|
`Box::new`",
|
||||||
),
|
),
|
||||||
sugg,
|
sugg,
|
||||||
|
@ -1841,41 +1829,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn point_at_returns_when_relevant(
|
|
||||||
&self,
|
|
||||||
err: &mut Diag<'_>,
|
|
||||||
obligation: &PredicateObligation<'tcx>,
|
|
||||||
) {
|
|
||||||
match obligation.cause.code().peel_derives() {
|
|
||||||
ObligationCauseCode::SizedReturnType => {}
|
|
||||||
_ => return,
|
|
||||||
}
|
|
||||||
|
|
||||||
let hir = self.tcx.hir();
|
|
||||||
let node = self.tcx.hir_node_by_def_id(obligation.cause.body_id);
|
|
||||||
if let hir::Node::Item(hir::Item {
|
|
||||||
kind: hir::ItemKind::Fn { body: body_id, .. }, ..
|
|
||||||
}) = node
|
|
||||||
{
|
|
||||||
let body = hir.body(*body_id);
|
|
||||||
// Point at all the `return`s in the function as they have failed trait bounds.
|
|
||||||
let mut visitor = ReturnsVisitor::default();
|
|
||||||
visitor.visit_body(body);
|
|
||||||
let typeck_results = self.typeck_results.as_ref().unwrap();
|
|
||||||
for expr in &visitor.returns {
|
|
||||||
if let Some(returned_ty) = typeck_results.node_type_opt(expr.hir_id) {
|
|
||||||
let ty = self.resolve_vars_if_possible(returned_ty);
|
|
||||||
if ty.references_error() {
|
|
||||||
// don't print out the [type error] here
|
|
||||||
err.downgrade_to_delayed_bug();
|
|
||||||
} else {
|
|
||||||
err.span_label(expr.span, format!("this returned value is of type `{ty}`"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) fn report_closure_arg_mismatch(
|
pub(super) fn report_closure_arg_mismatch(
|
||||||
&self,
|
&self,
|
||||||
span: Span,
|
span: Span,
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
//@ known-bug: #134355
|
|
||||||
|
|
||||||
//@compile-flags: --crate-type=lib
|
|
||||||
fn digit() -> str {
|
|
||||||
return { i32::MIN };
|
|
||||||
}
|
|
|
@ -1,12 +1,3 @@
|
||||||
error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type
|
|
||||||
--> $DIR/issue-58022.rs:4:25
|
|
||||||
|
|
|
||||||
LL | const SIZE: usize;
|
|
||||||
| ------------------ `Foo::SIZE` defined here
|
|
||||||
LL |
|
|
||||||
LL | fn new(slice: &[u8; Foo::SIZE]) -> Self;
|
|
||||||
| ^^^^^^^^^ cannot refer to the associated constant of trait
|
|
||||||
|
|
||||||
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
|
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
|
||||||
--> $DIR/issue-58022.rs:13:41
|
--> $DIR/issue-58022.rs:13:41
|
||||||
|
|
|
|
||||||
|
@ -21,6 +12,15 @@ LL | pub struct Bar<T: ?Sized>(T);
|
||||||
| ^^^
|
| ^^^
|
||||||
= note: the return type of a function must have a statically known size
|
= note: the return type of a function must have a statically known size
|
||||||
|
|
||||||
|
error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type
|
||||||
|
--> $DIR/issue-58022.rs:4:25
|
||||||
|
|
|
||||||
|
LL | const SIZE: usize;
|
||||||
|
| ------------------ `Foo::SIZE` defined here
|
||||||
|
LL |
|
||||||
|
LL | fn new(slice: &[u8; Foo::SIZE]) -> Self;
|
||||||
|
| ^^^^^^^^^ cannot refer to the associated constant of trait
|
||||||
|
|
||||||
error[E0423]: expected function, tuple struct or tuple variant, found trait `Foo`
|
error[E0423]: expected function, tuple struct or tuple variant, found trait `Foo`
|
||||||
--> $DIR/issue-58022.rs:15:9
|
--> $DIR/issue-58022.rs:15:9
|
||||||
|
|
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
const ONE: [u16] = [1];
|
const ONE: [u16] = [1];
|
||||||
//~^ ERROR the size for values of type `[u16]` cannot be known at compilation time
|
//~^ ERROR the size for values of type `[u16]` cannot be known at compilation time
|
||||||
//~| ERROR the size for values of type `[u16]` cannot be known at compilation time
|
|
||||||
//~| ERROR mismatched types
|
//~| ERROR mismatched types
|
||||||
|
|
||||||
const TWO: &'static u16 = &ONE[0];
|
const TWO: &'static u16 = &ONE[0];
|
||||||
|
|
|
@ -12,22 +12,13 @@ error[E0308]: mismatched types
|
||||||
LL | const ONE: [u16] = [1];
|
LL | const ONE: [u16] = [1];
|
||||||
| ^^^ expected `[u16]`, found `[u16; 1]`
|
| ^^^ expected `[u16]`, found `[u16; 1]`
|
||||||
|
|
||||||
error[E0277]: the size for values of type `[u16]` cannot be known at compilation time
|
|
||||||
--> $DIR/const-slice-array-deref.rs:1:20
|
|
||||||
|
|
|
||||||
LL | const ONE: [u16] = [1];
|
|
||||||
| ^^^ doesn't have a size known at compile-time
|
|
||||||
|
|
|
||||||
= help: the trait `Sized` is not implemented for `[u16]`
|
|
||||||
= note: constant expressions must have a statically known size
|
|
||||||
|
|
||||||
error[E0161]: cannot move a value of type `[u16]`
|
error[E0161]: cannot move a value of type `[u16]`
|
||||||
--> $DIR/const-slice-array-deref.rs:6:28
|
--> $DIR/const-slice-array-deref.rs:5:28
|
||||||
|
|
|
|
||||||
LL | const TWO: &'static u16 = &ONE[0];
|
LL | const TWO: &'static u16 = &ONE[0];
|
||||||
| ^^^ the size of `[u16]` cannot be statically determined
|
| ^^^ the size of `[u16]` cannot be statically determined
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0161, E0277, E0308.
|
Some errors have detailed explanations: E0161, E0277, E0308.
|
||||||
For more information about an error, try `rustc --explain E0161`.
|
For more information about an error, try `rustc --explain E0161`.
|
||||||
|
|
|
@ -2,19 +2,19 @@ use std::fmt::Debug;
|
||||||
|
|
||||||
const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync));
|
const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync));
|
||||||
//~^ ERROR the size for values of type
|
//~^ ERROR the size for values of type
|
||||||
//~| ERROR the size for values of type
|
//~| ERROR cannot move out of a shared reference
|
||||||
|
|
||||||
const CONST_FOO: str = *"foo";
|
const CONST_FOO: str = *"foo";
|
||||||
//~^ ERROR the size for values of type
|
//~^ ERROR the size for values of type
|
||||||
//~| ERROR the size for values of type
|
//~| ERROR cannot move out of a shared reference
|
||||||
|
|
||||||
static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync));
|
static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync));
|
||||||
//~^ ERROR the size for values of type
|
//~^ ERROR the size for values of type
|
||||||
//~| ERROR the size for values of type
|
//~| ERROR cannot move out of a shared reference
|
||||||
|
|
||||||
static STATIC_BAR: str = *"bar";
|
static STATIC_BAR: str = *"bar";
|
||||||
//~^ ERROR the size for values of type
|
//~^ ERROR the size for values of type
|
||||||
//~| ERROR the size for values of type
|
//~| ERROR cannot move out of a shared reference
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("{:?} {:?} {:?} {:?}", &CONST_0, &CONST_FOO, &STATIC_1, &STATIC_BAR);
|
println!("{:?} {:?} {:?} {:?}", &CONST_0, &CONST_FOO, &STATIC_1, &STATIC_BAR);
|
||||||
|
|
|
@ -6,15 +6,6 @@ LL | const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync));
|
||||||
|
|
|
|
||||||
= help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)`
|
= help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)`
|
||||||
|
|
||||||
error[E0277]: the size for values of type `(dyn Debug + Sync + 'static)` cannot be known at compilation time
|
|
||||||
--> $DIR/const-unsized.rs:3:35
|
|
||||||
|
|
|
||||||
LL | const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync));
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
|
||||||
|
|
|
||||||
= help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)`
|
|
||||||
= note: constant expressions must have a statically known size
|
|
||||||
|
|
||||||
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
||||||
--> $DIR/const-unsized.rs:7:18
|
--> $DIR/const-unsized.rs:7:18
|
||||||
|
|
|
|
||||||
|
@ -23,15 +14,6 @@ LL | const CONST_FOO: str = *"foo";
|
||||||
|
|
|
|
||||||
= help: the trait `Sized` is not implemented for `str`
|
= help: the trait `Sized` is not implemented for `str`
|
||||||
|
|
||||||
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
|
||||||
--> $DIR/const-unsized.rs:7:24
|
|
||||||
|
|
|
||||||
LL | const CONST_FOO: str = *"foo";
|
|
||||||
| ^^^^^^ doesn't have a size known at compile-time
|
|
||||||
|
|
|
||||||
= help: the trait `Sized` is not implemented for `str`
|
|
||||||
= note: constant expressions must have a statically known size
|
|
||||||
|
|
||||||
error[E0277]: the size for values of type `(dyn Debug + Sync + 'static)` cannot be known at compilation time
|
error[E0277]: the size for values of type `(dyn Debug + Sync + 'static)` cannot be known at compilation time
|
||||||
--> $DIR/const-unsized.rs:11:18
|
--> $DIR/const-unsized.rs:11:18
|
||||||
|
|
|
|
||||||
|
@ -40,15 +22,6 @@ LL | static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync));
|
||||||
|
|
|
|
||||||
= help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)`
|
= help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)`
|
||||||
|
|
||||||
error[E0277]: the size for values of type `(dyn Debug + Sync + 'static)` cannot be known at compilation time
|
|
||||||
--> $DIR/const-unsized.rs:11:37
|
|
||||||
|
|
|
||||||
LL | static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync));
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
|
||||||
|
|
|
||||||
= help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)`
|
|
||||||
= note: constant expressions must have a statically known size
|
|
||||||
|
|
||||||
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
||||||
--> $DIR/const-unsized.rs:15:20
|
--> $DIR/const-unsized.rs:15:20
|
||||||
|
|
|
|
||||||
|
@ -57,14 +30,29 @@ LL | static STATIC_BAR: str = *"bar";
|
||||||
|
|
|
|
||||||
= help: the trait `Sized` is not implemented for `str`
|
= help: the trait `Sized` is not implemented for `str`
|
||||||
|
|
||||||
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
error[E0507]: cannot move out of a shared reference
|
||||||
|
--> $DIR/const-unsized.rs:3:35
|
||||||
|
|
|
||||||
|
LL | const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync));
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ move occurs because value has type `dyn Debug + Sync`, which does not implement the `Copy` trait
|
||||||
|
|
||||||
|
error[E0507]: cannot move out of a shared reference
|
||||||
|
--> $DIR/const-unsized.rs:7:24
|
||||||
|
|
|
||||||
|
LL | const CONST_FOO: str = *"foo";
|
||||||
|
| ^^^^^^ move occurs because value has type `str`, which does not implement the `Copy` trait
|
||||||
|
|
||||||
|
error[E0507]: cannot move out of a shared reference
|
||||||
|
--> $DIR/const-unsized.rs:11:37
|
||||||
|
|
|
||||||
|
LL | static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync));
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ move occurs because value has type `dyn Debug + Sync`, which does not implement the `Copy` trait
|
||||||
|
|
||||||
|
error[E0507]: cannot move out of a shared reference
|
||||||
--> $DIR/const-unsized.rs:15:26
|
--> $DIR/const-unsized.rs:15:26
|
||||||
|
|
|
|
||||||
LL | static STATIC_BAR: str = *"bar";
|
LL | static STATIC_BAR: str = *"bar";
|
||||||
| ^^^^^^ doesn't have a size known at compile-time
|
| ^^^^^^ move occurs because value has type `str`, which does not implement the `Copy` trait
|
||||||
|
|
|
||||||
= help: the trait `Sized` is not implemented for `str`
|
|
||||||
= note: constant expressions must have a statically known size
|
|
||||||
|
|
||||||
error[E0161]: cannot move a value of type `str`
|
error[E0161]: cannot move a value of type `str`
|
||||||
--> $DIR/const-unsized.rs:20:48
|
--> $DIR/const-unsized.rs:20:48
|
||||||
|
@ -80,5 +68,5 @@ LL | println!("{:?} {:?} {:?} {:?}", &CONST_0, &CONST_FOO, &STATIC_1, &STATI
|
||||||
|
|
||||||
error: aborting due to 10 previous errors
|
error: aborting due to 10 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0161, E0277.
|
Some errors have detailed explanations: E0161, E0277, E0507.
|
||||||
For more information about an error, try `rustc --explain E0161`.
|
For more information about an error, try `rustc --explain E0161`.
|
||||||
|
|
|
@ -9,11 +9,9 @@ const REF_INTERIOR_MUT: &usize = {
|
||||||
//~^ ERROR failed to resolve: use of undeclared type `AtomicUsize`
|
//~^ ERROR failed to resolve: use of undeclared type `AtomicUsize`
|
||||||
//~| WARN trait objects without an explicit `dyn` are deprecated
|
//~| WARN trait objects without an explicit `dyn` are deprecated
|
||||||
//~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
|
//~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
|
||||||
//~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
|
|
||||||
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
//~| HELP if this is a dyn-compatible trait, use `dyn`
|
//~| HELP if this is a dyn-compatible trait, use `dyn`
|
||||||
//~| HELP the trait `Sized` is not implemented for `(dyn Sync + 'static)`
|
//~| HELP the trait `Sized` is not implemented for `(dyn Sync + 'static)`
|
||||||
//~| HELP the trait `Sized` is not implemented for `(dyn Sync + 'static)`
|
|
||||||
unsafe { &*(&FOO as *const _ as *const usize) }
|
unsafe { &*(&FOO as *const _ as *const usize) }
|
||||||
};
|
};
|
||||||
pub fn main() {}
|
pub fn main() {}
|
||||||
|
|
|
@ -31,16 +31,7 @@ LL | static FOO: Sync = AtomicUsize::new(0);
|
||||||
|
|
|
|
||||||
= help: the trait `Sized` is not implemented for `(dyn Sync + 'static)`
|
= help: the trait `Sized` is not implemented for `(dyn Sync + 'static)`
|
||||||
|
|
||||||
error[E0277]: the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
|
error: aborting due to 2 previous errors; 1 warning emitted
|
||||||
--> $DIR/const_refs_to_static-ice-121413.rs:8:24
|
|
||||||
|
|
|
||||||
LL | static FOO: Sync = AtomicUsize::new(0);
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
|
||||||
|
|
|
||||||
= help: the trait `Sized` is not implemented for `(dyn Sync + 'static)`
|
|
||||||
= note: constant expressions must have a statically known size
|
|
||||||
|
|
||||||
error: aborting due to 3 previous errors; 1 warning emitted
|
|
||||||
|
|
||||||
Some errors have detailed explanations: E0277, E0433.
|
Some errors have detailed explanations: E0277, E0433.
|
||||||
For more information about an error, try `rustc --explain E0277`.
|
For more information about an error, try `rustc --explain E0277`.
|
||||||
|
|
|
@ -8,6 +8,10 @@ error: unwinding panics are not supported without std
|
||||||
= note: since the core library is usually precompiled with panic="unwind", rebuilding your crate with panic="abort" may not be enough to fix the problem
|
= note: since the core library is usually precompiled with panic="unwind", rebuilding your crate with panic="abort" may not be enough to fix the problem
|
||||||
|
|
||||||
error: requires `sized` lang_item
|
error: requires `sized` lang_item
|
||||||
|
--> $DIR/empty-extern-arg.rs:6:11
|
||||||
|
|
|
||||||
|
LL | fn main() {}
|
||||||
|
| ^^
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|
|
@ -26,42 +26,17 @@ help: alternatively, consider constraining `foo` so it does not apply to trait o
|
||||||
LL | fn foo() -> Self where Self: Sized;
|
LL | fn foo() -> Self where Self: Sized;
|
||||||
| +++++++++++++++++
|
| +++++++++++++++++
|
||||||
|
|
||||||
error[E0038]: the trait `DynIncompatible` is not dyn compatible
|
|
||||||
--> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:30:17
|
|
||||||
|
|
|
||||||
LL | fn cat() -> Box<dyn DynIncompatible> {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^ `DynIncompatible` is not dyn compatible
|
|
||||||
|
|
|
||||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
|
||||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
|
||||||
--> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:4:8
|
|
||||||
|
|
|
||||||
LL | trait DynIncompatible {
|
|
||||||
| --------------- this trait is not dyn compatible...
|
|
||||||
LL | fn foo() -> Self;
|
|
||||||
| ^^^ ...because associated function `foo` has no `self` parameter
|
|
||||||
= help: the following types implement `DynIncompatible`:
|
|
||||||
A
|
|
||||||
B
|
|
||||||
consider defining an enum where each variant holds one of these types,
|
|
||||||
implementing `DynIncompatible` for this new enum and using it instead
|
|
||||||
help: consider turning `foo` into a method by giving it a `&self` argument
|
|
||||||
|
|
|
||||||
LL | fn foo(&self) -> Self;
|
|
||||||
| +++++
|
|
||||||
help: alternatively, consider constraining `foo` so it does not apply to trait objects
|
|
||||||
|
|
|
||||||
LL | fn foo() -> Self where Self: Sized;
|
|
||||||
| +++++++++++++++++
|
|
||||||
|
|
||||||
error[E0746]: return type cannot have an unboxed trait object
|
error[E0746]: return type cannot have an unboxed trait object
|
||||||
--> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:22:13
|
--> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:22:13
|
||||||
|
|
|
|
||||||
LL | fn car() -> dyn DynIncompatible {
|
LL | fn car() -> dyn DynIncompatible {
|
||||||
| ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
| ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
|
||||||
= help: if there were a single returned type, you could use `impl Trait` instead
|
help: consider returning an `impl Trait` instead of a `dyn Trait`
|
||||||
help: box the return type, and wrap all of the returned values in `Box::new`
|
|
|
||||||
|
LL | fn car() -> impl DynIncompatible {
|
||||||
|
| ~~~~
|
||||||
|
help: alternatively, box the return type, and wrap all of the returned values in `Box::new`
|
||||||
|
|
|
|
||||||
LL ~ fn car() -> Box<dyn DynIncompatible> {
|
LL ~ fn car() -> Box<dyn DynIncompatible> {
|
||||||
LL |
|
LL |
|
||||||
|
@ -71,6 +46,34 @@ LL | }
|
||||||
LL ~ Box::new(B)
|
LL ~ Box::new(B)
|
||||||
|
|
|
|
||||||
|
|
||||||
|
error[E0038]: the trait `DynIncompatible` is not dyn compatible
|
||||||
|
--> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:30:17
|
||||||
|
|
|
||||||
|
LL | fn cat() -> Box<dyn DynIncompatible> {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^ `DynIncompatible` is not dyn compatible
|
||||||
|
|
|
||||||
|
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||||
|
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||||
|
--> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:4:8
|
||||||
|
|
|
||||||
|
LL | trait DynIncompatible {
|
||||||
|
| --------------- this trait is not dyn compatible...
|
||||||
|
LL | fn foo() -> Self;
|
||||||
|
| ^^^ ...because associated function `foo` has no `self` parameter
|
||||||
|
= help: the following types implement `DynIncompatible`:
|
||||||
|
A
|
||||||
|
B
|
||||||
|
consider defining an enum where each variant holds one of these types,
|
||||||
|
implementing `DynIncompatible` for this new enum and using it instead
|
||||||
|
help: consider turning `foo` into a method by giving it a `&self` argument
|
||||||
|
|
|
||||||
|
LL | fn foo(&self) -> Self;
|
||||||
|
| +++++
|
||||||
|
help: alternatively, consider constraining `foo` so it does not apply to trait objects
|
||||||
|
|
|
||||||
|
LL | fn foo() -> Self where Self: Sized;
|
||||||
|
| +++++++++++++++++
|
||||||
|
|
||||||
error[E0038]: the trait `DynIncompatible` is not dyn compatible
|
error[E0038]: the trait `DynIncompatible` is not dyn compatible
|
||||||
--> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:32:16
|
--> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:32:16
|
||||||
|
|
|
|
||||||
|
|
|
@ -6,9 +6,11 @@ impl Trait for u32 {}
|
||||||
|
|
||||||
fn fuz() -> (usize, Trait) { (42, Struct) }
|
fn fuz() -> (usize, Trait) { (42, Struct) }
|
||||||
//~^ ERROR E0277
|
//~^ ERROR E0277
|
||||||
|
//~| ERROR E0277
|
||||||
//~| ERROR E0308
|
//~| ERROR E0308
|
||||||
fn bar() -> (usize, dyn Trait) { (42, Struct) }
|
fn bar() -> (usize, dyn Trait) { (42, Struct) }
|
||||||
//~^ ERROR E0277
|
//~^ ERROR E0277
|
||||||
|
//~| ERROR E0277
|
||||||
//~| ERROR E0308
|
//~| ERROR E0308
|
||||||
fn bap() -> Trait { Struct }
|
fn bap() -> Trait { Struct }
|
||||||
//~^ ERROR E0746
|
//~^ ERROR E0746
|
||||||
|
|
|
@ -1,49 +1,25 @@
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:35
|
|
||||||
|
|
|
||||||
LL | fn fuz() -> (usize, Trait) { (42, Struct) }
|
|
||||||
| ^^^^^^ expected `dyn Trait`, found `Struct`
|
|
||||||
|
|
|
||||||
= note: expected trait object `(dyn Trait + 'static)`
|
|
||||||
found struct `Struct`
|
|
||||||
= help: `Struct` implements `Trait` so you could box the found value and coerce it to the trait object `Box<dyn Trait>`, you will have to change the expected type as well
|
|
||||||
|
|
||||||
error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
|
error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:13
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:13
|
||||||
|
|
|
|
||||||
LL | fn fuz() -> (usize, Trait) { (42, Struct) }
|
LL | fn fuz() -> (usize, Trait) { (42, Struct) }
|
||||||
| ^^^^^^^^^^^^^^ ------------ this returned value is of type `(usize, (dyn Trait + 'static))`
|
| ^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
| |
|
|
||||||
| doesn't have a size known at compile-time
|
|
||||||
|
|
|
|
||||||
= help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)`
|
= help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)`
|
||||||
= note: required because it appears within the type `(usize, (dyn Trait + 'static))`
|
= 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
|
= note: the return type of a function must have a statically known size
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:10:39
|
|
||||||
|
|
|
||||||
LL | fn bar() -> (usize, dyn Trait) { (42, Struct) }
|
|
||||||
| ^^^^^^ expected `dyn Trait`, found `Struct`
|
|
||||||
|
|
|
||||||
= note: expected trait object `(dyn Trait + 'static)`
|
|
||||||
found struct `Struct`
|
|
||||||
= help: `Struct` implements `Trait` so you could box the found value and coerce it to the trait object `Box<dyn Trait>`, you will have to change the expected type as well
|
|
||||||
|
|
||||||
error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
|
error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:10:13
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:13
|
||||||
|
|
|
|
||||||
LL | fn bar() -> (usize, dyn Trait) { (42, Struct) }
|
LL | fn bar() -> (usize, dyn Trait) { (42, Struct) }
|
||||||
| ^^^^^^^^^^^^^^^^^^ ------------ this returned value is of type `(usize, (dyn Trait + 'static))`
|
| ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
| |
|
|
||||||
| doesn't have a size known at compile-time
|
|
||||||
|
|
|
|
||||||
= help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)`
|
= help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)`
|
||||||
= note: required because it appears within the type `(usize, (dyn Trait + 'static))`
|
= 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
|
= 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 have an unboxed trait object
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:13:13
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:13
|
||||||
|
|
|
|
||||||
LL | fn bap() -> Trait { Struct }
|
LL | fn bap() -> Trait { Struct }
|
||||||
| ^^^^^ doesn't have a size known at compile-time
|
| ^^^^^ doesn't have a size known at compile-time
|
||||||
|
@ -58,7 +34,7 @@ LL | fn bap() -> Box<dyn Trait> { Box::new(Struct) }
|
||||||
| +++++++ + +++++++++ +
|
| +++++++ + +++++++++ +
|
||||||
|
|
||||||
error[E0746]: return type cannot have an unboxed trait object
|
error[E0746]: return type cannot have an unboxed trait object
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:13
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:17:13
|
||||||
|
|
|
|
||||||
LL | fn ban() -> dyn Trait { Struct }
|
LL | fn ban() -> dyn Trait { Struct }
|
||||||
| ^^^^^^^^^ doesn't have a size known at compile-time
|
| ^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
@ -73,7 +49,7 @@ LL | fn ban() -> Box<dyn Trait> { Box::new(Struct) }
|
||||||
| ++++ + +++++++++ +
|
| ++++ + +++++++++ +
|
||||||
|
|
||||||
error[E0746]: return type cannot have an unboxed trait object
|
error[E0746]: return type cannot have an unboxed trait object
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:17:13
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:19:13
|
||||||
|
|
|
|
||||||
LL | fn bak() -> dyn Trait { unimplemented!() }
|
LL | fn bak() -> dyn Trait { unimplemented!() }
|
||||||
| ^^^^^^^^^ doesn't have a size known at compile-time
|
| ^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
@ -88,13 +64,16 @@ LL | fn bak() -> Box<dyn Trait> { Box::new(unimplemented!()) }
|
||||||
| ++++ + +++++++++ +
|
| ++++ + +++++++++ +
|
||||||
|
|
||||||
error[E0746]: return type cannot have an unboxed trait object
|
error[E0746]: return type cannot have an unboxed trait object
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:19:13
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:21:13
|
||||||
|
|
|
|
||||||
LL | fn bal() -> dyn Trait {
|
LL | fn bal() -> dyn Trait {
|
||||||
| ^^^^^^^^^ doesn't have a size known at compile-time
|
| ^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
|
||||||
= help: if there were a single returned type, you could use `impl Trait` instead
|
help: consider returning an `impl Trait` instead of a `dyn Trait`
|
||||||
help: box the return type, and wrap all of the returned values in `Box::new`
|
|
|
||||||
|
LL | fn bal() -> impl Trait {
|
||||||
|
| ~~~~
|
||||||
|
help: alternatively, box the return type, and wrap all of the returned values in `Box::new`
|
||||||
|
|
|
|
||||||
LL ~ fn bal() -> Box<dyn Trait> {
|
LL ~ fn bal() -> Box<dyn Trait> {
|
||||||
LL | if true {
|
LL | if true {
|
||||||
|
@ -104,13 +83,16 @@ LL ~ Box::new(42)
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0746]: return type cannot have an unboxed trait object
|
error[E0746]: return type cannot have an unboxed trait object
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:25:13
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:27:13
|
||||||
|
|
|
|
||||||
LL | fn bax() -> dyn Trait {
|
LL | fn bax() -> dyn Trait {
|
||||||
| ^^^^^^^^^ doesn't have a size known at compile-time
|
| ^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
|
||||||
= help: if there were a single returned type, you could use `impl Trait` instead
|
help: consider returning an `impl Trait` instead of a `dyn Trait`
|
||||||
help: box the return type, and wrap all of the returned values in `Box::new`
|
|
|
||||||
|
LL | fn bax() -> impl Trait {
|
||||||
|
| ~~~~
|
||||||
|
help: alternatively, box the return type, and wrap all of the returned values in `Box::new`
|
||||||
|
|
|
|
||||||
LL ~ fn bax() -> Box<dyn Trait> {
|
LL ~ fn bax() -> Box<dyn Trait> {
|
||||||
LL | if true {
|
LL | if true {
|
||||||
|
@ -119,144 +101,8 @@ LL | } else {
|
||||||
LL ~ Box::new(42)
|
LL ~ Box::new(42)
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:34:16
|
|
||||||
|
|
|
||||||
LL | fn bam() -> Box<dyn Trait> {
|
|
||||||
| -------------- expected `Box<(dyn Trait + 'static)>` because of return type
|
|
||||||
LL | if true {
|
|
||||||
LL | return Struct;
|
|
||||||
| ^^^^^^ expected `Box<dyn Trait>`, found `Struct`
|
|
||||||
|
|
|
||||||
= note: expected struct `Box<(dyn Trait + 'static)>`
|
|
||||||
found struct `Struct`
|
|
||||||
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
|
|
||||||
help: store this in the heap by calling `Box::new`
|
|
||||||
|
|
|
||||||
LL | return Box::new(Struct);
|
|
||||||
| +++++++++ +
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:36:5
|
|
||||||
|
|
|
||||||
LL | fn bam() -> Box<dyn Trait> {
|
|
||||||
| -------------- expected `Box<(dyn Trait + 'static)>` because of return type
|
|
||||||
...
|
|
||||||
LL | 42
|
|
||||||
| ^^ expected `Box<dyn Trait>`, found integer
|
|
||||||
|
|
|
||||||
= note: expected struct `Box<(dyn Trait + 'static)>`
|
|
||||||
found type `{integer}`
|
|
||||||
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
|
|
||||||
help: store this in the heap by calling `Box::new`
|
|
||||||
|
|
|
||||||
LL | Box::new(42)
|
|
||||||
| +++++++++ +
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:40:16
|
|
||||||
|
|
|
||||||
LL | fn baq() -> Box<dyn Trait> {
|
|
||||||
| -------------- expected `Box<(dyn Trait + 'static)>` because of return type
|
|
||||||
LL | if true {
|
|
||||||
LL | return 0;
|
|
||||||
| ^ expected `Box<dyn Trait>`, found integer
|
|
||||||
|
|
|
||||||
= note: expected struct `Box<(dyn Trait + 'static)>`
|
|
||||||
found type `{integer}`
|
|
||||||
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
|
|
||||||
help: store this in the heap by calling `Box::new`
|
|
||||||
|
|
|
||||||
LL | return Box::new(0);
|
|
||||||
| +++++++++ +
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:42:5
|
|
||||||
|
|
|
||||||
LL | fn baq() -> Box<dyn Trait> {
|
|
||||||
| -------------- expected `Box<(dyn Trait + 'static)>` because of return type
|
|
||||||
...
|
|
||||||
LL | 42
|
|
||||||
| ^^ expected `Box<dyn Trait>`, found integer
|
|
||||||
|
|
|
||||||
= note: expected struct `Box<(dyn Trait + 'static)>`
|
|
||||||
found type `{integer}`
|
|
||||||
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
|
|
||||||
help: store this in the heap by calling `Box::new`
|
|
||||||
|
|
|
||||||
LL | Box::new(42)
|
|
||||||
| +++++++++ +
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:46:9
|
|
||||||
|
|
|
||||||
LL | fn baz() -> Box<dyn Trait> {
|
|
||||||
| -------------- expected `Box<(dyn Trait + 'static)>` because of return type
|
|
||||||
LL | if true {
|
|
||||||
LL | Struct
|
|
||||||
| ^^^^^^ expected `Box<dyn Trait>`, found `Struct`
|
|
||||||
|
|
|
||||||
= note: expected struct `Box<(dyn Trait + 'static)>`
|
|
||||||
found struct `Struct`
|
|
||||||
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
|
|
||||||
help: store this in the heap by calling `Box::new`
|
|
||||||
|
|
|
||||||
LL | Box::new(Struct)
|
|
||||||
| +++++++++ +
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:48:9
|
|
||||||
|
|
|
||||||
LL | fn baz() -> Box<dyn Trait> {
|
|
||||||
| -------------- expected `Box<(dyn Trait + 'static)>` because of return type
|
|
||||||
...
|
|
||||||
LL | 42
|
|
||||||
| ^^ expected `Box<dyn Trait>`, found integer
|
|
||||||
|
|
|
||||||
= note: expected struct `Box<(dyn Trait + 'static)>`
|
|
||||||
found type `{integer}`
|
|
||||||
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
|
|
||||||
help: store this in the heap by calling `Box::new`
|
|
||||||
|
|
|
||||||
LL | Box::new(42)
|
|
||||||
| +++++++++ +
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:53:9
|
|
||||||
|
|
|
||||||
LL | fn baw() -> Box<dyn Trait> {
|
|
||||||
| -------------- expected `Box<(dyn Trait + 'static)>` because of return type
|
|
||||||
LL | if true {
|
|
||||||
LL | 0
|
|
||||||
| ^ expected `Box<dyn Trait>`, found integer
|
|
||||||
|
|
|
||||||
= note: expected struct `Box<(dyn Trait + 'static)>`
|
|
||||||
found type `{integer}`
|
|
||||||
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
|
|
||||||
help: store this in the heap by calling `Box::new`
|
|
||||||
|
|
|
||||||
LL | Box::new(0)
|
|
||||||
| +++++++++ +
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:55:9
|
|
||||||
|
|
|
||||||
LL | fn baw() -> Box<dyn Trait> {
|
|
||||||
| -------------- expected `Box<(dyn Trait + 'static)>` because of return type
|
|
||||||
...
|
|
||||||
LL | 42
|
|
||||||
| ^^ expected `Box<dyn Trait>`, found integer
|
|
||||||
|
|
|
||||||
= note: expected struct `Box<(dyn Trait + 'static)>`
|
|
||||||
found type `{integer}`
|
|
||||||
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
|
|
||||||
help: store this in the heap by calling `Box::new`
|
|
||||||
|
|
|
||||||
LL | Box::new(42)
|
|
||||||
| +++++++++ +
|
|
||||||
|
|
||||||
error[E0746]: return type cannot have an unboxed trait object
|
error[E0746]: return type cannot have an unboxed trait object
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:60:13
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:62:13
|
||||||
|
|
|
|
||||||
LL | fn bat() -> dyn Trait {
|
LL | fn bat() -> dyn Trait {
|
||||||
| ^^^^^^^^^ doesn't have a size known at compile-time
|
| ^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
@ -275,7 +121,7 @@ LL ~ Box::new(42)
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0746]: return type cannot have an unboxed trait object
|
error[E0746]: return type cannot have an unboxed trait object
|
||||||
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:66:13
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:68:13
|
||||||
|
|
|
|
||||||
LL | fn bay() -> dyn Trait {
|
LL | fn bay() -> dyn Trait {
|
||||||
| ^^^^^^^^^ doesn't have a size known at compile-time
|
| ^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
@ -293,7 +139,183 @@ LL | } else {
|
||||||
LL ~ Box::new(42)
|
LL ~ Box::new(42)
|
||||||
|
|
|
|
||||||
|
|
||||||
error: aborting due to 19 previous errors
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:35
|
||||||
|
|
|
||||||
|
LL | fn fuz() -> (usize, Trait) { (42, Struct) }
|
||||||
|
| ^^^^^^ expected `dyn Trait`, found `Struct`
|
||||||
|
|
|
||||||
|
= note: expected trait object `(dyn Trait + 'static)`
|
||||||
|
found struct `Struct`
|
||||||
|
= help: `Struct` implements `Trait` so you could box the found value and coerce it to the trait object `Box<dyn Trait>`, you will have to change the expected type as well
|
||||||
|
|
||||||
|
error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
|
||||||
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:30
|
||||||
|
|
|
||||||
|
LL | fn fuz() -> (usize, Trait) { (42, Struct) }
|
||||||
|
| ^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
||||||
|
= help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)`
|
||||||
|
= note: required because it appears within the type `(usize, (dyn Trait + 'static))`
|
||||||
|
= note: tuples must have a statically known size to be initialized
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:39
|
||||||
|
|
|
||||||
|
LL | fn bar() -> (usize, dyn Trait) { (42, Struct) }
|
||||||
|
| ^^^^^^ expected `dyn Trait`, found `Struct`
|
||||||
|
|
|
||||||
|
= note: expected trait object `(dyn Trait + 'static)`
|
||||||
|
found struct `Struct`
|
||||||
|
= help: `Struct` implements `Trait` so you could box the found value and coerce it to the trait object `Box<dyn Trait>`, you will have to change the expected type as well
|
||||||
|
|
||||||
|
error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
|
||||||
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:34
|
||||||
|
|
|
||||||
|
LL | fn bar() -> (usize, dyn Trait) { (42, Struct) }
|
||||||
|
| ^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
||||||
|
= help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)`
|
||||||
|
= note: required because it appears within the type `(usize, (dyn Trait + 'static))`
|
||||||
|
= note: tuples must have a statically known size to be initialized
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:36:16
|
||||||
|
|
|
||||||
|
LL | fn bam() -> Box<dyn Trait> {
|
||||||
|
| -------------- expected `Box<(dyn Trait + 'static)>` because of return type
|
||||||
|
LL | if true {
|
||||||
|
LL | return Struct;
|
||||||
|
| ^^^^^^ expected `Box<dyn Trait>`, found `Struct`
|
||||||
|
|
|
||||||
|
= note: expected struct `Box<(dyn Trait + 'static)>`
|
||||||
|
found struct `Struct`
|
||||||
|
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
|
||||||
|
help: store this in the heap by calling `Box::new`
|
||||||
|
|
|
||||||
|
LL | return Box::new(Struct);
|
||||||
|
| +++++++++ +
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:38:5
|
||||||
|
|
|
||||||
|
LL | fn bam() -> Box<dyn Trait> {
|
||||||
|
| -------------- expected `Box<(dyn Trait + 'static)>` because of return type
|
||||||
|
...
|
||||||
|
LL | 42
|
||||||
|
| ^^ expected `Box<dyn Trait>`, found integer
|
||||||
|
|
|
||||||
|
= note: expected struct `Box<(dyn Trait + 'static)>`
|
||||||
|
found type `{integer}`
|
||||||
|
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
|
||||||
|
help: store this in the heap by calling `Box::new`
|
||||||
|
|
|
||||||
|
LL | Box::new(42)
|
||||||
|
| +++++++++ +
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:42:16
|
||||||
|
|
|
||||||
|
LL | fn baq() -> Box<dyn Trait> {
|
||||||
|
| -------------- expected `Box<(dyn Trait + 'static)>` because of return type
|
||||||
|
LL | if true {
|
||||||
|
LL | return 0;
|
||||||
|
| ^ expected `Box<dyn Trait>`, found integer
|
||||||
|
|
|
||||||
|
= note: expected struct `Box<(dyn Trait + 'static)>`
|
||||||
|
found type `{integer}`
|
||||||
|
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
|
||||||
|
help: store this in the heap by calling `Box::new`
|
||||||
|
|
|
||||||
|
LL | return Box::new(0);
|
||||||
|
| +++++++++ +
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:44:5
|
||||||
|
|
|
||||||
|
LL | fn baq() -> Box<dyn Trait> {
|
||||||
|
| -------------- expected `Box<(dyn Trait + 'static)>` because of return type
|
||||||
|
...
|
||||||
|
LL | 42
|
||||||
|
| ^^ expected `Box<dyn Trait>`, found integer
|
||||||
|
|
|
||||||
|
= note: expected struct `Box<(dyn Trait + 'static)>`
|
||||||
|
found type `{integer}`
|
||||||
|
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
|
||||||
|
help: store this in the heap by calling `Box::new`
|
||||||
|
|
|
||||||
|
LL | Box::new(42)
|
||||||
|
| +++++++++ +
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:48:9
|
||||||
|
|
|
||||||
|
LL | fn baz() -> Box<dyn Trait> {
|
||||||
|
| -------------- expected `Box<(dyn Trait + 'static)>` because of return type
|
||||||
|
LL | if true {
|
||||||
|
LL | Struct
|
||||||
|
| ^^^^^^ expected `Box<dyn Trait>`, found `Struct`
|
||||||
|
|
|
||||||
|
= note: expected struct `Box<(dyn Trait + 'static)>`
|
||||||
|
found struct `Struct`
|
||||||
|
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
|
||||||
|
help: store this in the heap by calling `Box::new`
|
||||||
|
|
|
||||||
|
LL | Box::new(Struct)
|
||||||
|
| +++++++++ +
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:50:9
|
||||||
|
|
|
||||||
|
LL | fn baz() -> Box<dyn Trait> {
|
||||||
|
| -------------- expected `Box<(dyn Trait + 'static)>` because of return type
|
||||||
|
...
|
||||||
|
LL | 42
|
||||||
|
| ^^ expected `Box<dyn Trait>`, found integer
|
||||||
|
|
|
||||||
|
= note: expected struct `Box<(dyn Trait + 'static)>`
|
||||||
|
found type `{integer}`
|
||||||
|
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
|
||||||
|
help: store this in the heap by calling `Box::new`
|
||||||
|
|
|
||||||
|
LL | Box::new(42)
|
||||||
|
| +++++++++ +
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:55:9
|
||||||
|
|
|
||||||
|
LL | fn baw() -> Box<dyn Trait> {
|
||||||
|
| -------------- expected `Box<(dyn Trait + 'static)>` because of return type
|
||||||
|
LL | if true {
|
||||||
|
LL | 0
|
||||||
|
| ^ expected `Box<dyn Trait>`, found integer
|
||||||
|
|
|
||||||
|
= note: expected struct `Box<(dyn Trait + 'static)>`
|
||||||
|
found type `{integer}`
|
||||||
|
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
|
||||||
|
help: store this in the heap by calling `Box::new`
|
||||||
|
|
|
||||||
|
LL | Box::new(0)
|
||||||
|
| +++++++++ +
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/dyn-trait-return-should-be-impl-trait.rs:57:9
|
||||||
|
|
|
||||||
|
LL | fn baw() -> Box<dyn Trait> {
|
||||||
|
| -------------- expected `Box<(dyn Trait + 'static)>` because of return type
|
||||||
|
...
|
||||||
|
LL | 42
|
||||||
|
| ^^ expected `Box<dyn Trait>`, found integer
|
||||||
|
|
|
||||||
|
= note: expected struct `Box<(dyn Trait + 'static)>`
|
||||||
|
found type `{integer}`
|
||||||
|
= note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
|
||||||
|
help: store this in the heap by calling `Box::new`
|
||||||
|
|
|
||||||
|
LL | Box::new(42)
|
||||||
|
| +++++++++ +
|
||||||
|
|
||||||
|
error: aborting due to 21 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0277, E0308, E0746.
|
Some errors have detailed explanations: E0277, E0308, E0746.
|
||||||
For more information about an error, try `rustc --explain E0277`.
|
For more information about an error, try `rustc --explain E0277`.
|
||||||
|
|
|
@ -1,3 +1,62 @@
|
||||||
|
error[E0746]: return type cannot have an unboxed trait object
|
||||||
|
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:66:13
|
||||||
|
|
|
||||||
|
LL | fn hat() -> dyn std::fmt::Display {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
||||||
|
help: consider returning an `impl Trait` instead of a `dyn Trait`
|
||||||
|
|
|
||||||
|
LL | fn hat() -> impl std::fmt::Display {
|
||||||
|
| ~~~~
|
||||||
|
help: alternatively, box the return type, and wrap all of the returned values in `Box::new`
|
||||||
|
|
|
||||||
|
LL ~ fn hat() -> Box<dyn std::fmt::Display> {
|
||||||
|
LL | match 13 {
|
||||||
|
LL | 0 => {
|
||||||
|
LL ~ return Box::new(0i32);
|
||||||
|
LL | }
|
||||||
|
LL | _ => {
|
||||||
|
LL ~ Box::new(1u32)
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0746]: return type cannot have an unboxed trait object
|
||||||
|
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:77:13
|
||||||
|
|
|
||||||
|
LL | fn pug() -> dyn std::fmt::Display {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
||||||
|
help: consider returning an `impl Trait` instead of a `dyn Trait`
|
||||||
|
|
|
||||||
|
LL | fn pug() -> impl std::fmt::Display {
|
||||||
|
| ~~~~
|
||||||
|
help: alternatively, box the return type, and wrap all of the returned values in `Box::new`
|
||||||
|
|
|
||||||
|
LL ~ fn pug() -> Box<dyn std::fmt::Display> {
|
||||||
|
LL | match 13 {
|
||||||
|
LL ~ 0 => Box::new(0i32),
|
||||||
|
LL ~ 1 => Box::new(1u32),
|
||||||
|
LL ~ _ => Box::new(2u32),
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0746]: return type cannot have an unboxed trait object
|
||||||
|
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:85:13
|
||||||
|
|
|
||||||
|
LL | fn man() -> dyn std::fmt::Display {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
||||||
|
help: consider returning an `impl Trait` instead of a `dyn Trait`
|
||||||
|
|
|
||||||
|
LL | fn man() -> impl std::fmt::Display {
|
||||||
|
| ~~~~
|
||||||
|
help: alternatively, box the return type, and wrap all of the returned values in `Box::new`
|
||||||
|
|
|
||||||
|
LL ~ fn man() -> Box<dyn std::fmt::Display> {
|
||||||
|
LL | if false {
|
||||||
|
LL ~ Box::new(0i32)
|
||||||
|
LL | } else {
|
||||||
|
LL ~ Box::new(1u32)
|
||||||
|
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:5:5
|
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:5:5
|
||||||
|
|
|
|
||||||
|
@ -165,62 +224,6 @@ help: change the type of the numeric literal from `u32` to `i32`
|
||||||
LL | 1i32
|
LL | 1i32
|
||||||
| ~~~
|
| ~~~
|
||||||
|
|
||||||
error[E0746]: return type cannot have an unboxed trait object
|
|
||||||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:66:13
|
|
||||||
|
|
|
||||||
LL | fn hat() -> dyn std::fmt::Display {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
|
||||||
|
|
|
||||||
help: consider returning an `impl Trait` instead of a `dyn Trait`
|
|
||||||
|
|
|
||||||
LL | fn hat() -> impl std::fmt::Display {
|
|
||||||
| ~~~~
|
|
||||||
help: alternatively, box the return type, and wrap all of the returned values in `Box::new`
|
|
||||||
|
|
|
||||||
LL ~ fn hat() -> Box<dyn std::fmt::Display> {
|
|
||||||
LL | match 13 {
|
|
||||||
LL | 0 => {
|
|
||||||
LL ~ return Box::new(0i32);
|
|
||||||
LL | }
|
|
||||||
LL | _ => {
|
|
||||||
LL ~ Box::new(1u32)
|
|
||||||
|
|
|
||||||
|
|
||||||
error[E0746]: return type cannot have an unboxed trait object
|
|
||||||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:77:13
|
|
||||||
|
|
|
||||||
LL | fn pug() -> dyn std::fmt::Display {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
|
||||||
|
|
|
||||||
help: consider returning an `impl Trait` instead of a `dyn Trait`
|
|
||||||
|
|
|
||||||
LL | fn pug() -> impl std::fmt::Display {
|
|
||||||
| ~~~~
|
|
||||||
help: alternatively, box the return type, and wrap all of the returned values in `Box::new`
|
|
||||||
|
|
|
||||||
LL ~ fn pug() -> Box<dyn std::fmt::Display> {
|
|
||||||
LL | match 13 {
|
|
||||||
LL ~ 0 => Box::new(0i32),
|
|
||||||
LL ~ 1 => Box::new(1u32),
|
|
||||||
LL ~ _ => Box::new(2u32),
|
|
||||||
|
|
|
||||||
|
|
||||||
error[E0746]: return type cannot have an unboxed trait object
|
|
||||||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:85:13
|
|
||||||
|
|
|
||||||
LL | fn man() -> dyn std::fmt::Display {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
|
||||||
|
|
|
||||||
= help: if there were a single returned type, you could use `impl Trait` instead
|
|
||||||
help: box the return type, and wrap all of the returned values in `Box::new`
|
|
||||||
|
|
|
||||||
LL ~ fn man() -> Box<dyn std::fmt::Display> {
|
|
||||||
LL | if false {
|
|
||||||
LL ~ Box::new(0i32)
|
|
||||||
LL | } else {
|
|
||||||
LL ~ Box::new(1u32)
|
|
||||||
|
|
|
||||||
|
|
||||||
error: aborting due to 12 previous errors
|
error: aborting due to 12 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0308, E0746.
|
Some errors have detailed explanations: E0308, E0746.
|
||||||
|
|
|
@ -6,7 +6,7 @@ struct Struct {
|
||||||
|
|
||||||
fn new_struct(
|
fn new_struct(
|
||||||
r: dyn A + 'static //~ ERROR the size for values of type
|
r: dyn A + 'static //~ ERROR the size for values of type
|
||||||
) -> Struct {
|
) -> Struct { //~ ERROR the size for values of type
|
||||||
Struct { r: r }
|
Struct { r: r }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
|
error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time
|
||||||
|
--> $DIR/issue-5883.rs:9:6
|
||||||
|
|
|
||||||
|
LL | ) -> Struct {
|
||||||
|
| ^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
||||||
|
= help: within `Struct`, the trait `Sized` is not implemented for `(dyn A + 'static)`
|
||||||
|
note: required because it appears within the type `Struct`
|
||||||
|
--> $DIR/issue-5883.rs:3:8
|
||||||
|
|
|
||||||
|
LL | struct Struct {
|
||||||
|
| ^^^^^^
|
||||||
|
= note: the return type of a function must have a statically known size
|
||||||
|
|
||||||
error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time
|
error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time
|
||||||
--> $DIR/issue-5883.rs:8:8
|
--> $DIR/issue-5883.rs:8:8
|
||||||
|
|
|
|
||||||
|
@ -15,6 +29,6 @@ help: function arguments must have a statically known size, borrowed types alway
|
||||||
LL | r: &dyn A + 'static
|
LL | r: &dyn A + 'static
|
||||||
| +
|
| +
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0277`.
|
For more information about this error, try `rustc --explain E0277`.
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
error: requires `sized` lang_item
|
error: requires `sized` lang_item
|
||||||
|
--> $DIR/lang-item-missing.rs:11:60
|
||||||
|
|
|
||||||
|
LL | extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 {
|
||||||
|
| ^^^
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -14,16 +14,20 @@ mod bar {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn foo() {}
|
pub fn foo() {}
|
||||||
|
//~^ ERROR requires `sized` lang_item
|
||||||
|
|
||||||
fn test1() {
|
fn test1() {
|
||||||
|
//~^ ERROR requires `sized` lang_item
|
||||||
use bar::foo;
|
use bar::foo;
|
||||||
//~^ ERROR unresolved import `bar::foo` [E0432]
|
//~^ ERROR unresolved import `bar::foo` [E0432]
|
||||||
//~| no `foo` in `bar`
|
//~| no `foo` in `bar`
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test2() {
|
fn test2() {
|
||||||
|
//~^ ERROR requires `sized` lang_item
|
||||||
use bar::glob::foo;
|
use bar::glob::foo;
|
||||||
//~^ ERROR `foo` is private
|
//~^ ERROR `foo` is private
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
//~^ ERROR requires `sized` lang_item
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
error[E0432]: unresolved import `bar::foo`
|
error[E0432]: unresolved import `bar::foo`
|
||||||
--> $DIR/privacy2.rs:19:9
|
--> $DIR/privacy2.rs:21:9
|
||||||
|
|
|
|
||||||
LL | use bar::foo;
|
LL | use bar::foo;
|
||||||
| ^^^^^^^^ no `foo` in `bar`
|
| ^^^^^^^^ no `foo` in `bar`
|
||||||
|
|
||||||
error[E0603]: function import `foo` is private
|
error[E0603]: function import `foo` is private
|
||||||
--> $DIR/privacy2.rs:25:20
|
--> $DIR/privacy2.rs:28:20
|
||||||
|
|
|
|
||||||
LL | use bar::glob::foo;
|
LL | use bar::glob::foo;
|
||||||
| ^^^ private function import
|
| ^^^ private function import
|
||||||
|
@ -22,8 +22,40 @@ LL | pub fn foo() {}
|
||||||
| ^^^^^^^^^^^^ you could import this directly
|
| ^^^^^^^^^^^^ you could import this directly
|
||||||
|
|
||||||
error: requires `sized` lang_item
|
error: requires `sized` lang_item
|
||||||
|
--> $DIR/privacy2.rs:16:14
|
||||||
|
|
|
||||||
|
LL | pub fn foo() {}
|
||||||
|
| ^^
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: requires `sized` lang_item
|
||||||
|
--> $DIR/privacy2.rs:19:12
|
||||||
|
|
|
||||||
|
LL | fn test1() {
|
||||||
|
| ____________^
|
||||||
|
LL | |
|
||||||
|
LL | | use bar::foo;
|
||||||
|
... |
|
||||||
|
LL | | }
|
||||||
|
| |_^
|
||||||
|
|
||||||
|
error: requires `sized` lang_item
|
||||||
|
--> $DIR/privacy2.rs:26:12
|
||||||
|
|
|
||||||
|
LL | fn test2() {
|
||||||
|
| ____________^
|
||||||
|
LL | |
|
||||||
|
LL | | use bar::glob::foo;
|
||||||
|
LL | |
|
||||||
|
LL | | }
|
||||||
|
| |_^
|
||||||
|
|
||||||
|
error: requires `sized` lang_item
|
||||||
|
--> $DIR/privacy2.rs:32:11
|
||||||
|
|
|
||||||
|
LL | fn main() {}
|
||||||
|
| ^^
|
||||||
|
|
||||||
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0432, E0603.
|
Some errors have detailed explanations: E0432, E0603.
|
||||||
For more information about an error, try `rustc --explain E0432`.
|
For more information about an error, try `rustc --explain E0432`.
|
||||||
|
|
|
@ -11,12 +11,15 @@ mod bar {
|
||||||
|
|
||||||
mod glob {
|
mod glob {
|
||||||
fn gpriv() {}
|
fn gpriv() {}
|
||||||
|
//~^ ERROR requires `sized` lang_item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn foo() {}
|
pub fn foo() {}
|
||||||
|
//~^ ERROR requires `sized` lang_item
|
||||||
|
|
||||||
fn test1() {
|
fn test1() {
|
||||||
|
//~^ ERROR requires `sized` lang_item
|
||||||
use bar::gpriv;
|
use bar::gpriv;
|
||||||
//~^ ERROR unresolved import `bar::gpriv` [E0432]
|
//~^ ERROR unresolved import `bar::gpriv` [E0432]
|
||||||
//~| no `gpriv` in `bar`
|
//~| no `gpriv` in `bar`
|
||||||
|
@ -27,3 +30,4 @@ fn test1() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
//~^ ERROR requires `sized` lang_item
|
||||||
|
|
|
@ -1,11 +1,39 @@
|
||||||
error[E0432]: unresolved import `bar::gpriv`
|
error[E0432]: unresolved import `bar::gpriv`
|
||||||
--> $DIR/privacy3.rs:20:9
|
--> $DIR/privacy3.rs:23:9
|
||||||
|
|
|
|
||||||
LL | use bar::gpriv;
|
LL | use bar::gpriv;
|
||||||
| ^^^^^^^^^^ no `gpriv` in `bar`
|
| ^^^^^^^^^^ no `gpriv` in `bar`
|
||||||
|
|
||||||
error: requires `sized` lang_item
|
error: requires `sized` lang_item
|
||||||
|
--> $DIR/privacy3.rs:18:14
|
||||||
|
|
|
||||||
|
LL | pub fn foo() {}
|
||||||
|
| ^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: requires `sized` lang_item
|
||||||
|
--> $DIR/privacy3.rs:21:12
|
||||||
|
|
|
||||||
|
LL | fn test1() {
|
||||||
|
| ____________^
|
||||||
|
LL | |
|
||||||
|
LL | | use bar::gpriv;
|
||||||
|
... |
|
||||||
|
LL | | gpriv();
|
||||||
|
LL | | }
|
||||||
|
| |_^
|
||||||
|
|
||||||
|
error: requires `sized` lang_item
|
||||||
|
--> $DIR/privacy3.rs:32:11
|
||||||
|
|
|
||||||
|
LL | fn main() {}
|
||||||
|
| ^^
|
||||||
|
|
||||||
|
error: requires `sized` lang_item
|
||||||
|
--> $DIR/privacy3.rs:13:20
|
||||||
|
|
|
||||||
|
LL | fn gpriv() {}
|
||||||
|
| ^^
|
||||||
|
|
||||||
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0432`.
|
For more information about this error, try `rustc --explain E0432`.
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
error: requires `sized` lang_item
|
error: requires `sized` lang_item
|
||||||
|
--> $DIR/issue-59191-replace-root-with-fn.rs:9:1
|
||||||
|
|
|
||||||
|
LL | #![issue_59191::no_main]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this error originates in the attribute macro `issue_59191::no_main` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ fn main() {
|
||||||
static foo: dyn Fn() -> u32 = || -> u32 {
|
static foo: dyn Fn() -> u32 = || -> u32 {
|
||||||
//~^ ERROR the size for values of type
|
//~^ ERROR the size for values of type
|
||||||
//~| ERROR cannot be shared between threads safely
|
//~| ERROR cannot be shared between threads safely
|
||||||
//~| ERROR the size for values of type
|
|
||||||
//~| ERROR mismatched types
|
//~| ERROR mismatched types
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,33 +15,19 @@ LL | static foo: dyn Fn() -> u32 = || -> u32 {
|
||||||
|
|
|
|
||||||
= help: the trait `Sized` is not implemented for `(dyn Fn() -> u32 + 'static)`
|
= help: the trait `Sized` is not implemented for `(dyn Fn() -> u32 + 'static)`
|
||||||
|
|
||||||
error[E0277]: the size for values of type `(dyn Fn() -> u32 + 'static)` cannot be known at compilation time
|
|
||||||
--> $DIR/issue-24446.rs:2:35
|
|
||||||
|
|
|
||||||
LL | static foo: dyn Fn() -> u32 = || -> u32 {
|
|
||||||
| ___________________________________^
|
|
||||||
... |
|
|
||||||
LL | | 0
|
|
||||||
LL | | };
|
|
||||||
| |_____^ doesn't have a size known at compile-time
|
|
||||||
|
|
|
||||||
= help: the trait `Sized` is not implemented for `(dyn Fn() -> u32 + 'static)`
|
|
||||||
= note: constant expressions must have a statically known size
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-24446.rs:2:35
|
--> $DIR/issue-24446.rs:2:35
|
||||||
|
|
|
|
||||||
LL | static foo: dyn Fn() -> u32 = || -> u32 {
|
LL | static foo: dyn Fn() -> u32 = || -> u32 {
|
||||||
| ___________________________________^
|
| ___________________________________^
|
||||||
... |
|
... |
|
||||||
LL | | 0
|
|
||||||
LL | | };
|
LL | | };
|
||||||
| |_____^ expected `dyn Fn`, found closure
|
| |_____^ expected `dyn Fn`, found closure
|
||||||
|
|
|
|
||||||
= note: expected trait object `(dyn Fn() -> u32 + 'static)`
|
= note: expected trait object `(dyn Fn() -> u32 + 'static)`
|
||||||
found closure `{closure@$DIR/issue-24446.rs:2:35: 2:44}`
|
found closure `{closure@$DIR/issue-24446.rs:2:35: 2:44}`
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0277, E0308.
|
Some errors have detailed explanations: E0277, E0308.
|
||||||
For more information about an error, try `rustc --explain E0277`.
|
For more information about an error, try `rustc --explain E0277`.
|
||||||
|
|
|
@ -11,6 +11,12 @@ note: required because it appears within the type `Foo`
|
||||||
LL | pub struct Foo {
|
LL | pub struct Foo {
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/unsized_type2.rs:14:45
|
||||||
|
|
|
||||||
|
LL | pub static WITH_ERROR: Foo = Foo { version: 0 };
|
||||||
|
| ^ expected `str`, found integer
|
||||||
|
|
||||||
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
||||||
--> $DIR/unsized_type2.rs:14:30
|
--> $DIR/unsized_type2.rs:14:30
|
||||||
|
|
|
|
||||||
|
@ -23,13 +29,7 @@ note: required because it appears within the type `Foo`
|
||||||
|
|
|
|
||||||
LL | pub struct Foo {
|
LL | pub struct Foo {
|
||||||
| ^^^
|
| ^^^
|
||||||
= note: constant expressions must have a statically known size
|
= note: structs must have a statically known size to be initialized
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/unsized_type2.rs:14:45
|
|
||||||
|
|
|
||||||
LL | pub static WITH_ERROR: Foo = Foo { version: 0 };
|
|
||||||
| ^ expected `str`, found integer
|
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,18 @@ LL | trait Other: Sized {}
|
||||||
| |
|
| |
|
||||||
| this trait is not dyn compatible...
|
| this trait is not dyn compatible...
|
||||||
|
|
||||||
|
error[E0277]: the size for values of type `Self` cannot be known at compilation time
|
||||||
|
--> $DIR/dyn-incompatible-trait-references-self.rs:4:22
|
||||||
|
|
|
||||||
|
LL | fn bat(&self) -> Self {}
|
||||||
|
| ^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
||||||
|
= note: the return type of a function must have a statically known size
|
||||||
|
help: consider further restricting `Self`
|
||||||
|
|
|
||||||
|
LL | fn bat(&self) -> Self where Self: Sized {}
|
||||||
|
| +++++++++++++++++
|
||||||
|
|
||||||
error[E0277]: the size for values of type `Self` cannot be known at compilation time
|
error[E0277]: the size for values of type `Self` cannot be known at compilation time
|
||||||
--> $DIR/dyn-incompatible-trait-references-self.rs:2:22
|
--> $DIR/dyn-incompatible-trait-references-self.rs:2:22
|
||||||
|
|
|
|
||||||
|
@ -61,18 +73,6 @@ LL | fn bat(&self) -> Self {}
|
||||||
= note: expected type parameter `Self`
|
= note: expected type parameter `Self`
|
||||||
found unit type `()`
|
found unit type `()`
|
||||||
|
|
||||||
error[E0277]: the size for values of type `Self` cannot be known at compilation time
|
|
||||||
--> $DIR/dyn-incompatible-trait-references-self.rs:4:22
|
|
||||||
|
|
|
||||||
LL | fn bat(&self) -> Self {}
|
|
||||||
| ^^^^ doesn't have a size known at compile-time
|
|
||||||
|
|
|
||||||
= note: the return type of a function must have a statically known size
|
|
||||||
help: consider further restricting `Self`
|
|
||||||
|
|
|
||||||
LL | fn bat(&self) -> Self where Self: Sized {}
|
|
||||||
| +++++++++++++++++
|
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0038, E0277, E0308.
|
Some errors have detailed explanations: E0038, E0277, E0308.
|
||||||
|
|
|
@ -8,7 +8,6 @@ type Fn = dyn FnOnce() -> u8;
|
||||||
const TEST: Fn = some_fn;
|
const TEST: Fn = some_fn;
|
||||||
//~^ ERROR cannot find value `some_fn` in this scope
|
//~^ ERROR cannot find value `some_fn` in this scope
|
||||||
//~| ERROR the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time
|
//~| ERROR the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time
|
||||||
//~| ERROR the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time
|
|
||||||
const TEST2: (Fn, u8) = (TEST, 0);
|
const TEST2: (Fn, u8) = (TEST, 0);
|
||||||
//~^ ERROR the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time
|
//~^ ERROR the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time
|
||||||
//~| ERROR the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time
|
//~| ERROR the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time
|
||||||
|
|
|
@ -13,16 +13,7 @@ LL | const TEST: Fn = some_fn;
|
||||||
= help: the trait `Sized` is not implemented for `(dyn FnOnce() -> u8 + 'static)`
|
= help: the trait `Sized` is not implemented for `(dyn FnOnce() -> u8 + 'static)`
|
||||||
|
|
||||||
error[E0277]: the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time
|
error[E0277]: the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time
|
||||||
--> $DIR/ice-unsized-tuple-const-issue-121443.rs:8:18
|
--> $DIR/ice-unsized-tuple-const-issue-121443.rs:11:14
|
||||||
|
|
|
||||||
LL | const TEST: Fn = some_fn;
|
|
||||||
| ^^^^^^^ doesn't have a size known at compile-time
|
|
||||||
|
|
|
||||||
= help: the trait `Sized` is not implemented for `(dyn FnOnce() -> u8 + 'static)`
|
|
||||||
= note: constant expressions must have a statically known size
|
|
||||||
|
|
||||||
error[E0277]: the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time
|
|
||||||
--> $DIR/ice-unsized-tuple-const-issue-121443.rs:12:14
|
|
||||||
|
|
|
|
||||||
LL | const TEST2: (Fn, u8) = (TEST, 0);
|
LL | const TEST2: (Fn, u8) = (TEST, 0);
|
||||||
| ^^^^^^^^ doesn't have a size known at compile-time
|
| ^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
@ -31,7 +22,7 @@ LL | const TEST2: (Fn, u8) = (TEST, 0);
|
||||||
= note: only the last element of a tuple may have a dynamically sized type
|
= note: only the last element of a tuple may have a dynamically sized type
|
||||||
|
|
||||||
error[E0277]: the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time
|
error[E0277]: the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time
|
||||||
--> $DIR/ice-unsized-tuple-const-issue-121443.rs:12:25
|
--> $DIR/ice-unsized-tuple-const-issue-121443.rs:11:25
|
||||||
|
|
|
|
||||||
LL | const TEST2: (Fn, u8) = (TEST, 0);
|
LL | const TEST2: (Fn, u8) = (TEST, 0);
|
||||||
| ^^^^^^^^^ doesn't have a size known at compile-time
|
| ^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
@ -39,7 +30,7 @@ LL | const TEST2: (Fn, u8) = (TEST, 0);
|
||||||
= help: the trait `Sized` is not implemented for `(dyn FnOnce() -> u8 + 'static)`
|
= help: the trait `Sized` is not implemented for `(dyn FnOnce() -> u8 + 'static)`
|
||||||
= note: only the last element of a tuple may have a dynamically sized type
|
= note: only the last element of a tuple may have a dynamically sized type
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0277, E0425.
|
Some errors have detailed explanations: E0277, E0425.
|
||||||
For more information about an error, try `rustc --explain E0277`.
|
For more information about an error, try `rustc --explain E0277`.
|
||||||
|
|
|
@ -8,17 +8,6 @@ LL | impl const dyn T {
|
||||||
|
|
|
|
||||||
= note: only trait implementations may be annotated with `const`
|
= note: only trait implementations may be annotated with `const`
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/span-bug-issue-121418.rs:8:27
|
|
||||||
|
|
|
||||||
LL | pub const fn new() -> std::sync::Mutex<dyn T> {}
|
|
||||||
| --- ^^^^^^^^^^^^^^^^^^^^^^^ expected `Mutex<dyn T>`, found `()`
|
|
||||||
| |
|
|
||||||
| implicitly returns `()` as its body has no tail or `return` expression
|
|
||||||
|
|
|
||||||
= note: expected struct `Mutex<(dyn T + 'static)>`
|
|
||||||
found unit type `()`
|
|
||||||
|
|
||||||
error[E0277]: the size for values of type `(dyn T + 'static)` cannot be known at compilation time
|
error[E0277]: the size for values of type `(dyn T + 'static)` cannot be known at compilation time
|
||||||
--> $DIR/span-bug-issue-121418.rs:8:27
|
--> $DIR/span-bug-issue-121418.rs:8:27
|
||||||
|
|
|
|
||||||
|
@ -30,6 +19,17 @@ note: required because it appears within the type `Mutex<(dyn T + 'static)>`
|
||||||
--> $SRC_DIR/std/src/sync/poison/mutex.rs:LL:COL
|
--> $SRC_DIR/std/src/sync/poison/mutex.rs:LL:COL
|
||||||
= note: the return type of a function must have a statically known size
|
= note: the return type of a function must have a statically known size
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/span-bug-issue-121418.rs:8:27
|
||||||
|
|
|
||||||
|
LL | pub const fn new() -> std::sync::Mutex<dyn T> {}
|
||||||
|
| --- ^^^^^^^^^^^^^^^^^^^^^^^ expected `Mutex<dyn T>`, found `()`
|
||||||
|
| |
|
||||||
|
| implicitly returns `()` as its body has no tail or `return` expression
|
||||||
|
|
|
||||||
|
= note: expected struct `Mutex<(dyn T + 'static)>`
|
||||||
|
found unit type `()`
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0277, E0308.
|
Some errors have detailed explanations: E0277, E0308.
|
||||||
|
|
|
@ -13,8 +13,9 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn weird0() -> impl Sized + !Sized {}
|
fn weird0() -> impl Sized + !Sized {}
|
||||||
//~^ ERROR the trait bound `(): !Sized` is not satisfied
|
//~^ ERROR type mismatch resolving
|
||||||
fn weird1() -> impl !Sized + Sized {}
|
fn weird1() -> impl !Sized + Sized {}
|
||||||
//~^ ERROR the trait bound `(): !Sized` is not satisfied
|
//~^ ERROR type mismatch resolving
|
||||||
fn weird2() -> impl !Sized {}
|
fn weird2() -> impl !Sized {}
|
||||||
//~^ ERROR the trait bound `(): !Sized` is not satisfied
|
//~^ ERROR type mismatch resolving
|
||||||
|
//~| ERROR the size for values of type
|
||||||
|
|
|
@ -1,20 +1,29 @@
|
||||||
error[E0277]: the trait bound `(): !Sized` is not satisfied
|
error[E0277]: the size for values of type `impl !Sized` cannot be known at compilation time
|
||||||
--> $DIR/opaque-type-unsatisfied-bound.rs:15:16
|
|
||||||
|
|
|
||||||
LL | fn weird0() -> impl Sized + !Sized {}
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied
|
|
||||||
|
|
||||||
error[E0277]: the trait bound `(): !Sized` is not satisfied
|
|
||||||
--> $DIR/opaque-type-unsatisfied-bound.rs:17:16
|
|
||||||
|
|
|
||||||
LL | fn weird1() -> impl !Sized + Sized {}
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied
|
|
||||||
|
|
||||||
error[E0277]: the trait bound `(): !Sized` is not satisfied
|
|
||||||
--> $DIR/opaque-type-unsatisfied-bound.rs:19:16
|
--> $DIR/opaque-type-unsatisfied-bound.rs:19:16
|
||||||
|
|
|
|
||||||
LL | fn weird2() -> impl !Sized {}
|
LL | fn weird2() -> impl !Sized {}
|
||||||
| ^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied
|
| ^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
||||||
|
= help: the trait `Sized` is not implemented for `impl !Sized`
|
||||||
|
= note: the return type of a function must have a statically known size
|
||||||
|
|
||||||
|
error[E0271]: type mismatch resolving `impl !Sized + Sized == ()`
|
||||||
|
--> $DIR/opaque-type-unsatisfied-bound.rs:15:16
|
||||||
|
|
|
||||||
|
LL | fn weird0() -> impl Sized + !Sized {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^ types differ
|
||||||
|
|
||||||
|
error[E0271]: type mismatch resolving `impl !Sized + Sized == ()`
|
||||||
|
--> $DIR/opaque-type-unsatisfied-bound.rs:17:16
|
||||||
|
|
|
||||||
|
LL | fn weird1() -> impl !Sized + Sized {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^ types differ
|
||||||
|
|
||||||
|
error[E0271]: type mismatch resolving `impl !Sized == ()`
|
||||||
|
--> $DIR/opaque-type-unsatisfied-bound.rs:19:16
|
||||||
|
|
|
||||||
|
LL | fn weird2() -> impl !Sized {}
|
||||||
|
| ^^^^^^^^^^^ types differ
|
||||||
|
|
||||||
error[E0277]: the trait bound `impl !Trait: Trait` is not satisfied
|
error[E0277]: the trait bound `impl !Trait: Trait` is not satisfied
|
||||||
--> $DIR/opaque-type-unsatisfied-bound.rs:12:13
|
--> $DIR/opaque-type-unsatisfied-bound.rs:12:13
|
||||||
|
@ -30,6 +39,7 @@ note: required by a bound in `consume`
|
||||||
LL | fn consume(_: impl Trait) {}
|
LL | fn consume(_: impl Trait) {}
|
||||||
| ^^^^^ required by this bound in `consume`
|
| ^^^^^ required by this bound in `consume`
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0277`.
|
Some errors have detailed explanations: E0271, E0277.
|
||||||
|
For more information about an error, try `rustc --explain E0271`.
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
#![feature(negative_bounds, unboxed_closures)]
|
#![feature(negative_bounds, unboxed_closures)]
|
||||||
|
|
||||||
fn produce() -> impl !Fn<(u32,)> {}
|
fn produce() -> impl !Fn<(u32,)> {}
|
||||||
//~^ ERROR the trait bound `(): !Fn(u32)` is not satisfied
|
//~^ ERROR type mismatch resolving
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
error[E0277]: the trait bound `(): !Fn(u32)` is not satisfied
|
error[E0271]: type mismatch resolving `impl !Fn<(u32,)> == ()`
|
||||||
--> $DIR/opaque-type-unsatisfied-fn-bound.rs:5:17
|
--> $DIR/opaque-type-unsatisfied-fn-bound.rs:5:17
|
||||||
|
|
|
|
||||||
LL | fn produce() -> impl !Fn<(u32,)> {}
|
LL | fn produce() -> impl !Fn<(u32,)> {}
|
||||||
| ^^^^^^^^^^^^^^^^ the trait bound `(): !Fn(u32)` is not satisfied
|
| ^^^^^^^^^^^^^^^^ types differ
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0277`.
|
For more information about this error, try `rustc --explain E0271`.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
fn digit() -> str {
|
fn digit() -> str {
|
||||||
|
//~^ ERROR the size for values of type
|
||||||
return {};
|
return {};
|
||||||
//~^ ERROR: mismatched types [E0308]
|
//~^ ERROR: mismatched types [E0308]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0425]: cannot find value `_y` in this scope
|
error[E0425]: cannot find value `_y` in this scope
|
||||||
--> $DIR/issue-105946.rs:6:10
|
--> $DIR/issue-105946.rs:7:10
|
||||||
|
|
|
|
||||||
LL | let [_y..] = [Box::new(1), Box::new(2)];
|
LL | let [_y..] = [Box::new(1), Box::new(2)];
|
||||||
| ^^ not found in this scope
|
| ^^ not found in this scope
|
||||||
|
@ -10,7 +10,7 @@ LL | let [_y @ ..] = [Box::new(1), Box::new(2)];
|
||||||
| +
|
| +
|
||||||
|
|
||||||
error[E0658]: `X..` patterns in slices are experimental
|
error[E0658]: `X..` patterns in slices are experimental
|
||||||
--> $DIR/issue-105946.rs:6:10
|
--> $DIR/issue-105946.rs:7:10
|
||||||
|
|
|
|
||||||
LL | let [_y..] = [Box::new(1), Box::new(2)];
|
LL | let [_y..] = [Box::new(1), Box::new(2)];
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
@ -19,19 +19,28 @@ LL | let [_y..] = [Box::new(1), Box::new(2)];
|
||||||
= help: add `#![feature(half_open_range_patterns_in_slices)]` to the crate attributes to enable
|
= help: add `#![feature(half_open_range_patterns_in_slices)]` to the crate attributes to enable
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
|
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
||||||
|
--> $DIR/issue-105946.rs:1:15
|
||||||
|
|
|
||||||
|
LL | fn digit() -> str {
|
||||||
|
| ^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
||||||
|
= help: the trait `Sized` is not implemented for `str`
|
||||||
|
= note: the return type of a function must have a statically known size
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-105946.rs:2:12
|
--> $DIR/issue-105946.rs:3:12
|
||||||
|
|
|
|
||||||
LL | return {};
|
LL | return {};
|
||||||
| ^^ expected `str`, found `()`
|
| ^^ expected `str`, found `()`
|
||||||
|
|
||||||
error[E0527]: pattern requires 1 element but array has 2
|
error[E0527]: pattern requires 1 element but array has 2
|
||||||
--> $DIR/issue-105946.rs:6:9
|
--> $DIR/issue-105946.rs:7:9
|
||||||
|
|
|
|
||||||
LL | let [_y..] = [Box::new(1), Box::new(2)];
|
LL | let [_y..] = [Box::new(1), Box::new(2)];
|
||||||
| ^^^^^^ expected 2 elements
|
| ^^^^^^ expected 2 elements
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0308, E0425, E0527, E0658.
|
Some errors have detailed explanations: E0277, E0308, E0425, E0527, E0658.
|
||||||
For more information about an error, try `rustc --explain E0308`.
|
For more information about an error, try `rustc --explain E0277`.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
|
|
||||||
fn dbl<T>(x: T) -> <T as Add>::Output
|
fn dbl<T>(x: T) -> <T as Add>::Output
|
||||||
|
//~^ ERROR type annotations needed
|
||||||
where
|
where
|
||||||
T: Copy + Add,
|
T: Copy + Add,
|
||||||
UUU: Copy,
|
UUU: Copy,
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
error[E0412]: cannot find type `UUU` in this scope
|
error[E0412]: cannot find type `UUU` in this scope
|
||||||
--> $DIR/ignore-err-clauses.rs:6:5
|
--> $DIR/ignore-err-clauses.rs:7:5
|
||||||
|
|
|
|
||||||
LL | UUU: Copy,
|
LL | UUU: Copy,
|
||||||
| ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error[E0282]: type annotations needed
|
||||||
|
--> $DIR/ignore-err-clauses.rs:3:14
|
||||||
|
|
|
||||||
|
LL | fn dbl<T>(x: T) -> <T as Add>::Output
|
||||||
|
| ^ cannot infer type for type parameter `T`
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0412`.
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0282, E0412.
|
||||||
|
For more information about an error, try `rustc --explain E0282`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue