Some(values) => {
let (is_simple_error, exp_found) = match values {
ValuePairs::Types(exp_found) => {
- let is_simple_err =
- exp_found.expected.is_primitive() && exp_found.found.is_primitive();
+ let is_simple_err = exp_found.expected.is_simple_text()
+ && exp_found.found.is_simple_text();
(is_simple_err, Some(exp_found))
}
.unwrap_or("type".into());
let found_label = exp_found.map(|ef| ef.found.prefix_string())
.unwrap_or("type".into());
- match (terr, is_simple_error, expected == found) {
- (&TypeError::Sorts(ref values), false, extra) => {
+ match (&terr, expected == found) {
+ (TypeError::Sorts(values), extra) => {
let sort_string = |ty: Ty<'tcx>| match (extra, &ty.kind) {
(true, ty::Opaque(def_id, _)) => format!(
" (opaque type at {})",
(true, _) => format!(" ({})", ty.sort_string(self.tcx)),
(false, _) => "".to_string(),
};
- diag.note_expected_found_extra(
- &expected_label,
- expected,
- &found_label,
- found,
- &sort_string(values.expected),
- &sort_string(values.found),
- );
+ if !(values.expected.is_simple_text() && values.found.is_simple_text()) || (
+ exp_found.map_or(false, |ef| {
+ // This happens when the type error is a subset of the expectation,
+ // like when you have two references but one is `usize` and the other
+ // is `f32`. In those cases we still want to show the `note`. If the
+ // value from `ef` is `Infer(_)`, then we ignore it.
+ if !ef.expected.is_ty_infer() {
+ ef.expected != values.expected
+ } else if !ef.found.is_ty_infer() {
+ ef.found != values.found
+ } else {
+ false
+ }
+ })
+ ) {
+ diag.note_expected_found_extra(
+ &expected_label,
+ expected,
+ &found_label,
+ found,
+ &sort_string(values.expected),
+ &sort_string(values.found),
+ );
+ }
}
- (TypeError::ObjectUnsafeCoercion(_), ..) => {
+ (TypeError::ObjectUnsafeCoercion(_), _) => {
diag.note_unsuccessfull_coercion(found, expected);
}
- (_, false, _) => {
+ (_, _) => {
debug!(
"note_type_err: exp_found={:?}, expected={:?} found={:?}",
exp_found, expected, found
);
- diag.note_expected_found(&expected_label, expected, &found_label, found);
+ if !is_simple_error || terr.must_include_note() {
+ diag.note_expected_found(&expected_label, expected, &found_label, found);
+ }
}
- _ => (),
}
}
if let Some(exp_found) = exp_found {
impl<'tcx> fmt::Display for TypeError<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use self::TypeError::*;
- fn report_maybe_different(f: &mut fmt::Formatter<'_>,
- expected: &str, found: &str) -> fmt::Result {
+ fn report_maybe_different(
+ f: &mut fmt::Formatter<'_>,
+ expected: &str,
+ found: &str,
+ ) -> fmt::Result {
// A naive approach to making sure that we're not reporting silly errors such as:
// (expected closure, found closure).
if expected == found {
}
}
+impl<'tcx> TypeError<'tcx> {
+ pub fn must_include_note(&self) -> bool {
+ use self::TypeError::*;
+ match self {
+ CyclicTy(_) |
+ UnsafetyMismatch(_) |
+ Mismatch |
+ AbiMismatch(_) |
+ FixedArraySize(_) |
+ Sorts(_) |
+ IntMismatch(_) |
+ FloatMismatch(_) |
+ VariadicMismatch(_) => false,
+
+ Mutability |
+ TupleSize(_) |
+ ArgCount |
+ RegionsDoesNotOutlive(..) |
+ RegionsInsufficientlyPolymorphic(..) |
+ RegionsOverlyPolymorphic(..) |
+ RegionsPlaceholderMismatch |
+ Traits(_) |
+ ProjectionMismatched(_) |
+ ProjectionBoundsLength(_) |
+ ExistentialMismatch(_) |
+ ConstMismatch(_) |
+ IntrinsicCast |
+ ObjectUnsafeCoercion(_) => true,
+ }
+ }
+}
+
impl<'tcx> ty::TyS<'tcx> {
pub fn sort_string(&self, tcx: TyCtxt<'_>) -> Cow<'static, str> {
match self.kind {
ty::Bool | ty::Char | ty::Int(_) |
- ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => self.to_string().into(),
- ty::Tuple(ref tys) if tys.is_empty() => self.to_string().into(),
+ ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => format!("{}", self).into(),
+ ty::Tuple(ref tys) if tys.is_empty() => format!("{}", self).into(),
ty::Adt(def, _) => format!("{} `{}`", def.descr(), tcx.def_path_str(def.did)).into(),
ty::Foreign(def_id) => format!("extern type `{}`", tcx.def_path_str(def_id)).into(),
- ty::Array(_, n) => {
+ ty::Array(t, n) => {
let n = tcx.lift(&n).unwrap();
match n.try_eval_usize(tcx, ty::ParamEnv::empty()) {
- Some(n) => {
- format!("array of {} element{}", n, pluralize!(n)).into()
- }
+ _ if t.is_simple_ty() => format!("array `{}`", self).into(),
+ Some(n) => format!("array of {} element{} ", n, pluralize!(n)).into(),
None => "array".into(),
}
}
+ ty::Slice(ty) if ty.is_simple_ty() => format!("slice `{}`", self).into(),
ty::Slice(_) => "slice".into(),
ty::RawPtr(_) => "*-ptr".into(),
- ty::Ref(region, ty, mutbl) => {
+ ty::Ref(_, ty, mutbl) => {
let tymut = ty::TypeAndMut { ty, mutbl };
let tymut_string = tymut.to_string();
- if tymut_string == "_" || //unknown type name,
- tymut_string.len() > 10 || //name longer than saying "reference",
- region.to_string() != "'_" //... or a complex type
- {
- format!("{}reference", match mutbl {
- hir::Mutability::Mutable => "mutable ",
- _ => ""
- }).into()
- } else {
+ if tymut_string != "_" && (
+ ty.is_simple_text() || tymut_string.len() < "mutable reference".len()
+ ) {
format!("&{}", tymut_string).into()
+ } else { // Unknown type name, it's long or has type arguments
+ match mutbl {
+ hir::Mutability::Mutable => "mutable reference",
+ _ => "reference",
+ }.into()
}
}
ty::FnDef(..) => "fn item".into(),
}
pub fn prefix_string(&self) -> Cow<'static, str> {
- debug!("prefix_string {:?} {} {:?}", self, self, self.kind);
match self.kind {
ty::Infer(_) | ty::Error | ty::Bool | ty::Char | ty::Int(_) |
ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => "type".into(),
impl<'tcx> TyS<'tcx> {
pub fn is_primitive_ty(&self) -> bool {
match self.kind {
- Bool |
- Char |
- Int(_) |
- Uint(_) |
- Float(_) |
- Infer(InferTy::IntVar(_)) |
- Infer(InferTy::FloatVar(_)) |
- Infer(InferTy::FreshIntTy(_)) |
- Infer(InferTy::FreshFloatTy(_)) => true,
- Ref(_, x, _) => x.is_primitive_ty(),
+ Bool | Char | Str | Int(_) | Uint(_) | Float(_) |
+ Infer(InferTy::IntVar(_)) | Infer(InferTy::FloatVar(_)) |
+ Infer(InferTy::FreshIntTy(_)) | Infer(InferTy::FreshFloatTy(_)) => true,
+ _ => false,
+ }
+ }
+
+ pub fn is_simple_ty(&self) -> bool {
+ match self.kind {
+ Bool | Char | Str | Int(_) | Uint(_) | Float(_) |
+ Infer(InferTy::IntVar(_)) | Infer(InferTy::FloatVar(_)) |
+ Infer(InferTy::FreshIntTy(_)) | Infer(InferTy::FreshFloatTy(_)) => true,
+ Ref(_, x, _) | Array(x, _) | Slice(x) => x.peel_refs().is_simple_ty(),
+ Tuple(tys) if tys.is_empty() => true,
+ _ => false,
+ }
+ }
+
+ pub fn is_simple_text(&self) -> bool {
+ match self.kind {
+ Adt(_, substs) => substs.types().next().is_none(),
+ Ref(_, ty, _) => ty.is_simple_text(),
+ _ if self.is_simple_ty() => true,
_ => false,
}
}
|
LL | let x: () = 5i32;
| ^^^^ expected (), found i32
- |
- = note: expected type `()`
- found type `i32`
error: aborting due to previous error
|
LL | fn main() { let i: (); i = f(()); }
| ^^ expected isize, found ()
- |
- = note: expected type `isize`
- found unit type `()`
error: aborting due to previous error
fn main() {
let _x: i32 = [1, 2, 3];
//~^ ERROR mismatched types
- //~| expected type `i32`
- //~| found array `[{integer}; 3]`
- //~| expected i32, found array of 3 elements
+ //~| expected i32, found array
let x: &[i32] = &[1, 2, 3];
let _y: &i32 = x;
--> $DIR/array-not-vector.rs:2:19
|
LL | let _x: i32 = [1, 2, 3];
- | ^^^^^^^^^ expected i32, found array of 3 elements
- |
- = note: expected type `i32`
- found array `[{integer}; 3]`
+ | ^^^^^^^^^ expected i32, found array `[{integer}; 3]`
error[E0308]: mismatched types
- --> $DIR/array-not-vector.rs:9:20
+ --> $DIR/array-not-vector.rs:7:20
|
LL | let _y: &i32 = x;
- | ^ expected i32, found slice
+ | ^ expected i32, found slice `[i32]`
|
= note: expected reference `&i32`
found reference `&[i32]`
| --------- type in trait
...
LL | const FROM: &'static str = "foo";
- | ^^^^^^^^^^^^ expected associated type, found reference
+ | ^^^^^^^^^^^^ expected associated type, found &str
|
= note: expected associated type `<T as Foo>::Out`
found reference `&'static str`
|
LL | fn b() { dent(ModelT, Blue); }
| ^^^^ expected struct `Black`, found struct `Blue`
- |
- = note: expected struct `Black`
- found struct `Blue`
error[E0308]: mismatched types
--> $DIR/associated-type-projection-from-supertrait.rs:28:23
|
LL | fn c() { dent(ModelU, Black); }
| ^^^^^ expected struct `Blue`, found struct `Black`
- |
- = note: expected struct `Blue`
- found struct `Black`
error[E0308]: mismatched types
--> $DIR/associated-type-projection-from-supertrait.rs:32:28
|
LL | fn f() { ModelT.chip_paint(Blue); }
| ^^^^ expected struct `Black`, found struct `Blue`
- |
- = note: expected struct `Black`
- found struct `Blue`
error[E0308]: mismatched types
--> $DIR/associated-type-projection-from-supertrait.rs:33:28
|
LL | fn g() { ModelU.chip_paint(Black); }
| ^^^^^ expected struct `Blue`, found struct `Black`
- |
- = note: expected struct `Blue`
- found struct `Black`
error: aborting due to 4 previous errors
...
LL | fn b() { blue_car(ModelT); }
| ^^^^^^^^ expected struct `Blue`, found struct `Black`
- |
- = note: expected struct `Blue`
- found struct `Black`
error[E0271]: type mismatch resolving `<ModelU as Vehicle>::Color == Black`
--> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:32:10
...
LL | fn c() { black_car(ModelU); }
| ^^^^^^^^^ expected struct `Black`, found struct `Blue`
- |
- = note: expected struct `Black`
- found struct `Blue`
error: aborting due to 2 previous errors
...
LL | foo1(a);
| ^^^^ expected struct `Bar`, found usize
- |
- = note: expected struct `Bar`
- found type `usize`
error[E0271]: type mismatch resolving `<isize as Foo>::A == Bar`
--> $DIR/associated-types-eq-3.rs:41:9
LL | baz(&a);
| ^^ expected struct `Bar`, found usize
|
- = note: expected struct `Bar`
- found type `usize`
= note: required for the cast to the object type `dyn Foo<A = Bar>`
error: aborting due to 3 previous errors
LL | let _: &dyn I32Iterator<Item = u32> = &vec![42].into_iter();
| ^^^^^^^^^^^^^^^^^^^^^ expected i32, found u32
|
- = note: expected type `i32`
- found type `u32`
= note: required for the cast to the object type `dyn std::iter::Iterator<Item = u32, Item = i32>`
error: aborting due to previous error
LL | <() as Visit>::visit();
| ^^^^^^^^^^^^^^^^^^^^ expected (), found &()
|
- = note: expected unit type `()`
- found reference `&()`
= note: required because of the requirements on the impl of `Visit` for `()`
error: aborting due to previous error
| ---------------- in this `impl` item
LL | type Ok = ();
| ^^^^^^^^^^^^^ expected u32, found ()
- |
- = note: expected type `u32`
- found unit type `()`
error: aborting due to previous error
| --------------------------------- ^^ expected u8, found ()
| |
| implicitly returns `()` as its body has no tail or `return` expression
- |
- = note: expected type `u8`
- found unit type `()`
error[E0271]: type mismatch resolving `<impl std::future::Future as std::future::Future>::Output == ()`
--> $DIR/async-block-control-flow-static-semantics.rs:18:39
LL | let _: &dyn Future<Output = ()> = █
| ^^^^^^ expected (), found u8
|
- = note: expected unit type `()`
- found type `u8`
= note: required for the cast to the object type `dyn std::future::Future<Output = ()>`
error[E0308]: mismatched types
LL | |
LL | | }
| |_^ expected u8, found ()
- |
- = note: expected type `u8`
- found unit type `()`
error[E0271]: type mismatch resolving `<impl std::future::Future as std::future::Future>::Output == ()`
--> $DIR/async-block-control-flow-static-semantics.rs:27:39
LL | let _: &dyn Future<Output = ()> = █
| ^^^^^^ expected (), found u8
|
- = note: expected unit type `()`
- found type `u8`
= note: required for the cast to the object type `dyn std::future::Future<Output = ()>`
error[E0308]: mismatched types
static i: String = 10;
//~^ ERROR mismatched types
//~| expected struct `std::string::String`, found integer
-//~| expected struct `std::string::String`
-//~| found type `{integer}`
fn main() { println!("{}", i); }
| |
| expected struct `std::string::String`, found integer
| help: try using a conversion method: `10.to_string()`
- |
- = note: expected struct `std::string::String`
- found type `{integer}`
error: aborting due to previous error
|
LL | fn main() { let x = 1 && 2; }
| ^ expected bool, found integer
- |
- = note: expected type `bool`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/binop-logic-int.rs:1:26
|
LL | fn main() { let x = 1 && 2; }
| ^ expected bool, found integer
- |
- = note: expected type `bool`
- found type `{integer}`
error: aborting due to 2 previous errors
|
LL | let bar = 5;
| ^^^ expected integer, found struct `foo::bar`
- |
- = note: expected type `{integer}`
- found struct `foo::bar`
error: aborting due to previous error
| | - help: consider removing this semicolon
LL | | };
| |_____^ expected i32, found ()
- |
- = note: expected type `i32`
- found unit type `()`
error: aborting due to previous error
|
LL | true
| ^^^^ expected (), found bool
- |
- = note: expected unit type `()`
- found type `bool`
error: aborting due to previous error
| - expected `()` because of default return type
LL | true
| ^^^^ expected (), found bool
- |
- = note: expected unit type `()`
- found type `bool`
error: aborting due to previous error
fn main() {
while true { //~ WARN denote infinite loops with
true //~ ERROR mismatched types
- //~| expected unit type `()`
- //~| found type `bool`
//~| expected (), found bool
}
}
|
LL | true
| ^^^^ expected (), found bool
- |
- = note: expected unit type `()`
- found type `bool`
error: aborting due to previous error
LL | 0u8;
LL | "bla".to_string();
| - help: consider removing this semicolon
- |
- = note: expected struct `std::string::String`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/consider-removing-last-semi.rs:6:11
LL | "this won't work".to_string();
LL | "removeme".to_string();
| - help: consider removing this semicolon
- |
- = note: expected struct `std::string::String`
- found unit type `()`
error: aborting due to 2 previous errors
...
LL | ;
| - help: consider removing this semicolon
- |
- = note: expected type `i32`
- found unit type `()`
error: aborting due to previous error
...
LL | ;
| - help: consider removing this semicolon
- |
- = note: expected struct `std::string::String`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/issue-13428.rs:11:13
LL | "foobar".to_string()
LL | ;
| - help: consider removing this semicolon
- |
- = note: expected struct `std::string::String`
- found unit type `()`
error: aborting due to 2 previous errors
Enum::EnumStructVariant { x: 1, y: 2, z: 3 }
//~^ ERROR mismatched types
//~| expected (), found enum `a::Enum`
- //~| expected unit type `()`
- //~| found enum `a::Enum`
}
}
a::Enum::EnumStructVariant { x, y, z } => {
//~^ ERROR mismatched types
//~| expected (), found enum `a::Enum`
- //~| expected unit type `()`
- //~| found enum `a::Enum`
}
}
}
| -- expected `()` because of return type
LL | Enum::EnumStructVariant { x: 1, y: 2, z: 3 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `a::Enum`
- |
- = note: expected unit type `()`
- found enum `a::Enum`
error[E0308]: mismatched types
- --> $DIR/issue-13624.rs:22:9
+ --> $DIR/issue-13624.rs:20:9
|
LL | match enum_struct_variant {
| ------------------- this match expression has type `()`
LL | a::Enum::EnumStructVariant { x, y, z } => {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `a::Enum`
- |
- = note: expected unit type `()`
- found enum `a::Enum`
error: aborting due to 2 previous errors
LL | let b = Bob + 3.5;
LL | b + 3
| ^^^^^ expected (), found struct `Bob`
- |
- = note: expected unit type `()`
- found struct `Bob`
error: aborting due to 2 previous errors
LL | foo()
| ^^^^^ expected (), found usize
|
- = note: expected unit type `()`
- found type `usize`
help: try adding a semicolon
|
LL | foo();
|
LL | only_foo(x);
| ^ expected i32, found floating-point number
- |
- = note: expected type `i32`
- found type `{float}`
error[E0277]: the trait bound `{float}: Bar` is not satisfied
--> $DIR/type_inference.rs:25:5
LL | fn foo() {
| - help: try adding a return type: `-> &'static str`
LL | "bar boo"
- | ^^^^^^^^^^^^^^^^^^^^ expected (), found reference
- |
- = note: expected unit type `()`
- found reference `&'static str`
+ | ^^^^^^^^^^^^^^^^^^^^ expected (), found &str
error: aborting due to 2 previous errors
--> $DIR/coerce-expect-unsized-ascribed.rs:9:13
|
LL | let _ = box { [1, 2, 3] }: Box<[i32]>;
- | ^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements
+ | ^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]`
|
= note: expected struct `std::boxed::Box<[i32]>`
found struct `std::boxed::Box<[i32; 3]>`
--> $DIR/coerce-expect-unsized-ascribed.rs:10:13
|
LL | let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]`
|
= note: expected struct `std::boxed::Box<[i32]>`
found struct `std::boxed::Box<[i32; 3]>`
--> $DIR/coerce-expect-unsized-ascribed.rs:11:13
|
LL | let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[i32]>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]`
|
= note: expected struct `std::boxed::Box<[i32]>`
found struct `std::boxed::Box<[i32; 3]>`
--> $DIR/coerce-expect-unsized-ascribed.rs:17:13
|
LL | let _ = &{ [1, 2, 3] }: &[i32];
- | ^^^^^^^^^^^^^^ expected slice, found array of 3 elements
+ | ^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]`
|
= note: expected reference `&[i32]`
found reference `&[i32; 3]`
--> $DIR/coerce-expect-unsized-ascribed.rs:18:13
|
LL | let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32];
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]`
|
= note: expected reference `&[i32]`
found reference `&[i32; 3]`
--> $DIR/coerce-expect-unsized-ascribed.rs:19:13
|
LL | let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32];
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]`
|
= note: expected reference `&[i32]`
found reference `&[i32; 3]`
--> $DIR/coerce-expect-unsized-ascribed.rs:25:13
|
LL | let _ = Box::new([1, 2, 3]): Box<[i32]>;
- | ^^^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements
+ | ^^^^^^^^^^^^^^^^^^^ expected slice `[i32]`, found array `[i32; 3]`
|
= note: expected struct `std::boxed::Box<[i32]>`
found struct `std::boxed::Box<[i32; 3]>`
| implicitly returns `()` as its body has no tail or `return` expression
LL | x + 1;
| - help: consider removing this semicolon
- |
- = note: expected type `i32`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/coercion-missing-tail-expected-type.rs:7:13
fn main() {
let _: &[i32] = [0];
//~^ ERROR mismatched types
- //~| expected reference `&[i32]`
- //~| expected &[i32], found array of 1 element
+ //~| expected &[i32], found array `[{integer}; 1]`
}
LL | let _: &[i32] = [0];
| ^^^
| |
- | expected &[i32], found array of 1 element
+ | expected &[i32], found array `[{integer}; 1]`
| help: consider borrowing here: `&[0]`
- |
- = note: expected reference `&[i32]`
- found array `[{integer}; 1]`
error: aborting due to previous error
|
LL | let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8]));
| ^^^^^^^^^^ expected an array with a fixed size of 3 elements, found one with 2 elements
- |
- = note: expected array `[u8; 3]`
- found array `[u8; 2]`
error[E0308]: mismatched types
--> $DIR/const-argument-cross-crate-mismatch.rs:8:65
|
LL | let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]);
| ^^^^^^^^^^^^^^^ expected an array with a fixed size of 2 elements, found one with 3 elements
- |
- = note: expected array `[u8; 2]`
- found array `[u8; 3]`
error: aborting due to 2 previous errors
|
LL | const BLUB: [i32; (ARR[0] - 40) as usize] = [5];
| ^^^ expected an array with a fixed size of 2 elements, found one with 1 element
- |
- = note: expected array `[i32; 2]`
- found array `[i32; 1]`
error[E0308]: mismatched types
--> $DIR/const-array-oob-arith.rs:10:44
|
LL | const BOO: [i32; (ARR[0] - 41) as usize] = [5, 99];
| ^^^^^^^ expected an array with a fixed size of 1 element, found one with 2 elements
- |
- = note: expected array `[i32; 1]`
- found array `[i32; 2]`
error: aborting due to 2 previous errors
V = CONSTANT,
//~^ ERROR mismatched types
//~| expected isize, found struct `S`
- //~| found struct `S`
}
fn main() {}
|
LL | V = CONSTANT,
| ^^^^^^^^ expected isize, found struct `S`
- |
- = note: expected type `isize`
- found struct `S`
error: aborting due to previous error
|
LL | const X: usize = 42 && 39;
| ^^ expected bool, found integer
- |
- = note: expected type `bool`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:1:24
|
LL | const X: usize = 42 && 39;
| ^^ expected bool, found integer
- |
- = note: expected type `bool`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:1:18
|
LL | const X1: usize = 42 || 39;
| ^^ expected bool, found integer
- |
- = note: expected type `bool`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:11:25
|
LL | const X1: usize = 42 || 39;
| ^^ expected bool, found integer
- |
- = note: expected type `bool`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:11:19
|
LL | const X2: usize = -42 || -39;
| ^^^ expected bool, found integer
- |
- = note: expected type `bool`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:21:26
|
LL | const X2: usize = -42 || -39;
| ^^^ expected bool, found integer
- |
- = note: expected type `bool`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:21:19
|
LL | const X3: usize = -42 && -39;
| ^^^ expected bool, found integer
- |
- = note: expected type `bool`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:31:26
|
LL | const X3: usize = -42 && -39;
| ^^^ expected bool, found integer
- |
- = note: expected type `bool`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/const-integer-bool-ops.rs:31:19
LL | let _tis_an_instants_play: String = "'Tis a fond Ambush—";
| ^^^^^^^^^^^^^^^^^^^^^
| |
- | expected struct `std::string::String`, found reference
+ | expected struct `std::string::String`, found &str
| help: try using a conversion method: `"'Tis a fond Ambush—".to_string()`
- |
- = note: expected struct `std::string::String`
- found reference `&'static str`
error[E0308]: mismatched types
--> $DIR/conversion-methods.rs:6:40
LL | let _just_to_make_bliss: PathBuf = Path::new("/ern/her/own/surprise");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
- | expected struct `std::path::PathBuf`, found reference
+ | expected struct `std::path::PathBuf`, found &std::path::Path
| help: try using a conversion method: `Path::new("/ern/her/own/surprise").to_path_buf()`
- |
- = note: expected struct `std::path::PathBuf`
- found reference `&std::path::Path`
error[E0308]: mismatched types
--> $DIR/conversion-methods.rs:9:40
| |
| expected struct `std::string::String`, found integer
| help: try using a conversion method: `2.to_string()`
- |
- = note: expected struct `std::string::String`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/conversion-methods.rs:12:47
LL | let _prove_piercing_earnest: Vec<usize> = &[1, 2, 3];
| ^^^^^^^^^^
| |
- | expected struct `std::vec::Vec`, found reference
+ | expected struct `std::vec::Vec`, found &[{integer}; 3]
| help: try using a conversion method: `(&[1, 2, 3]).to_vec()`
|
= note: expected struct `std::vec::Vec<usize>`
LL | foo(s);
| ^
| |
- | expected struct `std::string::String`, found reference
+ | expected struct `std::string::String`, found &std::string::String
| help: try using a conversion method: `s.to_string()`
- |
- = note: expected struct `std::string::String`
- found reference `&std::string::String`
error[E0308]: mismatched types
--> $DIR/deref-suggestion.rs:14:10
| |
| expected u32, found &u32
| help: consider dereferencing the borrow: `*u`
- |
- = note: expected type `u32`
- found reference `&u32`
error[E0308]: mismatched types
--> $DIR/deref-suggestion.rs:30:9
LL | foo(&"aaa".to_owned());
| ^^^^^^^^^^^^^^^^^
| |
- | expected struct `std::string::String`, found reference
+ | expected struct `std::string::String`, found &std::string::String
| help: consider removing the borrow: `"aaa".to_owned()`
- |
- = note: expected struct `std::string::String`
- found reference `&std::string::String`
error[E0308]: mismatched types
--> $DIR/deref-suggestion.rs:32:9
LL | foo(&mut "aaa".to_owned());
| ^^^^^^^^^^^^^^^^^^^^^
| |
- | expected struct `std::string::String`, found mutable reference
+ | expected struct `std::string::String`, found &mut std::string::String
| help: consider removing the borrow: `"aaa".to_owned()`
- |
- = note: expected struct `std::string::String`
- found mutable reference `&mut std::string::String`
error[E0308]: mismatched types
--> $DIR/deref-suggestion.rs:2:20
...
LL | foo3(borrow!(0));
| ---------- in this macro invocation
- |
- = note: expected type `u32`
- found reference `&{integer}`
error[E0308]: mismatched types
--> $DIR/deref-suggestion.rs:36:5
LL | assert_eq!(3i32, &3i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected i32, found &i32
|
- = note: expected type `i32`
- found reference `&i32`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0308]: mismatched types
| |
| expected &u32, found integer
| help: consider borrowing here: `u: &u`
- |
- = note: expected reference `&u32`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/deref-suggestion.rs:41:20
| |
| expected &u32, found integer
| help: consider borrowing here: `&u`
- |
- = note: expected reference `&u32`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/deref-suggestion.rs:44:17
| |
| expected u32, found &{integer}
| help: consider dereferencing the borrow: `i: *i`
- |
- = note: expected type `u32`
- found reference `&{integer}`
error[E0308]: mismatched types
--> $DIR/deref-suggestion.rs:46:20
| |
| expected u32, found &{integer}
| help: consider dereferencing the borrow: `*i`
- |
- = note: expected type `u32`
- found reference `&{integer}`
error: aborting due to 10 previous errors
|
LL | let _c = Context { wrapper: Payload{} };
| ^^^^^^^^^ expected struct `Wrapper`, found struct `Payload`
- |
- = note: expected struct `Wrapper`
- found struct `Payload`
error: aborting due to 2 previous errors
| |
| expected f32, found integer
| help: use a float literal: `16.0`
- |
- = note: expected type `f32`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/issue-53280-expected-float-found-integer-literal.rs:5:38
| |
| expected f64, found integer
| help: use a float literal: `1_000_070.0`
- |
- = note: expected type `f64`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/issue-53280-expected-float-found-integer-literal.rs:8:30
| |
| expected f32, found integer
| help: use a float literal: `-9.0`
- |
- = note: expected type `f32`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/issue-53280-expected-float-found-integer-literal.rs:15:30
|
LL | let sixteen_again: f64 = 0x10;
| ^^^^ expected f64, found integer
- |
- = note: expected type `f64`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/issue-53280-expected-float-found-integer-literal.rs:17:30
|
LL | let and_once_more: f32 = 0o20;
| ^^^^ expected f32, found integer
- |
- = note: expected type `f32`
- found type `{integer}`
error: aborting due to 5 previous errors
| - expected `!` because of return type
LL | unsafe {
LL | ::std::mem::transmute::<f64, [u8; 8]>(panic!())
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected !, found array of 8 elements
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected !, found array `[u8; 8]`
|
= note: expected type `!`
found array `[u8; 8]`
--> $DIR/dst-bad-coerce1.rs:16:29
|
LL | let f3: &Fat<[usize]> = f2;
- | ^^ expected slice, found array of 3 elements
+ | ^^ expected slice `[usize]`, found array `[isize; 3]`
|
= note: expected reference `&Fat<[usize]>`
found reference `&Fat<[isize; 3]>`
--> $DIR/dst-bad-coerce1.rs:28:27
|
LL | let f3: &([usize],) = f2;
- | ^^ expected slice, found array of 3 elements
+ | ^^ expected slice `[usize]`, found array `[isize; 3]`
|
= note: expected reference `&([usize],)`
found reference `&([isize; 3],)`
let f1: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] };
let f2: &Fat<[isize; 3]> = f1;
//~^ ERROR mismatched types
+ //~| expected array `[isize; 3]`, found slice `[isize]`
//~| expected reference `&Fat<[isize; 3]>`
//~| found reference `&Fat<[isize]>`
- //~| expected array of 3 elements, found slice
// Tuple with a vec of isizes.
let f1: &([isize],) = &([1, 2, 3],);
let f2: &([isize; 3],) = f1;
//~^ ERROR mismatched types
+ //~| expected array `[isize; 3]`, found slice `[isize]`
//~| expected reference `&([isize; 3],)`
//~| found reference `&([isize],)`
- //~| expected array of 3 elements, found slice
}
--> $DIR/dst-bad-coerce4.rs:12:32
|
LL | let f2: &Fat<[isize; 3]> = f1;
- | ^^ expected array of 3 elements, found slice
+ | ^^ expected array `[isize; 3]`, found slice `[isize]`
|
= note: expected reference `&Fat<[isize; 3]>`
found reference `&Fat<[isize]>`
--> $DIR/dst-bad-coerce4.rs:20:30
|
LL | let f2: &([isize; 3],) = f1;
- | ^^ expected array of 3 elements, found slice
+ | ^^ expected array `[isize; 3]`, found slice `[isize]`
|
= note: expected reference `&([isize; 3],)`
found reference `&([isize],)`
|
LL | some_other_func() = 4;
| ^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error[E0070]: invalid left-hand side expression
--> $DIR/E0070.rs:8:5
| --- ------------------ required by this bound in `foo`
...
LL | foo(3_i8);
- | ^^^ expected u32, found reference
- |
- = note: expected type `u32`
- found reference `&'static str`
+ | ^^^ expected u32, found &str
error: aborting due to previous error
| |
| expected struct `std::string::String`, found &str
| help: try using a conversion method: `x.to_string()`
- |
- = note: expected struct `std::string::String`
- found reference `&str`
error: aborting due to previous error
| |
| expected f32, found integer
| help: use a float literal: `1.0`
- |
- = note: expected type `f32`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/float-literal-inference-restrictions.rs:3:18
return x;
//~^ ERROR mismatched types
//~| expected enum `y::Foo`, found enum `x::Foo`
- //~| expected enum `y::Foo`
- //~| found enum `x::Foo`
}
fn main() {
| ------ expected `y::Foo` because of return type
LL | return x;
| ^ expected enum `y::Foo`, found enum `x::Foo`
- |
- = note: expected enum `y::Foo`
- found enum `x::Foo`
error: aborting due to previous error
LL | let v = Unit2.m(
| ^ expected struct `Unit4`, found struct `Unit3`
|
- = note: expected struct `Unit4`
- found struct `Unit3`
= note: required because of the requirements on the impl of `for<'r> T0<'r, (<Unit2 as Ty<'r>>::V,)>` for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]>`
error: aborting due to 2 previous errors
| | ^^^^ expected i32, found u32
LL | | };
| |_____- if and else have incompatible types
- |
- = note: expected type `i32`
- found type `u32`
error[E0308]: if and else have incompatible types
--> $DIR/if-else-type-mismatch.rs:8:38
| ----- ^^^^^ expected i32, found u32
| |
| expected because of this
- |
- = note: expected type `i32`
- found type `u32`
error[E0308]: if and else have incompatible types
--> $DIR/if-else-type-mismatch.rs:13:9
| | ^^^^ expected (), found u32
LL | | };
| |_____- if and else have incompatible types
- |
- = note: expected type `()`
- found type `u32`
error[E0308]: if and else have incompatible types
--> $DIR/if-else-type-mismatch.rs:19:9
| | expected u32, found ()
LL | | };
| |_____- if and else have incompatible types
- |
- = note: expected type `u32`
- found unit type `()`
error[E0308]: if and else have incompatible types
--> $DIR/if-else-type-mismatch.rs:25:9
| | ^^^^ expected (), found u32
LL | | };
| |_____- if and else have incompatible types
- |
- = note: expected type `()`
- found type `u32`
error[E0308]: if and else have incompatible types
--> $DIR/if-else-type-mismatch.rs:31:9
| | ^^^^^^ expected i32, found ()
LL | | };
| |_____- if and else have incompatible types
- |
- = note: expected type `i32`
- found unit type `()`
error[E0308]: if and else have incompatible types
--> $DIR/if-else-type-mismatch.rs:37:9
| |_____- expected because of this
LL | 11u32
| ^^^^^ expected (), found u32
- |
- = note: expected type `()`
- found type `u32`
error[E0308]: if and else have incompatible types
--> $DIR/if-else-type-mismatch.rs:42:12
LL | |
LL | | };
| |_____^ expected i32, found ()
- |
- = note: expected type `i32`
- found unit type `()`
error: aborting due to 8 previous errors
| ----- ^^^^^ expected i32, found u32
| |
| expected because of this
- |
- = note: expected type `i32`
- found type `u32`
error: aborting due to previous error
};
//~^^ ERROR: if and else have incompatible types
//~| NOTE expected (), found integer
- //~| NOTE expected type `()`
}
| | ^ expected (), found integer
LL | | };
| |_____- if and else have incompatible types
- |
- = note: expected type `()`
- found type `{integer}`
error: aborting due to previous error
| |
| expected bool, found &bool
| help: consider dereferencing the borrow: `*b_ref()`
- |
- = note: expected type `bool`
- found reference `&bool`
error[E0308]: mismatched types
--> $DIR/if-no-match-bindings.rs:19:8
| |
| expected bool, found &mut bool
| help: consider dereferencing the borrow: `*b_mut_ref()`
- |
- = note: expected type `bool`
- found mutable reference `&mut bool`
error[E0308]: mismatched types
--> $DIR/if-no-match-bindings.rs:20:8
| |
| expected bool, found &bool
| help: consider removing the borrow: `true`
- |
- = note: expected type `bool`
- found reference `&bool`
error[E0308]: mismatched types
--> $DIR/if-no-match-bindings.rs:21:8
| |
| expected bool, found &mut bool
| help: consider removing the borrow: `true`
- |
- = note: expected type `bool`
- found mutable reference `&mut bool`
error[E0308]: mismatched types
--> $DIR/if-no-match-bindings.rs:24:11
| |
| expected bool, found &bool
| help: consider dereferencing the borrow: `*b_ref()`
- |
- = note: expected type `bool`
- found reference `&bool`
error[E0308]: mismatched types
--> $DIR/if-no-match-bindings.rs:25:11
| |
| expected bool, found &mut bool
| help: consider dereferencing the borrow: `*b_mut_ref()`
- |
- = note: expected type `bool`
- found mutable reference `&mut bool`
error[E0308]: mismatched types
--> $DIR/if-no-match-bindings.rs:26:11
| |
| expected bool, found &bool
| help: consider removing the borrow: `true`
- |
- = note: expected type `bool`
- found reference `&bool`
error[E0308]: mismatched types
--> $DIR/if-no-match-bindings.rs:27:11
| |
| expected bool, found &mut bool
| help: consider removing the borrow: `true`
- |
- = note: expected type `bool`
- found mutable reference `&mut bool`
error: aborting due to 8 previous errors
LL | | }
| |_____^ expected usize, found ()
|
- = note: expected type `usize`
- found unit type `()`
= note: `if` expressions without `else` evaluate to `()`
= help: consider adding an `else` block that evaluates to the expected type
LL | | };
| |_____^ expected usize, found ()
|
- = note: expected type `usize`
- found unit type `()`
= note: `if` expressions without `else` evaluate to `()`
= help: consider adding an `else` block that evaluates to the expected type
LL | | }
| |_____^ expected usize, found ()
|
- = note: expected type `usize`
- found unit type `()`
= note: `if` expressions without `else` evaluate to `()`
= help: consider adding an `else` block that evaluates to the expected type
LL | | }
| |_____^ expected usize, found ()
|
- = note: expected type `usize`
- found unit type `()`
= note: `if` expressions without `else` evaluate to `()`
= help: consider adding an `else` block that evaluates to the expected type
LL | | };
| |_____^ expected usize, found ()
|
- = note: expected type `usize`
- found unit type `()`
= note: `if` expressions without `else` evaluate to `()`
= help: consider adding an `else` block that evaluates to the expected type
LL | | }
| |_____^ expected usize, found ()
|
- = note: expected type `usize`
- found unit type `()`
= note: `if` expressions without `else` evaluate to `()`
= help: consider adding an `else` block that evaluates to the expected type
fn main() {
let a = if true { true };
//~^ ERROR if may be missing an else clause [E0317]
- //~| expected unit type `()`
- //~| found type `bool`
//~| expected (), found bool
println!("{}", a);
}
| | found here
| expected (), found bool
|
- = note: expected unit type `()`
- found type `bool`
= note: `if` expressions without `else` evaluate to `()`
= help: consider adding an `else` block that evaluates to the expected type
LL | }
LL | 0_u32
| ^^^^^ expected i32, found u32
- |
- = note: expected type `i32`
- found type `u32`
error[E0277]: cannot add `impl Foo` to `u32`
--> $DIR/equality.rs:24:11
--> $DIR/mismatched-types.rs:2:20
|
LL | let b: &[u8] = include_str!("file.txt");
- | ^^^^^^^^^^^^^^^^^^^^^^^^ expected slice, found str
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ expected slice `[u8]`, found str
|
= note: expected reference `&[u8]`
found reference `&'static str`
--> $DIR/mismatched-types.rs:3:19
|
LL | let s: &str = include_bytes!("file.txt");
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected str, found array of 0 elements
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected str, found array `[u8; 0]`
|
= note: expected reference `&str`
found reference `&'static [u8; 0]`
let mut x = 2;
x = 5.0;
//~^ ERROR mismatched types
- //~| expected type `{integer}`
- //~| found type `{float}`
//~| expected integer, found floating-point number
}
|
LL | x = 5.0;
| ^^^ expected integer, found floating-point number
- |
- = note: expected type `{integer}`
- found type `{float}`
error: aborting due to previous error
None => (),
//~^ ERROR match arms have incompatible types
//~| NOTE expected bool, found ()
- //~| NOTE expected type `bool`
_ => true
}
}
LL | | _ => true
LL | | }
| |_____- `match` arms have incompatible types
- |
- = note: expected type `bool`
- found unit type `()`
error: aborting due to previous error
--> $DIR/issue-12997-2.rs:8:1
|
LL | fn bar(x: isize) { }
- | ^^^^^^^^^^^^^^^^^^^^ expected isize, found mutable reference
- |
- = note: expected type `isize`
- found mutable reference `&mut test::Bencher`
+ | ^^^^^^^^^^^^^^^^^^^^ expected isize, found &mut test::Bencher
error: aborting due to previous error
|
LL | A::C = 1;
| ^ expected struct `A::C`, found integer
- |
- = note: expected struct `A::C`
- found type `{integer}`
error[E0070]: invalid left-hand side expression
--> $DIR/issue-13407.rs:6:5
--> $DIR/issue-13446.rs:3:26
|
LL | static VEC: [u32; 256] = vec![];
- | ^^^^^^ expected array of 256 elements, found struct `std::vec::Vec`
+ | ^^^^^^ expected array `[u32; 256]`, found struct `std::vec::Vec`
|
= note: expected array `[u32; 256]`
found struct `std::vec::Vec<_>`
|
LL | assert!(1,1);
| ^^^^^^^^^^^^^ expected bool, found integer
- |
- = note: expected type `bool`
- found type `{integer}`
error: aborting due to previous error
let Vec3 { y: _, z: _ } = v;
//~^ ERROR mismatched types
//~| expected struct `Vec2`, found struct `Vec3`
- //~| expected struct `Vec2`
- //~| found struct `Vec3`
}
fn main() { }
|
LL | let Vec3 { y: _, z: _ } = v;
| ^^^^^^^^^^^^^^^^^^^ expected struct `Vec2`, found struct `Vec3`
- |
- = note: expected struct `Vec2`
- found struct `Vec3`
error: aborting due to previous error
//~^ ERROR mismatched types
//~| expected enum `std::option::Option<&[&str]>`
//~| found enum `std::option::Option<&[&str; 1]>`
- //~| expected slice, found array of 1 element
+ //~| expected slice `[&str]`, found array `[&str; 1]`
assert_eq!(msg, 3);
}
--> $DIR/issue-15783.rs:8:19
|
LL | let msg = foo(x);
- | ^ expected slice, found array of 1 element
+ | ^ expected slice `[&str]`, found array `[&str; 1]`
|
= note: expected enum `std::option::Option<&[&str]>`
found enum `std::option::Option<&[&str; 1]>`
Tau{t: x},
//~^ ERROR mismatched types
//~| expected enum `main::R`, found struct `main::Tau`
- //~| expected enum `main::R`
- //~| found struct `main::Tau`
_) => x,
};
}
LL | E::B(
LL | Tau{t: x},
| ^^^^^^^^^ expected enum `main::R`, found struct `main::Tau`
- |
- = note: expected enum `main::R`
- found struct `main::Tau`
error: aborting due to previous error
fn f<'r>(p: &'r mut fn(p: &mut ())) {
(*p)(()) //~ ERROR mismatched types
- //~| expected mutable reference `&mut ()`
- //~| found unit type `()`
//~| expected &mut (), found ()
}
| |
| expected &mut (), found ()
| help: consider mutably borrowing here: `&mut ()`
- |
- = note: expected mutable reference `&mut ()`
- found unit type `()`
error: aborting due to previous error
fn main() {
if let Some(homura) = Some("madoka") { //~ ERROR missing an else clause
- //~| expected unit type `()`
- //~| found type `{integer}`
//~| expected (), found integer
765
};
|
LL | / if let Some(homura) = Some("madoka") {
LL | |
-LL | |
-LL | |
LL | | 765
| | --- found here
LL | | };
| |_____^ expected (), found integer
|
- = note: expected unit type `()`
- found type `{integer}`
= note: `if` expressions without `else` evaluate to `()`
= help: consider adding an `else` block that evaluates to the expected type
impl<'a, T> Fn<(&'a T,)> for Foo {
extern "rust-call" fn call(&self, (_,): (T,)) {}
//~^ ERROR: has an incompatible type for trait
- //~| expected reference
}
impl<'a, T> FnMut<(&'a T,)> for Foo {
extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {}
//~^ ERROR: has an incompatible type for trait
- //~| expected reference
}
impl<'a, T> FnOnce<(&'a T,)> for Foo {
extern "rust-call" fn call_once(self, (_,): (T,)) {}
//~^ ERROR: has an incompatible type for trait
- //~| expected reference
}
fn main() {}
LL | impl<'a, T> Fn<(&'a T,)> for Foo {
| - this type parameter
LL | extern "rust-call" fn call(&self, (_,): (T,)) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found type parameter `T`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected &T, found type parameter `T`
|
= note: expected fn pointer `extern "rust-call" fn(&Foo, (&'a T,))`
found fn pointer `extern "rust-call" fn(&Foo, (T,))`
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
error[E0053]: method `call_mut` has an incompatible type for trait
- --> $DIR/issue-20225.rs:12:3
+ --> $DIR/issue-20225.rs:11:3
|
LL | impl<'a, T> FnMut<(&'a T,)> for Foo {
| - this type parameter
LL | extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found type parameter `T`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected &T, found type parameter `T`
|
= note: expected fn pointer `extern "rust-call" fn(&mut Foo, (&'a T,))`
found fn pointer `extern "rust-call" fn(&mut Foo, (T,))`
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
error[E0053]: method `call_once` has an incompatible type for trait
- --> $DIR/issue-20225.rs:20:3
+ --> $DIR/issue-20225.rs:18:3
|
LL | impl<'a, T> FnOnce<(&'a T,)> for Foo {
| - this type parameter
...
LL | extern "rust-call" fn call_once(self, (_,): (T,)) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found type parameter `T`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected &T, found type parameter `T`
|
= note: expected fn pointer `extern "rust-call" fn(Foo, (&'a T,))`
found fn pointer `extern "rust-call" fn(Foo, (T,))`
|
LL | let _: () = foo::Foo.bar();
| ^^^^^^^^^^^^^^ expected (), found bool
- |
- = note: expected unit type `()`
- found type `bool`
error: aborting due to previous error
|
LL | let v: Vec(&str) = vec!['1', '2'];
| ^^^ expected &str, found char
- |
- = note: expected reference `&str`
- found type `char`
error: aborting due to 2 previous errors
let b = [0; S];
//~^ ERROR mismatched types
//~| expected usize, found struct `S`
- //~| expected type `usize`
- //~| found struct `S`
}
|
LL | let b = [0; S];
| ^ expected usize, found struct `S`
- |
- = note: expected type `usize`
- found struct `S`
error: aborting due to previous error
| |
| expected i32, found ()
| help: give it a value of the expected type: `break 42`
- |
- = note: expected type `i32`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/issue-27042.rs:8:9
LL | |
LL | | while true { break }; // but here we cite the whole loop
| |____________________________^ expected i32, found ()
- |
- = note: expected type `i32`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/issue-27042.rs:12:9
LL | / 'c:
LL | | for _ in None { break }; // but here we cite the whole loop
| |_______________________________^ expected i32, found ()
- |
- = note: expected type `i32`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/issue-27042.rs:15:9
LL | / 'd:
LL | | while let Some(_) = None { break };
| |__________________________________________^ expected i32, found ()
- |
- = note: expected type `i32`
- found unit type `()`
error: aborting due to 4 previous errors
bar(&mut $d);
//~^ ERROR mismatched types
//~| expected u8, found &mut u8
- //~| expected type `u8`
- //~| found mutable reference `&mut u8`
}}
}
...
LL | foo!(0u8);
| ---------- in this macro invocation
- |
- = note: expected type `u8`
- found mutable reference `&mut u8`
error: aborting due to previous error
|
LL | u = v; // mark $0 and $1 in a subtype relationship
| ^ expected struct `A`, found struct `B`
- |
- = note: expected struct `A`
- found struct `B`
error: aborting due to previous error
|
LL | let Test = 1;
| ^^^^ expected integer, found struct `Test`
- |
- = note: expected type `{integer}`
- found struct `Test`
error: aborting due to previous error
|
LL | let empty_struct::XEmpty2 = ();
| ^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `empty_struct::XEmpty2`
- |
- = note: expected unit type `()`
- found struct `empty_struct::XEmpty2`
error[E0308]: mismatched types
--> $DIR/issue-37026.rs:7:9
|
LL | let empty_struct::XEmpty6(..) = ();
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `empty_struct::XEmpty6`
- |
- = note: expected unit type `()`
- found struct `empty_struct::XEmpty6`
error: aborting due to 2 previous errors
|
LL | let x: () = 0;
| ^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error: aborting due to previous error
LL | <() as Visit>::visit();
| ^^^^^^^^^^^^^^^^^^^^ expected &(), found ()
|
- = note: expected reference `&()`
- found unit type `()`
= note: required because of the requirements on the impl of `Visit` for `()`
error: aborting due to previous error
|
LL | const CONST: () = ();
| ^^ expected u32, found ()
- |
- = note: expected type `u32`
- found unit type `()`
error: aborting due to previous error
--> $DIR/issue-41742.rs:24:7
|
LL | H["?"].f();
- | ^^^ expected u32, found reference
- |
- = note: expected type `u32`
- found reference `&'static str`
+ | ^^^ expected u32, found &str
error: aborting due to previous error
0
} else if false {
//~^ ERROR if may be missing an else clause
-//~| expected unit type `()`
-//~| found type `{integer}`
//~| expected (), found integer
1
};
| ____________^
LL | |
LL | |
-LL | |
-LL | |
LL | | 1
| | - found here
LL | | };
| |_____^ expected (), found integer
|
- = note: expected unit type `()`
- found type `{integer}`
= note: `if` expressions without `else` evaluate to `()`
= help: consider adding an `else` block that evaluates to the expected type
LL |
LL | break true;
| - help: consider removing this semicolon
- |
- = note: expected type `bool`
- found unit type `()`
error: aborting due to 3 previous errors
--> $DIR/issue-43420-no-over-suggest.rs:8:9
|
LL | foo(&a);
- | ^^ expected slice, found struct `std::vec::Vec`
+ | ^^ expected slice `[u16]`, found struct `std::vec::Vec`
|
= note: expected reference `&[u16]`
found reference `&std::vec::Vec<u8>`
| ------------------------ ^^^^^ expected isize, found ()
| |
| implicitly returns `()` as its body has no tail or `return` expression
- |
- = note: expected type `isize`
- found unit type `()`
error: aborting due to previous error
let foo: [u8; 4] = [1; 4];
bar(foo);
//~^ ERROR mismatched types
- //~| expected type `usize`
- //~| found array `[u8; 4]`
- //~| expected usize, found array of 4 elements
+ //~| expected usize, found array `[u8; 4]`
}
--> $DIR/issue-4517.rs:5:9
|
LL | bar(foo);
- | ^^^ expected usize, found array of 4 elements
- |
- = note: expected type `usize`
- found array `[u8; 4]`
+ | ^^^ expected usize, found array `[u8; 4]`
error: aborting due to previous error
| |
| expected &str, found str
| help: consider borrowing here: `&s[..2]`
- |
- = note: expected reference `&str`
- found type `str`
error: aborting due to previous error
| |
| expected &usize, found usize
| help: consider borrowing here: `&(behold as usize)`
- |
- = note: expected reference `&usize`
- found type `usize`
error[E0308]: mismatched types
--> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:14:42
| |
| expected &usize, found usize
| help: consider borrowing here: `&(with_tears + 4)`
- |
- = note: expected reference `&usize`
- found type `usize`
error: aborting due to 2 previous errors
|
LL | () < std::mem::size_of::<_>();
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found usize
- |
- = note: expected unit type `()`
- found type `usize`
error[E0282]: type annotations needed
--> $DIR/issue-47486.rs:3:11
--> $DIR/issue-48364.rs:2:21
|
LL | b"".starts_with(stringify!(foo))
- | ^^^^^^^^^^^^^^^ expected slice, found str
+ | ^^^^^^^^^^^^^^^ expected slice `[u8]`, found str
|
= note: expected reference `&[u8]`
found reference `&'static str`
| expected (), found isize
| found here
|
- = note: expected unit type `()`
- found type `isize`
= note: `if` expressions without `else` evaluate to `()`
= help: consider adding an `else` block that evaluates to the expected type
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
LL | |y: Vec<[(); for x in 0..2 {}]>| {};
| ^^^^^^^^^^^^^^^^ expected usize, found ()
- |
- = note: expected type `usize`
- found unit type `()`
error: aborting due to 2 previous errors
a = *i.to_string();
//~^ ERROR mismatched types
//~| NOTE expected struct `std::string::String`, found str
- //~| NOTE expected struct
v2.push(a);
}
}
|
LL | a = *i.to_string();
| ^^^^^^^^^^^^^^ expected struct `std::string::String`, found str
- |
- = note: expected struct `std::string::String`
- found type `str`
error: aborting due to previous error
| |
| expected struct `std::string::String`, found &str
| help: try using a conversion method: `s.to_string()`
- |
- = note: expected struct `std::string::String`
- found reference `&str`
error: aborting due to 2 previous errors
|
LL | let _: issue_56943::S = issue_56943::S2;
| ^^^^^^^^^^^^^^^ expected struct `issue_56943::S`, found struct `issue_56943::S2`
- |
- = note: expected struct `issue_56943::S`
- found struct `issue_56943::S2`
error: aborting due to previous error
| |
| expected &str, found struct `std::string::String`
| help: consider borrowing here: `&x`
- |
- = note: expected reference `&str`
- found struct `std::string::String`
error: aborting due to previous error
|
LL | const B: A<u8> = Self(0);
| ^ expected bool, found integer
- |
- = note: expected type `bool`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/issue-61882.rs:4:22
--> $DIR/issue-7061.rs:4:46
|
LL | fn foo(&'a mut self) -> Box<BarStruct> { self }
- | -------------- ^^^^ expected struct `std::boxed::Box`, found mutable reference
+ | -------------- ^^^^ expected struct `std::boxed::Box`, found &mut BarStruct
| |
| expected `std::boxed::Box<BarStruct>` because of return type
|
// |
// type `i32` assigned to variable `x`
```
-"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected struct `std::string::String`
- found type `{integer}`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:17:22: error[E0308]: mismatched types
+"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:17:22: error[E0308]: mismatched types
"}
{"message":"mismatched types","code":{"code":"E0308","explanation":"This error occurs when the compiler was unable to infer the concrete type of a
variable. It can occur for several cases, the most common of which is a
// |
// type `i32` assigned to variable `x`
```
-"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected struct `std::string::String`
- found type `{integer}`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:19:22: error[E0308]: mismatched types
+"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:19:22: error[E0308]: mismatched types
"}
{"message":"mismatched types","code":{"code":"E0308","explanation":"This error occurs when the compiler was unable to infer the concrete type of a
variable. It can occur for several cases, the most common of which is a
// |
// type `i32` assigned to variable `x`
```
-"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected struct `std::string::String`
- found type `{integer}`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:23:1: error[E0308]: mismatched types
+"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:23:1: error[E0308]: mismatched types
"}
{"message":"mismatched types","code":{"code":"E0308","explanation":"This error occurs when the compiler was unable to infer the concrete type of a
variable. It can occur for several cases, the most common of which is a
// |
// type `i32` assigned to variable `x`
```
-"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":801,"byte_end":809,"line_start":25,"line_end":26,"column_start":22,"column_end":6,"is_primary":true,"text":[{"text":" let s : String = (","highlight_start":22,"highlight_end":23},{"text":" ); // Error spanning the newline.","highlight_start":1,"highlight_end":6}],"label":"expected struct `std::string::String`, found ()","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected struct `std::string::String`
-found unit type `()`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:25:22: error[E0308]: mismatched types
+"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":801,"byte_end":809,"line_start":25,"line_end":26,"column_start":22,"column_end":6,"is_primary":true,"text":[{"text":" let s : String = (","highlight_start":22,"highlight_end":23},{"text":" ); // Error spanning the newline.","highlight_start":1,"highlight_end":6}],"label":"expected struct `std::string::String`, found ()","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:25:22: error[E0308]: mismatched types
"}
{"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors
"}
// |
// type `i32` assigned to variable `x`
```
-"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected struct `std::string::String`
- found type `{integer}`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:17:22: error[E0308]: mismatched types
+"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:17:22: error[E0308]: mismatched types
"}
{"message":"mismatched types","code":{"code":"E0308","explanation":"This error occurs when the compiler was unable to infer the concrete type of a
variable. It can occur for several cases, the most common of which is a
// |
// type `i32` assigned to variable `x`
```
-"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected struct `std::string::String`
- found type `{integer}`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:19:22: error[E0308]: mismatched types
+"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:19:22: error[E0308]: mismatched types
"}
{"message":"mismatched types","code":{"code":"E0308","explanation":"This error occurs when the compiler was unable to infer the concrete type of a
variable. It can occur for several cases, the most common of which is a
// |
// type `i32` assigned to variable `x`
```
-"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected struct `std::string::String`
- found type `{integer}`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:23:1: error[E0308]: mismatched types
+"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:23:1: error[E0308]: mismatched types
"}
{"message":"mismatched types","code":{"code":"E0308","explanation":"This error occurs when the compiler was unable to infer the concrete type of a
variable. It can occur for several cases, the most common of which is a
// |
// type `i32` assigned to variable `x`
```
-"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":801,"byte_end":809,"line_start":25,"line_end":26,"column_start":22,"column_end":6,"is_primary":true,"text":[{"text":" let s : String = (","highlight_start":22,"highlight_end":23},{"text":" ); // Error spanning the newline.","highlight_start":1,"highlight_end":6}],"label":"expected struct `std::string::String`, found ()","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected struct `std::string::String`
-found unit type `()`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:25:22: error[E0308]: mismatched types
+"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":801,"byte_end":809,"line_start":25,"line_end":26,"column_start":22,"column_end":6,"is_primary":true,"text":[{"text":" let s : String = (","highlight_start":22,"highlight_end":23},{"text":" ); // Error spanning the newline.","highlight_start":1,"highlight_end":6}],"label":"expected struct `std::string::String`, found ()","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"$DIR/json-bom-plus-crlf.rs:25:22: error[E0308]: mismatched types
"}
{"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors
"}
|
LL | let false = 22;
| ^^^^^ expected integer, found bool
- |
- = note: expected type `{integer}`
- found type `bool`
error: aborting due to previous error
|
LL | let true = 22;
| ^^^^ expected integer, found bool
- |
- = note: expected type `{integer}`
- found type `bool`
error: aborting due to previous error
|
LL | fn main() { println!("{}", force(|| {})); }
| ^^ expected isize, found ()
- |
- = note: expected type `isize`
- found unit type `()`
error: aborting due to previous error
| - ^^^^^ expected isize, found ()
| |
| implicitly returns `()` as its body has no tail or `return` expression
- |
- = note: expected type `isize`
- found unit type `()`
error: aborting due to previous error
LL | |
LL | | });
| |_____^ expected bool, found ()
- |
- = note: expected type `bool`
- found unit type `()`
error: aborting due to previous error
| - ^^^^^ expected isize, found ()
| |
| implicitly returns `()` as its body has no tail or `return` expression
- |
- = note: expected type `isize`
- found unit type `()`
error: aborting due to previous error
...
LL | test!();
| -------- in this macro invocation
- |
- = note: expected type `i32`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/liveness-return-last-stmt-semi.rs:7:19
| --------- ^^^ expected i32, found ()
| |
| implicitly returns `()` as its body has no tail or `return` expression
- |
- = note: expected type `i32`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/liveness-return-last-stmt-semi.rs:9:19
| implicitly returns `()` as its body has no tail or `return` expression
LL | x * 2;
| - help: consider removing this semicolon
- |
- = note: expected type `u32`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/liveness-return-last-stmt-semi.rs:13:19
| --- ^^^ expected u32, found ()
| |
| implicitly returns `()` as its body has no tail or `return` expression
- |
- = note: expected type `u32`
- found unit type `()`
error: aborting due to 4 previous errors
|
LL | break 123;
| ^^^ expected &str, found integer
- |
- = note: expected type `&str`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/loop-break-value.rs:16:15
|
LL | break "asdf";
- | ^^^^^^ expected i32, found reference
- |
- = note: expected type `i32`
- found reference `&'static str`
+ | ^^^^^^ expected i32, found &str
error[E0308]: mismatched types
--> $DIR/loop-break-value.rs:21:31
|
LL | break 'outer_loop "nope";
- | ^^^^^^ expected i32, found reference
- |
- = note: expected type `i32`
- found reference `&'static str`
+ | ^^^^^^ expected i32, found &str
error[E0308]: mismatched types
--> $DIR/loop-break-value.rs:73:26
|
LL | break 'c 123;
| ^^^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/loop-break-value.rs:80:15
|
LL | break 2;
| ^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/loop-break-value.rs:90:9
| |
| expected integer, found ()
| help: give it a value of the expected type: `break value`
- |
- = note: expected type `{integer}`
- found unit type `()`
error: aborting due to 16 previous errors
| |
| expected i32, found ()
| help: give it a value of the expected type: `break 42`
- |
- = note: expected type `i32`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/loop-labeled-break-value.rs:6:37
| |
| expected i32, found ()
| help: give it a value of the expected type: `break 'inner 42`
- |
- = note: expected type `i32`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/loop-labeled-break-value.rs:9:45
| |
| expected i32, found ()
| help: give it a value of the expected type: `break 'inner2 42`
- |
- = note: expected type `i32`
- found unit type `()`
error: aborting due to 3 previous errors
| |
| expected i32, found ()
| help: give it a value of the expected type: `break 42`
- |
- = note: expected type `i32`
- found unit type `()`
error: aborting due to previous error
LL | | E::E => unimplemented!(""),
| | ------------------ this and all prior arms are found to be of type `{integer}`
LL | | E::F => "",
- | | ^^ expected integer, found reference
+ | | ^^ expected integer, found &str
LL | | };
| |_____- `match` arms have incompatible types
|
- = note: expected type `{integer}`
- found reference `&'static str`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error
_ => { }
};
//~^^^ ERROR mismatched types
- //~| expected type `{integer}`
- //~| found type `char`
}
|
LL | 'c' ..= 100 => { }
| ^^^^^^^^^^^ expected integer, found char
- |
- = note: expected type `{integer}`
- found type `char`
error: aborting due to 4 previous errors
E::C(_) => (),
//~^ ERROR mismatched types
//~| expected struct `S`, found enum `E`
- //~| expected struct `S`
- //~| found enum `E`
_ => ()
}
}
| ------------ this match expression has type `S`
LL | E::C(_) => (),
| ^^^^^^^ expected struct `S`, found enum `E`
- |
- = note: expected struct `S`
- found enum `E`
error: aborting due to previous error
|
LL | fn main() { let x: A = A::A; match x { B::B => { } } }
| ^^^^ expected enum `A`, found enum `B`
- |
- = note: expected enum `A`
- found enum `B`
error: aborting due to previous error
| - ^^^^^^^ expected enum `A`, found enum `B`
| |
| this match expression has type `A`
- |
- = note: expected enum `A`
- found enum `B`
error: aborting due to previous error
_ => 42,
//~^ ERROR match arms have incompatible types
//~| NOTE expected char, found integer
- //~| NOTE expected type `char`
};
x
}
_ => 42,
//~^ ERROR match arms have incompatible types
//~| NOTE expected char, found integer
- //~| NOTE expected type `char`
};
x
}
None => {}
//~^ ERROR match arms have incompatible types
//~| NOTE expected u32, found ()
- //~| NOTE expected type `u32`
};
}
| | ^^ expected char, found integer
LL | |
LL | |
-LL | |
LL | | };
| |_____- `match` arms have incompatible types
- |
- = note: expected type `char`
- found type `{integer}`
error[E0308]: match arms have incompatible types
- --> $DIR/match-type-err-first-arm.rs:35:14
+ --> $DIR/match-type-err-first-arm.rs:34:14
|
LL | let x = match n {
| _____________-
LL | |
LL | | _ => 42,
| | ^^ expected char, found integer
-... |
+LL | |
LL | |
LL | | };
| |_____- `match` arms have incompatible types
- |
- = note: expected type `char`
- found type `{integer}`
error[E0308]: match arms have incompatible types
- --> $DIR/match-type-err-first-arm.rs:48:17
+ --> $DIR/match-type-err-first-arm.rs:46:17
|
LL | / match Some(0u32) {
LL | | Some(x) => {
LL | | },
LL | | None => {}
| | ^^ expected u32, found ()
-... |
+LL | |
LL | |
LL | | };
| |_____- `match` arms have incompatible types
- |
- = note: expected type `u32`
- found unit type `()`
error: aborting due to 4 previous errors
|
LL | let _seetype: () = z;
| ^ expected (), found u32
- |
- = note: expected unit type `()`
- found type `u32`
error[E0308]: mismatched types
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:102:24
|
LL | let _seetype: () = z;
| ^ expected (), found u64
- |
- = note: expected unit type `()`
- found type `u64`
error[E0034]: multiple applicable items in scope
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:120:15
|
LL | let _seetype: () = z;
| ^ expected (), found u8
- |
- = note: expected unit type `()`
- found type `u8`
error[E0308]: mismatched types
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:155:24
|
LL | let _seetype: () = z;
| ^ expected (), found u32
- |
- = note: expected unit type `()`
- found type `u32`
error[E0308]: mismatched types
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:172:24
|
LL | let _seetype: () = z;
| ^ expected (), found u32
- |
- = note: expected unit type `()`
- found type `u32`
error: aborting due to 6 previous errors
let x = Foo;
Foo::bar(x); //~ ERROR mismatched types
//~| expected &Foo, found struct `Foo`
- //~| expected reference `&Foo`
- //~| found struct `Foo`
Foo::bar(&42); //~ ERROR mismatched types
//~| expected struct `Foo`, found integer
//~| expected reference `&Foo`
| |
| expected &Foo, found struct `Foo`
| help: consider borrowing here: `&x`
- |
- = note: expected reference `&Foo`
- found struct `Foo`
error[E0308]: mismatched types
- --> $DIR/method-self-arg-1.rs:15:14
+ --> $DIR/method-self-arg-1.rs:13:14
|
LL | Foo::bar(&42);
| ^^^ expected struct `Foo`, found integer
|
LL | let x: () = 0;
| ^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error: aborting due to previous error
|
LL | (0, ref y) | (y, 0) => {}
| ^ expected &{integer}, found integer
- |
- = note: expected type `&{integer}`
- found type `{integer}`
error: aborting due to 2 previous errors
| |
| expected struct `std::string::String`, found integer
| help: try using a conversion method: `(1+2).to_string()`
- |
- = note: expected struct `std::string::String`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/abridged.rs:59:5
| |
| expected struct `std::string::String`, found integer
| help: try using a conversion method: `(-2).to_string()`
- |
- = note: expected struct `std::string::String`
- found type `{integer}`
error: aborting due to 8 previous errors
|
LL | x
| ^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error: aborting due to previous error
| __________________^
LL | | );
| |_____^ expected u32, found ()
- |
- = note: expected type `u32`
- found unit type `()`
error: aborting due to previous error
--> $DIR/overloaded-calls-bad.rs:28:17
|
LL | let ans = s("what");
- | ^^^^^^ expected isize, found reference
- |
- = note: expected type `isize`
- found reference `&'static str`
+ | ^^^^^^ expected isize, found &str
error[E0057]: this function takes 1 parameter but 0 parameters were supplied
--> $DIR/overloaded-calls-bad.rs:29:15
| - ^^^^^ expected isize, found ()
| |
| implicitly returns `()` as its body has no tail or `return` expression
- |
- = note: expected type `isize`
- found unit type `()`
error: aborting due to previous error
--> $DIR/call-fn-never-arg-wrong-type.rs:10:9
|
LL | foo("wow");
- | ^^^^^ expected !, found reference
+ | ^^^^^ expected !, found &str
|
= note: expected type `!`
found reference `&'static str`
--> $DIR/never-assign-wrong-type.rs:7:16
|
LL | let x: ! = "hello";
- | ^^^^^^^ expected !, found reference
+ | ^^^^^^^ expected !, found &str
|
= note: expected type `!`
found reference `&'static str`
|
LL | let () = 0;
| ^^ expected integer, found ()
- |
- = note: expected type `{integer}`
- found unit type `()`
error: aborting due to previous error
|
LL | let recovery_witness: bool = 0;
| ^ expected bool, found integer
- |
- = note: expected type `bool`
- found type `{integer}`
error: aborting due to 2 previous errors
|
LL | fn main() { match Blah::A(1, 1, 2) { Blah::A(_, x, y) | Blah::B(x, y) => { } } }
| ^ expected usize, found isize
- |
- = note: expected type `usize`
- found type `isize`
error: aborting due to previous error
| |
| expected struct `std::string::String`, found integer
| help: try using a conversion method: `0.to_string()`
- |
- = note: expected struct `std::string::String`
- found type `{integer}`
error: aborting due to 16 previous errors
|
LL | fn main() { let i: isize; i = f(); }
| ^^^ expected isize, found ()
- |
- = note: expected type `isize`
- found unit type `()`
error: aborting due to previous error
|
LL | {2} + {2}
| ^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/expr-as-stmt.rs:12:6
|
LL | {2} + 2
| ^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/expr-as-stmt.rs:18:7
|
LL | { 42 } + foo;
| ^^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/expr-as-stmt.rs:24:7
|
LL | { 3 } * 3
| ^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error[E0614]: type `{integer}` cannot be dereferenced
--> $DIR/expr-as-stmt.rs:24:11
// verify that the parser recovered and properly typechecked the args
f("", "");
//~^ ERROR mismatched types
- //~| NOTE expected u8, found reference
- //~| NOTE expected
+ //~| NOTE expected u8, found &str
//~| ERROR mismatched types
- //~| NOTE expected u8, found reference
- //~| NOTE expected
+ //~| NOTE expected u8, found &str
bar("");
//~^ ERROR mismatched types
- //~| NOTE expected i32, found reference
- //~| NOTE expected
+ //~| NOTE expected i32, found &str
}
--> $DIR/fn-arg-doc-comment.rs:18:7
|
LL | f("", "");
- | ^^ expected u8, found reference
- |
- = note: expected type `u8`
- found reference `&'static str`
+ | ^^ expected u8, found &str
error[E0308]: mismatched types
--> $DIR/fn-arg-doc-comment.rs:18:11
|
LL | f("", "");
- | ^^ expected u8, found reference
- |
- = note: expected type `u8`
- found reference `&'static str`
+ | ^^ expected u8, found &str
error[E0308]: mismatched types
- --> $DIR/fn-arg-doc-comment.rs:25:9
+ --> $DIR/fn-arg-doc-comment.rs:23:9
|
LL | bar("");
- | ^^ expected i32, found reference
- |
- = note: expected type `i32`
- found reference `&'static str`
+ | ^^ expected i32, found &str
error: aborting due to 6 previous errors
| - ^^ expected u8, found ()
| |
| implicitly returns `()` as its body has no tail or `return` expression
- |
- = note: expected type `u8`
- found unit type `()`
error: aborting due to 2 previous errors
| - ^^^^^ expected isize, found ()
| |
| implicitly returns `()` as its body has no tail or `return` expression
- |
- = note: expected type `isize`
- found unit type `()`
error: aborting due to 3 previous errors
| - ^^^^^ expected isize, found ()
| |
| implicitly returns `()` as its body has no tail or `return` expression
- |
- = note: expected type `isize`
- found unit type `()`
error: aborting due to 6 previous errors
--> $DIR/lex-bad-char-literals-6.rs:15:20
|
LL | let a: usize = "";
- | ^^ expected usize, found reference
- |
- = note: expected type `usize`
- found reference `&'static str`
+ | ^^ expected usize, found &str
error[E0277]: can't compare `&str` with `char`
--> $DIR/lex-bad-char-literals-6.rs:12:10
|
LL | const RECOVERY_WITNESS: () = 0;
| ^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error: aborting due to 5 previous errors
--> $DIR/numeric-lifetime.rs:6:20
|
LL | let x: usize = "";
- | ^^ expected usize, found reference
- |
- = note: expected type `usize`
- found reference `&'static str`
+ | ^^ expected usize, found &str
error: aborting due to 3 previous errors
|
LL | const RECOVERY_WITNESS: () = 0;
| ^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error: aborting due to 3 previous errors
|
LL | const RECOVERY_WITNESS: () = 0;
| ^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error: aborting due to 2 previous errors
|
LL | const RECOVERY_WITNESS: () = 0;
| ^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error: aborting due to 3 previous errors
|
LL | const RECOVERY_WITNESS: () = 0;
| ^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error: aborting due to 3 previous errors
|
LL | let x: usize = ();
| ^^ expected usize, found ()
- |
- = note: expected type `usize`
- found unit type `()`
error: aborting due to 2 previous errors
|
LL | let _: usize = ()
| ^^ expected usize, found ()
- |
- = note: expected type `usize`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/recover-missing-semi.rs:9:20
|
LL | let _: usize = ()
| ^^ expected usize, found ()
- |
- = note: expected type `usize`
- found unit type `()`
error: aborting due to 4 previous errors
|
LL | if let .0..Y = 0 {}
| ^^^^^ expected integer, found floating-point number
- |
- = note: expected type `{integer}`
- found type `{float}`
error[E0308]: mismatched types
--> $DIR/recover-range-pats.rs:23:12
|
LL | if let X.. .0 = 0 {}
| ^^^^^^ expected integer, found floating-point number
- |
- = note: expected type `u8`
- found type `{float}`
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:32:12
|
LL | if let .0..=Y = 0 {}
| ^^^^^^ expected integer, found floating-point number
- |
- = note: expected type `{integer}`
- found type `{float}`
error[E0308]: mismatched types
--> $DIR/recover-range-pats.rs:36:12
|
LL | if let X..=.0 = 0 {}
| ^^^^^^ expected integer, found floating-point number
- |
- = note: expected type `u8`
- found type `{float}`
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:45:12
|
LL | if let .0...Y = 0 {}
| ^^^^^^ expected integer, found floating-point number
- |
- = note: expected type `{integer}`
- found type `{float}`
error[E0308]: mismatched types
--> $DIR/recover-range-pats.rs:52:12
|
LL | if let X... .0 = 0 {}
| ^^^^^^^ expected integer, found floating-point number
- |
- = note: expected type `u8`
- found type `{float}`
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:60:12
|
LL | if let .0.. = 0 {}
| ^^^^ expected integer, found floating-point number
- |
- = note: expected type `{integer}`
- found type `{float}`
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:70:12
|
LL | if let .0..= = 0 {}
| ^^^^^ expected integer, found floating-point number
- |
- = note: expected type `{integer}`
- found type `{float}`
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:82:12
|
LL | if let .0... = 0 {}
| ^^^^^ expected integer, found floating-point number
- |
- = note: expected type `{integer}`
- found type `{float}`
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:94:14
|
LL | if let .. .0 = 0 {}
| ^^^^^ expected integer, found floating-point number
- |
- = note: expected type `{integer}`
- found type `{float}`
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:104:15
|
LL | if let ..=.0 = 0 {}
| ^^^^^ expected integer, found floating-point number
- |
- = note: expected type `{integer}`
- found type `{float}`
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:116:15
|
LL | if let ....3 = 0 {}
| ^^^^^ expected integer, found floating-point number
- |
- = note: expected type `{integer}`
- found type `{float}`
error: aborting due to 85 previous errors
--> $DIR/recover-tuple.rs:6:20
|
LL | let y: usize = "";
- | ^^ expected usize, found reference
- |
- = note: expected type `usize`
- found reference `&'static str`
+ | ^^ expected usize, found &str
error: aborting due to 2 previous errors
|
LL | false == 0 < 2;
| ^ expected bool, found integer
- |
- = note: expected type `bool`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/require-parens-for-chained-comparison.rs:8:18
|
LL | false == 0 < 2;
| ^ expected bool, found integer
- |
- = note: expected type `bool`
- found type `{integer}`
error: aborting due to 7 previous errors
|
LL | (..) => {}
| ^^^^ expected u8, found ()
- |
- = note: expected type `u8`
- found unit type `()`
error: aborting due to 2 previous errors
S { .. } => (),
//~^ ERROR mismatched types
//~| expected char, found struct `S`
- //~| expected type `char`
- //~| found struct `S`
_ => ()
}
error[E0433]: failed to resolve: use of undeclared type or module `E`
- --> $DIR/pattern-error-continue.rs:35:9
+ --> $DIR/pattern-error-continue.rs:33:9
|
LL | E::V => {}
| ^ use of undeclared type or module `E`
| --- this match expression has type `char`
LL | S { .. } => (),
| ^^^^^^^^ expected char, found struct `S`
- |
- = note: expected type `char`
- found struct `S`
error[E0308]: mismatched types
- --> $DIR/pattern-error-continue.rs:30:7
+ --> $DIR/pattern-error-continue.rs:28:7
|
LL | f(true);
| ^^^^ expected char, found bool
LL | }
LL | 1u32
| ^^^^ expected i32, found u32
- |
- = note: expected type `i32`
- found type `u32`
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:13:16
LL | } else {
LL | return 1u32;
| ^^^^ expected i32, found u32
- |
- = note: expected type `i32`
- found type `u32`
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:22:9
LL | } else {
LL | 1u32
| ^^^^ expected i32, found u32
- |
- = note: expected type `i32`
- found type `u32`
error[E0308]: if and else have incompatible types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:31:9
LL | |
LL | | }
| |_____- if and else have incompatible types
- |
- = note: expected type `i32`
- found type `u32`
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:39:14
| ---- ...is found to be `i32` here
LL | _ => 1u32,
| ^^^^ expected i32, found u32
- |
- = note: expected type `i32`
- found type `u32`
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:45:5
LL | | _ => 2u32,
LL | | }
| |_____^ expected i32, found u32
- |
- = note: expected type `i32`
- found type `u32`
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:59:13
...
LL | 1u32
| ^^^^ expected i32, found u32
- |
- = note: expected type `i32`
- found type `u32`
error: aborting due to 7 previous errors
--> $DIR/attribute-spans-preserved.rs:7:23
|
LL | #[ foo ( let y: u32 = "z"; ) ]
- | ^^^ expected u32, found reference
- |
- = note: expected type `u32`
- found reference `&'static str`
+ | ^^^ expected u32, found &str
error[E0308]: mismatched types
--> $DIR/attribute-spans-preserved.rs:8:23
|
LL | #[ bar { let x: u32 = "y"; } ]
- | ^^^ expected u32, found reference
- |
- = note: expected type `u32`
- found reference `&'static str`
+ | ^^^ expected u32, found &str
error: aborting due to 2 previous errors
--> $DIR/attribute-with-error.rs:10:18
|
LL | let a: i32 = "foo";
- | ^^^^^ expected i32, found reference
- |
- = note: expected type `i32`
- found reference `&'static str`
+ | ^^^^^ expected i32, found &str
error[E0308]: mismatched types
--> $DIR/attribute-with-error.rs:12:18
|
LL | let b: i32 = "f'oo";
- | ^^^^^^ expected i32, found reference
- |
- = note: expected type `i32`
- found reference `&'static str`
+ | ^^^^^^ expected i32, found &str
error[E0308]: mismatched types
--> $DIR/attribute-with-error.rs:25:22
|
LL | let a: i32 = "foo";
- | ^^^^^ expected i32, found reference
- |
- = note: expected type `i32`
- found reference `&'static str`
+ | ^^^^^ expected i32, found &str
error[E0308]: mismatched types
--> $DIR/attribute-with-error.rs:35:22
|
LL | let a: i32 = "foo";
- | ^^^^^ expected i32, found reference
- |
- = note: expected type `i32`
- found reference `&'static str`
+ | ^^^^^ expected i32, found &str
error: aborting due to 4 previous errors
--> $DIR/nested-item-spans.rs:9:22
|
LL | let x: u32 = "x";
- | ^^^ expected u32, found reference
- |
- = note: expected type `u32`
- found reference `&'static str`
+ | ^^^ expected u32, found &str
error[E0308]: mismatched types
--> $DIR/nested-item-spans.rs:18:22
|
LL | let x: u32 = "x";
- | ^^^ expected u32, found reference
- |
- = note: expected type `u32`
- found reference `&'static str`
+ | ^^^ expected u32, found &str
error: aborting due to 2 previous errors
--> $DIR/span-preservation.rs:11:20
|
LL | let x: usize = "hello";
- | ^^^^^^^ expected usize, found reference
- |
- = note: expected type `usize`
- found reference `&'static str`
+ | ^^^^^^^ expected usize, found &str
error[E0308]: mismatched types
--> $DIR/span-preservation.rs:17:29
| - possibly return type missing here?
LL | 0
| ^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/span-preservation.rs:49:5
let b = [0; ()];
//~^ ERROR mismatched types
//~| expected usize, found ()
- //~| expected type `usize`
- //~| found unit type `()`
let c = [0; true];
//~^ ERROR mismatched types
//~| expected usize, found bool
let d = [0; 0.5];
//~^ ERROR mismatched types
//~| expected usize, found floating-point number
- //~| expected type `usize`
- //~| found type `{float}`
let e = [0; "foo"];
//~^ ERROR mismatched types
- //~| expected usize, found reference
- //~| expected type `usize`
- //~| found reference `&'static str`
+ //~| expected usize, found &str
let f = [0; -4_isize];
//~^ ERROR mismatched types
//~| expected usize, found isize
let g = [0; G { g: () }];
//~^ ERROR mismatched types
//~| expected usize, found struct `main::G`
- //~| expected type `usize`
- //~| found struct `main::G`
}
|
LL | let b = [0; ()];
| ^^ expected usize, found ()
- |
- = note: expected type `usize`
- found unit type `()`
error[E0308]: mismatched types
- --> $DIR/repeat_count.rs:12:17
+ --> $DIR/repeat_count.rs:10:17
|
LL | let c = [0; true];
| ^^^^ expected usize, found bool
error[E0308]: mismatched types
- --> $DIR/repeat_count.rs:15:17
+ --> $DIR/repeat_count.rs:13:17
|
LL | let d = [0; 0.5];
| ^^^ expected usize, found floating-point number
- |
- = note: expected type `usize`
- found type `{float}`
error[E0308]: mismatched types
- --> $DIR/repeat_count.rs:20:17
+ --> $DIR/repeat_count.rs:16:17
|
LL | let e = [0; "foo"];
- | ^^^^^ expected usize, found reference
- |
- = note: expected type `usize`
- found reference `&'static str`
+ | ^^^^^ expected usize, found &str
error[E0308]: mismatched types
- --> $DIR/repeat_count.rs:25:17
+ --> $DIR/repeat_count.rs:19:17
|
LL | let f = [0; -4_isize];
| ^^^^^^^^ expected usize, found isize
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
- --> $DIR/repeat_count.rs:28:23
+ --> $DIR/repeat_count.rs:22:23
|
LL | let f = [0_usize; -1_isize];
| ^^^^^^^^ expected usize, found isize
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
- --> $DIR/repeat_count.rs:34:17
+ --> $DIR/repeat_count.rs:28:17
|
LL | let g = [0; G { g: () }];
| ^^^^^^^^^^^ expected usize, found struct `main::G`
- |
- = note: expected type `usize`
- found struct `main::G`
error: aborting due to 8 previous errors
|
LL | Opts::A(ref i) | Opts::B(i) => {}
| ^ expected &isize, found isize
- |
- = note: expected type `&isize`
- found type `isize`
error[E0308]: mismatched types
--> $DIR/resolve-inconsistent-binding-mode.rs:16:32
|
LL | Opts::A(ref i) | Opts::B(i) => {}
| ^ expected &isize, found isize
- |
- = note: expected type `&isize`
- found type `isize`
error[E0308]: mismatched types
--> $DIR/resolve-inconsistent-binding-mode.rs:25:36
|
LL | (A, B) | (ref B, c) | (c, A) => ()
| ^^^^^ expected enum `E`, found &E
- |
- = note: expected type `E`
- found type `&E`
error: aborting due to 9 previous errors
LL | fn fail() -> ! {
| - expected `!` because of return type
LL | return "wow";
- | ^^^^^ expected !, found reference
+ | ^^^^^ expected !, found &str
|
= note: expected type `!`
found reference `&'static str`
|
LL | FOO => {},
| ^^^ expected &Foo, found struct `Foo`
- |
- = note: expected type `&Foo`
- found struct `Foo`
error: aborting due to previous error
--> $DIR/lit.rs:16:9
|
LL | b"abc" => true,
- | ^^^^^^ expected &[u8], found array of 3 elements
+ | ^^^^^^ expected &[u8], found array `[u8; 3]`
|
= note: expected type `&&[u8]`
found reference `&'static [u8; 3]`
| - expected `A` because of return type
LL | x
| ^ expected struct `A`, found enum `uninhabited::UninhabitedEnum`
- |
- = note: expected struct `A`
- found enum `uninhabited::UninhabitedEnum`
error[E0308]: mismatched types
--> $DIR/coercions.rs:27:5
| - expected `A` because of return type
LL | x
| ^ expected struct `A`, found struct `uninhabited::UninhabitedTupleStruct`
- |
- = note: expected struct `A`
- found struct `uninhabited::UninhabitedTupleStruct`
error[E0308]: mismatched types
--> $DIR/coercions.rs:31:5
| - expected `A` because of return type
LL | x
| ^ expected struct `A`, found struct `uninhabited::UninhabitedStruct`
- |
- = note: expected struct `A`
- found struct `uninhabited::UninhabitedStruct`
error[E0308]: mismatched types
--> $DIR/coercions.rs:35:5
| - expected `A` because of return type
LL | x
| ^ expected struct `A`, found enum `uninhabited::UninhabitedVariants`
- |
- = note: expected struct `A`
- found enum `uninhabited::UninhabitedVariants`
error: aborting due to 4 previous errors
| - expected `A` because of return type
LL | x
| ^ expected struct `A`, found enum `UninhabitedEnum`
- |
- = note: expected struct `A`
- found enum `UninhabitedEnum`
error[E0308]: mismatched types
--> $DIR/coercions_same_crate.rs:34:5
| - expected `A` because of return type
LL | x
| ^ expected struct `A`, found struct `UninhabitedTupleStruct`
- |
- = note: expected struct `A`
- found struct `UninhabitedTupleStruct`
error[E0308]: mismatched types
--> $DIR/coercions_same_crate.rs:38:5
| - expected `A` because of return type
LL | x
| ^ expected struct `A`, found struct `UninhabitedStruct`
- |
- = note: expected struct `A`
- found struct `UninhabitedStruct`
error[E0308]: mismatched types
--> $DIR/coercions_same_crate.rs:42:5
| - expected `A` because of return type
LL | x
| ^ expected struct `A`, found enum `UninhabitedVariants`
- |
- = note: expected struct `A`
- found enum `UninhabitedVariants`
error: aborting due to 4 previous errors
| |
| expected bool, found &bool
| help: consider removing the borrow: `let 0 = 0`
- |
- = note: expected type `bool`
- found reference `&bool`
error[E0614]: type `bool` cannot be dereferenced
--> $DIR/disallowed-positions.rs:36:8
| |
| expected bool, found ()
| help: try comparing for equality: `x == let 0 = 0`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/disallowed-positions.rs:59:8
|
LL | if let Range { start: true, end } = t..&&false {}
| ^^^^^^^ expected bool, found &&bool
- |
- = note: expected type `bool`
- found reference `&&bool`
error[E0308]: mismatched types
--> $DIR/disallowed-positions.rs:86:8
| |
| expected bool, found &bool
| help: consider removing the borrow: `let 0 = 0`
- |
- = note: expected type `bool`
- found reference `&bool`
error[E0614]: type `bool` cannot be dereferenced
--> $DIR/disallowed-positions.rs:100:11
| |
| expected bool, found ()
| help: try comparing for equality: `x == let 0 = 0`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/disallowed-positions.rs:123:11
|
LL | while let Range { start: true, end } = t..&&false {}
| ^^^^^^^ expected bool, found &&bool
- |
- = note: expected type `bool`
- found reference `&&bool`
error[E0308]: mismatched types
--> $DIR/disallowed-positions.rs:150:11
...
LL | &let 0 = 0
| ^^^^^^^^^^ expected (), found &bool
- |
- = note: expected unit type `()`
- found reference `&bool`
error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
--> $DIR/disallowed-positions.rs:179:17
|
LL | let x: usize = String::new();
| ^^^^^^^^^^^^^ expected usize, found struct `std::string::String`
- |
- = note: expected type `usize`
- found struct `std::string::String`
error[E0308]: mismatched types
--> $DIR/coerce-suggestions.rs:9:19
| |
| expected &str, found struct `std::string::String`
| help: consider borrowing here: `&String::new()`
- |
- = note: expected reference `&str`
- found struct `std::string::String`
error[E0308]: mismatched types
--> $DIR/coerce-suggestions.rs:12:10
--> $DIR/coerce-suggestions.rs:21:9
|
LL | s = format!("foo");
- | ^^^^^^^^^^^^^^ expected mutable reference, found struct `std::string::String`
+ | ^^^^^^^^^^^^^^ expected &mut std::string::String, found struct `std::string::String`
|
- = note: expected mutable reference `&mut std::string::String`
- found struct `std::string::String`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to 6 previous errors
LL | stream.write_fmt(format!("message received"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::fmt::Arguments`, found struct `std::string::String`
|
- = note: expected struct `std::fmt::Arguments<'_>`
- found struct `std::string::String`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error
--> $DIR/issue-34264.rs:8:13
|
LL | bar("", "");
- | ^^ expected usize, found reference
- |
- = note: expected type `usize`
- found reference `&'static str`
+ | ^^ expected usize, found &str
error[E0061]: this function takes 2 parameters but 3 parameters were supplied
--> $DIR/issue-34264.rs:10:5
| |
| expected &str, found struct `std::string::String`
| help: consider borrowing here: `&b`
- |
- = note: expected reference `&str`
- found struct `std::string::String`
error[E0369]: binary operation `+` cannot be applied to type `&std::string::String`
--> $DIR/issue-39018.rs:30:15
| ------ ^ expected str, found &str
| |
| expected because of this
- |
- = note: expected type `str`
- found reference `&str`
error[E0308]: mismatched types
--> $DIR/str-array-assignment.rs:5:27
| |
| expected &str, found str
| help: consider borrowing here: `&s[..2]`
- |
- = note: expected reference `&str`
- found type `str`
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> $DIR/str-array-assignment.rs:7:7
| |
| expected &str, found str
| help: consider borrowing here: `&s[..2]`
- |
- = note: expected reference `&str`
- found type `str`
error: aborting due to 4 previous errors
LL | let x: &[u8] = "foo";
| ^^^^^
| |
- | expected slice, found str
+ | expected slice `[u8]`, found str
| help: consider adding a leading `b`: `b"foo"`
|
= note: expected reference `&[u8]`
LL | let y: &[u8; 4] = "baaa";
| ^^^^^^
| |
- | expected array of 4 elements, found str
+ | expected array `[u8; 4]`, found str
| help: consider adding a leading `b`: `b"baaa"`
|
= note: expected reference `&[u8; 4]`
LL | let z: &str = b"foo";
| ^^^^^^
| |
- | expected str, found array of 3 elements
+ | expected str, found array `[u8; 3]`
| help: consider removing the leading `b`: `"foo"`
|
= note: expected reference `&str`
| | |
| | expected (), found bool
| expected this to be `()`
- |
- = note: expected unit type `()`
- found type `bool`
error[E0308]: mismatched types
--> $DIR/struct-literal-variant-in-if.rs:21:20
|
LL | let y: usize = ();
| ^^ expected usize, found ()
- |
- = note: expected type `usize`
- found unit type `()`
error: aborting due to 7 previous errors
|
LL | static foo: Foo = Foo { a: 2, ..bar };
| ^^^ expected struct `Foo`, found struct `Bar`
- |
- = note: expected struct `Foo`
- found struct `Bar`
error[E0308]: mismatched types
--> $DIR/struct-base-wrong-type.rs:8:35
|
LL | static foo_i: Foo = Foo { a: 2, ..4 };
| ^ expected struct `Foo`, found integer
- |
- = note: expected struct `Foo`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/struct-base-wrong-type.rs:12:27
|
LL | let f = Foo { a: 2, ..b };
| ^ expected struct `Foo`, found struct `Bar`
- |
- = note: expected struct `Foo`
- found struct `Bar`
error[E0308]: mismatched types
--> $DIR/struct-base-wrong-type.rs:13:34
|
LL | let f__isize = Foo { a: 2, ..4 };
| ^ expected struct `Foo`, found integer
- |
- = note: expected struct `Foo`
- found type `{integer}`
error: aborting due to 4 previous errors
| |
| expected f32, found integer
| help: use a float literal: `1.0`
- |
- = note: expected type `f32`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/structure-constructor-type-mismatch.rs:20:12
| |
| expected f32, found integer
| help: use a float literal: `2.0`
- |
- = note: expected type `f32`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/structure-constructor-type-mismatch.rs:26:12
| |
| expected f32, found integer
| help: use a float literal: `3.0`
- |
- = note: expected type `f32`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/structure-constructor-type-mismatch.rs:29:12
| |
| expected f32, found integer
| help: use a float literal: `4.0`
- |
- = note: expected type `f32`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/structure-constructor-type-mismatch.rs:35:12
| |
| expected f32, found integer
| help: use a float literal: `5.0`
- |
- = note: expected type `f32`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/structure-constructor-type-mismatch.rs:42:12
| |
| expected f32, found integer
| help: use a float literal: `7.0`
- |
- = note: expected type `f32`
- found type `{integer}`
error[E0107]: wrong number of type arguments: expected 0, found 1
--> $DIR/structure-constructor-type-mismatch.rs:48:24
| |
| expected f32, found integer
| help: use a float literal: `9.0`
- |
- = note: expected type `f32`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/structure-constructor-type-mismatch.rs:50:12
| |
| expected f32, found integer
| help: use a float literal: `10.0`
- |
- = note: expected type `f32`
- found type `{integer}`
error[E0107]: wrong number of type arguments: expected 0, found 1
--> $DIR/structure-constructor-type-mismatch.rs:54:18
| --- ^^^ expected &Foo, found struct `Foo`
| |
| help: consider using `as_ref` instead: `as_ref().map`
- |
- = note: expected reference `&Foo`
- found struct `Foo`
error[E0308]: mismatched types
--> $DIR/as-ref.rs:8:37
| -------- ^^^ expected &Foo, found struct `Foo`
| |
| help: consider using `as_ref` instead: `as_ref().and_then`
- |
- = note: expected reference `&Foo`
- found struct `Foo`
error[E0308]: mismatched types
--> $DIR/as-ref.rs:11:27
| --- ^^^ expected &Foo, found struct `Foo`
| |
| help: consider using `as_ref` instead: `as_ref().map`
- |
- = note: expected reference `&Foo`
- found struct `Foo`
error[E0308]: mismatched types
--> $DIR/as-ref.rs:13:35
| -------- ^^^ expected &Foo, found struct `Foo`
| |
| help: consider using `as_ref` instead: `as_ref().and_then`
- |
- = note: expected reference `&Foo`
- found struct `Foo`
error[E0308]: mismatched types
--> $DIR/as-ref.rs:16:27
| |______expected &str, found struct `std::string::String`
| in this macro invocation
|
- = note: expected reference `&str`
- found struct `std::string::String`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error
LL | let a: String = &String::from("a");
| ^^^^^^^^^^^^^^^^^^
| |
- | expected struct `std::string::String`, found reference
+ | expected struct `std::string::String`, found &std::string::String
| help: consider removing the borrow: `String::from("a")`
- |
- = note: expected struct `std::string::String`
- found reference `&std::string::String`
error[E0308]: mismatched types
--> $DIR/format-borrow.rs:4:21
LL | let b: String = &format!("b");
| ^^^^^^^^^^^^^
| |
- | expected struct `std::string::String`, found reference
+ | expected struct `std::string::String`, found &std::string::String
| help: consider removing the borrow: `format!("b")`
- |
- = note: expected struct `std::string::String`
- found reference `&std::string::String`
error: aborting due to 2 previous errors
| |
| expected struct `std::string::String`, found &str
| help: try using a conversion method: `guts: guts.to_string()`
- |
- = note: expected struct `std::string::String`
- found reference `&str`
error[E0308]: mismatched types
--> $DIR/issue-52820.rs:10:17
| |
| expected struct `std::string::String`, found &str
| help: try using a conversion method: `guts.to_string()`
- |
- = note: expected struct `std::string::String`
- found reference `&str`
error: aborting due to 2 previous errors
| |
| expected i32, found struct `Foo`
| help: consider dereferencing the type: `*x`
- |
- = note: expected type `i32`
- found struct `Foo`
error[E0308]: mismatched types
--> $DIR/issue-59819.rs:30:18
| |
| expected i32, found &{integer}
| help: consider dereferencing the borrow: `*a`
- |
- = note: expected type `i32`
- found reference `&{integer}`
error[E0308]: mismatched types
--> $DIR/issue-59819.rs:34:21
| |
| expected struct `std::string::String`, found struct `Bar`
| help: try using a conversion method: `f.to_string()`
- |
- = note: expected struct `std::string::String`
- found struct `Bar`
error: aborting due to 3 previous errors
| | -- help: consider using a semicolon here
| |_____|
| expected this to be `()`
- |
- = note: expected unit type `()`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/match-needing-semi.rs:12:5
| | ^- help: consider using a semicolon here
| |_____|
| expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error: aborting due to 2 previous errors
|
LL | let _: usize = S {};
| ^^^^ expected usize, found struct `S`
- |
- = note: expected type `usize`
- found struct `S`
error[E0308]: mismatched types
--> $DIR/recover-from-semicolon-trailing-item.rs:12:20
|
LL | let _: usize = X {};
| ^^^^ expected usize, found struct `main::X`
- |
- = note: expected type `usize`
- found struct `main::X`
error[E0308]: mismatched types
--> $DIR/recover-from-semicolon-trailing-item.rs:14:9
|
LL | foo("");
- | ^^ expected usize, found reference
- |
- = note: expected type `usize`
- found reference `&'static str`
+ | ^^ expected usize, found &str
error: aborting due to 6 previous errors
|
LL | let ref string: String = var;
| ^^^ expected struct `std::string::String`, found i32
- |
- = note: expected struct `std::string::String`
- found type `i32`
error: aborting due to previous error
|
LL | ...; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _:...
| ^^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error: aborting due to previous error
|
LL | ...♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42; let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆...
| ^^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error: aborting due to previous error
|
LL | ...) = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ()...
| ^^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error: aborting due to previous error
| ----- expected `usize` because of return type
LL | ... ()
| ^^ expected usize, found ()
- |
- = note: expected type `usize`
- found unit type `()`
error: aborting due to previous error
|
LL | ... let _: () = 42;
| ^^ expected (), found integer
- |
- = note: expected unit type `()`
- found type `{integer}`
error: aborting due to previous error
fn have_bar(b: Bar) {
want_foo(b); //~ ERROR mismatched types
//~| expected struct `Foo`, found struct `Bar`
- //~| expected struct `Foo`
- //~| found struct `Bar`
}
fn main() {}
|
LL | want_foo(b);
| ^ expected struct `Foo`, found struct `Bar`
- |
- = note: expected struct `Foo`
- found struct `Bar`
error: aborting due to previous error
|
LL | impl Foo for IntoIter<i32> {
| ^^^ expected i32, found u32
- |
- = note: expected type `i32`
- found type `u32`
error: aborting due to previous error
|
LL | ""
| ^^ expected i32, found &str
- |
- = note: expected type `i32`
- found reference `&str`
error[E0271]: type mismatch resolving `<std::result::Result<i32, i32> as std::ops::Try>::Ok == ()`
--> $DIR/try-block-bad-type.rs:15:39
|
LL | let res: Result<i32, i32> = try { };
| ^ expected i32, found ()
- |
- = note: expected type `i32`
- found unit type `()`
error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
--> $DIR/try-block-bad-type.rs:17:23
| |
| expected f32, found integer
| help: use a float literal: `42.0`
- |
- = note: expected type `f32`
- found type `{integer}`
error[E0271]: type mismatch resolving `<std::option::Option<i32> as std::ops::Try>::Ok == ()`
--> $DIR/try-block-type-error.rs:16:5
|
LL | };
| ^ expected i32, found ()
- |
- = note: expected type `i32`
- found unit type `()`
error: aborting due to 2 previous errors
|
LL | let _: u8 = <E2>::V;
| ^^^^^^^ expected u8, found enum `E2`
- |
- = note: expected type `u8`
- found enum `E2`
error: aborting due to 2 previous errors
--> $DIR/never_reveal_concrete_type.rs:13:27
|
LL | let _: &'static str = x;
- | ^ expected reference, found opaque type
+ | ^ expected &str, found opaque type
|
= note: expected reference `&'static str`
found opaque type `NoReveal`
LL | fn bomp() -> boo::Boo {
| -------- expected `Boo` because of return type
LL | ""
- | ^^ expected opaque type, found reference
+ | ^^ expected opaque type, found &str
|
= note: expected opaque type `Boo`
found reference `&'static str`
|
LL | &(S: &S);
| ^ expected &S, found struct `S`
- |
- = note: expected reference `&S`
- found struct `S`
error[E0308]: mismatched types
--> $DIR/type-ascription-precedence.rs:35:7
|
LL | *(S: Z);
| ^ expected struct `Z`, found struct `S`
- |
- = note: expected struct `Z`
- found struct `S`
error[E0614]: type `Z` cannot be dereferenced
--> $DIR/type-ascription-precedence.rs:35:5
|
LL | -(S: Z);
| ^ expected struct `Z`, found struct `S`
- |
- = note: expected struct `Z`
- found struct `S`
error[E0600]: cannot apply unary operator `-` to type `Z`
--> $DIR/type-ascription-precedence.rs:40:5
|
LL | (S + Z): Z;
| ^^^^^^^ expected struct `Z`, found struct `S`
- |
- = note: expected struct `Z`
- found struct `S`
error[E0308]: mismatched types
--> $DIR/type-ascription-precedence.rs:49:5
|
LL | (S * Z): Z;
| ^^^^^^^ expected struct `Z`, found struct `S`
- |
- = note: expected struct `Z`
- found struct `S`
error[E0308]: mismatched types
--> $DIR/type-ascription-precedence.rs:53:5
--> $DIR/type-ascription-soundness.rs:7:17
|
LL | let ref x = arr: &[u8];
- | ^^^ expected slice, found array of 3 elements
+ | ^^^ expected slice `[u8]`, found array `[u8; 3]`
|
= note: expected reference `&[u8]`
found reference `&[u8; 3]`
--> $DIR/type-ascription-soundness.rs:8:21
|
LL | let ref mut x = arr: &[u8];
- | ^^^ expected slice, found array of 3 elements
+ | ^^^ expected slice `[u8]`, found array `[u8; 3]`
|
= note: expected reference `&[u8]`
found reference `&[u8; 3]`
--> $DIR/type-ascription-soundness.rs:9:11
|
LL | match arr: &[u8] {
- | ^^^ expected slice, found array of 3 elements
+ | ^^^ expected slice `[u8]`, found array `[u8; 3]`
|
= note: expected reference `&[u8]`
found reference `&[u8; 3]`
--> $DIR/type-ascription-soundness.rs:12:17
|
LL | let _len = (arr: &[u8]).len();
- | ^^^ expected slice, found array of 3 elements
+ | ^^^ expected slice `[u8]`, found array `[u8; 3]`
|
= note: expected reference `&[u8]`
found reference `&[u8; 3]`
| |
| expected bool, found ()
| help: try comparing for equality: `0 == 0`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:9:14
| |
| expected bool, found ()
| help: try comparing for equality: `0 == 0`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:10:14
| |
| expected bool, found ()
| help: try comparing for equality: `0 == 0`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:14:17
| |
| expected bool, found ()
| help: try comparing for equality: `0 == 0`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:18:8
| |
| expected bool, found ()
| help: try comparing for equality: `0 == 0`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:20:24
| |
| expected bool, found ()
| help: try comparing for equality: `0 == 0`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:21:9
| |
| expected bool, found ()
| help: try comparing for equality: `0 == 0`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:23:9
| |
| expected bool, found ()
| help: try comparing for equality: `0 == 0`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:26:13
| |
| expected bool, found ()
| help: try comparing for equality: `0 == 0`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:27:14
| |
| expected bool, found ()
| help: try comparing for equality: `0 == 0`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:28:12
| |
| expected bool, found ()
| help: try comparing for equality: `0 == 0`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0070]: invalid left-hand side expression
--> $DIR/assignment-expected-bool.rs:31:20
|
LL | let _: usize = 0 = 0;
| ^^^^^ expected usize, found ()
- |
- = note: expected type `usize`
- found unit type `()`
error: aborting due to 13 previous errors
| |
| expected bool, found ()
| help: try comparing for equality: `x == x`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/assignment-in-if.rs:20:8
| |
| expected bool, found ()
| help: try comparing for equality: `x == x`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/assignment-in-if.rs:25:8
| |
| expected bool, found ()
| help: try comparing for equality: `y == (Foo { foo: x })`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/assignment-in-if.rs:30:8
| |
| expected bool, found ()
| help: try comparing for equality: `3 == x`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/assignment-in-if.rs:36:13
| |
| expected bool, found ()
| help: try comparing for equality: `x == 4`
- |
- = note: expected type `bool`
- found unit type `()`
error[E0308]: mismatched types
--> $DIR/assignment-in-if.rs:38:13
| |
| expected bool, found ()
| help: try comparing for equality: `x == 5`
- |
- = note: expected type `bool`
- found unit type `()`
error: aborting due to 6 previous errors
| |
| expected i32, found ()
| help: give it a value of the expected type: `break 42`
- |
- = note: expected type `i32`
- found unit type `()`
error: aborting due to previous error
fn main() { let a: bool = 1; let b: i32 = true; }
//~^ ERROR mismatched types
-//~| expected type `bool`
-//~| found type `{integer}`
//~| expected bool, found integer
//~| ERROR mismatched types
//~| expected i32, found bool
|
LL | fn main() { let a: bool = 1; let b: i32 = true; }
| ^ expected bool, found integer
- |
- = note: expected type `bool`
- found type `{integer}`
error[E0308]: mismatched types
--> $DIR/type-mismatch-multiple.rs:3:43
//~^ ERROR mismatched types
//~| Perhaps two different versions of crate `crate_a1`
//~| expected struct `main::a::Foo`
- //~| expected struct `main::a::Foo`
- //~| found struct `main::a::Foo`
a::try_bar(bar2);
//~^ ERROR mismatched types
//~| Perhaps two different versions of crate `crate_a1`
LL | a::try_foo(foo2);
| ^^^^ expected struct `main::a::Foo`, found a different struct `main::a::Foo`
|
- = note: expected struct `main::a::Foo` (struct `main::a::Foo`)
- found struct `main::a::Foo` (struct `main::a::Foo`)
note: Perhaps two different versions of crate `crate_a1` are being used?
--> $DIR/type-mismatch-same-crate-name.rs:16:20
|
| ^^^^
error[E0308]: mismatched types
- --> $DIR/type-mismatch-same-crate-name.rs:22:20
+ --> $DIR/type-mismatch-same-crate-name.rs:20:20
|
LL | a::try_bar(bar2);
| ^^^^ expected trait `main::a::Bar`, found a different trait `main::a::Bar`
= note: expected struct `std::boxed::Box<(dyn main::a::Bar + 'static)>`
found struct `std::boxed::Box<dyn main::a::Bar>`
note: Perhaps two different versions of crate `crate_a1` are being used?
- --> $DIR/type-mismatch-same-crate-name.rs:22:20
+ --> $DIR/type-mismatch-same-crate-name.rs:20:20
|
LL | a::try_bar(bar2);
| ^^^^
|
LL | want::<foo>(f);
| ^ expected struct `foo`, found usize
- |
- = note: expected struct `foo`
- found type `usize`
error[E0308]: mismatched types
--> $DIR/type-mismatch.rs:18:17
|
LL | want::<bar>(f);
| ^ expected struct `bar`, found usize
- |
- = note: expected struct `bar`
- found type `usize`
error[E0308]: mismatched types
--> $DIR/type-mismatch.rs:19:24
|
LL | want::<usize>(f);
| ^ expected usize, found struct `foo`
- |
- = note: expected type `usize`
- found struct `foo`
error[E0308]: mismatched types
--> $DIR/type-mismatch.rs:29:17
|
LL | want::<bar>(f);
| ^ expected struct `bar`, found struct `foo`
- |
- = note: expected struct `bar`
- found struct `foo`
error[E0308]: mismatched types
--> $DIR/type-mismatch.rs:30:24
--> $DIR/type-mismatch.rs:48:26
|
LL | want::<&Foo<foo, B>>(f);
- | ^ expected reference, found struct `Foo`
+ | ^ expected &Foo<foo, B>, found struct `Foo`
|
= note: expected reference `&Foo<foo, B>`
found struct `Foo<foo>`
LL | want::<&Foo<foo, B>>(f);
| ^
| |
- | expected reference, found struct `Foo`
+ | expected &Foo<foo, B>, found struct `Foo`
| help: consider borrowing here: `&f`
|
= note: expected reference `&Foo<foo, B>`
--> $DIR/type-mismatch.rs:75:26
|
LL | want::<&Foo<foo, B>>(f);
- | ^ expected reference, found struct `Foo`
+ | ^ expected &Foo<foo, B>, found struct `Foo`
|
= note: expected reference `&Foo<foo, B>`
found struct `Foo<foo, B, A>`
--> $DIR/type-shadow.rs:6:20
|
LL | let y: Y = "hello";
- | ^^^^^^^ expected isize, found reference
- |
- = note: expected type `isize`
- found reference `&'static str`
+ | ^^^^^^^ expected isize, found &str
error: aborting due to previous error
|
LL | let x: Vec2 = Vec2 { x: 1.0, y: 2.0 } * 2.0; // trait had reversed order
| ^^^ expected struct `Vec2`, found floating-point number
- |
- = note: expected struct `Vec2`
- found type `{float}`
error[E0308]: mismatched types
--> $DIR/wrong-mul-method-signature.rs:63:19
|
LL | let x: Vec2 = Vec2 { x: 1.0, y: 2.0 } * 2.0; // trait had reversed order
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Vec2`, found f64
- |
- = note: expected struct `Vec2`
- found type `f64`
error: aborting due to 5 previous errors