Auto merge of #153919 - matthiaskrgr:rollup-UnSAPBk, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#153870 (docs: remove stale reference to `check_let_chain`)
 - rust-lang/rust#153881 (Provide more context on type errors in const context)
 - rust-lang/rust#153887 (Turn label into structured suggestion for `.as_ref()` and `.as_mut()`)
 - rust-lang/rust#153897 (Use less `#[macro_use]` in the query system)
 - rust-lang/rust#153914 (add test for param-env shadowing)
 - rust-lang/rust#153917 (compiletest: show rustdoc logs when `--no-capture`)
This commit is contained in:
bors
2026-03-15 17:27:21 +00:00
104 changed files with 736 additions and 179 deletions
@@ -1377,7 +1377,9 @@ fn explain_captures(
matches!(tcx.get_diagnostic_name(def_id), Some(sym::Option | sym::Result))
});
if is_option_or_result && maybe_reinitialized_locations_is_empty {
err.subdiagnostic(CaptureReasonLabel::BorrowContent { var_span });
err.subdiagnostic(CaptureReasonLabel::BorrowContent {
var_span: var_span.shrink_to_hi(),
});
}
if let Some((CallDesugaringKind::ForLoopIntoIter, _)) = desugaring {
let ty = moved_place.ty(self.body, tcx).ty;
@@ -456,7 +456,18 @@ pub(crate) enum CaptureReasonLabel<'a> {
is_move_msg: bool,
is_loop_message: bool,
},
#[label("help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents")]
#[suggestion(
"consider calling `.as_ref()` to borrow the value's contents",
applicability = "maybe-incorrect",
code = ".as_ref()",
style = "verbose"
)]
#[suggestion(
"consider calling `.as_mut()` to mutably borrow the value's contents",
applicability = "maybe-incorrect",
code = ".as_mut()",
style = "verbose"
)]
BorrowContent {
#[primary_span]
var_span: Span,
+124 -2
View File
@@ -41,7 +41,7 @@
use fn_ctxt::FnCtxt;
use rustc_data_structures::unord::UnordSet;
use rustc_errors::codes::*;
use rustc_errors::{Applicability, ErrorGuaranteed, pluralize, struct_span_code_err};
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, pluralize, struct_span_code_err};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::{HirId, HirIdMap, Node};
@@ -204,7 +204,9 @@ fn typeck_with_inspect<'tcx>(
);
}
fcx.check_expr_coercible_to_type(body.value, expected_type, None);
fcx.check_expr_coercible_to_type_or_error(body.value, expected_type, None, |err, _| {
extend_err_with_const_context(err, tcx, node, expected_type);
});
fcx.write_ty(id, expected_type);
};
@@ -274,6 +276,126 @@ fn typeck_with_inspect<'tcx>(
typeck_results
}
fn extend_err_with_const_context(
err: &mut Diag<'_>,
tcx: TyCtxt<'_>,
node: hir::Node<'_>,
expected_ty: Ty<'_>,
) {
match node {
hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(ty, _), .. })
| hir::Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Const(ty, _, _), ..
}) => {
// Point at the `Type` in `const NAME: Type = value;`.
err.span_label(ty.span, "expected because of the type of the associated constant");
}
hir::Node::Item(hir::Item { kind: hir::ItemKind::Const(_, _, ty, _), .. }) => {
// Point at the `Type` in `const NAME: Type = value;`.
err.span_label(ty.span, "expected because of the type of the constant");
}
hir::Node::Item(hir::Item { kind: hir::ItemKind::Static(_, _, ty, _), .. }) => {
// Point at the `Type` in `static NAME: Type = value;`.
err.span_label(ty.span, "expected because of the type of the static");
}
hir::Node::AnonConst(anon)
if let hir::Node::ConstArg(parent) = tcx.parent_hir_node(anon.hir_id)
&& let hir::Node::Ty(parent) = tcx.parent_hir_node(parent.hir_id)
&& let hir::TyKind::Array(_ty, _len) = parent.kind =>
{
// `[type; len]` in type context.
err.note("array length can only be `usize`");
}
hir::Node::AnonConst(anon)
if let hir::Node::ConstArg(parent) = tcx.parent_hir_node(anon.hir_id)
&& let hir::Node::Expr(parent) = tcx.parent_hir_node(parent.hir_id)
&& let hir::ExprKind::Repeat(_ty, _len) = parent.kind =>
{
// `[type; len]` in expr context.
err.note("array length can only be `usize`");
}
// FIXME: support method calls too.
hir::Node::AnonConst(anon)
if let hir::Node::ConstArg(parent) = tcx.parent_hir_node(anon.hir_id)
&& let hir::Node::Expr(expr) = tcx.parent_hir_node(parent.hir_id)
&& let hir::ExprKind::Path(path) = expr.kind
&& let hir::QPath::Resolved(_, path) = path
&& let Res::Def(_, def_id) = path.res =>
{
// `foo<N>()` in expression context, point at `foo`'s const parameter.
if let Some(i) =
path.segments.iter().last().and_then(|segment| segment.args).and_then(|args| {
args.args.iter().position(|arg| {
matches!(arg, hir::GenericArg::Const(arg) if arg.hir_id == parent.hir_id)
})
})
{
let generics = tcx.generics_of(def_id);
let param = &generics.param_at(i, tcx);
let sp = tcx.def_span(param.def_id);
err.span_note(sp, "expected because of the type of the const parameter");
}
}
hir::Node::AnonConst(anon)
if let hir::Node::ConstArg(parent) = tcx.parent_hir_node(anon.hir_id)
&& let hir::Node::Ty(ty) = tcx.parent_hir_node(parent.hir_id)
&& let hir::TyKind::Path(path) = ty.kind
&& let hir::QPath::Resolved(_, path) = path
&& let Res::Def(_, def_id) = path.res =>
{
// `Foo<N>` in type context, point at `Foo`'s const parameter.
if let Some(i) =
path.segments.iter().last().and_then(|segment| segment.args).and_then(|args| {
args.args.iter().position(|arg| {
matches!(arg, hir::GenericArg::Const(arg) if arg.hir_id == parent.hir_id)
})
})
{
let generics = tcx.generics_of(def_id);
let param = &generics.param_at(i, tcx);
let sp = tcx.def_span(param.def_id);
err.span_note(sp, "expected because of the type of the const parameter");
}
}
hir::Node::AnonConst(anon)
if let hir::Node::Variant(_variant) = tcx.parent_hir_node(anon.hir_id) =>
{
// FIXME: point at `repr` when present in the type.
err.note(
"enum variant discriminant can only be of a primitive type compatible with the \
enum's `repr`",
);
}
hir::Node::AnonConst(anon)
if let hir::Node::ConstArg(parent) = tcx.parent_hir_node(anon.hir_id)
&& let hir::Node::GenericParam(param) = tcx.parent_hir_node(parent.hir_id)
&& let hir::GenericParamKind::Const { ty, .. } = param.kind =>
{
// `fn foo<const N: usize = ()>` point at the `usize`.
err.span_label(ty.span, "expected because of the type of the const parameter");
}
hir::Node::AnonConst(anon)
if let hir::Node::ConstArg(parent) = tcx.parent_hir_node(anon.hir_id)
&& let hir::Node::TyPat(ty_pat) = tcx.parent_hir_node(parent.hir_id)
&& let hir::Node::Ty(ty) = tcx.parent_hir_node(ty_pat.hir_id)
&& let hir::TyKind::Pat(ty, _) = ty.kind =>
{
// Point at `char` in `pattern_type!(char is 1..=1)`.
err.span_label(ty.span, "the pattern must match the type");
}
hir::Node::AnonConst(anon)
if let hir::Node::Field(_) = tcx.parent_hir_node(anon.hir_id)
&& let ty::Param(_) = expected_ty.kind() =>
{
err.note(
"the type of default fields referencing type parameters can't be assumed inside \
the struct defining them",
);
}
_ => {}
}
}
fn infer_type_if_missing<'tcx>(fcx: &FnCtxt<'_, 'tcx>, node: Node<'tcx>) -> Option<Ty<'tcx>> {
let tcx = fcx.tcx;
let def_id = fcx.body_id;
+2 -2
View File
@@ -498,8 +498,8 @@ fn #name(#key_ty) #return_ty
/// Higher-order macro that invokes the specified macro with (a) a list of all query
/// signatures (including modifiers), and (b) a list of non-query names. This allows
/// multiple simpler macros to each have access to these lists.
#[macro_export]
macro_rules! rustc_with_all_queries {
#[rustc_macro_transparency = "semiopaque"] // Use `macro_rules!` hygiene.
pub macro rustc_with_all_queries {
(
// The macro to invoke once, on all queries and non-queries.
$macro:ident!
@@ -331,7 +331,7 @@ pub mod label_strs {
}
// Create various data structures for each query, and also for a few things that aren't queries.
rustc_with_all_queries! { define_dep_nodes! }
crate::queries::rustc_with_all_queries! { define_dep_nodes! }
// WARNING: `construct` is generic and does not know that `CompileCodegenUnit` takes `Symbol`s as keys.
// Be very careful changing this type signature!
+4 -7
View File
@@ -67,6 +67,8 @@
#[macro_use]
pub mod arena;
pub mod dep_graph;
pub mod error;
pub mod hir;
pub mod hooks;
@@ -76,18 +78,13 @@
pub mod metadata;
pub mod middle;
pub mod mir;
pub mod queries;
pub mod query;
pub mod thir;
pub mod traits;
pub mod ty;
pub mod util;
pub mod verify_ich;
#[macro_use]
pub mod query;
#[macro_use]
pub mod queries;
#[macro_use]
pub mod dep_graph;
// Allows macros to refer to this crate as `::rustc_middle`
extern crate self as rustc_middle;
+1
View File
@@ -101,6 +101,7 @@
CodegenUnit, CollectionMode, MonoItem, MonoItemPartitions, NormalizationErrorInMono,
};
use crate::query::describe_as_module;
use crate::query::plumbing::{define_callbacks, query_helper_param_ty};
use crate::traits::query::{
CanonicalAliasGoal, CanonicalDropckOutlivesGoal, CanonicalImpliedOutlivesBoundsGoal,
CanonicalMethodAutoderefStepsGoal, CanonicalPredicateGoal, CanonicalTypeOpAscribeUserTypeGoal,
+2 -3
View File
@@ -17,10 +17,9 @@
pub(crate) mod inner;
mod job;
mod keys;
pub mod on_disk_cache;
#[macro_use]
pub mod plumbing;
pub(crate) mod modifiers;
pub mod on_disk_cache;
pub mod plumbing;
mod stack;
pub fn describe_as_module(def_id: impl Into<LocalDefId>, tcx: TyCtxt<'_>) -> String {
@@ -630,6 +630,10 @@ fn clone(&self) -> Self { *self }
};
}
// Re-export `macro_rules!` macros as normal items, so that they can be imported normally.
pub(crate) use define_callbacks;
pub(crate) use query_helper_param_ty;
mod sealed {
use rustc_hir::def_id::{LocalModDefId, ModDefId};
@@ -101,8 +101,7 @@ struct MatchVisitor<'p, 'tcx> {
error: Result<(), ErrorGuaranteed>,
}
// Visitor for a thir body. This calls `check_match`, `check_let` and `check_let_chain` as
// appropriate.
// Visitor for a thir body. This calls `check_match` and `check_let` as appropriate.
impl<'p, 'tcx> Visitor<'p, 'tcx> for MatchVisitor<'p, 'tcx> {
fn thir(&self) -> &'p Thir<'tcx> {
self.thir
@@ -179,7 +179,7 @@ fn $name:ident($K:ty) -> $V:ty
// Create an array of vtables, one for each dep kind (non-query and query).
pub fn make_dep_kind_vtables<'tcx>(arena: &'tcx Arena<'tcx>) -> &'tcx [DepKindVTable<'tcx>] {
let (nq_vtables, q_vtables) =
rustc_middle::rustc_with_all_queries! { define_dep_kind_vtables! };
rustc_middle::queries::rustc_with_all_queries! { define_dep_kind_vtables! };
// Non-query vtables must come before query vtables, to match the order of `DepKind`.
arena.alloc_from_iter(nq_vtables.into_iter().chain(q_vtables.into_iter()))
+1 -1
View File
@@ -272,4 +272,4 @@ macro_rules! for_each_query_vtable {
}
}
rustc_middle::rustc_with_all_queries! { define_queries! }
rustc_middle::queries::rustc_with_all_queries! { define_queries! }
+6 -3
View File
@@ -1707,7 +1707,8 @@ pub enum TypeErrorAdditionalDiags {
#[suggestion(
"if you meant to write a byte literal, prefix with `b`",
code = "b'{code}'",
applicability = "machine-applicable"
applicability = "machine-applicable",
style = "verbose"
)]
MeantByteLiteral {
#[primary_span]
@@ -1717,7 +1718,8 @@ pub enum TypeErrorAdditionalDiags {
#[suggestion(
"if you meant to write a `char` literal, use single quotes",
code = "'{code}'",
applicability = "machine-applicable"
applicability = "machine-applicable",
style = "verbose"
)]
MeantCharLiteral {
#[primary_span]
@@ -1737,7 +1739,8 @@ pub enum TypeErrorAdditionalDiags {
#[suggestion(
"consider specifying the actual array length",
code = "{length}",
applicability = "maybe-incorrect"
applicability = "maybe-incorrect",
style = "verbose"
)]
ConsiderSpecifyingLength {
#[primary_span]
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> tests/ui/track-diagnostics.rs:LL:CC
|
LL | const S: A = B;
| ^ expected `A`, found `B`
| - ^ expected `A`, found `B`
| |
| expected because of the type of the constant
|
= note: -Ztrack-diagnostics: created at compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs:LL:CC
@@ -14,6 +14,11 @@ pub(super) fn run_rustdoc_json_test(&self) {
});
let proc_res = self.document(&out_dir, DocKind::Json);
if !self.config.capture {
writeln!(self.stdout, "{}", proc_res.format_info());
}
if !proc_res.status.success() {
self.fatal_proc_rec("rustdoc failed!", &proc_res);
}
+1
View File
@@ -11,3 +11,4 @@
//~^ ERROR mismatched types
//~| NOTE created at
//~| NOTE expected `A`, found `B`
//~| NOTE expected because of the type of the const
+3 -1
View File
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/track-diagnostics.rs:LL:CC
|
LL | pub const S: A = B;
| ^ expected `A`, found `B`
| - ^ expected `A`, found `B`
| |
| expected because of the type of the constant
|
= note: -Ztrack-diagnostics: created at compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs:LL:CC
@@ -6,6 +6,7 @@ LL | fn([u8; |x: u8| {}]),
|
= note: expected type `usize`
found closure `{closure@$DIR/closure-in-array-len.rs:3:13: 3:20}`
= note: array length can only be `usize`
error: aborting due to 1 previous error
@@ -16,7 +16,9 @@ error[E0308]: mismatched types
--> $DIR/subslice-only-once-semantic-restriction.rs:11:30
|
LL | const RECOVERY_WITNESS: () = 0;
| ^ expected `()`, found integer
| -- ^ expected `()`, found integer
| |
| expected because of the type of the constant
error: aborting due to 3 previous errors
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/suggest-contraining-assoc-type-because-of-assoc-const.rs:13:21
|
LL | const N: C::M = 4u8;
| ^^^ expected associated type, found `u8`
| ---- ^^^ expected associated type, found `u8`
| |
| expected because of the type of the associated constant
|
= note: expected associated type `<C as O>::M`
found type `u8`
@@ -0,0 +1,19 @@
error[E0277]: the trait bound `Self: Eq<<Self as Trait>::Assoc>` is not satisfied
--> $DIR/always-applicable-impls-shadowed-in-trait-def.rs:13:17
|
LL | fn foo() -> IsEqual<Self, Self::Assoc> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq<<Self as Trait>::Assoc>` is not implemented for `Self`
|
note: required by a bound in `IsEqual`
--> $DIR/always-applicable-impls-shadowed-in-trait-def.rs:9:19
|
LL | struct IsEqual<T: Eq<U>, U>(T, U);
| ^^^^^ required by this bound in `IsEqual`
help: consider further restricting `Self`
|
LL | fn foo() -> IsEqual<Self, Self::Assoc> where Self: Eq<<Self as Trait>::Assoc> {
| ++++++++++++++++++++++++++++++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
@@ -0,0 +1,19 @@
error[E0277]: the trait bound `Self: Eq<<Self as Trait>::Assoc>` is not satisfied
--> $DIR/always-applicable-impls-shadowed-in-trait-def.rs:13:17
|
LL | fn foo() -> IsEqual<Self, Self::Assoc> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq<<Self as Trait>::Assoc>` is not implemented for `Self`
|
note: required by a bound in `IsEqual`
--> $DIR/always-applicable-impls-shadowed-in-trait-def.rs:9:19
|
LL | struct IsEqual<T: Eq<U>, U>(T, U);
| ^^^^^ required by this bound in `IsEqual`
help: consider further restricting `Self`
|
LL | fn foo() -> IsEqual<Self, Self::Assoc> where Self: Eq<<Self as Trait>::Assoc> {
| ++++++++++++++++++++++++++++++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
@@ -0,0 +1,23 @@
//@ revisions: old next
//@[next] compile-flags: -Znext-solver
// Testing that even if there's an always applicable blanket impl, the trait
// definition cannot use that impl to normalize its own associated types.
trait Eq<T> {}
impl<T> Eq<T> for T {}
struct IsEqual<T: Eq<U>, U>(T, U);
trait Trait: Sized {
type Assoc;
fn foo() -> IsEqual<Self, Self::Assoc> {
//~^ ERROR the trait bound `Self: Eq<<Self as Trait>::Assoc>` is not satisfied
todo!()
}
}
impl<T> Trait for T {
type Assoc = T;
}
fn main() {}
@@ -37,6 +37,7 @@ trait AssocConst {
//~^ ERROR mismatched types
//~| NOTE expected associated type, found `u8`
//~| NOTE expected associated type `<Self as AssocConst>::Ty`
//~| NOTE expected because
}
// An impl can, however
@@ -19,13 +19,15 @@ LL | type Ty = u8;
| ------- associated type defaults can't be assumed inside the trait defining them
...
LL | const C: Self::Ty = 0u8;
| ^^^ expected associated type, found `u8`
| -------- ^^^ expected associated type, found `u8`
| |
| expected because of the type of the associated constant
|
= note: expected associated type `<Self as AssocConst>::Ty`
found type `u8`
error[E0308]: mismatched types
--> $DIR/defaults-in-other-trait-items.rs:54:9
--> $DIR/defaults-in-other-trait-items.rs:55:9
|
LL | type Res = isize;
| -------- associated type defaults can't be assumed inside the trait defining them
+3 -1
View File
@@ -4,7 +4,9 @@ error[E0308]: mismatched types
LL | type Fv: Foo = u8;
| ------------ associated type defaults can't be assumed inside the trait defining them
LL | const C: <Self::Fv as Foo>::Bar = 6665;
| ^^^^ expected associated type, found integer
| ---------------------- ^^^^ expected associated type, found integer
| |
| expected because of the type of the associated constant
|
= note: expected associated type `<<Self as Baz>::Fv as Foo>::Bar`
found type `{integer}`
@@ -4,11 +4,18 @@ error[E0507]: cannot move out of `*cb` which is behind a mutable reference
LL | cb.map(|cb| cb());
| ^^ -------------- `*cb` moved due to this method call
| |
| help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents
| move occurs because `*cb` has type `Option<&mut dyn FnMut()>`, which does not implement the `Copy` trait
|
note: `Option::<T>::map` takes ownership of the receiver `self`, which moves `*cb`
--> $SRC_DIR/core/src/option.rs:LL:COL
help: consider calling `.as_ref()` to borrow the value's contents
|
LL | cb.as_ref().map(|cb| cb());
| +++++++++
help: consider calling `.as_mut()` to mutably borrow the value's contents
|
LL | cb.as_mut().map(|cb| cb());
| +++++++++
help: you could `clone` the value and consume it, if the `&mut dyn FnMut(): Clone` trait bound could be satisfied
|
LL | <Option<&mut dyn FnMut()> as Clone>::clone(&cb).map(|cb| cb());
+1
View File
@@ -20,6 +20,7 @@ LL | type_ascribe!(2, n([u8; || 1]))
|
= note: expected type `usize`
found closure `{closure@$DIR/issue-90871.rs:4:29: 4:31}`
= note: array length can only be `usize`
help: use parentheses to call this closure
|
LL | type_ascribe!(2, n([u8; (|| 1)()]))
@@ -9,6 +9,7 @@
//~^ ERROR rustc_dump_predicates
//~| NOTE Binder { value: ConstArgHasType(T/#0, &'static [*mut u8; 3_usize]), bound_vars: [] }
//~| NOTE Binder { value: TraitPredicate(<ConstBytes<b"AAA"> as std::marker::Sized>, polarity:Positive), bound_vars: [] }
//~| NOTE expected because of the type of the const parameter
where
ConstBytes<b"AAA">: Sized;
@@ -1,11 +1,16 @@
error[E0308]: mismatched types
--> $DIR/byte-string-u8-validation.rs:14:16
--> $DIR/byte-string-u8-validation.rs:15:16
|
LL | ConstBytes<b"AAA">: Sized;
| ^^^^^^ expected `&[*mut u8; 3]`, found `&[u8; 3]`
|
= note: expected reference `&'static [*mut u8; 3]`
found reference `&'static [u8; 3]`
note: expected because of the type of the const parameter
--> $DIR/byte-string-u8-validation.rs:8:19
|
LL | struct ConstBytes<const T: &'static [*mut u8; 3]>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: rustc_dump_predicates
--> $DIR/byte-string-u8-validation.rs:8:1
@@ -15,6 +15,11 @@ LL | let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">;
|
= note: expected reference `&'static [*mut u8; 3]`
found reference `&'static [u8; 3]`
note: expected because of the type of the const parameter
--> $DIR/mismatch-raw-ptr-in-adt.rs:5:19
|
LL | struct ConstBytes<const T: &'static [*mut u8; 3]>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/mismatch-raw-ptr-in-adt.rs:9:46
@@ -24,6 +29,11 @@ LL | let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">;
|
= note: expected reference `&'static [*mut u8; 3]`
found reference `&'static [u8; 3]`
note: expected because of the type of the const parameter
--> $DIR/mismatch-raw-ptr-in-adt.rs:5:19
|
LL | struct ConstBytes<const T: &'static [*mut u8; 3]>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors
@@ -16,7 +16,9 @@ error[E0308]: mismatched types
--> $DIR/transmutable-ice-110969.rs:25:29
|
LL | const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
| ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
| |
| expected because of the type of the associated constant
error: aborting due to 3 previous errors
@@ -36,7 +36,9 @@ error[E0308]: mismatched types
--> $DIR/unsized-anon-const-err-1.rs:8:34
|
LL | const EMPTY_MATRIX: Matrix = [[0; 4]; 4];
| ^^^^^^^^^^^ expected `[&u32]`, found `[&u32; 4]`
| ------ ^^^^^^^^^^^ expected `[&u32]`, found `[&u32; 4]`
| |
| expected because of the type of the constant
error: aborting due to 5 previous errors
@@ -21,7 +21,9 @@ error[E0308]: mismatched types
--> $DIR/unsized-anon-const-func-err.rs:9:22
|
LL | const VALUE: [u32] = [0; 4];
| ^^^^^^ expected `[u32]`, found `[u32; 4]`
| ----- ^^^^^^ expected `[u32]`, found `[u32; 4]`
| |
| expected because of the type of the constant
error[E0277]: the size for values of type `[u32]` cannot be known at compilation time
--> $DIR/unsized-anon-const-func-err.rs:14:12
@@ -30,7 +30,9 @@ error[E0308]: mismatched types
--> $DIR/unsized-anon-const-struct-err.rs:6:22
|
LL | const VALUE: [u32] = [0; 4];
| ^^^^^^ expected `[u32]`, found `[u32; 4]`
| ----- ^^^^^^ expected `[u32]`, found `[u32; 4]`
| |
| expected because of the type of the constant
error: aborting due to 4 previous errors
@@ -3,6 +3,8 @@ error[E0308]: mismatched types
|
LL | x: [u8; SIZE],
| ^^^^ expected `usize`, found `u32`
|
= note: array length can only be `usize`
error[E0308]: mismatched types
--> $DIR/bad-generic-in-copy-impl.rs:3:13
@@ -10,6 +12,7 @@ error[E0308]: mismatched types
LL | x: [u8; SIZE],
| ^^^^ expected `usize`, found `u32`
|
= note: array length can only be `usize`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors
@@ -29,12 +29,24 @@ error[E0308]: mismatched types
|
LL | impl A<2> {
| ^ expected `[usize; x]`, found integer
|
note: expected because of the type of the const parameter
--> $DIR/error_in_ty.rs:6:14
|
LL | pub struct A<const z: [usize; x]> {}
| ^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/error_in_ty.rs:16:8
|
LL | impl A<2> {
| ^ expected `[usize; x]`, found integer
|
note: expected because of the type of the const parameter
--> $DIR/error_in_ty.rs:6:14
|
LL | pub struct A<const z: [usize; x]> {}
| ^^^^^^^^^^^^^^^^^^^
error[E0592]: duplicate definitions with name `B`
--> $DIR/error_in_ty.rs:12:5
@@ -14,7 +14,9 @@ error[E0308]: mismatched types
--> $DIR/issue-105257.rs:5:29
|
LL | fn fnc<const N: usize = "">(&self) {}
| ^^ expected `usize`, found `&str`
| ----- ^^ expected `usize`, found `&str`
| |
| expected because of the type of the const parameter
error: aborting due to 3 previous errors
@@ -9,6 +9,7 @@ LL | let _: [u8; (N / 2) as Foo] = [0; (N / 2) as usize];
|
= note: expected type `usize`
found opaque type `Foo`
= note: array length can only be `usize`
error[E0605]: non-primitive cast: `usize` as `Foo`
--> $DIR/opaque_type.rs:11:17
@@ -3,24 +3,48 @@ error[E0308]: mismatched types
|
LL | get_flag::<false, 0xFF>();
| ^^^^ expected `char`, found `u8`
|
note: expected because of the type of the const parameter
--> $DIR/invalid-patterns.rs:6:34
|
LL | fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> {
| ^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:33:14
|
LL | get_flag::<7, 'c'>();
| ^ expected `bool`, found integer
|
note: expected because of the type of the const parameter
--> $DIR/invalid-patterns.rs:6:13
|
LL | fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> {
| ^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:35:14
|
LL | get_flag::<42, 0x5ad>();
| ^^ expected `bool`, found integer
|
note: expected because of the type of the const parameter
--> $DIR/invalid-patterns.rs:6:13
|
LL | fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> {
| ^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:35:18
|
LL | get_flag::<42, 0x5ad>();
| ^^^^^ expected `char`, found `u8`
|
note: expected because of the type of the const parameter
--> $DIR/invalid-patterns.rs:6:34
|
LL | fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> {
| ^^^^^^^^^^^^^^^^^^^^^
error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
--> $DIR/invalid-patterns.rs:40:32
@@ -3,24 +3,48 @@ error[E0308]: mismatched types
|
LL | get_flag::<false, 0xFF>();
| ^^^^ expected `char`, found `u8`
|
note: expected because of the type of the const parameter
--> $DIR/invalid-patterns.rs:6:34
|
LL | fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> {
| ^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:33:14
|
LL | get_flag::<7, 'c'>();
| ^ expected `bool`, found integer
|
note: expected because of the type of the const parameter
--> $DIR/invalid-patterns.rs:6:13
|
LL | fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> {
| ^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:35:14
|
LL | get_flag::<42, 0x5ad>();
| ^^ expected `bool`, found integer
|
note: expected because of the type of the const parameter
--> $DIR/invalid-patterns.rs:6:13
|
LL | fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> {
| ^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:35:18
|
LL | get_flag::<42, 0x5ad>();
| ^^^^^ expected `char`, found `u8`
|
note: expected because of the type of the const parameter
--> $DIR/invalid-patterns.rs:6:34
|
LL | fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> {
| ^^^^^^^^^^^^^^^^^^^^^
error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
--> $DIR/invalid-patterns.rs:40:32
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/basic-fail.rs:15:30
|
LL | const ARR: [(); ADD1::<0>] = [(); INC::<0>];
| ^^^^^^^^^^^^^^ expected an array with a size of const { N + 1 }, found one with a size of const { N + 1 }
| --------------- ^^^^^^^^^^^^^^ expected an array with a size of const { N + 1 }, found one with a size of const { N + 1 }
| |
| expected because of the type of the constant
error: aborting due to 1 previous error
@@ -30,6 +30,11 @@ LL | foo::<42>();
|
= note: expected opaque type `Foo`
found type `{integer}`
note: expected because of the type of the const parameter
--> $DIR/opaque_types.rs:6:8
|
LL | fn foo<const C: Foo>() {}
| ^^^^^^^^^^^^
error: aborting due to 3 previous errors
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/vec-macro-in-static-array.rs:5:26
|
LL | static VEC: [u32; 256] = vec![];
| ^^^^^^ expected `[u32; 256]`, found `Vec<_>`
| ---------- ^^^^^^ expected `[u32; 256]`, found `Vec<_>`
| |
| expected because of the type of the static
|
= note: expected array `[u32; 256]`
found struct `Vec<_>`
@@ -2,9 +2,15 @@ error[E0308]: mismatched types
--> $DIR/array-literal-len-mismatch.rs:1:26
|
LL | const NUMBERS: [u8; 3] = [10, 20];
| - ^^^^^^^^ expected an array with a size of 3, found one with a size of 2
| |
| help: consider specifying the actual array length: `2`
| ------- ^^^^^^^^ expected an array with a size of 3, found one with a size of 2
| |
| expected because of the type of the constant
|
help: consider specifying the actual array length
|
LL - const NUMBERS: [u8; 3] = [10, 20];
LL + const NUMBERS: [u8; 2] = [10, 20];
|
error: aborting due to 1 previous error
+4 -2
View File
@@ -4,10 +4,12 @@
const BONG: [i32; (ARR[0] - 41) as usize] = [5];
const BLUB: [i32; (ARR[0] - 40) as usize] = [5];
//~^ ERROR: mismatched types
//~| NOTE expected an array
//~| NOTE: expected an array
//~| NOTE: expected because
const BOO: [i32; (ARR[0] - 41) as usize] = [5, 99];
//~^ ERROR: mismatched types
//~| NOTE expected an array
//~| NOTE: expected an array
//~| NOTE: expected because
fn main() {
let _ = VAL;
+19 -7
View File
@@ -2,17 +2,29 @@ error[E0308]: mismatched types
--> $DIR/const-array-oob-arith.rs:5:45
|
LL | const BLUB: [i32; (ARR[0] - 40) as usize] = [5];
| ---------------------- ^^^ expected an array with a size of 2, found one with a size of 1
| |
| help: consider specifying the actual array length: `1`
| ----------------------------- ^^^ expected an array with a size of 2, found one with a size of 1
| |
| expected because of the type of the constant
|
help: consider specifying the actual array length
|
LL - const BLUB: [i32; (ARR[0] - 40) as usize] = [5];
LL + const BLUB: [i32; 1] = [5];
|
error[E0308]: mismatched types
--> $DIR/const-array-oob-arith.rs:8:44
--> $DIR/const-array-oob-arith.rs:9:44
|
LL | const BOO: [i32; (ARR[0] - 41) as usize] = [5, 99];
| ---------------------- ^^^^^^^ expected an array with a size of 1, found one with a size of 2
| |
| help: consider specifying the actual array length: `2`
| ----------------------------- ^^^^^^^ expected an array with a size of 1, found one with a size of 2
| |
| expected because of the type of the constant
|
help: consider specifying the actual array length
|
LL - const BOO: [i32; (ARR[0] - 41) as usize] = [5, 99];
LL + const BOO: [i32; 2] = [5, 99];
|
error: aborting due to 2 previous errors
@@ -4,6 +4,7 @@ error[E0308]: mismatched types
LL | pub struct Data([[&'static str]; 5_i32]);
| ^^^^^ expected `usize`, found `i32`
|
= note: array length can only be `usize`
help: change the type of the numeric literal from `i32` to `usize`
|
LL - pub struct Data([[&'static str]; 5_i32]);
@@ -7,8 +7,9 @@
enum E {
V = CONSTANT,
//~^ ERROR mismatched types
//~| NOTE expected `isize`, found `S`
//~^ ERROR: mismatched types
//~| NOTE: expected `isize`, found `S`
//~| NOTE: enum variant discriminant
}
fn main() {}
@@ -3,6 +3,8 @@ error[E0308]: mismatched types
|
LL | V = CONSTANT,
| ^^^^^^^^ expected `isize`, found `S`
|
= note: enum variant discriminant can only be of a primitive type compatible with the enum's `repr`
error: aborting due to 1 previous error
+10
View File
@@ -5,6 +5,7 @@
//~| NOTE expected `bool`, found integer
//~| ERROR mismatched types
//~| NOTE expected `usize`, found `bool`
//~| NOTE expected because
const ARR: [i32; X] = [99; 34];
const X1: usize = 42 || 39;
@@ -14,6 +15,7 @@
//~| NOTE expected `bool`, found integer
//~| ERROR mismatched types
//~| NOTE expected `usize`, found `bool`
//~| NOTE expected because
const ARR1: [i32; X1] = [99; 47];
const X2: usize = -42 || -39;
@@ -23,6 +25,7 @@
//~| NOTE expected `bool`, found integer
//~| ERROR mismatched types
//~| NOTE expected `usize`, found `bool`
//~| NOTE expected because
const ARR2: [i32; X2] = [99; 18446744073709551607];
const X3: usize = -42 && -39;
@@ -32,36 +35,43 @@
//~| NOTE expected `bool`, found integer
//~| ERROR mismatched types
//~| NOTE expected `usize`, found `bool`
//~| NOTE expected because
const ARR3: [i32; X3] = [99; 6];
const Y: usize = 42.0 == 42.0;
//~^ ERROR mismatched types
//~| NOTE expected `usize`, found `bool`
//~| NOTE expected because
const ARRR: [i32; Y] = [99; 1];
const Y1: usize = 42.0 >= 42.0;
//~^ ERROR mismatched types
//~| NOTE expected `usize`, found `bool`
//~| NOTE expected because
const ARRR1: [i32; Y1] = [99; 1];
const Y2: usize = 42.0 <= 42.0;
//~^ ERROR mismatched types
//~| NOTE expected `usize`, found `bool`
//~| NOTE expected because
const ARRR2: [i32; Y2] = [99; 1];
const Y3: usize = 42.0 > 42.0;
//~^ ERROR mismatched types
//~| NOTE expected `usize`, found `bool`
//~| NOTE expected because
const ARRR3: [i32; Y3] = [99; 0];
const Y4: usize = 42.0 < 42.0;
//~^ ERROR mismatched types
//~| NOTE expected `usize`, found `bool`
//~| NOTE expected because
const ARRR4: [i32; Y4] = [99; 0];
const Y5: usize = 42.0 != 42.0;
//~^ ERROR mismatched types
//~| NOTE expected `usize`, found `bool`
//~| NOTE expected because
const ARRR5: [i32; Y5] = [99; 0];
fn main() {
+49 -29
View File
@@ -14,97 +14,117 @@ error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:1:18
|
LL | const X: usize = 42 && 39;
| ^^^^^^^^ expected `usize`, found `bool`
| ----- ^^^^^^^^ expected `usize`, found `bool`
| |
| expected because of the type of the constant
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:10:19
--> $DIR/const-integer-bool-ops.rs:11:19
|
LL | const X1: usize = 42 || 39;
| ^^ expected `bool`, found integer
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:10:25
--> $DIR/const-integer-bool-ops.rs:11:25
|
LL | const X1: usize = 42 || 39;
| ^^ expected `bool`, found integer
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:10:19
--> $DIR/const-integer-bool-ops.rs:11:19
|
LL | const X1: usize = 42 || 39;
| ^^^^^^^^ expected `usize`, found `bool`
| ----- ^^^^^^^^ expected `usize`, found `bool`
| |
| expected because of the type of the constant
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:19:19
--> $DIR/const-integer-bool-ops.rs:21:19
|
LL | const X2: usize = -42 || -39;
| ^^^ expected `bool`, found integer
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:19:26
--> $DIR/const-integer-bool-ops.rs:21:26
|
LL | const X2: usize = -42 || -39;
| ^^^ expected `bool`, found integer
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:19:19
--> $DIR/const-integer-bool-ops.rs:21:19
|
LL | const X2: usize = -42 || -39;
| ^^^^^^^^^^ expected `usize`, found `bool`
| ----- ^^^^^^^^^^ expected `usize`, found `bool`
| |
| expected because of the type of the constant
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:28:19
--> $DIR/const-integer-bool-ops.rs:31:19
|
LL | const X3: usize = -42 && -39;
| ^^^ expected `bool`, found integer
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:28:26
--> $DIR/const-integer-bool-ops.rs:31:26
|
LL | const X3: usize = -42 && -39;
| ^^^ expected `bool`, found integer
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:28:19
--> $DIR/const-integer-bool-ops.rs:31:19
|
LL | const X3: usize = -42 && -39;
| ^^^^^^^^^^ expected `usize`, found `bool`
| ----- ^^^^^^^^^^ expected `usize`, found `bool`
| |
| expected because of the type of the constant
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:37:18
--> $DIR/const-integer-bool-ops.rs:41:18
|
LL | const Y: usize = 42.0 == 42.0;
| ^^^^^^^^^^^^ expected `usize`, found `bool`
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:42:19
|
LL | const Y1: usize = 42.0 >= 42.0;
| ^^^^^^^^^^^^ expected `usize`, found `bool`
| ----- ^^^^^^^^^^^^ expected `usize`, found `bool`
| |
| expected because of the type of the constant
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:47:19
|
LL | const Y2: usize = 42.0 <= 42.0;
| ^^^^^^^^^^^^ expected `usize`, found `bool`
LL | const Y1: usize = 42.0 >= 42.0;
| ----- ^^^^^^^^^^^^ expected `usize`, found `bool`
| |
| expected because of the type of the constant
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:52:19
--> $DIR/const-integer-bool-ops.rs:53:19
|
LL | const Y2: usize = 42.0 <= 42.0;
| ----- ^^^^^^^^^^^^ expected `usize`, found `bool`
| |
| expected because of the type of the constant
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:59:19
|
LL | const Y3: usize = 42.0 > 42.0;
| ^^^^^^^^^^^ expected `usize`, found `bool`
| ----- ^^^^^^^^^^^ expected `usize`, found `bool`
| |
| expected because of the type of the constant
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:57:19
--> $DIR/const-integer-bool-ops.rs:65:19
|
LL | const Y4: usize = 42.0 < 42.0;
| ^^^^^^^^^^^ expected `usize`, found `bool`
| ----- ^^^^^^^^^^^ expected `usize`, found `bool`
| |
| expected because of the type of the constant
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:62:19
--> $DIR/const-integer-bool-ops.rs:71:19
|
LL | const Y5: usize = 42.0 != 42.0;
| ^^^^^^^^^^^^ expected `usize`, found `bool`
| ----- ^^^^^^^^^^^^ expected `usize`, found `bool`
| |
| expected because of the type of the constant
error: aborting due to 18 previous errors
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/const-result-no-expect-suggestion.rs:5:19
|
LL | const TEST: u32 = f(2);
| ^^^^ expected `u32`, found `Result<u32, ()>`
| --- ^^^^ expected `u32`, found `Result<u32, ()>`
| |
| expected because of the type of the constant
|
= note: expected type `u32`
found enum `Result<u32, ()>`
@@ -11,7 +11,9 @@ error[E0308]: mismatched types
--> $DIR/const-slice-array-deref.rs:1:20
|
LL | const ONE: [u16] = [1];
| ^^^ expected `[u16]`, found `[u16; 1]`
| ----- ^^^ expected `[u16]`, found `[u16; 1]`
| |
| expected because of the type of the constant
error[E0161]: cannot move a value of type `[u16]`
--> $DIR/const-slice-array-deref.rs:5:28
+4 -3
View File
@@ -1,9 +1,10 @@
// Test spans of errors
const TUP: (usize,) = 5usize << 64;
//~^ ERROR mismatched types
//~| NOTE expected `(usize,)`, found `usize`
//~| NOTE expected tuple `(usize,)`
//~^ ERROR: mismatched types
//~| NOTE: expected `(usize,)`, found `usize`
//~| NOTE: expected tuple `(usize,)`
//~| NOTE: expected because
const ARR: [i32; TUP.0] = [];
fn main() {
+3 -1
View File
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/const-tup-index-span.rs:3:23
|
LL | const TUP: (usize,) = 5usize << 64;
| ^^^^^^^^^^^^ expected `(usize,)`, found `usize`
| -------- ^^^^^^^^^^^^ expected `(usize,)`, found `usize`
| |
| expected because of the type of the constant
|
= note: expected tuple `(usize,)`
found type `usize`
+6 -2
View File
@@ -2,13 +2,17 @@ error[E0308]: mismatched types
--> $DIR/const-type-mismatch.rs:4:21
|
LL | const TWELVE: u16 = TEN + 2;
| ^^^^^^^ expected `u16`, found `u8`
| --- ^^^^^^^ expected `u16`, found `u8`
| |
| expected because of the type of the constant
error[E0308]: mismatched types
--> $DIR/const-type-mismatch.rs:9:27
|
LL | const ALSO_TEN: u16 = TEN;
| ^^^ expected `u16`, found `u8`
| --- ^^^ expected `u16`, found `u8`
| |
| expected because of the type of the constant
error: aborting due to 2 previous errors
@@ -10,6 +10,7 @@ LL | | B = T,
LL | | }
| |_- in this macro invocation
|
= note: enum variant discriminant can only be of a primitive type compatible with the enum's `repr`
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
@@ -24,6 +25,7 @@ LL | | B = T,
LL | | }
| |_- in this macro invocation
|
= note: enum variant discriminant can only be of a primitive type compatible with the enum's `repr`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
+3 -1
View File
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/issue-104768.rs:1:15
|
LL | const A: &_ = 0_u32;
| ^^^^^ expected `&_`, found `u32`
| -- ^^^^^ expected `&_`, found `u32`
| |
| expected because of the type of the constant
|
= note: expected reference `&'static _`
found type `u32`
+6 -4
View File
@@ -1,11 +1,13 @@
const LENGTH: f64 = 2;
//~^ ERROR mismatched types
//~| NOTE expected `f64`, found integer
//~^ ERROR: mismatched types
//~| NOTE: expected `f64`, found integer
//~| NOTE: expected because
struct Thing {
f: [[f64; 2]; LENGTH],
//~^ ERROR mismatched types
//~| NOTE expected `usize`, found `f64`
//~^ ERROR: mismatched types
//~| NOTE: expected `usize`, found `f64`
//~| NOTE: array length
}
fn main() {
+6 -2
View File
@@ -1,14 +1,18 @@
error[E0308]: mismatched types
--> $DIR/issue-39974.rs:6:19
--> $DIR/issue-39974.rs:7:19
|
LL | f: [[f64; 2]; LENGTH],
| ^^^^^^ expected `usize`, found `f64`
|
= note: array length can only be `usize`
error[E0308]: mismatched types
--> $DIR/issue-39974.rs:1:21
|
LL | const LENGTH: f64 = 2;
| ^ expected `f64`, found integer
| --- ^ expected `f64`, found integer
| |
| expected because of the type of the constant
|
help: use a float literal
|
@@ -3,12 +3,16 @@ error[E0308]: mismatched types
|
LL | const A: [(); 0.1] = [()];
| ^^^ expected `usize`, found floating-point number
|
= note: array length can only be `usize`
error[E0308]: mismatched types
--> $DIR/issue-69310-array-size-lit-wrong-ty.rs:11:15
|
LL | const B: [(); b"a"] = [()];
| ^^^^ expected `usize`, found `&[u8; 1]`
|
= note: array length can only be `usize`
error: aborting due to 2 previous errors
@@ -6,6 +6,7 @@ LL | [9; || [9; []]];
|
= note: expected type `usize`
found array `[_; 0]`
= note: array length can only be `usize`
error: aborting due to 1 previous error
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/promoted-type-error-issue-133968.rs:4:29
|
LL | static STR: &'static [u8] = "a b";
| ^^^^^ expected `&[u8]`, found `&str`
| ------------- ^^^^^ expected `&[u8]`, found `&str`
| |
| expected because of the type of the static
|
= note: expected reference `&'static [u8]`
found reference `&'static str`
@@ -9,8 +9,10 @@ LL │ …u8 = [0, 0, 0, 0, 0, 0, 0, 0, 0, …, 0, 0, 0, 0, 0, 0, 0] + [0, 0, 0,
error[E0308]: mismatched types
╭▸ $DIR/long-span.rs:9:15
LL │ …u8 = [0, 0, 0, 0, 0, 0, 0, 0, 0, , 0, 0, 0, 0, 0, 0, 0];
╰╴ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ expected `u8`, found `[{integer}; 1680]`
LL │ …t D: u8 = [0, 0, 0, 0, 0, 0, 0, 0 0, 0, 0, 0, 0, 0, 0, 0, 0];
┬─ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ expected `u8`, found `[{integer}; 1680]`
│ │
╰╴ expected because of the type of the constant
error: aborting due to 2 previous errors
@@ -9,8 +9,10 @@ LL | ... = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...0, 0, 0, 0, 0, 0, 0, 0, 0
error[E0308]: mismatched types
--> $DIR/long-span.rs:9:15
|
LL | ... = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `[{integer}; 1680]`
LL | ...D: u8 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,..., 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `[{integer}; 1680]`
| |
| expected because of the type of the constant
error: aborting due to 2 previous errors
@@ -9,8 +9,10 @@ LL │ …u8 = [0, 0, 0…0] + [0, 0, 0…0];
error[E0308]: mismatched types
╭▸ $DIR/long-span.rs:9:15
LL │ …u8 = [0, 0, 0…0];
╰╴ ━━━━━━━━━━ expected `u8`, found `[{integer}; 1680]`
LL │ …t D: u8 = [0,…, 0, 0];
┬─ ━━━━━━━━━━ expected `u8`, found `[{integer}; 1680]`
│ │
╰╴ expected because of the type of the constant
error: aborting due to 2 previous errors
@@ -9,8 +9,10 @@ LL | ... = [0, 0, 0...0] + [0, 0, 0...0];
error[E0308]: mismatched types
--> $DIR/long-span.rs:9:15
|
LL | ... = [0, 0, 0...0];
| ^^^^^^^^...^^ expected `u8`, found `[{integer}; 1680]`
LL | ...D: u8 = [0,..., 0, 0];
| -- ^^^...^^^^^^^ expected `u8`, found `[{integer}; 1680]`
| |
| expected because of the type of the constant
error: aborting due to 2 previous errors
@@ -14,7 +14,9 @@ error[E0308]: mismatched types
--> $DIR/brackets-to-braces-single-element.rs:4:19
|
LL | const B: &[u32] = &{ 1 };
| ^^^^^^ expected `&[u32]`, found `&{integer}`
| ------ ^^^^^^ expected `&[u32]`, found `&{integer}`
| |
| expected because of the type of the constant
|
= note: expected reference `&'static [u32]`
found reference `&{integer}`
@@ -13,8 +13,9 @@ enum A {
Ok = i8::MAX - 1,
Ok2,
OhNo = 0_u8,
//~^ ERROR mismatched types
//~| NOTE expected `i8`, found `u8`
//~^ ERROR: mismatched types
//~| NOTE: expected `i8`, found `u8`
//~| NOTE: enum variant discriminant
}
let x = A::Ok;
@@ -26,8 +27,9 @@ enum A {
Ok = u8::MAX - 1,
Ok2,
OhNo = 0_i8,
//~^ ERROR mismatched types
//~| NOTE expected `u8`, found `i8`
//~^ ERROR: mismatched types
//~| NOTE: expected `u8`, found `i8`
//~| NOTE: enum variant discriminant
}
let x = A::Ok;
@@ -39,8 +41,9 @@ enum A {
Ok = i16::MAX - 1,
Ok2,
OhNo = 0_u16,
//~^ ERROR mismatched types
//~| NOTE expected `i16`, found `u16`
//~^ ERROR: mismatched types
//~| NOTE: expected `i16`, found `u16`
//~| NOTE: enum variant discriminant
}
let x = A::Ok;
@@ -52,8 +55,9 @@ enum A {
Ok = u16::MAX - 1,
Ok2,
OhNo = 0_i16,
//~^ ERROR mismatched types
//~| NOTE expected `u16`, found `i16`
//~^ ERROR: mismatched types
//~| NOTE: expected `u16`, found `i16`
//~| NOTE: enum variant discriminant
}
let x = A::Ok;
@@ -65,8 +69,9 @@ enum A {
Ok = i32::MAX - 1,
Ok2,
OhNo = 0_u32,
//~^ ERROR mismatched types
//~| NOTE expected `i32`, found `u32`
//~^ ERROR: mismatched types
//~| NOTE: expected `i32`, found `u32`
//~| NOTE: enum variant discriminant
}
let x = A::Ok;
@@ -78,8 +83,9 @@ enum A {
Ok = u32::MAX - 1,
Ok2,
OhNo = 0_i32,
//~^ ERROR mismatched types
//~| NOTE expected `u32`, found `i32`
//~^ ERROR: mismatched types
//~| NOTE: expected `u32`, found `i32`
//~| NOTE: enum variant discriminant
}
let x = A::Ok;
@@ -91,8 +97,9 @@ enum A {
Ok = i64::MAX - 1,
Ok2,
OhNo = 0_u64,
//~^ ERROR mismatched types
//~| NOTE expected `i64`, found `u64`
//~^ ERROR: mismatched types
//~| NOTE: expected `i64`, found `u64`
//~| NOTE: enum variant discriminant
}
let x = A::Ok;
@@ -104,8 +111,9 @@ enum A {
Ok = u64::MAX - 1,
Ok2,
OhNo = 0_i64,
//~^ ERROR mismatched types
//~| NOTE expected `u64`, found `i64`
//~^ ERROR: mismatched types
//~| NOTE: expected `u64`, found `i64`
//~| NOTE: enum variant discriminant
}
let x = A::Ok;
@@ -4,6 +4,7 @@ error[E0308]: mismatched types
LL | OhNo = 0_u8,
| ^^^^ expected `i8`, found `u8`
|
= note: enum variant discriminant can only be of a primitive type compatible with the enum's `repr`
help: change the type of the numeric literal from `u8` to `i8`
|
LL - OhNo = 0_u8,
@@ -11,11 +12,12 @@ LL + OhNo = 0_i8,
|
error[E0308]: mismatched types
--> $DIR/discriminant-ill-typed.rs:28:16
--> $DIR/discriminant-ill-typed.rs:29:16
|
LL | OhNo = 0_i8,
| ^^^^ expected `u8`, found `i8`
|
= note: enum variant discriminant can only be of a primitive type compatible with the enum's `repr`
help: change the type of the numeric literal from `i8` to `u8`
|
LL - OhNo = 0_i8,
@@ -23,11 +25,12 @@ LL + OhNo = 0_u8,
|
error[E0308]: mismatched types
--> $DIR/discriminant-ill-typed.rs:41:16
--> $DIR/discriminant-ill-typed.rs:43:16
|
LL | OhNo = 0_u16,
| ^^^^^ expected `i16`, found `u16`
|
= note: enum variant discriminant can only be of a primitive type compatible with the enum's `repr`
help: change the type of the numeric literal from `u16` to `i16`
|
LL - OhNo = 0_u16,
@@ -35,11 +38,12 @@ LL + OhNo = 0_i16,
|
error[E0308]: mismatched types
--> $DIR/discriminant-ill-typed.rs:54:16
--> $DIR/discriminant-ill-typed.rs:57:16
|
LL | OhNo = 0_i16,
| ^^^^^ expected `u16`, found `i16`
|
= note: enum variant discriminant can only be of a primitive type compatible with the enum's `repr`
help: change the type of the numeric literal from `i16` to `u16`
|
LL - OhNo = 0_i16,
@@ -47,11 +51,12 @@ LL + OhNo = 0_u16,
|
error[E0308]: mismatched types
--> $DIR/discriminant-ill-typed.rs:67:16
--> $DIR/discriminant-ill-typed.rs:71:16
|
LL | OhNo = 0_u32,
| ^^^^^ expected `i32`, found `u32`
|
= note: enum variant discriminant can only be of a primitive type compatible with the enum's `repr`
help: change the type of the numeric literal from `u32` to `i32`
|
LL - OhNo = 0_u32,
@@ -59,11 +64,12 @@ LL + OhNo = 0_i32,
|
error[E0308]: mismatched types
--> $DIR/discriminant-ill-typed.rs:80:16
--> $DIR/discriminant-ill-typed.rs:85:16
|
LL | OhNo = 0_i32,
| ^^^^^ expected `u32`, found `i32`
|
= note: enum variant discriminant can only be of a primitive type compatible with the enum's `repr`
help: change the type of the numeric literal from `i32` to `u32`
|
LL - OhNo = 0_i32,
@@ -71,11 +77,12 @@ LL + OhNo = 0_u32,
|
error[E0308]: mismatched types
--> $DIR/discriminant-ill-typed.rs:93:16
--> $DIR/discriminant-ill-typed.rs:99:16
|
LL | OhNo = 0_u64,
| ^^^^^ expected `i64`, found `u64`
|
= note: enum variant discriminant can only be of a primitive type compatible with the enum's `repr`
help: change the type of the numeric literal from `u64` to `i64`
|
LL - OhNo = 0_u64,
@@ -83,11 +90,12 @@ LL + OhNo = 0_i64,
|
error[E0308]: mismatched types
--> $DIR/discriminant-ill-typed.rs:106:16
--> $DIR/discriminant-ill-typed.rs:113:16
|
LL | OhNo = 0_i64,
| ^^^^^ expected `u64`, found `i64`
|
= note: enum variant discriminant can only be of a primitive type compatible with the enum's `repr`
help: change the type of the numeric literal from `i64` to `u64`
|
LL - OhNo = 0_i64,
@@ -6,6 +6,7 @@ LL | Square = |x| x,
|
= note: expected type `isize`
found closure `{closure@$DIR/closure-in-enum-issue-48838.rs:2:14: 2:17}`
= note: enum variant discriminant can only be of a primitive type compatible with the enum's `repr`
error: aborting due to 1 previous error
@@ -1,11 +1,13 @@
// https://github.com/rust-lang/rust/issues/8761
enum Foo {
A = 1i64,
//~^ ERROR mismatched types
//~| NOTE expected `isize`, found `i64`
//~^ ERROR: mismatched types
//~| NOTE: expected `isize`, found `i64`
//~| NOTE: enum variant discriminant
B = 2u8
//~^ ERROR mismatched types
//~| NOTE expected `isize`, found `u8`
//~^ ERROR: mismatched types
//~| NOTE: expected `isize`, found `u8`
//~| NOTE: enum variant discriminant
}
fn main() {}
@@ -4,6 +4,7 @@ error[E0308]: mismatched types
LL | A = 1i64,
| ^^^^ expected `isize`, found `i64`
|
= note: enum variant discriminant can only be of a primitive type compatible with the enum's `repr`
help: change the type of the numeric literal from `i64` to `isize`
|
LL - A = 1i64,
@@ -11,11 +12,12 @@ LL + A = 1isize,
|
error[E0308]: mismatched types
--> $DIR/enum-discriminant-type-mismatch-8761.rs:6:9
--> $DIR/enum-discriminant-type-mismatch-8761.rs:7:9
|
LL | B = 2u8
| ^^^ expected `isize`, found `u8`
|
= note: enum variant discriminant can only be of a primitive type compatible with the enum's `repr`
help: change the type of the numeric literal from `u8` to `isize`
|
LL - B = 2u8
@@ -2,8 +2,9 @@ error[E0308]: mismatched types
--> $DIR/assoc-const-missing-type.rs:12:18
|
LL | const K<T> = ();
| - ^^ expected type parameter `T`, found `()`
| |
| - - ^^ expected type parameter `T`, found `()`
| | |
| | expected because of the type of the associated constant
| expected this type parameter
|
= note: expected type parameter `T`
@@ -22,7 +22,9 @@ error[E0308]: mismatched types
LL | impl<T> S0<T> {
| - found this type parameter
LL | const C: S0<u8> = Self(0);
| ^^^^^^^ expected `S0<u8>`, found `S0<T>`
| ------ ^^^^^^^ expected `S0<u8>`, found `S0<T>`
| |
| expected because of the type of the associated constant
|
= note: expected struct `S0<u8>`
found struct `S0<T>`
@@ -89,7 +91,9 @@ error[E0308]: mismatched types
LL | impl<T> S1<T, u8> {
| - found this type parameter
LL | const C: S1<u8, u8> = Self(0, 1);
| ^^^^^^^^^^ expected `S1<u8, u8>`, found `S1<T, u8>`
| ---------- ^^^^^^^^^^ expected `S1<u8, u8>`, found `S1<T, u8>`
| |
| expected because of the type of the associated constant
|
= note: expected struct `S1<u8, _>`
found struct `S1<T, _>`
+14 -4
View File
@@ -3,18 +3,28 @@ error[E0308]: mismatched types
|
LL | let wrong: [u8; 3] = [10, 20];
| ------- ^^^^^^^^ expected an array with a size of 3, found one with a size of 2
| | |
| | help: consider specifying the actual array length: `2`
| |
| expected due to this
|
help: consider specifying the actual array length
|
LL - let wrong: [u8; 3] = [10, 20];
LL + let wrong: [u8; 2] = [10, 20];
|
error[E0308]: mismatched types
--> $DIR/array-len-mismatch.rs:9:26
|
LL | let wrong: [u8; 3] = returns_arr();
| ------- ^^^^^^^^^^^^^ expected an array with a size of 3, found one with a size of 2
| | |
| | help: consider specifying the actual array length: `2`
| |
| expected due to this
|
help: consider specifying the actual array length
|
LL - let wrong: [u8; 3] = returns_arr();
LL + let wrong: [u8; 2] = returns_arr();
|
error: aborting due to 2 previous errors
+5 -4
View File
@@ -1,9 +1,10 @@
enum Enum<T: Trait> {
//~^ ERROR `T` is never used
//~| NOTE unused type parameter
//~^ ERROR: `T` is never used
//~| NOTE: unused type parameter
X = Trait::Number,
//~^ ERROR mismatched types
//~| NOTE expected `isize`, found `i32`
//~^ ERROR: mismatched types
//~| NOTE: expected `isize`, found `i32`
//~| NOTE: enum variant discriminant
}
trait Trait {
+2
View File
@@ -3,6 +3,8 @@ error[E0308]: mismatched types
|
LL | X = Trait::Number,
| ^^^^^^^^^^^^^ expected `isize`, found `i32`
|
= note: enum variant discriminant can only be of a primitive type compatible with the enum's `repr`
error[E0392]: type parameter `T` is never used
--> $DIR/issue-31910.rs:1:11
@@ -37,6 +37,8 @@ error[E0308]: mismatched types
|
LL | fn a() -> [u8; foo()] {
| ^^^^^ expected `usize`, found `()`
|
= note: array length can only be `usize`
error: aborting due to 6 previous errors
@@ -6,6 +6,7 @@ LL | [1; || {}];
|
= note: expected type `usize`
found closure `{closure@$DIR/array-len-is-closure.rs:4:9: 4:11}`
= note: array length can only be `usize`
error: aborting due to 1 previous error
@@ -4,6 +4,7 @@
fn main() {
let b = [0; S];
//~^ ERROR mismatched types
//~| NOTE expected `usize`, found `S`
//~^ ERROR: mismatched types
//~| NOTE: expected `usize`, found `S`
//~| NOTE: array length
}
@@ -3,6 +3,8 @@ error[E0308]: mismatched types
|
LL | let b = [0; S];
| ^ expected `usize`, found `S`
|
= note: array length can only be `usize`
error: aborting due to 1 previous error
@@ -14,6 +14,7 @@ LL | [(); & { loop { continue } } ];
|
= note: expected type `usize`
found reference `&_`
= note: array length can only be `usize`
help: consider removing the borrow
|
LL - [(); & { loop { continue } } ];
+6 -2
View File
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/const-scope.rs:1:16
|
LL | const C: i32 = 1i8;
| ^^^ expected `i32`, found `i8`
| --- ^^^ expected `i32`, found `i8`
| |
| expected because of the type of the constant
|
help: change the type of the numeric literal from `i8` to `i32`
|
@@ -14,7 +16,9 @@ error[E0308]: mismatched types
--> $DIR/const-scope.rs:2:15
|
LL | const D: i8 = C;
| ^ expected `i8`, found `i32`
| -- ^ expected `i8`, found `i32`
| |
| expected because of the type of the constant
error[E0308]: mismatched types
--> $DIR/const-scope.rs:5:18
+3 -1
View File
@@ -24,7 +24,9 @@ error[E0308]: mismatched types
--> $DIR/pat-lt-bracket-6.rs:10:30
|
LL | const RECOVERY_WITNESS: () = 0;
| ^ expected `()`, found integer
| -- ^ expected `()`, found integer
| |
| expected because of the type of the constant
error: aborting due to 3 previous errors
+3 -1
View File
@@ -11,7 +11,9 @@ error[E0308]: mismatched types
--> $DIR/pat-lt-bracket-7.rs:9:30
|
LL | const RECOVERY_WITNESS: () = 0;
| ^ expected `()`, found integer
| -- ^ expected `()`, found integer
| |
| expected because of the type of the constant
error: aborting due to 2 previous errors
@@ -14,7 +14,9 @@ error[E0308]: mismatched types
--> $DIR/recover-for-loop-parens-around-head.rs:13:40
|
LL | const _RECOVERY_WITNESS: u32 = 0u8;
| ^^^ expected `u32`, found `u8`
| --- ^^^ expected `u32`, found `u8`
| |
| expected because of the type of the constant
|
help: change the type of the numeric literal from `u8` to `u32`
|
+3 -1
View File
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/macro-brackets.rs:11:21
|
LL | id![static X: u32 = 'a';];
| ^^^ expected `u32`, found `char`
| --- ^^^ expected `u32`, found `char`
| |
| expected because of the type of the static
|
help: you can cast a `char` to a `u32`, since a `char` always occupies 4 bytes
|
+13
View File
@@ -15,24 +15,32 @@ error[E0308]: mismatched types
|
LL | let b = [0; ()];
| ^^ expected `usize`, found `()`
|
= note: array length can only be `usize`
error[E0308]: mismatched types
--> $DIR/repeat_count.rs:12:17
|
LL | let c = [0; true];
| ^^^^ expected `usize`, found `bool`
|
= note: array length can only be `usize`
error[E0308]: mismatched types
--> $DIR/repeat_count.rs:15:17
|
LL | let d = [0; 0.5];
| ^^^ expected `usize`, found floating-point number
|
= note: array length can only be `usize`
error[E0308]: mismatched types
--> $DIR/repeat_count.rs:18:17
|
LL | let e = [0; "foo"];
| ^^^^^ expected `usize`, found `&str`
|
= note: array length can only be `usize`
error[E0308]: mismatched types
--> $DIR/repeat_count.rs:21:17
@@ -41,6 +49,7 @@ LL | let f = [0; -4_isize];
| ^^^^^^^^ expected `usize`, found `isize`
|
= note: `-4_isize` cannot fit into type `usize`
= note: array length can only be `usize`
error[E0308]: mismatched types
--> $DIR/repeat_count.rs:25:23
@@ -49,6 +58,7 @@ LL | let g = [0_usize; -1_isize];
| ^^^^^^^^ expected `usize`, found `isize`
|
= note: `-1_isize` cannot fit into type `usize`
= note: array length can only be `usize`
error[E0308]: mismatched types
--> $DIR/repeat_count.rs:29:17
@@ -56,6 +66,7 @@ error[E0308]: mismatched types
LL | let h = [0; 4u8];
| ^^^ expected `usize`, found `u8`
|
= note: array length can only be `usize`
help: change the type of the numeric literal from `u8` to `usize`
|
LL - let h = [0; 4u8];
@@ -67,6 +78,8 @@ error[E0308]: mismatched types
|
LL | let i = [0; I { i: () }];
| ^^^^^^^^^^^ expected `usize`, found `I`
|
= note: array length can only be `usize`
error: aborting due to 9 previous errors
+3 -1
View File
@@ -16,7 +16,9 @@ error[E0308]: mismatched types
--> $DIR/issue-61882.rs:4:22
|
LL | const B: A<u8> = Self(0);
| ^^^^^^^ expected `A<u8>`, found `A<bool>`
| ----- ^^^^^^^ expected `A<u8>`, found `A<bool>`
| |
| expected because of the type of the associated constant
|
= note: expected struct `A<u8>`
found struct `A<bool>`
+3 -2
View File
@@ -1,4 +1,5 @@
static i: String = 10;
//~^ ERROR mismatched types
//~| NOTE expected `String`, found integer
//~^ ERROR: mismatched types
//~| NOTE: expected `String`, found integer
//~| NOTE: expected because
fn main() { println!("{}", i); }
+3 -1
View File
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/bad-const-type.rs:1:20
|
LL | static i: String = 10;
| ^^ expected `String`, found integer
| ------ ^^ expected `String`, found integer
| |
| expected because of the type of the static
|
help: try using a conversion method
|
+3 -1
View File
@@ -18,7 +18,9 @@ error[E0308]: mismatched types
--> $DIR/issue-5216.rs:8:19
|
LL | pub static D: T = g;
| ^ expected `Box<dyn FnMut() + Sync>`, found fn item
| - ^ expected `Box<dyn FnMut() + Sync>`, found fn item
| |
| expected because of the type of the static
|
= note: expected struct `Box<(dyn FnMut() + Sync + 'static)>`
found fn item `fn() {g}`
@@ -0,0 +1,11 @@
// Test for #147748, providing additional clarification that default field values aren't compatible
// with type parameters unless going through the type parameter.
#![feature(default_field_values)]
struct Foo<T = String> { //~ NOTE: expected this type parameter
x: T = String::new(),
//~^ ERROR: mismatched types
//~| NOTE: expected type parameter
//~| NOTE: expected type parameter
//~| NOTE: the type of default fields referencing type parameters can't be assumed inside the struct defining them
}
fn main() {}
@@ -0,0 +1,15 @@
error[E0308]: mismatched types
--> $DIR/struct-type-parameter-with-default.rs:5:12
|
LL | struct Foo<T = String> {
| ---------- expected this type parameter
LL | x: T = String::new(),
| ^^^^^^^^^^^^^ expected type parameter `T`, found `String`
|
= note: expected type parameter `T`
found struct `String`
= note: the type of default fields referencing type parameters can't be assumed inside the struct defining them
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
+9 -3
View File
@@ -4,14 +4,20 @@ error[E0382]: use of moved value: `foo`
LL | let foo = Some(Struct);
| --- move occurs because `foo` has type `Option<Struct>`, which does not implement the `Copy` trait
LL | let _x: Option<Struct> = foo.map(|s| bar(&s));
| --- ---------------- `foo` moved due to this method call
| |
| help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents
| ---------------- `foo` moved due to this method call
LL | let _y = foo;
| ^^^ value used here after move
|
note: `Option::<T>::map` takes ownership of the receiver `self`, which moves `foo`
--> $SRC_DIR/core/src/option.rs:LL:COL
help: consider calling `.as_ref()` to borrow the value's contents
|
LL | let _x: Option<Struct> = foo.as_ref().map(|s| bar(&s));
| +++++++++
help: consider calling `.as_mut()` to mutably borrow the value's contents
|
LL | let _x: Option<Struct> = foo.as_mut().map(|s| bar(&s));
| +++++++++
help: you could `clone` the value and consume it, if the `Struct: Clone` trait bound could be satisfied
|
LL | let _x: Option<Struct> = foo.clone().map(|s| bar(&s));
@@ -7,7 +7,7 @@ impl LipogramCorpora {
pub fn validate_all(&mut self) -> Result<(), char> {
for selection in &self.selections {
if selection.1.is_some() {
if <Option<String> as Clone>::clone(&selection.1.clone()).unwrap().contains(selection.0) {
if <Option<String> as Clone>::clone(&selection.1.clone()).as_mut().as_ref().unwrap().contains(selection.0) {
//~^ ERROR cannot move out of `selection.1`
return Err(selection.0);
}
@@ -25,7 +25,7 @@ impl LipogramCorpora2 {
pub fn validate_all(&mut self) -> Result<(), char> {
for selection in &self.selections {
if selection.1.is_ok() {
if <Result<String, String> as Clone>::clone(&selection.1.clone()).unwrap().contains(selection.0) {
if <Result<String, String> as Clone>::clone(&selection.1.clone()).as_mut().as_ref().unwrap().contains(selection.0) {
//~^ ERROR cannot move out of `selection.1`
return Err(selection.0);
}
@@ -4,11 +4,18 @@ error[E0507]: cannot move out of `selection.1` which is behind a shared referenc
LL | if selection.1.unwrap().contains(selection.0) {
| ^^^^^^^^^^^ -------- `selection.1` moved due to this method call
| |
| help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents
| move occurs because `selection.1` has type `Option<String>`, which does not implement the `Copy` trait
|
note: `Option::<T>::unwrap` takes ownership of the receiver `self`, which moves `selection.1`
--> $SRC_DIR/core/src/option.rs:LL:COL
help: consider calling `.as_ref()` to borrow the value's contents
|
LL | if selection.1.as_ref().unwrap().contains(selection.0) {
| +++++++++
help: consider calling `.as_mut()` to mutably borrow the value's contents
|
LL | if selection.1.as_mut().unwrap().contains(selection.0) {
| +++++++++
help: you can `clone` the value and consume it, but this might not be your desired behavior
|
LL | if <Option<String> as Clone>::clone(&selection.1).unwrap().contains(selection.0) {
@@ -24,11 +31,18 @@ error[E0507]: cannot move out of `selection.1` which is behind a shared referenc
LL | if selection.1.unwrap().contains(selection.0) {
| ^^^^^^^^^^^ -------- `selection.1` moved due to this method call
| |
| help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents
| move occurs because `selection.1` has type `Result<String, String>`, which does not implement the `Copy` trait
|
note: `Result::<T, E>::unwrap` takes ownership of the receiver `self`, which moves `selection.1`
--> $SRC_DIR/core/src/result.rs:LL:COL
help: consider calling `.as_ref()` to borrow the value's contents
|
LL | if selection.1.as_ref().unwrap().contains(selection.0) {
| +++++++++
help: consider calling `.as_mut()` to mutably borrow the value's contents
|
LL | if selection.1.as_mut().unwrap().contains(selection.0) {
| +++++++++
help: you can `clone` the value and consume it, but this might not be your desired behavior
|
LL | if <Result<String, String> as Clone>::clone(&selection.1).unwrap().contains(selection.0) {
@@ -3,6 +3,8 @@ error[E0308]: mismatched types
|
LL | type NaughtyLenArray = [u32; 3.14159];
| ^^^^^^^ expected `usize`, found floating-point number
|
= note: array length can only be `usize`
error: aborting due to 1 previous error

Some files were not shown because too many files have changed in this diff Show More