Auto merge of #66389 - estebank:type-err-labels, r=petrochenkov
Specific labels when referring to "expected" and "found" types
This commit is contained in:
commit
53712f8637
581 changed files with 2540 additions and 3536 deletions
|
@ -1163,8 +1163,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
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))
|
||||
}
|
||||
|
@ -1197,40 +1197,61 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
};
|
||||
|
||||
if let Some((expected, found)) = expected_found {
|
||||
match (terr, is_simple_error, expected == found) {
|
||||
(&TypeError::Sorts(ref values), false, true) => {
|
||||
let sort_string = | a_type: Ty<'tcx> |
|
||||
if let ty::Opaque(def_id, _) = a_type.kind {
|
||||
format!(" (opaque type at {})", self.tcx.sess.source_map()
|
||||
.mk_substr_filename(self.tcx.def_span(def_id)))
|
||||
} else {
|
||||
format!(" ({})", a_type.sort_string(self.tcx))
|
||||
};
|
||||
diag.note_expected_found_extra(
|
||||
&"type",
|
||||
expected,
|
||||
found,
|
||||
&sort_string(values.expected),
|
||||
&sort_string(values.found),
|
||||
);
|
||||
let expected_label = exp_found.map_or("type".into(), |ef| ef.expected.prefix_string());
|
||||
let found_label = exp_found.map_or("type".into(), |ef| ef.found.prefix_string());
|
||||
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 {})",
|
||||
self.tcx.sess.source_map()
|
||||
.mk_substr_filename(self.tcx.def_span(*def_id)),
|
||||
),
|
||||
(true, _) => format!(" ({})", ty.sort_string(self.tcx)),
|
||||
(false, _) => "".to_string(),
|
||||
};
|
||||
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
|
||||
);
|
||||
if let Some(exp_found) = exp_found {
|
||||
self.suggest_as_ref_where_appropriate(span, &exp_found, diag);
|
||||
if !is_simple_error || terr.must_include_note() {
|
||||
diag.note_expected_found(&expected_label, expected, &found_label, found);
|
||||
}
|
||||
|
||||
diag.note_expected_found(&"type", expected, found);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
if let Some(exp_found) = exp_found {
|
||||
self.suggest_as_ref_where_appropriate(span, &exp_found, diag);
|
||||
}
|
||||
|
||||
// In some (most?) cases cause.body_id points to actual body, but in some cases
|
||||
// it's a actual definition. According to the comments (e.g. in
|
||||
|
|
56
src/librustc/ty/diagnostics.rs
Normal file
56
src/librustc/ty/diagnostics.rs
Normal file
|
@ -0,0 +1,56 @@
|
|||
//! Diagnostics related methods for `TyS`.
|
||||
|
||||
use crate::ty::TyS;
|
||||
use crate::ty::TyKind::*;
|
||||
use crate::ty::sty::InferTy;
|
||||
|
||||
impl<'tcx> TyS<'tcx> {
|
||||
/// Similar to `TyS::is_primitive`, but also considers inferred numeric values to be primitive.
|
||||
pub fn is_primitive_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,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the type is succinctly representable as a type instead of just refered to with a
|
||||
/// description in error messages. This is used in the main error message.
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the type is succinctly representable as a type instead of just refered to with a
|
||||
/// description in error messages. This is used in the primary span label. Beyond what
|
||||
/// `is_simple_ty` includes, it also accepts ADTs with no type arguments and references to
|
||||
/// ADTs with no type arguments.
|
||||
pub fn is_simple_text(&self) -> bool {
|
||||
match self.kind {
|
||||
Adt(_, substs) => substs.types().next().is_none(),
|
||||
Ref(_, ty, _) => ty.is_simple_text(),
|
||||
_ => self.is_simple_ty(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the type can be safely suggested during error recovery.
|
||||
pub fn is_suggestable(&self) -> bool {
|
||||
match self.kind {
|
||||
Opaque(..) |
|
||||
FnDef(..) |
|
||||
FnPtr(..) |
|
||||
Dynamic(..) |
|
||||
Closure(..) |
|
||||
Infer(..) |
|
||||
Projection(..) => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -64,8 +64,11 @@ pub enum UnconstrainedNumeric {
|
|||
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 {
|
||||
|
@ -183,46 +186,77 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
format!("&{}", tymut_string).into()
|
||||
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(),
|
||||
ty::FnPtr(_) => "fn pointer".into(),
|
||||
ty::Dynamic(ref inner, ..) => {
|
||||
if let Some(principal) = inner.principal() {
|
||||
format!("trait {}", tcx.def_path_str(principal.def_id())).into()
|
||||
format!("trait `{}`", tcx.def_path_str(principal.def_id())).into()
|
||||
} else {
|
||||
"trait".into()
|
||||
}
|
||||
|
@ -246,6 +280,36 @@ impl<'tcx> ty::TyS<'tcx> {
|
|||
ty::Error => "type error".into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn prefix_string(&self) -> Cow<'static, str> {
|
||||
match self.kind {
|
||||
ty::Infer(_) | ty::Error | ty::Bool | ty::Char | ty::Int(_) |
|
||||
ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => "type".into(),
|
||||
ty::Tuple(ref tys) if tys.is_empty() => "unit type".into(),
|
||||
ty::Adt(def, _) => def.descr().into(),
|
||||
ty::Foreign(_) => "extern type".into(),
|
||||
ty::Array(..) => "array".into(),
|
||||
ty::Slice(_) => "slice".into(),
|
||||
ty::RawPtr(_) => "raw pointer".into(),
|
||||
ty::Ref(.., mutbl) => match mutbl {
|
||||
hir::Mutability::Mutable => "mutable reference",
|
||||
_ => "reference"
|
||||
}.into(),
|
||||
ty::FnDef(..) => "fn item".into(),
|
||||
ty::FnPtr(_) => "fn pointer".into(),
|
||||
ty::Dynamic(..) => "trait object".into(),
|
||||
ty::Closure(..) => "closure".into(),
|
||||
ty::Generator(..) => "generator".into(),
|
||||
ty::GeneratorWitness(..) => "generator witness".into(),
|
||||
ty::Tuple(..) => "tuple".into(),
|
||||
ty::Placeholder(..) => "higher-ranked type".into(),
|
||||
ty::Bound(..) => "bound type variable".into(),
|
||||
ty::Projection(_) => "associated type".into(),
|
||||
ty::UnnormalizedProjection(_) => "associated type".into(),
|
||||
ty::Param(_) => "type parameter".into(),
|
||||
ty::Opaque(..) => "opaque type".into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TyCtxt<'tcx> {
|
||||
|
|
|
@ -71,6 +71,7 @@ pub use self::sty::BoundRegion::*;
|
|||
pub use self::sty::InferTy::*;
|
||||
pub use self::sty::RegionKind::*;
|
||||
pub use self::sty::TyKind::*;
|
||||
pub use crate::ty::diagnostics::*;
|
||||
|
||||
pub use self::binding::BindingMode;
|
||||
pub use self::binding::BindingMode::*;
|
||||
|
@ -122,6 +123,7 @@ mod instance;
|
|||
mod structural_impls;
|
||||
mod structural_match;
|
||||
mod sty;
|
||||
mod diagnostics;
|
||||
|
||||
// Data types
|
||||
|
||||
|
@ -552,37 +554,6 @@ impl<'tcx> Hash for TyS<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
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(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_suggestable(&self) -> bool {
|
||||
match self.kind {
|
||||
Opaque(..) |
|
||||
FnDef(..) |
|
||||
FnPtr(..) |
|
||||
Dynamic(..) |
|
||||
Closure(..) |
|
||||
Infer(..) |
|
||||
Projection(..) => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::TyS<'tcx> {
|
||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||
let ty::TyS {
|
||||
|
|
|
@ -209,7 +209,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
|||
// LL | impl Bar for Foo {
|
||||
// | ---------------- in this `impl` item
|
||||
// LL | type Ok = ();
|
||||
// | ^^^^^^^^^^^^^ expected u32, found ()
|
||||
// | ^^^^^^^^^^^^^ expected `u32`, found `()`
|
||||
// |
|
||||
// = note: expected type `u32`
|
||||
// found type `()`
|
||||
|
@ -228,7 +228,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
|||
// LL | impl Bar for Foo {
|
||||
// | ---------------- in this `impl` item
|
||||
// LL | type Ok = ();
|
||||
// | ^^^^^^^^^^^^^ expected u32, found ()
|
||||
// | ^^^^^^^^^^^^^ expected `u32`, found `()`
|
||||
// ...
|
||||
// LL | impl Bar2 for Foo2 {
|
||||
// | ---------------- in this `impl` item
|
||||
|
|
|
@ -154,20 +154,21 @@ impl Diagnostic {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn note_expected_found(&mut self,
|
||||
label: &dyn fmt::Display,
|
||||
expected: DiagnosticStyledString,
|
||||
found: DiagnosticStyledString)
|
||||
-> &mut Self
|
||||
{
|
||||
self.note_expected_found_extra(label, expected, found, &"", &"")
|
||||
pub fn note_expected_found(
|
||||
&mut self,
|
||||
expected_label: &dyn fmt::Display,
|
||||
expected: DiagnosticStyledString,
|
||||
found_label: &dyn fmt::Display,
|
||||
found: DiagnosticStyledString,
|
||||
) -> &mut Self {
|
||||
self.note_expected_found_extra(expected_label, expected, found_label, found, &"", &"")
|
||||
}
|
||||
|
||||
pub fn note_unsuccessfull_coercion(&mut self,
|
||||
expected: DiagnosticStyledString,
|
||||
found: DiagnosticStyledString)
|
||||
-> &mut Self
|
||||
{
|
||||
pub fn note_unsuccessfull_coercion(
|
||||
&mut self,
|
||||
expected: DiagnosticStyledString,
|
||||
found: DiagnosticStyledString,
|
||||
) -> &mut Self {
|
||||
let mut msg: Vec<_> =
|
||||
vec![(format!("required when trying to coerce from type `"),
|
||||
Style::NoStyle)];
|
||||
|
@ -189,27 +190,38 @@ impl Diagnostic {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn note_expected_found_extra(&mut self,
|
||||
label: &dyn fmt::Display,
|
||||
expected: DiagnosticStyledString,
|
||||
found: DiagnosticStyledString,
|
||||
expected_extra: &dyn fmt::Display,
|
||||
found_extra: &dyn fmt::Display)
|
||||
-> &mut Self
|
||||
{
|
||||
let mut msg: Vec<_> = vec![(format!("expected {} `", label), Style::NoStyle)];
|
||||
pub fn note_expected_found_extra(
|
||||
&mut self,
|
||||
expected_label: &dyn fmt::Display,
|
||||
expected: DiagnosticStyledString,
|
||||
found_label: &dyn fmt::Display,
|
||||
found: DiagnosticStyledString,
|
||||
expected_extra: &dyn fmt::Display,
|
||||
found_extra: &dyn fmt::Display,
|
||||
) -> &mut Self {
|
||||
let expected_label = format!("expected {}", expected_label);
|
||||
let found_label = format!("found {}", found_label);
|
||||
let (found_padding, expected_padding) = if expected_label.len() > found_label.len() {
|
||||
(expected_label.len() - found_label.len(), 0)
|
||||
} else {
|
||||
(0, found_label.len() - expected_label.len())
|
||||
};
|
||||
let mut msg: Vec<_> = vec![(
|
||||
format!("{}{} `", " ".repeat(expected_padding), expected_label),
|
||||
Style::NoStyle,
|
||||
)];
|
||||
msg.extend(expected.0.iter()
|
||||
.map(|x| match *x {
|
||||
StringPart::Normal(ref s) => (s.to_owned(), Style::NoStyle),
|
||||
StringPart::Highlighted(ref s) => (s.to_owned(), Style::Highlight),
|
||||
}));
|
||||
.map(|x| match *x {
|
||||
StringPart::Normal(ref s) => (s.to_owned(), Style::NoStyle),
|
||||
StringPart::Highlighted(ref s) => (s.to_owned(), Style::Highlight),
|
||||
}));
|
||||
msg.push((format!("`{}\n", expected_extra), Style::NoStyle));
|
||||
msg.push((format!(" found {} `", label), Style::NoStyle));
|
||||
msg.push((format!("{}{} `", " ".repeat(found_padding), found_label), Style::NoStyle));
|
||||
msg.extend(found.0.iter()
|
||||
.map(|x| match *x {
|
||||
StringPart::Normal(ref s) => (s.to_owned(), Style::NoStyle),
|
||||
StringPart::Highlighted(ref s) => (s.to_owned(), Style::Highlight),
|
||||
}));
|
||||
.map(|x| match *x {
|
||||
StringPart::Normal(ref s) => (s.to_owned(), Style::NoStyle),
|
||||
StringPart::Highlighted(ref s) => (s.to_owned(), Style::Highlight),
|
||||
}));
|
||||
msg.push((format!("`{}", found_extra), Style::NoStyle));
|
||||
|
||||
// For now, just attach these as notes
|
||||
|
|
|
@ -195,37 +195,44 @@ impl<'a> DiagnosticBuilder<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
forward!(pub fn note_expected_found(&mut self,
|
||||
label: &dyn fmt::Display,
|
||||
expected: DiagnosticStyledString,
|
||||
found: DiagnosticStyledString,
|
||||
) -> &mut Self);
|
||||
forward!(pub fn note_expected_found(
|
||||
&mut self,
|
||||
expected_label: &dyn fmt::Display,
|
||||
expected: DiagnosticStyledString,
|
||||
found_label: &dyn fmt::Display,
|
||||
found: DiagnosticStyledString,
|
||||
) -> &mut Self);
|
||||
|
||||
forward!(pub fn note_expected_found_extra(&mut self,
|
||||
label: &dyn fmt::Display,
|
||||
expected: DiagnosticStyledString,
|
||||
found: DiagnosticStyledString,
|
||||
expected_extra: &dyn fmt::Display,
|
||||
found_extra: &dyn fmt::Display,
|
||||
) -> &mut Self);
|
||||
forward!(pub fn note_expected_found_extra(
|
||||
&mut self,
|
||||
expected_label: &dyn fmt::Display,
|
||||
expected: DiagnosticStyledString,
|
||||
found_label: &dyn fmt::Display,
|
||||
found: DiagnosticStyledString,
|
||||
expected_extra: &dyn fmt::Display,
|
||||
found_extra: &dyn fmt::Display,
|
||||
) -> &mut Self);
|
||||
|
||||
forward!(pub fn note_unsuccessfull_coercion(&mut self,
|
||||
expected: DiagnosticStyledString,
|
||||
found: DiagnosticStyledString,
|
||||
) -> &mut Self);
|
||||
forward!(pub fn note_unsuccessfull_coercion(
|
||||
&mut self,
|
||||
expected: DiagnosticStyledString,
|
||||
found: DiagnosticStyledString,
|
||||
) -> &mut Self);
|
||||
|
||||
forward!(pub fn note(&mut self, msg: &str) -> &mut Self);
|
||||
forward!(pub fn span_note<S: Into<MultiSpan>>(&mut self,
|
||||
sp: S,
|
||||
msg: &str,
|
||||
) -> &mut Self);
|
||||
forward!(pub fn span_note<S: Into<MultiSpan>>(
|
||||
&mut self,
|
||||
sp: S,
|
||||
msg: &str,
|
||||
) -> &mut Self);
|
||||
forward!(pub fn warn(&mut self, msg: &str) -> &mut Self);
|
||||
forward!(pub fn span_warn<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self);
|
||||
forward!(pub fn help(&mut self, msg: &str) -> &mut Self);
|
||||
forward!(pub fn span_help<S: Into<MultiSpan>>(&mut self,
|
||||
sp: S,
|
||||
msg: &str,
|
||||
) -> &mut Self);
|
||||
forward!(pub fn span_help<S: Into<MultiSpan>>(
|
||||
&mut self,
|
||||
sp: S,
|
||||
msg: &str,
|
||||
) -> &mut Self);
|
||||
|
||||
pub fn multipart_suggestion(
|
||||
&mut self,
|
||||
|
|
|
@ -285,7 +285,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// || ----- expected because of this
|
||||
// LL || } else {
|
||||
// LL || 10u32
|
||||
// || ^^^^^ expected i32, found u32
|
||||
// || ^^^^^ expected `i32`, found `u32`
|
||||
// LL || };
|
||||
// ||_____- if and else have incompatible types
|
||||
// ```
|
||||
|
@ -294,7 +294,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// The entire expression is in one line, only point at the arms
|
||||
// ```
|
||||
// LL | let x = if true { 10i32 } else { 10u32 };
|
||||
// | ----- ^^^^^ expected i32, found u32
|
||||
// | ----- ^^^^^ expected `i32`, found `u32`
|
||||
// | |
|
||||
// | expected because of this
|
||||
// ```
|
||||
|
@ -323,7 +323,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// | || ^
|
||||
// | ||_____|
|
||||
// | |______if and else have incompatible types
|
||||
// | expected integer, found ()
|
||||
// | expected integer, found `()`
|
||||
// ```
|
||||
// by not pointing at the entire expression:
|
||||
// ```
|
||||
|
@ -335,7 +335,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// | ____________^
|
||||
// 5 | |
|
||||
// 6 | | };
|
||||
// | |_____^ expected integer, found ()
|
||||
// | |_____^ expected integer, found `()`
|
||||
// ```
|
||||
if outer_sp.is_some() {
|
||||
outer_sp = Some(self.tcx.sess.source_map().def_span(span));
|
||||
|
|
|
@ -47,7 +47,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
/// 4 | let temp: usize = match a + b {
|
||||
/// | ----- this expression has type `usize`
|
||||
/// 5 | Ok(num) => num,
|
||||
/// | ^^^^^^^ expected usize, found enum `std::result::Result`
|
||||
/// | ^^^^^^^ expected `usize`, found enum `std::result::Result`
|
||||
/// |
|
||||
/// = note: expected type `usize`
|
||||
/// found type `std::result::Result<_, _>`
|
||||
|
|
|
@ -9,10 +9,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/failed-doctest-missing-codes.rs:9:13
|
||||
|
|
||||
LL | let x: () = 5i32;
|
||||
| ^^^^ expected (), found i32
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `i32`
|
||||
| ^^^^ expected `()`, found `i32`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -2,10 +2,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/arg-type-mismatch.rs:5:30
|
||||
|
|
||||
LL | fn main() { let i: (); i = f(()); }
|
||||
| ^^ expected isize, found ()
|
||||
|
|
||||
= note: expected type `isize`
|
||||
found type `()`
|
||||
| ^^ expected `isize`, found `()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -14,19 +14,19 @@ error[E0308]: mismatched types
|
|||
--> $DIR/array-break-length.rs:3:9
|
||||
|
|
||||
LL | |_: [_; break]| {}
|
||||
| ^^^^^^^^^^^^^^^^^^ expected (), found closure
|
||||
| ^^^^^^^^^^^^^^^^^^ expected `()`, found closure
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `[closure@$DIR/array-break-length.rs:3:9: 3:27]`
|
||||
= note: expected unit type `()`
|
||||
found closure `[closure@$DIR/array-break-length.rs:3:9: 3:27]`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/array-break-length.rs:8:9
|
||||
|
|
||||
LL | |_: [_; continue]| {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ expected (), found closure
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found closure
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `[closure@$DIR/array-break-length.rs:8:9: 8:30]`
|
||||
= note: expected unit type `()`
|
||||
found closure `[closure@$DIR/array-break-length.rs:8:9: 8:30]`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
fn main() {
|
||||
let _x: i32 = [1, 2, 3];
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `i32`
|
||||
//~| found type `[{integer}; 3]`
|
||||
//~| expected i32, found array of 3 elements
|
||||
//~| expected `i32`, found array
|
||||
|
||||
let x: &[i32] = &[1, 2, 3];
|
||||
let _y: &i32 = x;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `&i32`
|
||||
//~| found type `&[i32]`
|
||||
//~| expected i32, found slice
|
||||
//~| expected reference `&i32`
|
||||
//~| found reference `&[i32]`
|
||||
//~| expected `i32`, found slice
|
||||
}
|
||||
|
|
|
@ -2,19 +2,16 @@ error[E0308]: mismatched types
|
|||
--> $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 type `[{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 type `&i32`
|
||||
found type `&[i32]`
|
||||
= note: expected reference `&i32`
|
||||
found reference `&[i32]`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -5,10 +5,10 @@ LL | const FROM: Self::Out;
|
|||
| --------- type in trait
|
||||
...
|
||||
LL | const FROM: &'static str = "foo";
|
||||
| ^^^^^^^^^^^^ expected associated type, found reference
|
||||
| ^^^^^^^^^^^^ expected associated type, found `&str`
|
||||
|
|
||||
= note: expected type `<T as Foo>::Out`
|
||||
found type `&'static str`
|
||||
= note: expected associated type `<T as Foo>::Out`
|
||||
found reference `&'static str`
|
||||
= note: consider constraining the associated type `<T as Foo>::Out` to `&'static str` or calling a method that returns `<T as Foo>::Out`
|
||||
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ error[E0308]: mismatched types
|
|||
LL | const NAME: &'a str = "unit";
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
|
||||
|
|
||||
= note: expected type `&'static str`
|
||||
found type `&'a str`
|
||||
= note: expected reference `&'static str`
|
||||
found reference `&'a str`
|
||||
note: the lifetime `'a` as defined on the impl at 6:6...
|
||||
--> $DIR/associated-const-impl-wrong-lifetime.rs:6:6
|
||||
|
|
||||
|
|
|
@ -5,7 +5,7 @@ LL | const BAR: u32;
|
|||
| --- type in trait
|
||||
...
|
||||
LL | const BAR: i32 = -1;
|
||||
| ^^^ expected u32, found i32
|
||||
| ^^^ expected `u32`, found `i32`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -3,36 +3,24 @@ error[E0308]: mismatched types
|
|||
|
|
||||
LL | fn b() { dent(ModelT, Blue); }
|
||||
| ^^^^ expected struct `Black`, found struct `Blue`
|
||||
|
|
||||
= note: expected type `Black`
|
||||
found type `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 type `Blue`
|
||||
found type `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 type `Black`
|
||||
found type `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 type `Blue`
|
||||
found type `Black`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -6,9 +6,6 @@ LL | fn blue_car<C:Car<Color=Blue>>(c: C) {
|
|||
...
|
||||
LL | fn b() { blue_car(ModelT); }
|
||||
| ^^^^^^^^ expected struct `Blue`, found struct `Black`
|
||||
|
|
||||
= note: expected type `Blue`
|
||||
found type `Black`
|
||||
|
||||
error[E0271]: type mismatch resolving `<ModelU as Vehicle>::Color == Black`
|
||||
--> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:32:10
|
||||
|
@ -18,9 +15,6 @@ LL | fn black_car<C:Car<Color=Black>>(c: C) {
|
|||
...
|
||||
LL | fn c() { black_car(ModelU); }
|
||||
| ^^^^^^^^^ expected struct `Black`, found struct `Blue`
|
||||
|
|
||||
= note: expected type `Black`
|
||||
found type `Blue`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ fn foo1<I: Foo<A=Bar>>(x: I) {
|
|||
fn foo2<I: Foo>(x: I) {
|
||||
let _: Bar = x.boo();
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `Bar`
|
||||
//~| found type `<I as Foo>::A`
|
||||
//~| found associated type `<I as Foo>::A`
|
||||
//~| expected struct `Bar`, found associated type
|
||||
//~| expected struct `Bar`
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,8 +37,8 @@ pub fn main() {
|
|||
let a = 42;
|
||||
foo1(a);
|
||||
//~^ ERROR type mismatch resolving
|
||||
//~| expected struct `Bar`, found usize
|
||||
//~| expected struct `Bar`, found `usize`
|
||||
baz(&a);
|
||||
//~^ ERROR type mismatch resolving
|
||||
//~| expected struct `Bar`, found usize
|
||||
//~| expected struct `Bar`, found `usize`
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ error[E0308]: mismatched types
|
|||
LL | let _: Bar = x.boo();
|
||||
| ^^^^^^^ expected struct `Bar`, found associated type
|
||||
|
|
||||
= note: expected type `Bar`
|
||||
found type `<I as Foo>::A`
|
||||
= note: expected struct `Bar`
|
||||
found associated type `<I as Foo>::A`
|
||||
= note: consider constraining the associated type `<I as Foo>::A` to `Bar`
|
||||
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
||||
|
||||
|
@ -16,19 +16,14 @@ LL | fn foo1<I: Foo<A=Bar>>(x: I) {
|
|||
| ---- ----- required by this bound in `foo1`
|
||||
...
|
||||
LL | foo1(a);
|
||||
| ^^^^ expected struct `Bar`, found usize
|
||||
|
|
||||
= note: expected type `Bar`
|
||||
found type `usize`
|
||||
| ^^^^ expected struct `Bar`, found `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
|
||||
| ^^ expected struct `Bar`, found `usize`
|
||||
|
|
||||
= note: expected type `Bar`
|
||||
found type `usize`
|
||||
= note: required for the cast to the object type `dyn Foo<A = Bar>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
|
|
@ -7,10 +7,10 @@ LL | where T : for<'x> TheTrait<&'x isize, A = &'x isize>
|
|||
| ------------- required by this bound in `foo`
|
||||
...
|
||||
LL | foo::<UintStruct>();
|
||||
| ^^^^^^^^^^^^^^^^^ expected isize, found usize
|
||||
| ^^^^^^^^^^^^^^^^^ expected `isize`, found `usize`
|
||||
|
|
||||
= note: expected type `&isize`
|
||||
found type `&usize`
|
||||
= note: expected reference `&isize`
|
||||
found reference `&usize`
|
||||
|
||||
error[E0271]: type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize`
|
||||
--> $DIR/associated-types-eq-hr.rs:86:5
|
||||
|
@ -21,10 +21,10 @@ LL | where T : for<'x> TheTrait<&'x isize, A = &'x usize>
|
|||
| ------------- required by this bound in `bar`
|
||||
...
|
||||
LL | bar::<IntStruct>();
|
||||
| ^^^^^^^^^^^^^^^^ expected usize, found isize
|
||||
| ^^^^^^^^^^^^^^^^ expected `usize`, found `isize`
|
||||
|
|
||||
= note: expected type `&usize`
|
||||
found type `&isize`
|
||||
= note: expected reference `&usize`
|
||||
found reference `&isize`
|
||||
|
||||
error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied
|
||||
--> $DIR/associated-types-eq-hr.rs:91:17
|
||||
|
|
|
@ -10,7 +10,7 @@ LL | fn test_adapter<T, I: Iterator<Item=Option<T>>>(it: I) {
|
|||
LL | is_iterator_of::<Option<T>, _>(&adapter);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found type parameter `T`
|
||||
|
|
||||
= note: expected type `std::option::Option<T>`
|
||||
= note: expected enum `std::option::Option<T>`
|
||||
found type `T`
|
||||
= help: type parameters must be constrained to match other types
|
||||
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
|
||||
|
|
|
@ -2,13 +2,13 @@ error[E0271]: type mismatch resolving `<T as Foo>::Y == i32`
|
|||
--> $DIR/associated-types-multiple-types-one-trait.rs:13:5
|
||||
|
|
||||
LL | want_y(t);
|
||||
| ^^^^^^ expected i32, found associated type
|
||||
| ^^^^^^ expected `i32`, found associated type
|
||||
...
|
||||
LL | fn want_y<T:Foo<Y=i32>>(t: &T) { }
|
||||
| ------ ----- required by this bound in `want_y`
|
||||
|
|
||||
= note: expected type `i32`
|
||||
found type `<T as Foo>::Y`
|
||||
= note: expected type `i32`
|
||||
found associated type `<T as Foo>::Y`
|
||||
= note: consider constraining the associated type `<T as Foo>::Y` to `i32`
|
||||
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
||||
|
||||
|
@ -16,13 +16,13 @@ error[E0271]: type mismatch resolving `<T as Foo>::X == u32`
|
|||
--> $DIR/associated-types-multiple-types-one-trait.rs:18:5
|
||||
|
|
||||
LL | want_x(t);
|
||||
| ^^^^^^ expected u32, found associated type
|
||||
| ^^^^^^ expected `u32`, found associated type
|
||||
...
|
||||
LL | fn want_x<T:Foo<X=u32>>(t: &T) { }
|
||||
| ------ ----- required by this bound in `want_x`
|
||||
|
|
||||
= note: expected type `u32`
|
||||
found type `<T as Foo>::X`
|
||||
= note: expected type `u32`
|
||||
found associated type `<T as Foo>::X`
|
||||
= note: consider constraining the associated type `<T as Foo>::X` to `u32`
|
||||
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
||||
|
||||
|
|
|
@ -2,10 +2,8 @@ error[E0271]: type mismatch resolving `<std::vec::IntoIter<u32> as std::iter::It
|
|||
--> $DIR/associated-types-overridden-binding-2.rs:6:43
|
||||
|
|
||||
LL | let _: &dyn I32Iterator<Item = u32> = &vec![42].into_iter();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ expected i32, found u32
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ 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
|
||||
|
|
|
@ -18,7 +18,7 @@ pub fn f2<T: Foo>(a: T) -> T::A {
|
|||
pub fn f1_int_int() {
|
||||
f1(2i32, 4i32);
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected u32, found i32
|
||||
//~| expected `u32`, found `i32`
|
||||
}
|
||||
|
||||
pub fn f1_int_uint() {
|
||||
|
@ -40,7 +40,7 @@ pub fn f1_uint_int() {
|
|||
pub fn f2_int() {
|
||||
let _: i32 = f2(2i32);
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected i32, found u32
|
||||
//~| expected `i32`, found `u32`
|
||||
}
|
||||
|
||||
pub fn main() { }
|
||||
|
|
|
@ -2,7 +2,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/associated-types-path-2.rs:19:14
|
||||
|
|
||||
LL | f1(2i32, 4i32);
|
||||
| ^^^^ expected u32, found i32
|
||||
| ^^^^ expected `u32`, found `i32`
|
||||
|
|
||||
help: change the type of the numeric literal from `i32` to `u32`
|
||||
|
|
||||
|
@ -43,7 +43,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/associated-types-path-2.rs:41:18
|
||||
|
|
||||
LL | let _: i32 = f2(2i32);
|
||||
| ^^^^^^^^ expected i32, found u32
|
||||
| ^^^^^^^^ expected `i32`, found `u32`
|
||||
|
|
||||
help: you can convert an `u32` to `i32` and panic if the converted value wouldn't fit
|
||||
|
|
||||
|
|
|
@ -5,10 +5,8 @@ LL | fn visit() {}
|
|||
| ---------- required by `Visit::visit`
|
||||
...
|
||||
LL | <() as Visit>::visit();
|
||||
| ^^^^^^^^^^^^^^^^^^^^ expected (), found &()
|
||||
| ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `&()`
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `&()`
|
||||
= note: required because of the requirements on the impl of `Visit` for `()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
|
@ -7,10 +7,7 @@ LL | type Ok;
|
|||
LL | impl Bar for Foo {
|
||||
| ---------------- in this `impl` item
|
||||
LL | type Ok = ();
|
||||
| ^^^^^^^^^^^^^ expected u32, found ()
|
||||
|
|
||||
= note: expected type `u32`
|
||||
found type `()`
|
||||
| ^^^^^^^^^^^^^ expected `u32`, found `()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -22,21 +22,16 @@ error[E0308]: mismatched types
|
|||
--> $DIR/async-block-control-flow-static-semantics.rs:13:43
|
||||
|
|
||||
LL | fn return_targets_async_block_not_fn() -> u8 {
|
||||
| --------------------------------- ^^ expected u8, found ()
|
||||
| --------------------------------- ^^ expected `u8`, found `()`
|
||||
| |
|
||||
| implicitly returns `()` as its body has no tail or `return` expression
|
||||
|
|
||||
= note: expected type `u8`
|
||||
found 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
|
||||
| ^^^^^^ expected `()`, found `u8`
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `u8`
|
||||
= note: required for the cast to the object type `dyn std::future::Future<Output = ()>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
|
@ -50,42 +45,37 @@ LL | | return 0u8;
|
|||
... |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_^ expected u8, found ()
|
||||
|
|
||||
= note: expected type `u8`
|
||||
found type `()`
|
||||
| |_^ expected `u8`, found `()`
|
||||
|
||||
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
|
||||
| ^^^^^^ expected `()`, found `u8`
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `u8`
|
||||
= note: required for the cast to the object type `dyn std::future::Future<Output = ()>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/async-block-control-flow-static-semantics.rs:48:44
|
||||
|
|
||||
LL | fn rethrow_targets_async_block_not_fn() -> Result<u8, MyErr> {
|
||||
| ---------------------------------- ^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found ()
|
||||
| ---------------------------------- ^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found `()`
|
||||
| |
|
||||
| implicitly returns `()` as its body has no tail or `return` expression
|
||||
|
|
||||
= note: expected type `std::result::Result<u8, MyErr>`
|
||||
found type `()`
|
||||
= note: expected enum `std::result::Result<u8, MyErr>`
|
||||
found unit type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/async-block-control-flow-static-semantics.rs:57:50
|
||||
|
|
||||
LL | fn rethrow_targets_async_block_not_async_fn() -> Result<u8, MyErr> {
|
||||
| ---------------------------------------- ^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found ()
|
||||
| ---------------------------------------- ^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found `()`
|
||||
| |
|
||||
| implicitly returns `()` as its body has no tail or `return` expression
|
||||
|
|
||||
= note: expected type `std::result::Result<u8, MyErr>`
|
||||
found type `()`
|
||||
= note: expected enum `std::result::Result<u8, MyErr>`
|
||||
found unit type `()`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@ error[E0308]: mismatched types
|
|||
--> $DIR/dont-suggest-missing-await.rs:14:18
|
||||
|
|
||||
LL | take_u32(x)
|
||||
| ^ expected u32, found opaque type
|
||||
| ^ expected `u32`, found opaque type
|
||||
|
|
||||
= note: expected type `u32`
|
||||
found type `impl std::future::Future`
|
||||
= note: expected type `u32`
|
||||
found opaque type `impl std::future::Future`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -4,10 +4,8 @@ error[E0317]: if may be missing an else clause
|
|||
LL | / if true {
|
||||
LL | | return 0;
|
||||
LL | | }
|
||||
| |_____^ expected (), found i32
|
||||
| |_____^ expected `()`, found `i32`
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `i32`
|
||||
= note: `if` expressions without `else` evaluate to `()`
|
||||
= help: consider adding an `else` block that evaluates to the expected type
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@ error[E0308]: mismatched types
|
|||
LL | take_u32(x)
|
||||
| ^
|
||||
| |
|
||||
| expected u32, found opaque type
|
||||
| expected `u32`, found opaque type
|
||||
| help: consider using `.await` here: `x.await`
|
||||
|
|
||||
= note: expected type `u32`
|
||||
found type `impl std::future::Future`
|
||||
= note: expected type `u32`
|
||||
found opaque type `impl std::future::Future`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@ error[E0308]: mismatched types
|
|||
LL | take_u32(x)
|
||||
| ^
|
||||
| |
|
||||
| expected u32, found opaque type
|
||||
| expected `u32`, found opaque type
|
||||
| help: consider using `.await` here: `x.await`
|
||||
|
|
||||
= note: expected type `u32`
|
||||
found type `impl std::future::Future`
|
||||
= note: expected type `u32`
|
||||
found opaque type `impl std::future::Future`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
static i: String = 10;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `std::string::String`
|
||||
//~| found type `{integer}`
|
||||
//~| expected struct `std::string::String`, found integer
|
||||
fn main() { println!("{}", i); }
|
||||
|
|
|
@ -6,9 +6,6 @@ LL | static i: String = 10;
|
|||
| |
|
||||
| expected struct `std::string::String`, found integer
|
||||
| help: try using a conversion method: `10.to_string()`
|
||||
|
|
||||
= note: expected type `std::string::String`
|
||||
found type `{integer}`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ error[E0580]: main function has wrong type
|
|||
LL | fn main(arguments: Vec<String>) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters
|
||||
|
|
||||
= note: expected type `fn()`
|
||||
found type `fn(std::vec::Vec<std::string::String>)`
|
||||
= note: expected fn pointer `fn()`
|
||||
found fn pointer `fn(std::vec::Vec<std::string::String>)`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ error[E0580]: main function has wrong type
|
|||
LL | fn main(arguments: Vec<String>) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters
|
||||
|
|
||||
= note: expected type `fn()`
|
||||
found type `fn(std::vec::Vec<std::string::String>)`
|
||||
= note: expected fn pointer `fn()`
|
||||
found fn pointer `fn(std::vec::Vec<std::string::String>)`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ error[E0580]: main function has wrong type
|
|||
LL | fn main(x: isize) { }
|
||||
| ^^^^^^^^^^^^^^^^^ incorrect number of function parameters
|
||||
|
|
||||
= note: expected type `fn()`
|
||||
found type `fn(isize)`
|
||||
= note: expected fn pointer `fn()`
|
||||
found fn pointer `fn(isize)`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@ error[E0308]: mismatched types
|
|||
--> $DIR/binop-logic-float.rs:1:21
|
||||
|
|
||||
LL | fn main() { let x = 1.0_f32 || 2.0_f32; }
|
||||
| ^^^^^^^ expected bool, found f32
|
||||
| ^^^^^^^ expected `bool`, found `f32`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/binop-logic-float.rs:1:32
|
||||
|
|
||||
LL | fn main() { let x = 1.0_f32 || 2.0_f32; }
|
||||
| ^^^^^^^ expected bool, found f32
|
||||
| ^^^^^^^ expected `bool`, found `f32`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -2,19 +2,13 @@ error[E0308]: mismatched types
|
|||
--> $DIR/binop-logic-int.rs:1:21
|
||||
|
|
||||
LL | fn main() { let x = 1 && 2; }
|
||||
| ^ expected bool, found integer
|
||||
|
|
||||
= note: expected type `bool`
|
||||
found type `{integer}`
|
||||
| ^ expected `bool`, found 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}`
|
||||
| ^ expected `bool`, found integer
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -3,9 +3,6 @@ error[E0308]: mismatched types
|
|||
|
|
||||
LL | let bar = 5;
|
||||
| ^^^ expected integer, found struct `foo::bar`
|
||||
|
|
||||
= note: expected type `{integer}`
|
||||
found type `foo::bar`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -7,10 +7,7 @@ LL | |
|
|||
LL | | foo();
|
||||
| | - help: consider removing this semicolon
|
||||
LL | | };
|
||||
| |_____^ expected i32, found ()
|
||||
|
|
||||
= note: expected type `i32`
|
||||
found type `()`
|
||||
| |_____^ expected `i32`, found `()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -2,10 +2,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/block-must-not-have-result-do.rs:3:9
|
||||
|
|
||||
LL | true
|
||||
| ^^^^ expected (), found bool
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `bool`
|
||||
| ^^^^ expected `()`, found `bool`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -4,10 +4,7 @@ error[E0308]: mismatched types
|
|||
LL | fn drop(&mut self) {
|
||||
| - expected `()` because of default return type
|
||||
LL | true
|
||||
| ^^^^ expected (), found bool
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `bool`
|
||||
| ^^^^ expected `()`, found `bool`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
fn main() {
|
||||
while true { //~ WARN denote infinite loops with
|
||||
true //~ ERROR mismatched types
|
||||
//~| expected type `()`
|
||||
//~| found type `bool`
|
||||
//~| expected (), found bool
|
||||
//~| expected `()`, found `bool`
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/block-must-not-have-result-while.rs:3:9
|
||||
|
|
||||
LL | true
|
||||
| ^^^^ expected (), found bool
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `bool`
|
||||
| ^^^^ expected `()`, found `bool`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -2,29 +2,23 @@ error[E0308]: mismatched types
|
|||
--> $DIR/consider-removing-last-semi.rs:1:11
|
||||
|
|
||||
LL | fn f() -> String {
|
||||
| - ^^^^^^ expected struct `std::string::String`, found ()
|
||||
| - ^^^^^^ expected struct `std::string::String`, found `()`
|
||||
| |
|
||||
| implicitly returns `()` as its body has no tail or `return` expression
|
||||
LL | 0u8;
|
||||
LL | "bla".to_string();
|
||||
| - help: consider removing this semicolon
|
||||
|
|
||||
= note: expected type `std::string::String`
|
||||
found type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/consider-removing-last-semi.rs:6:11
|
||||
|
|
||||
LL | fn g() -> String {
|
||||
| - ^^^^^^ expected struct `std::string::String`, found ()
|
||||
| - ^^^^^^ expected struct `std::string::String`, found `()`
|
||||
| |
|
||||
| implicitly returns `()` as its body has no tail or `return` expression
|
||||
LL | "this won't work".to_string();
|
||||
LL | "removeme".to_string();
|
||||
| - help: consider removing this semicolon
|
||||
|
|
||||
= note: expected type `std::string::String`
|
||||
found type `()`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -2,15 +2,12 @@ error[E0308]: mismatched types
|
|||
--> $DIR/issue-11714.rs:1:14
|
||||
|
|
||||
LL | fn blah() -> i32 {
|
||||
| ---- ^^^ expected i32, found ()
|
||||
| ---- ^^^ expected `i32`, found `()`
|
||||
| |
|
||||
| implicitly returns `()` as its body has no tail or `return` expression
|
||||
...
|
||||
LL | ;
|
||||
| - help: consider removing this semicolon
|
||||
|
|
||||
= note: expected type `i32`
|
||||
found type `()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -2,29 +2,23 @@ error[E0308]: mismatched types
|
|||
--> $DIR/issue-13428.rs:3:13
|
||||
|
|
||||
LL | fn foo() -> String {
|
||||
| --- ^^^^^^ expected struct `std::string::String`, found ()
|
||||
| --- ^^^^^^ expected struct `std::string::String`, found `()`
|
||||
| |
|
||||
| implicitly returns `()` as its body has no tail or `return` expression
|
||||
...
|
||||
LL | ;
|
||||
| - help: consider removing this semicolon
|
||||
|
|
||||
= note: expected type `std::string::String`
|
||||
found type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-13428.rs:11:13
|
||||
|
|
||||
LL | fn bar() -> String {
|
||||
| --- ^^^^^^ expected struct `std::string::String`, found ()
|
||||
| --- ^^^^^^ expected struct `std::string::String`, found `()`
|
||||
| |
|
||||
| implicitly returns `()` as its body has no tail or `return` expression
|
||||
LL | "foobar".to_string()
|
||||
LL | ;
|
||||
| - help: consider removing this semicolon
|
||||
|
|
||||
= note: expected type `std::string::String`
|
||||
found type `()`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -6,9 +6,7 @@ mod a {
|
|||
pub fn get_enum_struct_variant() -> () {
|
||||
Enum::EnumStructVariant { x: 1, y: 2, z: 3 }
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `()`
|
||||
//~| found type `a::Enum`
|
||||
//~| expected (), found enum `a::Enum`
|
||||
//~| expected `()`, found enum `a::Enum`
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,9 +19,7 @@ mod b {
|
|||
match enum_struct_variant {
|
||||
a::Enum::EnumStructVariant { x, y, z } => {
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `()`
|
||||
//~| found type `a::Enum`
|
||||
//~| expected (), found enum `a::Enum`
|
||||
//~| expected `()`, found enum `a::Enum`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,21 +4,15 @@ error[E0308]: mismatched types
|
|||
LL | pub fn get_enum_struct_variant() -> () {
|
||||
| -- expected `()` because of return type
|
||||
LL | Enum::EnumStructVariant { x: 1, y: 2, z: 3 }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `a::Enum`
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `a::Enum`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, 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 type `()`
|
||||
found type `a::Enum`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found enum `a::Enum`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ error[E0308]: mismatched types
|
|||
LL | fn foo(x: i32) {
|
||||
| - possibly return type missing here?
|
||||
LL | |y| x + y
|
||||
| ^^^^^^^^^ expected (), found closure
|
||||
| ^^^^^^^^^ expected `()`, found closure
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `[closure@$DIR/issue-20862.rs:2:5: 2:14 x:_]`
|
||||
= note: expected unit type `()`
|
||||
found closure `[closure@$DIR/issue-20862.rs:2:5: 2:14 x:_]`
|
||||
|
||||
error[E0618]: expected function, found `()`
|
||||
--> $DIR/issue-20862.rs:7:13
|
||||
|
|
|
@ -15,10 +15,7 @@ LL | fn main() {
|
|||
| - expected `()` because of default return type
|
||||
LL | let b = Bob + 3.5;
|
||||
LL | b + 3
|
||||
| ^^^^^ expected (), found struct `Bob`
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `Bob`
|
||||
| ^^^^^ expected `()`, found struct `Bob`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
fn main() {
|
||||
&panic!()
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `()`
|
||||
//~| found type `&_`
|
||||
//~| expected (), found reference
|
||||
//~| expected unit type `()`
|
||||
//~| found reference `&_`
|
||||
//~| expected `()`, found reference
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@ LL | fn main() {
|
|||
LL | &panic!()
|
||||
| ^^^^^^^^^
|
||||
| |
|
||||
| expected (), found reference
|
||||
| expected `()`, found reference
|
||||
| help: consider removing the borrow: `panic!()`
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `&_`
|
||||
= note: expected unit type `()`
|
||||
found reference `&_`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -2,10 +2,8 @@ error[E0308]: mismatched types
|
|||
--> $DIR/unexpected-return-on-unit.rs:9:5
|
||||
|
|
||||
LL | foo()
|
||||
| ^^^^^ expected (), found usize
|
||||
| ^^^^^ expected `()`, found `usize`
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `usize`
|
||||
help: try adding a semicolon
|
||||
|
|
||||
LL | foo();
|
||||
|
|
|
@ -22,8 +22,8 @@ error[E0308]: method not compatible with trait
|
|||
LL | fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
|
||||
|
|
||||
= note: expected type `fn(&'a isize, Inv<'c>, Inv<'c>, Inv<'d>)`
|
||||
found type `fn(&'a isize, Inv<'_>, Inv<'c>, Inv<'d>)`
|
||||
= note: expected fn pointer `fn(&'a isize, Inv<'c>, Inv<'c>, Inv<'d>)`
|
||||
found fn pointer `fn(&'a isize, Inv<'_>, Inv<'c>, Inv<'d>)`
|
||||
note: the lifetime `'c` as defined on the method body at 27:24...
|
||||
--> $DIR/regions-bound-missing-bound-in-impl.rs:27:24
|
||||
|
|
||||
|
|
|
@ -5,10 +5,10 @@ LL | let _: ! = {
|
|||
| ____________________^
|
||||
LL | | 'a: while break 'a {};
|
||||
LL | | };
|
||||
| |_________^ expected !, found ()
|
||||
| |_________^ expected `!`, found `()`
|
||||
|
|
||||
= note: expected type `!`
|
||||
found type `()`
|
||||
= note: expected type `!`
|
||||
found unit type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/break-while-condition.rs:14:13
|
||||
|
@ -16,10 +16,10 @@ error[E0308]: mismatched types
|
|||
LL | / while false {
|
||||
LL | | break
|
||||
LL | | }
|
||||
| |_____________^ expected !, found ()
|
||||
| |_____________^ expected `!`, found `()`
|
||||
|
|
||||
= note: expected type `!`
|
||||
found type `()`
|
||||
= note: expected type `!`
|
||||
found unit type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/break-while-condition.rs:22:13
|
||||
|
@ -27,10 +27,10 @@ error[E0308]: mismatched types
|
|||
LL | / while false {
|
||||
LL | | return
|
||||
LL | | }
|
||||
| |_____________^ expected !, found ()
|
||||
| |_____________^ expected `!`, found `()`
|
||||
|
|
||||
= note: expected type `!`
|
||||
found type `()`
|
||||
= note: expected type `!`
|
||||
found unit type `()`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ error[E0308]: mismatched types
|
|||
LL | let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
|
||||
| ^^^ expected non-variadic fn, found variadic function
|
||||
|
|
||||
= note: expected type `unsafe extern "C" fn(isize, u8)`
|
||||
found type `unsafe extern "C" fn(isize, u8, ...) {foo}`
|
||||
= note: expected fn pointer `unsafe extern "C" fn(isize, u8)`
|
||||
found fn item `unsafe extern "C" fn(isize, u8, ...) {foo}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/variadic-ffi-1.rs:20:54
|
||||
|
@ -37,8 +37,8 @@ error[E0308]: mismatched types
|
|||
LL | let y: extern "C" fn(f: isize, x: u8, ...) = bar;
|
||||
| ^^^ expected variadic fn, found non-variadic function
|
||||
|
|
||||
= note: expected type `extern "C" fn(isize, u8, ...)`
|
||||
found type `extern "C" fn(isize, u8) {bar}`
|
||||
= note: expected fn pointer `extern "C" fn(isize, u8, ...)`
|
||||
found fn item `extern "C" fn(isize, u8) {bar}`
|
||||
|
||||
error[E0617]: can't pass `f32` to variadic function
|
||||
--> $DIR/variadic-ffi-1.rs:22:19
|
||||
|
|
|
@ -4,8 +4,8 @@ error[E0308]: mismatched types
|
|||
LL | ap
|
||||
| ^^ lifetime mismatch
|
||||
|
|
||||
= note: expected type `core::ffi::VaListImpl<'f>`
|
||||
found type `core::ffi::VaListImpl<'_>`
|
||||
= note: expected struct `core::ffi::VaListImpl<'f>`
|
||||
found struct `core::ffi::VaListImpl<'_>`
|
||||
note: the scope of call-site for function at 7:78...
|
||||
--> $DIR/variadic-ffi-4.rs:7:78
|
||||
|
|
||||
|
@ -26,8 +26,8 @@ error[E0308]: mismatched types
|
|||
LL | ap
|
||||
| ^^ lifetime mismatch
|
||||
|
|
||||
= note: expected type `core::ffi::VaListImpl<'static>`
|
||||
found type `core::ffi::VaListImpl<'_>`
|
||||
= note: expected struct `core::ffi::VaListImpl<'static>`
|
||||
found struct `core::ffi::VaListImpl<'_>`
|
||||
note: the scope of call-site for function at 11:79...
|
||||
--> $DIR/variadic-ffi-4.rs:11:79
|
||||
|
|
||||
|
@ -69,8 +69,8 @@ error[E0308]: mismatched types
|
|||
LL | *ap0 = ap1;
|
||||
| ^^^ lifetime mismatch
|
||||
|
|
||||
= note: expected type `core::ffi::VaListImpl<'_>`
|
||||
found type `core::ffi::VaListImpl<'_>`
|
||||
= note: expected struct `core::ffi::VaListImpl<'_>`
|
||||
found struct `core::ffi::VaListImpl<'_>`
|
||||
note: the scope of call-site for function at 19:87...
|
||||
--> $DIR/variadic-ffi-4.rs:19:87
|
||||
|
|
||||
|
@ -121,8 +121,8 @@ error[E0308]: mismatched types
|
|||
LL | ap0 = &mut ap1;
|
||||
| ^^^^^^^^ lifetime mismatch
|
||||
|
|
||||
= note: expected type `&mut core::ffi::VaListImpl<'_>`
|
||||
found type `&mut core::ffi::VaListImpl<'_>`
|
||||
= note: expected mutable reference `&mut core::ffi::VaListImpl<'_>`
|
||||
found mutable reference `&mut core::ffi::VaListImpl<'_>`
|
||||
note: the scope of call-site for function at 23:83...
|
||||
--> $DIR/variadic-ffi-4.rs:23:83
|
||||
|
|
||||
|
@ -189,8 +189,8 @@ error[E0308]: mismatched types
|
|||
LL | *ap0 = ap1.clone();
|
||||
| ^^^^^^^^^^^ lifetime mismatch
|
||||
|
|
||||
= note: expected type `core::ffi::VaListImpl<'_>`
|
||||
found type `core::ffi::VaListImpl<'_>`
|
||||
= note: expected struct `core::ffi::VaListImpl<'_>`
|
||||
found struct `core::ffi::VaListImpl<'_>`
|
||||
note: the scope of call-site for function at 30:87...
|
||||
--> $DIR/variadic-ffi-4.rs:30:87
|
||||
|
|
||||
|
|
|
@ -2,10 +2,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/type_inference.rs:21:14
|
||||
|
|
||||
LL | only_foo(x);
|
||||
| ^ expected i32, found floating-point number
|
||||
|
|
||||
= note: expected type `i32`
|
||||
found type `{float}`
|
||||
| ^ expected `i32`, found floating-point number
|
||||
|
||||
error[E0277]: the trait bound `{float}: Bar` is not satisfied
|
||||
--> $DIR/type_inference.rs:25:5
|
||||
|
|
|
@ -4,8 +4,8 @@ error[E0308]: mismatched types
|
|||
LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
|
||||
| ^^^^^^^^^^^ lifetime mismatch
|
||||
|
|
||||
= note: expected type `fn(&u32)`
|
||||
found type `fn(&'x u32)`
|
||||
= note: expected fn pointer `fn(&u32)`
|
||||
found fn pointer `fn(&'x u32)`
|
||||
note: the anonymous lifetime #2 defined on the body at 14:48...
|
||||
--> $DIR/expect-fn-supply-fn.rs:14:48
|
||||
|
|
||||
|
@ -23,8 +23,8 @@ error[E0308]: mismatched types
|
|||
LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
|
||||
| ^^^^^^^^^^^ lifetime mismatch
|
||||
|
|
||||
= note: expected type `fn(&u32)`
|
||||
found type `fn(&'x u32)`
|
||||
= note: expected fn pointer `fn(&u32)`
|
||||
found fn pointer `fn(&'x u32)`
|
||||
note: the lifetime `'x` as defined on the function body at 11:36...
|
||||
--> $DIR/expect-fn-supply-fn.rs:11:36
|
||||
|
|
||||
|
|
|
@ -20,19 +20,19 @@ error[E0308]: mismatched types
|
|||
--> $DIR/closure-array-break-length.rs:4:11
|
||||
|
|
||||
LL | while |_: [_; continue]| {} {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ expected bool, found closure
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found closure
|
||||
|
|
||||
= note: expected type `bool`
|
||||
found type `[closure@$DIR/closure-array-break-length.rs:4:11: 4:32]`
|
||||
found closure `[closure@$DIR/closure-array-break-length.rs:4:11: 4:32]`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/closure-array-break-length.rs:7:11
|
||||
|
|
||||
LL | while |_: [_; break]| {} {}
|
||||
| ^^^^^^^^^^^^^^^^^^ expected bool, found closure
|
||||
| ^^^^^^^^^^^^^^^^^^ expected `bool`, found closure
|
||||
|
|
||||
= note: expected type `bool`
|
||||
found type `[closure@$DIR/closure-array-break-length.rs:7:11: 7:29]`
|
||||
found closure `[closure@$DIR/closure-array-break-length.rs:7:11: 7:29]`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ error[E0308]: mismatched types
|
|||
LL | closure_expecting_bound(|x: &'x u32| {
|
||||
| ^^^^^^^ lifetime mismatch
|
||||
|
|
||||
= note: expected type `&u32`
|
||||
found type `&'x u32`
|
||||
= note: expected reference `&u32`
|
||||
found reference `&'x u32`
|
||||
note: the anonymous lifetime #2 defined on the body at 37:29...
|
||||
--> $DIR/expect-region-supply-region.rs:37:29
|
||||
|
|
||||
|
@ -50,8 +50,8 @@ error[E0308]: mismatched types
|
|||
LL | closure_expecting_bound(|x: &'x u32| {
|
||||
| ^^^^^^^ lifetime mismatch
|
||||
|
|
||||
= note: expected type `&u32`
|
||||
found type `&'x u32`
|
||||
= note: expected reference `&u32`
|
||||
found reference `&'x u32`
|
||||
note: the lifetime `'x` as defined on the function body at 32:30...
|
||||
--> $DIR/expect-region-supply-region.rs:32:30
|
||||
|
|
||||
|
|
|
@ -4,8 +4,8 @@ error[E0308]: mismatched types
|
|||
LL | let foo: fn(u8) -> u8 = |v: u8| { a += v; a };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found closure
|
||||
|
|
||||
= note: expected type `fn(u8) -> u8`
|
||||
found type `[closure@$DIR/closure-no-fn-1.rs:6:29: 6:50 a:_]`
|
||||
= note: expected fn pointer `fn(u8) -> u8`
|
||||
found closure `[closure@$DIR/closure-no-fn-1.rs:6:29: 6:50 a:_]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ error[E0308]: mismatched types
|
|||
LL | let bar: fn() -> u8 = || { b };
|
||||
| ^^^^^^^^ expected fn pointer, found closure
|
||||
|
|
||||
= note: expected type `fn() -> u8`
|
||||
found type `[closure@$DIR/closure-no-fn-2.rs:6:27: 6:35 b:_]`
|
||||
= note: expected fn pointer `fn() -> u8`
|
||||
found closure `[closure@$DIR/closure-no-fn-2.rs:6:27: 6:35 b:_]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ error[E0308]: mismatched types
|
|||
LL | call_bare(f)
|
||||
| ^ expected fn pointer, found closure
|
||||
|
|
||||
= note: expected type `for<'r> fn(&'r str)`
|
||||
found type `[closure@$DIR/closure-reform-bad.rs:10:13: 10:50 string:_]`
|
||||
= note: expected fn pointer `for<'r> fn(&'r str)`
|
||||
found closure `[closure@$DIR/closure-reform-bad.rs:10:13: 10:50 string:_]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -10,10 +10,7 @@ error[E0308]: mismatched types
|
|||
LL | fn foo() {
|
||||
| - help: try adding a return type: `-> &'static str`
|
||||
LL | "bar boo"
|
||||
| ^^^^^^^^^^^^^^^^^^^^ expected (), found reference
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `&'static str`
|
||||
| ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `&str`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -2,127 +2,127 @@ error[E0308]: mismatched types
|
|||
--> $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 type `std::boxed::Box<[i32]>`
|
||||
found type `std::boxed::Box<[i32; 3]>`
|
||||
= note: expected struct `std::boxed::Box<[i32]>`
|
||||
found struct `std::boxed::Box<[i32; 3]>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $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 type `std::boxed::Box<[i32]>`
|
||||
found type `std::boxed::Box<[i32; 3]>`
|
||||
= note: expected struct `std::boxed::Box<[i32]>`
|
||||
found struct `std::boxed::Box<[i32; 3]>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $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 type `std::boxed::Box<[i32]>`
|
||||
found type `std::boxed::Box<[i32; 3]>`
|
||||
= note: expected struct `std::boxed::Box<[i32]>`
|
||||
found struct `std::boxed::Box<[i32; 3]>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-expect-unsized-ascribed.rs:13:13
|
||||
|
|
||||
LL | let _ = box { |x| (x as u8) }: Box<dyn Fn(i32) -> _>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ expected trait `std::ops::Fn`, found closure
|
||||
|
|
||||
= note: expected type `std::boxed::Box<dyn std::ops::Fn(i32) -> u8>`
|
||||
found type `std::boxed::Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:13:19: 13:32]>`
|
||||
= note: expected struct `std::boxed::Box<dyn std::ops::Fn(i32) -> u8>`
|
||||
found struct `std::boxed::Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:13:19: 13:32]>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-expect-unsized-ascribed.rs:14:13
|
||||
|
|
||||
LL | let _ = box if true { false } else { true }: Box<dyn Debug>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found bool
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait `std::fmt::Debug`, found `bool`
|
||||
|
|
||||
= note: expected type `std::boxed::Box<dyn std::fmt::Debug>`
|
||||
found type `std::boxed::Box<bool>`
|
||||
= note: expected struct `std::boxed::Box<dyn std::fmt::Debug>`
|
||||
found struct `std::boxed::Box<bool>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-expect-unsized-ascribed.rs:15:13
|
||||
|
|
||||
LL | let _ = box match true { true => 'a', false => 'b' }: Box<dyn Debug>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found char
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait `std::fmt::Debug`, found `char`
|
||||
|
|
||||
= note: expected type `std::boxed::Box<dyn std::fmt::Debug>`
|
||||
found type `std::boxed::Box<char>`
|
||||
= note: expected struct `std::boxed::Box<dyn std::fmt::Debug>`
|
||||
found struct `std::boxed::Box<char>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $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 type `&[i32]`
|
||||
found type `&[i32; 3]`
|
||||
= note: expected reference `&[i32]`
|
||||
found reference `&[i32; 3]`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $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 type `&[i32]`
|
||||
found type `&[i32; 3]`
|
||||
= note: expected reference `&[i32]`
|
||||
found reference `&[i32; 3]`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $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 type `&[i32]`
|
||||
found type `&[i32; 3]`
|
||||
= note: expected reference `&[i32]`
|
||||
found reference `&[i32; 3]`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-expect-unsized-ascribed.rs:21:13
|
||||
|
|
||||
LL | let _ = &{ |x| (x as u8) }: &dyn Fn(i32) -> _;
|
||||
| ^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure
|
||||
| ^^^^^^^^^^^^^^^^^^ expected trait `std::ops::Fn`, found closure
|
||||
|
|
||||
= note: expected type `&dyn std::ops::Fn(i32) -> u8`
|
||||
found type `&[closure@$DIR/coerce-expect-unsized-ascribed.rs:21:16: 21:29]`
|
||||
= note: expected reference `&dyn std::ops::Fn(i32) -> u8`
|
||||
found reference `&[closure@$DIR/coerce-expect-unsized-ascribed.rs:21:16: 21:29]`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-expect-unsized-ascribed.rs:22:13
|
||||
|
|
||||
LL | let _ = &if true { false } else { true }: &dyn Debug;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found bool
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait `std::fmt::Debug`, found `bool`
|
||||
|
|
||||
= note: expected type `&dyn std::fmt::Debug`
|
||||
found type `&bool`
|
||||
= note: expected reference `&dyn std::fmt::Debug`
|
||||
found reference `&bool`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-expect-unsized-ascribed.rs:23:13
|
||||
|
|
||||
LL | let _ = &match true { true => 'a', false => 'b' }: &dyn Debug;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found char
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait `std::fmt::Debug`, found `char`
|
||||
|
|
||||
= note: expected type `&dyn std::fmt::Debug`
|
||||
found type `&char`
|
||||
= note: expected reference `&dyn std::fmt::Debug`
|
||||
found reference `&char`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $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 type `std::boxed::Box<[i32]>`
|
||||
found type `std::boxed::Box<[i32; 3]>`
|
||||
= note: expected struct `std::boxed::Box<[i32]>`
|
||||
found struct `std::boxed::Box<[i32; 3]>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-expect-unsized-ascribed.rs:26:13
|
||||
|
|
||||
LL | let _ = Box::new(|x| (x as u8)): Box<dyn Fn(i32) -> _>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ expected trait `std::ops::Fn`, found closure
|
||||
|
|
||||
= note: expected type `std::boxed::Box<dyn std::ops::Fn(i32) -> _>`
|
||||
found type `std::boxed::Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:26:22: 26:35]>`
|
||||
= note: expected struct `std::boxed::Box<dyn std::ops::Fn(i32) -> _>`
|
||||
found struct `std::boxed::Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:26:22: 26:35]>`
|
||||
|
||||
error: aborting due to 14 previous errors
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ fn main() {
|
|||
let x = 0;
|
||||
f(&x);
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `&mut i32`
|
||||
//~| found type `&{integer}`
|
||||
//~| expected mutable reference `&mut i32`
|
||||
//~| found reference `&{integer}`
|
||||
//~| types differ in mutability
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ error[E0308]: mismatched types
|
|||
LL | f(&x);
|
||||
| ^^ types differ in mutability
|
||||
|
|
||||
= note: expected type `&mut i32`
|
||||
found type `&{integer}`
|
||||
= note: expected mutable reference `&mut i32`
|
||||
found reference `&{integer}`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/coerce-to-bang.rs:4:17
|
||||
|
|
||||
LL | foo(return, 22, 44);
|
||||
| ^^ expected !, found integer
|
||||
| ^^ expected `!`, found integer
|
||||
|
|
||||
= note: expected type `!`
|
||||
found type `{integer}`
|
||||
|
@ -11,7 +11,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/coerce-to-bang.rs:16:13
|
||||
|
|
||||
LL | foo(22, 44, return);
|
||||
| ^^ expected !, found integer
|
||||
| ^^ expected `!`, found integer
|
||||
|
|
||||
= note: expected type `!`
|
||||
found type `{integer}`
|
||||
|
@ -20,7 +20,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/coerce-to-bang.rs:24:12
|
||||
|
|
||||
LL | foo(a, b, c); // ... and hence a reference to `a` is expected to diverge.
|
||||
| ^ expected !, found integer
|
||||
| ^ expected `!`, found integer
|
||||
|
|
||||
= note: expected type `!`
|
||||
found type `{integer}`
|
||||
|
@ -29,7 +29,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/coerce-to-bang.rs:34:12
|
||||
|
|
||||
LL | foo(a, b, c);
|
||||
| ^ expected !, found integer
|
||||
| ^ expected `!`, found integer
|
||||
|
|
||||
= note: expected type `!`
|
||||
found type `{integer}`
|
||||
|
@ -38,7 +38,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/coerce-to-bang.rs:43:12
|
||||
|
|
||||
LL | foo(a, b, c);
|
||||
| ^ expected !, found integer
|
||||
| ^ expected `!`, found integer
|
||||
|
|
||||
= note: expected type `!`
|
||||
found type `{integer}`
|
||||
|
@ -47,16 +47,16 @@ error[E0308]: mismatched types
|
|||
--> $DIR/coerce-to-bang.rs:48:21
|
||||
|
|
||||
LL | let x: [!; 2] = [return, 22];
|
||||
| ^^^^^^^^^^^^ expected !, found integer
|
||||
| ^^^^^^^^^^^^ expected `!`, found integer
|
||||
|
|
||||
= note: expected type `[!; 2]`
|
||||
found type `[{integer}; 2]`
|
||||
= note: expected array `[!; 2]`
|
||||
found array `[{integer}; 2]`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coerce-to-bang.rs:53:22
|
||||
|
|
||||
LL | let x: [!; 2] = [22, return];
|
||||
| ^^ expected !, found integer
|
||||
| ^^ expected `!`, found integer
|
||||
|
|
||||
= note: expected type `!`
|
||||
found type `{integer}`
|
||||
|
@ -65,7 +65,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/coerce-to-bang.rs:58:37
|
||||
|
|
||||
LL | let x: (usize, !, usize) = (22, 44, 66);
|
||||
| ^^ expected !, found integer
|
||||
| ^^ expected `!`, found integer
|
||||
|
|
||||
= note: expected type `!`
|
||||
found type `{integer}`
|
||||
|
@ -74,7 +74,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/coerce-to-bang.rs:63:41
|
||||
|
|
||||
LL | let x: (usize, !, usize) = (return, 44, 66);
|
||||
| ^^ expected !, found integer
|
||||
| ^^ expected `!`, found integer
|
||||
|
|
||||
= note: expected type `!`
|
||||
found type `{integer}`
|
||||
|
@ -83,7 +83,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/coerce-to-bang.rs:74:37
|
||||
|
|
||||
LL | let x: (usize, !, usize) = (22, 44, return);
|
||||
| ^^ expected !, found integer
|
||||
| ^^ expected `!`, found integer
|
||||
|
|
||||
= note: expected type `!`
|
||||
found type `{integer}`
|
||||
|
|
|
@ -2,27 +2,24 @@ error[E0308]: mismatched types
|
|||
--> $DIR/coercion-missing-tail-expected-type.rs:3:24
|
||||
|
|
||||
LL | fn plus_one(x: i32) -> i32 {
|
||||
| -------- ^^^ expected i32, found ()
|
||||
| -------- ^^^ expected `i32`, found `()`
|
||||
| |
|
||||
| implicitly returns `()` as its body has no tail or `return` expression
|
||||
LL | x + 1;
|
||||
| - help: consider removing this semicolon
|
||||
|
|
||||
= note: expected type `i32`
|
||||
found type `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/coercion-missing-tail-expected-type.rs:7:13
|
||||
|
|
||||
LL | fn foo() -> Result<u8, u64> {
|
||||
| --- ^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found ()
|
||||
| --- ^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found `()`
|
||||
| |
|
||||
| implicitly returns `()` as its body has no tail or `return` expression
|
||||
LL | Ok(1);
|
||||
| - help: consider removing this semicolon
|
||||
|
|
||||
= note: expected type `std::result::Result<u8, u64>`
|
||||
found type `()`
|
||||
= note: expected enum `std::result::Result<u8, u64>`
|
||||
found unit type `()`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -3,6 +3,5 @@
|
|||
fn main() {
|
||||
let _: &[i32] = [0];
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `&[i32]`
|
||||
//~| expected &[i32], found array of 1 element
|
||||
//~| expected `&[i32]`, found array `[{integer}; 1]`
|
||||
}
|
||||
|
|
|
@ -4,11 +4,8 @@ error[E0308]: mismatched types
|
|||
LL | let _: &[i32] = [0];
|
||||
| ^^^
|
||||
| |
|
||||
| expected &[i32], found array of 1 element
|
||||
| expected `&[i32]`, found array `[{integer}; 1]`
|
||||
| help: consider borrowing here: `&[0]`
|
||||
|
|
||||
= note: expected type `&[i32]`
|
||||
found type `[{integer}; 1]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ LL | fn b<F:Clone,G>(&self, _x: G) -> G { panic!() }
|
|||
| | found type parameter
|
||||
| expected type parameter
|
||||
|
|
||||
= note: expected type `fn(&E, F) -> F`
|
||||
found type `fn(&E, G) -> G`
|
||||
= note: expected fn pointer `fn(&E, F) -> F`
|
||||
found fn pointer `fn(&E, G) -> G`
|
||||
= note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
|
||||
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
|
||||
|
||||
|
|
|
@ -3,18 +3,12 @@ error[E0308]: mismatched types
|
|||
|
|
||||
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 type `[u8; 3]`
|
||||
found type `[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 type `[u8; 2]`
|
||||
found type `[u8; 3]`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -12,17 +12,17 @@ error[E0308]: mismatched types
|
|||
LL | let _: Checked<not_one> = Checked::<not_two>;
|
||||
| ^^^^^^^^^^^^^^^^^^ expected `not_one`, found `not_two`
|
||||
|
|
||||
= note: expected type `Checked<not_one>`
|
||||
found type `Checked<not_two>`
|
||||
= note: expected struct `Checked<not_one>`
|
||||
found struct `Checked<not_two>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/fn-const-param-infer.rs:20:24
|
||||
|
|
||||
LL | let _ = Checked::<{generic_arg::<u32>}>;
|
||||
| ^^^^^^^^^^^^^^^^^^ expected usize, found u32
|
||||
| ^^^^^^^^^^^^^^^^^^ expected `usize`, found `u32`
|
||||
|
|
||||
= note: expected type `fn(usize) -> bool`
|
||||
found type `fn(u32) -> bool {generic_arg::<u32>}`
|
||||
= note: expected fn pointer `fn(usize) -> bool`
|
||||
found fn item `fn(u32) -> bool {generic_arg::<u32>}`
|
||||
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/fn-const-param-infer.rs:22:23
|
||||
|
@ -36,8 +36,8 @@ error[E0308]: mismatched types
|
|||
LL | let _: Checked<{generic::<u32>}> = Checked::<{generic::<u16>}>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `generic::<u32>`, found `generic::<u16>`
|
||||
|
|
||||
= note: expected type `Checked<generic::<u32>>`
|
||||
found type `Checked<generic::<u16>>`
|
||||
= note: expected struct `Checked<generic::<u32>>`
|
||||
found struct `Checked<generic::<u16>>`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ error[E0308]: mismatched types
|
|||
LL | let _: Const<{15 as *const _}> = Const::<{10 as *const _}>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{pointer}`, found `{pointer}`
|
||||
|
|
||||
= note: expected type `Const<{pointer}>`
|
||||
found type `Const<{pointer}>`
|
||||
= note: expected struct `Const<{pointer}>`
|
||||
found struct `Const<{pointer}>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ error[E0308]: mismatched types
|
|||
LL | let _: ConstString<"Hello"> = ConstString::<"World">;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ expected `"Hello"`, found `"World"`
|
||||
|
|
||||
= note: expected type `ConstString<"Hello">`
|
||||
found type `ConstString<"World">`
|
||||
= note: expected struct `ConstString<"Hello">`
|
||||
found struct `ConstString<"World">`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/slice-const-param-mismatch.rs:11:33
|
||||
|
@ -21,8 +21,8 @@ error[E0308]: mismatched types
|
|||
LL | let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↥">;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ expected `"ℇ㇈↦"`, found `"ℇ㇈↥"`
|
||||
|
|
||||
= note: expected type `ConstString<"ℇ㇈↦">`
|
||||
found type `ConstString<"ℇ㇈↥">`
|
||||
= note: expected struct `ConstString<"ℇ㇈↦">`
|
||||
found struct `ConstString<"ℇ㇈↥">`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/slice-const-param-mismatch.rs:13:33
|
||||
|
@ -30,8 +30,8 @@ error[E0308]: mismatched types
|
|||
LL | let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ expected `b"AAA"`, found `b"BBB"`
|
||||
|
|
||||
= note: expected type `ConstBytes<b"AAA">`
|
||||
found type `ConstBytes<b"BBB">`
|
||||
= note: expected struct `ConstBytes<b"AAA">`
|
||||
found struct `ConstBytes<b"BBB">`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -12,17 +12,17 @@ error[E0308]: mismatched types
|
|||
LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data: PhantomData };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2u32`, found `4u32`
|
||||
|
|
||||
= note: expected type `A<'_, _, 2u32, _>`
|
||||
found type `A<'_, _, 4u32, _>`
|
||||
= note: expected struct `A<'_, _, 2u32, _>`
|
||||
found struct `A<'_, _, 4u32, _>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/types-mismatch-const-args.rs:15:41
|
||||
|
|
||||
LL | let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u16, found u32
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32`
|
||||
|
|
||||
= note: expected type `A<'a, u16, _, _>`
|
||||
found type `A<'b, u32, _, _>`
|
||||
= note: expected struct `A<'a, u16, _, _>`
|
||||
found struct `A<'b, u32, _, _>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -3,18 +3,12 @@ error[E0308]: mismatched types
|
|||
|
|
||||
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 type `[i32; 2]`
|
||||
found type `[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 type `[i32; 1]`
|
||||
found type `[i32; 2]`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/const-cast-wrong-type.rs:2:23
|
||||
|
|
||||
LL | static b: *const i8 = &a as *const i8;
|
||||
| ^^^^^^^^^^^^^^^ expected u8, found i8
|
||||
| ^^^^^^^^^^^^^^^ expected `u8`, found `i8`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/const-eval-overflow-3b.rs:18:22
|
||||
|
|
||||
LL | = [0; (i8::MAX + 1u8) as usize];
|
||||
| ^^^ expected i8, found u8
|
||||
| ^^^ expected `i8`, found `u8`
|
||||
|
||||
error[E0277]: cannot add `u8` to `i8`
|
||||
--> $DIR/const-eval-overflow-3b.rs:18:20
|
||||
|
|
|
@ -11,7 +11,7 @@ use std::{u8, u16, u32, u64, usize};
|
|||
const A_I8_T
|
||||
: [u32; (i8::MAX as i8 + 1u8) as usize]
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected i8, found u8
|
||||
//~| expected `i8`, found `u8`
|
||||
//~| ERROR cannot add `u8` to `i8`
|
||||
= [0; (i8::MAX as usize) + 1];
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/const-eval-overflow-4b.rs:12:30
|
||||
|
|
||||
LL | : [u32; (i8::MAX as i8 + 1u8) as usize]
|
||||
| ^^^ expected i8, found u8
|
||||
| ^^^ expected `i8`, found `u8`
|
||||
|
||||
error[E0277]: cannot add `u8` to `i8`
|
||||
--> $DIR/const-eval-overflow-4b.rs:12:28
|
||||
|
|
|
@ -8,8 +8,7 @@ const CONSTANT: S = S(0);
|
|||
enum E {
|
||||
V = CONSTANT,
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected isize, found struct `S`
|
||||
//~| found type `S`
|
||||
//~| expected `isize`, found struct `S`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -2,10 +2,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/const-eval-span.rs:9:9
|
||||
|
|
||||
LL | V = CONSTANT,
|
||||
| ^^^^^^^^ expected isize, found struct `S`
|
||||
|
|
||||
= note: expected type `isize`
|
||||
found type `S`
|
||||
| ^^^^^^^^ expected `isize`, found struct `S`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,76 +1,76 @@
|
|||
const X: usize = 42 && 39;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected bool, found integer
|
||||
//~| expected `bool`, found integer
|
||||
//~| ERROR mismatched types
|
||||
//~| expected bool, found integer
|
||||
//~| expected `bool`, found integer
|
||||
//~| ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
//~| expected `usize`, found `bool`
|
||||
const ARR: [i32; X] = [99; 34];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const X1: usize = 42 || 39;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected bool, found integer
|
||||
//~| expected `bool`, found integer
|
||||
//~| ERROR mismatched types
|
||||
//~| expected bool, found integer
|
||||
//~| expected `bool`, found integer
|
||||
//~| ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
//~| expected `usize`, found `bool`
|
||||
const ARR1: [i32; X1] = [99; 47];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const X2: usize = -42 || -39;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected bool, found integer
|
||||
//~| expected `bool`, found integer
|
||||
//~| ERROR mismatched types
|
||||
//~| expected bool, found integer
|
||||
//~| expected `bool`, found integer
|
||||
//~| ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
//~| expected `usize`, found `bool`
|
||||
const ARR2: [i32; X2] = [99; 18446744073709551607];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const X3: usize = -42 && -39;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected bool, found integer
|
||||
//~| expected `bool`, found integer
|
||||
//~| ERROR mismatched types
|
||||
//~| expected bool, found integer
|
||||
//~| expected `bool`, found integer
|
||||
//~| ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
//~| expected `usize`, found `bool`
|
||||
const ARR3: [i32; X3] = [99; 6];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Y: usize = 42.0 == 42.0;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
//~| expected `usize`, found `bool`
|
||||
const ARRR: [i32; Y] = [99; 1];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Y1: usize = 42.0 >= 42.0;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
//~| expected `usize`, found `bool`
|
||||
const ARRR1: [i32; Y1] = [99; 1];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Y2: usize = 42.0 <= 42.0;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
//~| expected `usize`, found `bool`
|
||||
const ARRR2: [i32; Y2] = [99; 1];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Y3: usize = 42.0 > 42.0;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
//~| expected `usize`, found `bool`
|
||||
const ARRR3: [i32; Y3] = [99; 0];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Y4: usize = 42.0 < 42.0;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
//~| expected `usize`, found `bool`
|
||||
const ARRR4: [i32; Y4] = [99; 0];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Y5: usize = 42.0 != 42.0;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
//~| expected `usize`, found `bool`
|
||||
const ARRR5: [i32; Y5] = [99; 0];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
|
|
|
@ -2,25 +2,19 @@ error[E0308]: mismatched types
|
|||
--> $DIR/const-integer-bool-ops.rs:1:18
|
||||
|
|
||||
LL | const X: usize = 42 && 39;
|
||||
| ^^ expected bool, found integer
|
||||
|
|
||||
= note: expected type `bool`
|
||||
found type `{integer}`
|
||||
| ^^ expected `bool`, found 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}`
|
||||
| ^^ expected `bool`, found integer
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:1:18
|
||||
|
|
||||
LL | const X: usize = 42 && 39;
|
||||
| ^^^^^^^^ expected usize, found bool
|
||||
| ^^^^^^^^ expected `usize`, found `bool`
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:8:18
|
||||
|
@ -32,25 +26,19 @@ error[E0308]: mismatched types
|
|||
--> $DIR/const-integer-bool-ops.rs:11:19
|
||||
|
|
||||
LL | const X1: usize = 42 || 39;
|
||||
| ^^ expected bool, found integer
|
||||
|
|
||||
= note: expected type `bool`
|
||||
found type `{integer}`
|
||||
| ^^ expected `bool`, found 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}`
|
||||
| ^^ expected `bool`, found integer
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:11:19
|
||||
|
|
||||
LL | const X1: usize = 42 || 39;
|
||||
| ^^^^^^^^ expected usize, found bool
|
||||
| ^^^^^^^^ expected `usize`, found `bool`
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:18:19
|
||||
|
@ -62,25 +50,19 @@ error[E0308]: mismatched types
|
|||
--> $DIR/const-integer-bool-ops.rs:21:19
|
||||
|
|
||||
LL | const X2: usize = -42 || -39;
|
||||
| ^^^ expected bool, found integer
|
||||
|
|
||||
= note: expected type `bool`
|
||||
found type `{integer}`
|
||||
| ^^^ expected `bool`, found 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}`
|
||||
| ^^^ expected `bool`, found integer
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:21:19
|
||||
|
|
||||
LL | const X2: usize = -42 || -39;
|
||||
| ^^^^^^^^^^ expected usize, found bool
|
||||
| ^^^^^^^^^^ expected `usize`, found `bool`
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:28:19
|
||||
|
@ -92,25 +74,19 @@ error[E0308]: mismatched types
|
|||
--> $DIR/const-integer-bool-ops.rs:31:19
|
||||
|
|
||||
LL | const X3: usize = -42 && -39;
|
||||
| ^^^ expected bool, found integer
|
||||
|
|
||||
= note: expected type `bool`
|
||||
found type `{integer}`
|
||||
| ^^^ expected `bool`, found 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}`
|
||||
| ^^^ expected `bool`, found integer
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:31:19
|
||||
|
|
||||
LL | const X3: usize = -42 && -39;
|
||||
| ^^^^^^^^^^ expected usize, found bool
|
||||
| ^^^^^^^^^^ expected `usize`, found `bool`
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:38:19
|
||||
|
@ -122,7 +98,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/const-integer-bool-ops.rs:41:18
|
||||
|
|
||||
LL | const Y: usize = 42.0 == 42.0;
|
||||
| ^^^^^^^^^^^^ expected usize, found bool
|
||||
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:44:19
|
||||
|
@ -134,7 +110,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/const-integer-bool-ops.rs:47:19
|
||||
|
|
||||
LL | const Y1: usize = 42.0 >= 42.0;
|
||||
| ^^^^^^^^^^^^ expected usize, found bool
|
||||
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:50:20
|
||||
|
@ -146,7 +122,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/const-integer-bool-ops.rs:53:19
|
||||
|
|
||||
LL | const Y2: usize = 42.0 <= 42.0;
|
||||
| ^^^^^^^^^^^^ expected usize, found bool
|
||||
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:56:20
|
||||
|
@ -158,7 +134,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/const-integer-bool-ops.rs:59:19
|
||||
|
|
||||
LL | const Y3: usize = 42.0 > 42.0;
|
||||
| ^^^^^^^^^^^ expected usize, found bool
|
||||
| ^^^^^^^^^^^ expected `usize`, found `bool`
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:62:20
|
||||
|
@ -170,7 +146,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/const-integer-bool-ops.rs:65:19
|
||||
|
|
||||
LL | const Y4: usize = 42.0 < 42.0;
|
||||
| ^^^^^^^^^^^ expected usize, found bool
|
||||
| ^^^^^^^^^^^ expected `usize`, found `bool`
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:68:20
|
||||
|
@ -182,7 +158,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/const-integer-bool-ops.rs:71:19
|
||||
|
|
||||
LL | const Y5: usize = 42.0 != 42.0;
|
||||
| ^^^^^^^^^^^^ expected usize, found bool
|
||||
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:74:20
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const TUP: (usize,) = 5usize << 64;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected tuple, found usize
|
||||
//~| expected tuple, found `usize`
|
||||
const ARR: [i32; TUP.0] = [];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@ error[E0308]: mismatched types
|
|||
--> $DIR/const-tup-index-span.rs:3:23
|
||||
|
|
||||
LL | const TUP: (usize,) = 5usize << 64;
|
||||
| ^^^^^^^^^^^^ expected tuple, found usize
|
||||
| ^^^^^^^^^^^^ expected tuple, found `usize`
|
||||
|
|
||||
= note: expected type `(usize,)`
|
||||
found type `usize`
|
||||
= note: expected tuple `(usize,)`
|
||||
found type `usize`
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-tup-index-span.rs:6:18
|
||||
|
|
|
@ -2,13 +2,13 @@ error[E0308]: mismatched types
|
|||
--> $DIR/const-type-mismatch.rs:4:21
|
||||
|
|
||||
LL | const TWELVE: u16 = TEN + 2;
|
||||
| ^^^^^^^ expected u16, found u8
|
||||
| ^^^^^^^ expected `u16`, found `u8`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-type-mismatch.rs:9:27
|
||||
|
|
||||
LL | const ALSO_TEN: u16 = TEN;
|
||||
| ^^^ expected u16, found u8
|
||||
| ^^^ expected `u16`, found `u8`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/enum-discr-type-err.rs:18:21
|
||||
|
|
||||
LL | $( $v = $s::V, )*
|
||||
| ^^^^^ expected isize, found i32
|
||||
| ^^^^^ expected `isize`, found `i32`
|
||||
...
|
||||
LL | / mac! {
|
||||
LL | | A = F,
|
||||
|
|
|
@ -4,11 +4,8 @@ error[E0308]: mismatched types
|
|||
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 type `std::string::String`
|
||||
found type `&'static str`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/conversion-methods.rs:6:40
|
||||
|
@ -16,11 +13,8 @@ error[E0308]: mismatched types
|
|||
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 type `std::path::PathBuf`
|
||||
found type `&std::path::Path`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/conversion-methods.rs:9:40
|
||||
|
@ -30,9 +24,6 @@ LL | let _but_should_the_play: String = 2; // Perhaps surprisingly, we sugge
|
|||
| |
|
||||
| expected struct `std::string::String`, found integer
|
||||
| help: try using a conversion method: `2.to_string()`
|
||||
|
|
||||
= note: expected type `std::string::String`
|
||||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/conversion-methods.rs:12:47
|
||||
|
@ -40,11 +31,11 @@ error[E0308]: mismatched types
|
|||
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 type `std::vec::Vec<usize>`
|
||||
found type `&[{integer}; 3]`
|
||||
= note: expected struct `std::vec::Vec<usize>`
|
||||
found reference `&[{integer}; 3]`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -8,6 +8,6 @@ impl Trait for Foo {}
|
|||
pub fn main() {
|
||||
let x: Box<dyn Trait> = Box::new(Foo);
|
||||
let _y: &dyn Trait = x; //~ ERROR E0308
|
||||
//~| expected type `&dyn Trait`
|
||||
//~| found type `std::boxed::Box<dyn Trait>`
|
||||
//~| expected reference `&dyn Trait`
|
||||
//~| found struct `std::boxed::Box<dyn Trait>`
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@ error[E0308]: mismatched types
|
|||
LL | let _y: &dyn Trait = x;
|
||||
| ^
|
||||
| |
|
||||
| expected &dyn Trait, found struct `std::boxed::Box`
|
||||
| expected `&dyn Trait`, found struct `std::boxed::Box`
|
||||
| help: consider borrowing here: `&x`
|
||||
|
|
||||
= note: expected type `&dyn Trait`
|
||||
found type `std::boxed::Box<dyn Trait>`
|
||||
= note: expected reference `&dyn Trait`
|
||||
found struct `std::boxed::Box<dyn Trait>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -4,11 +4,8 @@ error[E0308]: mismatched types
|
|||
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 type `std::string::String`
|
||||
found type `&std::string::String`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:14:10
|
||||
|
@ -16,11 +13,8 @@ error[E0308]: mismatched types
|
|||
LL | foo3(u);
|
||||
| ^
|
||||
| |
|
||||
| expected u32, found &u32
|
||||
| expected `u32`, found `&u32`
|
||||
| help: consider dereferencing the borrow: `*u`
|
||||
|
|
||||
= note: expected type `u32`
|
||||
found type `&u32`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:30:9
|
||||
|
@ -28,11 +22,8 @@ error[E0308]: mismatched types
|
|||
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 type `std::string::String`
|
||||
found type `&std::string::String`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:32:9
|
||||
|
@ -40,32 +31,24 @@ error[E0308]: mismatched types
|
|||
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 type `std::string::String`
|
||||
found type `&mut std::string::String`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:2:20
|
||||
|
|
||||
LL | ($x:expr) => { &$x }
|
||||
| ^^^ expected u32, found &{integer}
|
||||
| ^^^ expected `u32`, found `&{integer}`
|
||||
...
|
||||
LL | foo3(borrow!(0));
|
||||
| ---------- in this macro invocation
|
||||
|
|
||||
= note: expected type `u32`
|
||||
found type `&{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:36:5
|
||||
|
|
||||
LL | assert_eq!(3i32, &3i32);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected i32, found &i32
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `&i32`
|
||||
|
|
||||
= note: expected type `i32`
|
||||
found type `&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
|
||||
|
@ -74,11 +57,8 @@ error[E0308]: mismatched types
|
|||
LL | let s = S { u };
|
||||
| ^
|
||||
| |
|
||||
| expected &u32, found integer
|
||||
| expected `&u32`, found integer
|
||||
| help: consider borrowing here: `u: &u`
|
||||
|
|
||||
= note: expected type `&u32`
|
||||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:41:20
|
||||
|
@ -86,11 +66,8 @@ error[E0308]: mismatched types
|
|||
LL | let s = S { u: u };
|
||||
| ^
|
||||
| |
|
||||
| expected &u32, found integer
|
||||
| expected `&u32`, found integer
|
||||
| help: consider borrowing here: `&u`
|
||||
|
|
||||
= note: expected type `&u32`
|
||||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:44:17
|
||||
|
@ -98,11 +75,8 @@ error[E0308]: mismatched types
|
|||
LL | let r = R { i };
|
||||
| ^
|
||||
| |
|
||||
| expected u32, found &{integer}
|
||||
| expected `u32`, found `&{integer}`
|
||||
| help: consider dereferencing the borrow: `i: *i`
|
||||
|
|
||||
= note: expected type `u32`
|
||||
found type `&{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/deref-suggestion.rs:46:20
|
||||
|
@ -110,11 +84,8 @@ error[E0308]: mismatched types
|
|||
LL | let r = R { i: i };
|
||||
| ^
|
||||
| |
|
||||
| expected u32, found &{integer}
|
||||
| expected `u32`, found `&{integer}`
|
||||
| help: consider dereferencing the borrow: `*i`
|
||||
|
|
||||
= note: expected type `u32`
|
||||
found type `&{integer}`
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
|
|
@ -31,16 +31,16 @@ fn main() {
|
|||
// n > m
|
||||
let &&x = &1isize as &dyn T;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `dyn T`
|
||||
//~| found type `&_`
|
||||
//~| expected trait T, found reference
|
||||
//~| expected trait object `dyn T`
|
||||
//~| found reference `&_`
|
||||
//~| expected trait `T`, found reference
|
||||
let &&&x = &(&1isize as &dyn T);
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `dyn T`
|
||||
//~| found type `&_`
|
||||
//~| expected trait T, found reference
|
||||
//~| expected trait object `dyn T`
|
||||
//~| found reference `&_`
|
||||
//~| expected trait `T`, found reference
|
||||
let box box x = box 1isize as Box<dyn T>;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected type `dyn T`
|
||||
//~| found type `std::boxed::Box<_>`
|
||||
//~| expected trait object `dyn T`
|
||||
//~| found struct `std::boxed::Box<_>`
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue