Use smaller spans for some structured suggestions

Use more accurate suggestion spans for

* argument parse error
* fully qualified path
* missing code block type
* numeric casts
* E0212
This commit is contained in:
Esteban Kuber 2021-08-10 10:53:43 +00:00
parent eb2226b1f1
commit 34d19634f5
60 changed files with 1200 additions and 958 deletions

View file

@ -298,6 +298,21 @@ impl Diagnostic {
) )
} }
/// Show a suggestion that has multiple parts to it, always as it's own subdiagnostic.
/// In other words, multiple changes need to be applied as part of this suggestion.
pub fn multipart_suggestion_verbose(
&mut self,
msg: &str,
suggestion: Vec<(Span, String)>,
applicability: Applicability,
) -> &mut Self {
self.multipart_suggestion_with_style(
msg,
suggestion,
applicability,
SuggestionStyle::ShowAlways,
)
}
/// [`Diagnostic::multipart_suggestion()`] but you can set the [`SuggestionStyle`]. /// [`Diagnostic::multipart_suggestion()`] but you can set the [`SuggestionStyle`].
pub fn multipart_suggestion_with_style( pub fn multipart_suggestion_with_style(
&mut self, &mut self,

View file

@ -257,6 +257,20 @@ impl<'a> DiagnosticBuilder<'a> {
self self
} }
/// See [`Diagnostic::multipart_suggestion()`].
pub fn multipart_suggestion_verbose(
&mut self,
msg: &str,
suggestion: Vec<(Span, String)>,
applicability: Applicability,
) -> &mut Self {
if !self.0.allow_suggestions {
return self;
}
self.0.diagnostic.multipart_suggestion_verbose(msg, suggestion, applicability);
self
}
/// See [`Diagnostic::tool_only_multipart_suggestion()`]. /// See [`Diagnostic::tool_only_multipart_suggestion()`].
pub fn tool_only_multipart_suggestion( pub fn tool_only_multipart_suggestion(
&mut self, &mut self,

View file

@ -1618,50 +1618,57 @@ impl<'a> Parser<'a> {
{ {
let rfc_note = "anonymous parameters are removed in the 2018 edition (see RFC 1685)"; let rfc_note = "anonymous parameters are removed in the 2018 edition (see RFC 1685)";
let (ident, self_sugg, param_sugg, type_sugg) = match pat.kind { let (ident, self_sugg, param_sugg, type_sugg, self_span, param_span, type_span) =
PatKind::Ident(_, ident, _) => ( match pat.kind {
ident, PatKind::Ident(_, ident, _) => (
format!("self: {}", ident), ident,
format!("{}: TypeName", ident), "self: ".to_string(),
format!("_: {}", ident), ": TypeName".to_string(),
), "_: ".to_string(),
// Also catches `fn foo(&a)`. pat.span.shrink_to_lo(),
PatKind::Ref(ref pat, mutab) pat.span.shrink_to_hi(),
if matches!(pat.clone().into_inner().kind, PatKind::Ident(..)) => pat.span.shrink_to_lo(),
{ ),
match pat.clone().into_inner().kind { // Also catches `fn foo(&a)`.
PatKind::Ident(_, ident, _) => { PatKind::Ref(ref inner_pat, mutab)
let mutab = mutab.prefix_str(); if matches!(inner_pat.clone().into_inner().kind, PatKind::Ident(..)) =>
( {
ident, match inner_pat.clone().into_inner().kind {
format!("self: &{}{}", mutab, ident), PatKind::Ident(_, ident, _) => {
format!("{}: &{}TypeName", ident, mutab), let mutab = mutab.prefix_str();
format!("_: &{}{}", mutab, ident), (
) ident,
"self: ".to_string(),
format!("{}: &{}TypeName", ident, mutab),
"_: ".to_string(),
pat.span.shrink_to_lo(),
pat.span,
pat.span.shrink_to_lo(),
)
}
_ => unreachable!(),
} }
_ => unreachable!(),
}
}
_ => {
// Otherwise, try to get a type and emit a suggestion.
if let Some(ty) = pat.to_ty() {
err.span_suggestion_verbose(
pat.span,
"explicitly ignore the parameter name",
format!("_: {}", pprust::ty_to_string(&ty)),
Applicability::MachineApplicable,
);
err.note(rfc_note);
} }
_ => {
// Otherwise, try to get a type and emit a suggestion.
if let Some(ty) = pat.to_ty() {
err.span_suggestion_verbose(
pat.span,
"explicitly ignore the parameter name",
format!("_: {}", pprust::ty_to_string(&ty)),
Applicability::MachineApplicable,
);
err.note(rfc_note);
}
return None; return None;
} }
}; };
// `fn foo(a, b) {}`, `fn foo(a<x>, b<y>) {}` or `fn foo(usize, usize) {}` // `fn foo(a, b) {}`, `fn foo(a<x>, b<y>) {}` or `fn foo(usize, usize) {}`
if first_param { if first_param {
err.span_suggestion( err.span_suggestion(
pat.span, self_span,
"if this is a `self` type, give it a parameter name", "if this is a `self` type, give it a parameter name",
self_sugg, self_sugg,
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
@ -1671,14 +1678,14 @@ impl<'a> Parser<'a> {
// `fn foo(HashMap: TypeName<u32>)`. // `fn foo(HashMap: TypeName<u32>)`.
if self.token != token::Lt { if self.token != token::Lt {
err.span_suggestion( err.span_suggestion(
pat.span, param_span,
"if this is a parameter name, give it a type", "if this is a parameter name, give it a type",
param_sugg, param_sugg,
Applicability::HasPlaceholders, Applicability::HasPlaceholders,
); );
} }
err.span_suggestion( err.span_suggestion(
pat.span, type_span,
"if this is a type, explicitly ignore the parameter name", "if this is a type, explicitly ignore the parameter name",
type_sugg, type_sugg,
Applicability::MachineApplicable, Applicability::MachineApplicable,

View file

@ -12,7 +12,7 @@ use rustc_ast::{
}; };
use rustc_ast_pretty::pprust::path_segment_to_string; use rustc_ast_pretty::pprust::path_segment_to_string;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, SuggestionStyle}; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::Namespace::{self, *};
use rustc_hir::def::{self, CtorKind, CtorOf, DefKind}; use rustc_hir::def::{self, CtorKind, CtorOf, DefKind};
@ -1950,11 +1950,10 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
introduce_suggestion.push((*span, formatter(&lt_name))); introduce_suggestion.push((*span, formatter(&lt_name)));
} }
} }
err.multipart_suggestion_with_style( err.multipart_suggestion_verbose(
&msg, &msg,
introduce_suggestion, introduce_suggestion,
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
SuggestionStyle::ShowAlways,
); );
} }
@ -1966,14 +1965,13 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
}) })
.map(|(formatter, span)| (*span, formatter(name))) .map(|(formatter, span)| (*span, formatter(name)))
.collect(); .collect();
err.multipart_suggestion_with_style( err.multipart_suggestion_verbose(
&format!( &format!(
"consider using the `{}` lifetime", "consider using the `{}` lifetime",
lifetime_names.iter().next().unwrap() lifetime_names.iter().next().unwrap()
), ),
spans_suggs, spans_suggs,
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
SuggestionStyle::ShowAlways,
); );
}; };
let suggest_new = |err: &mut DiagnosticBuilder<'_>, suggs: Vec<Option<String>>| { let suggest_new = |err: &mut DiagnosticBuilder<'_>, suggs: Vec<Option<String>>| {
@ -2064,11 +2062,10 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
}; };
spans_suggs.push((span, sugg.to_string())); spans_suggs.push((span, sugg.to_string()));
} }
err.multipart_suggestion_with_style( err.multipart_suggestion_verbose(
"consider using the `'static` lifetime", "consider using the `'static` lifetime",
spans_suggs, spans_suggs,
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
SuggestionStyle::ShowAlways,
); );
continue; continue;
} }
@ -2088,11 +2085,10 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
introduce_suggestion.push((span, sugg.to_string())); introduce_suggestion.push((span, sugg.to_string()));
} }
} }
err.multipart_suggestion_with_style( err.multipart_suggestion_verbose(
&msg, &msg,
introduce_suggestion, introduce_suggestion,
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
SuggestionStyle::ShowAlways,
); );
if should_break { if should_break {
break; break;
@ -2167,11 +2163,10 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
if spans_suggs.len() > 0 { if spans_suggs.len() > 0 {
// This happens when we have `Foo<T>` where we point at the space before `T`, // This happens when we have `Foo<T>` where we point at the space before `T`,
// but this can be confusing so we give a suggestion with placeholders. // but this can be confusing so we give a suggestion with placeholders.
err.multipart_suggestion_with_style( err.multipart_suggestion_verbose(
"consider using one of the available lifetimes here", "consider using one of the available lifetimes here",
spans_suggs, spans_suggs,
Applicability::HasPlaceholders, Applicability::HasPlaceholders,
SuggestionStyle::ShowAlways,
); );
} }
} }

View file

@ -1648,14 +1648,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
constraint=constraint, constraint=constraint,
)); ));
} else { } else {
err.span_suggestion( err.span_suggestion_verbose(
span, span.with_hi(assoc_name.span.lo()),
"use fully qualified syntax to disambiguate", "use fully qualified syntax to disambiguate",
format!( format!(
"<{} as {}>::{}", "<{} as {}>::",
ty_param_name(), ty_param_name(),
bound.print_only_trait_path(), bound.print_only_trait_path(),
assoc_name,
), ),
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );

View file

@ -17,7 +17,6 @@ use rustc_span::{BytePos, Span};
use super::method::probe; use super::method::probe;
use std::fmt;
use std::iter; use std::iter;
impl<'a, 'tcx> FnCtxt<'a, 'tcx> { impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
@ -771,9 +770,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// For now, don't suggest casting with `as`. // For now, don't suggest casting with `as`.
let can_cast = false; let can_cast = false;
let prefix = if let Some(hir::Node::Expr(hir::Expr { let mut sugg = vec![];
kind: hir::ExprKind::Struct(_, fields, _),
.. if let Some(hir::Node::Expr(hir::Expr {
kind: hir::ExprKind::Struct(_, fields, _), ..
})) = self.tcx.hir().find(self.tcx.hir().get_parent_node(expr.hir_id)) })) = self.tcx.hir().find(self.tcx.hir().get_parent_node(expr.hir_id))
{ {
// `expr` is a literal field for a struct, only suggest if appropriate // `expr` is a literal field for a struct, only suggest if appropriate
@ -782,12 +782,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.find(|field| field.expr.hir_id == expr.hir_id && field.is_shorthand) .find(|field| field.expr.hir_id == expr.hir_id && field.is_shorthand)
{ {
// This is a field literal // This is a field literal
Some(field) => format!("{}: ", field.ident), Some(field) => {
sugg.push((field.ident.span.shrink_to_lo(), format!("{}: ", field.ident)));
}
// Likely a field was meant, but this field wasn't found. Do not suggest anything. // Likely a field was meant, but this field wasn't found. Do not suggest anything.
None => return false, None => return false,
} }
} else {
String::new()
}; };
if let hir::ExprKind::Call(path, args) = &expr.kind { if let hir::ExprKind::Call(path, args) = &expr.kind {
@ -842,28 +842,38 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
checked_ty, expected_ty, checked_ty, expected_ty,
); );
let with_opt_paren: fn(&dyn fmt::Display) -> String = let close_paren = if expr.precedence().order() < PREC_POSTFIX {
if expr.precedence().order() < PREC_POSTFIX { sugg.push((expr.span.shrink_to_lo(), "(".to_string()));
|s| format!("({})", s) ")"
} else { } else {
|s| s.to_string() ""
}; };
let cast_suggestion = format!("{}{} as {}", prefix, with_opt_paren(&src), expected_ty); let mut cast_suggestion = sugg.clone();
let into_suggestion = format!("{}{}.into()", prefix, with_opt_paren(&src)); cast_suggestion
let suffix_suggestion = with_opt_paren(&format_args!( .push((expr.span.shrink_to_hi(), format!("{} as {}", close_paren, expected_ty)));
"{}{}", let mut into_suggestion = sugg.clone();
into_suggestion.push((expr.span.shrink_to_hi(), format!("{}.into()", close_paren)));
let mut suffix_suggestion = sugg.clone();
suffix_suggestion.push((
if matches!( if matches!(
(&expected_ty.kind(), &checked_ty.kind()), (&expected_ty.kind(), &checked_ty.kind()),
(ty::Int(_) | ty::Uint(_), ty::Float(_)) (ty::Int(_) | ty::Uint(_), ty::Float(_))
) { ) {
// Remove fractional part from literal, for example `42.0f32` into `42` // Remove fractional part from literal, for example `42.0f32` into `42`
let src = src.trim_end_matches(&checked_ty.to_string()); let src = src.trim_end_matches(&checked_ty.to_string());
src.split('.').next().unwrap() let len = src.split('.').next().unwrap().len();
expr.span.with_lo(expr.span.lo() + BytePos(len as u32))
} else { } else {
src.trim_end_matches(&checked_ty.to_string()) let len = src.trim_end_matches(&checked_ty.to_string()).len();
expr.span.with_lo(expr.span.lo() + BytePos(len as u32))
},
if expr.precedence().order() < PREC_POSTFIX {
// Readd `)`
format!("{})", expected_ty)
} else {
expected_ty.to_string()
}, },
expected_ty,
)); ));
let literal_is_ty_suffixed = |expr: &hir::Expr<'_>| { let literal_is_ty_suffixed = |expr: &hir::Expr<'_>| {
if let hir::ExprKind::Lit(lit) = &expr.kind { lit.node.is_suffixed() } else { false } if let hir::ExprKind::Lit(lit) = &expr.kind { lit.node.is_suffixed() } else { false }
@ -890,22 +900,32 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.ok() .ok()
.map(|src| (expr, src)) .map(|src| (expr, src))
}); });
let (span, msg, suggestion) = if let (Some((lhs_expr, lhs_src)), false) = let (msg, suggestion) = if let (Some((lhs_expr, lhs_src)), false) =
(lhs_expr_and_src, exp_to_found_is_fallible) (lhs_expr_and_src, exp_to_found_is_fallible)
{ {
let msg = format!( let msg = format!(
"you can convert `{}` from `{}` to `{}`, matching the type of `{}`", "you can convert `{}` from `{}` to `{}`, matching the type of `{}`",
lhs_src, expected_ty, checked_ty, src lhs_src, expected_ty, checked_ty, src
); );
let suggestion = format!("{}::from({})", checked_ty, lhs_src); let suggestion = vec![
(lhs_expr.span, msg, suggestion) (lhs_expr.span.shrink_to_lo(), format!("{}::from(", checked_ty)),
(lhs_expr.span.shrink_to_hi(), ")".to_string()),
];
(msg, suggestion)
} else { } else {
let msg = format!("{} and panic if the converted value doesn't fit", msg); let msg = format!("{} and panic if the converted value doesn't fit", msg);
let suggestion = let mut suggestion = sugg.clone();
format!("{}{}.try_into().unwrap()", prefix, with_opt_paren(&src)); suggestion.push((
(expr.span, msg, suggestion) expr.span.shrink_to_hi(),
format!("{}.try_into().unwrap()", close_paren),
));
(msg, suggestion)
}; };
err.span_suggestion(span, &msg, suggestion, Applicability::MachineApplicable); err.multipart_suggestion_verbose(
&msg,
suggestion,
Applicability::MachineApplicable,
);
}; };
let suggest_to_change_suffix_or_into = let suggest_to_change_suffix_or_into =
@ -943,7 +963,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else { } else {
into_suggestion.clone() into_suggestion.clone()
}; };
err.span_suggestion(expr.span, msg, suggestion, Applicability::MachineApplicable); err.multipart_suggestion_verbose(msg, suggestion, Applicability::MachineApplicable);
}; };
match (&expected_ty.kind(), &checked_ty.kind()) { match (&expected_ty.kind(), &checked_ty.kind()) {
@ -997,16 +1017,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if found.bit_width() < exp.bit_width() { if found.bit_width() < exp.bit_width() {
suggest_to_change_suffix_or_into(err, false, true); suggest_to_change_suffix_or_into(err, false, true);
} else if literal_is_ty_suffixed(expr) { } else if literal_is_ty_suffixed(expr) {
err.span_suggestion( err.multipart_suggestion_verbose(
expr.span,
&lit_msg, &lit_msg,
suffix_suggestion, suffix_suggestion,
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} else if can_cast { } else if can_cast {
// Missing try_into implementation for `f64` to `f32` // Missing try_into implementation for `f64` to `f32`
err.span_suggestion( err.multipart_suggestion_verbose(
expr.span,
&format!("{}, producing the closest possible value", cast_msg), &format!("{}, producing the closest possible value", cast_msg),
cast_suggestion, cast_suggestion,
Applicability::MaybeIncorrect, // lossy conversion Applicability::MaybeIncorrect, // lossy conversion
@ -1016,16 +1034,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
(&ty::Uint(_) | &ty::Int(_), &ty::Float(_)) => { (&ty::Uint(_) | &ty::Int(_), &ty::Float(_)) => {
if literal_is_ty_suffixed(expr) { if literal_is_ty_suffixed(expr) {
err.span_suggestion( err.multipart_suggestion_verbose(
expr.span,
&lit_msg, &lit_msg,
suffix_suggestion, suffix_suggestion,
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} else if can_cast { } else if can_cast {
// Missing try_into implementation for `{float}` to `{integer}` // Missing try_into implementation for `{float}` to `{integer}`
err.span_suggestion( err.multipart_suggestion_verbose(
expr.span,
&format!("{}, rounding the float towards zero", msg), &format!("{}, rounding the float towards zero", msg),
cast_suggestion, cast_suggestion,
Applicability::MaybeIncorrect, // lossy conversion Applicability::MaybeIncorrect, // lossy conversion
@ -1036,8 +1052,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
(&ty::Float(ref exp), &ty::Uint(ref found)) => { (&ty::Float(ref exp), &ty::Uint(ref found)) => {
// if `found` is `None` (meaning found is `usize`), don't suggest `.into()` // if `found` is `None` (meaning found is `usize`), don't suggest `.into()`
if exp.bit_width() > found.bit_width().unwrap_or(256) { if exp.bit_width() > found.bit_width().unwrap_or(256) {
err.span_suggestion( err.multipart_suggestion_verbose(
expr.span,
&format!( &format!(
"{}, producing the floating point representation of the integer", "{}, producing the floating point representation of the integer",
msg, msg,
@ -1046,16 +1061,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} else if literal_is_ty_suffixed(expr) { } else if literal_is_ty_suffixed(expr) {
err.span_suggestion( err.multipart_suggestion_verbose(
expr.span,
&lit_msg, &lit_msg,
suffix_suggestion, suffix_suggestion,
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} else { } else {
// Missing try_into implementation for `{integer}` to `{float}` // Missing try_into implementation for `{integer}` to `{float}`
err.span_suggestion( err.multipart_suggestion_verbose(
expr.span,
&format!( &format!(
"{}, producing the floating point representation of the integer, "{}, producing the floating point representation of the integer,
rounded if necessary", rounded if necessary",
@ -1070,8 +1083,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
(&ty::Float(ref exp), &ty::Int(ref found)) => { (&ty::Float(ref exp), &ty::Int(ref found)) => {
// if `found` is `None` (meaning found is `isize`), don't suggest `.into()` // if `found` is `None` (meaning found is `isize`), don't suggest `.into()`
if exp.bit_width() > found.bit_width().unwrap_or(256) { if exp.bit_width() > found.bit_width().unwrap_or(256) {
err.span_suggestion( err.multipart_suggestion_verbose(
expr.span,
&format!( &format!(
"{}, producing the floating point representation of the integer", "{}, producing the floating point representation of the integer",
&msg, &msg,
@ -1080,16 +1092,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} else if literal_is_ty_suffixed(expr) { } else if literal_is_ty_suffixed(expr) {
err.span_suggestion( err.multipart_suggestion_verbose(
expr.span,
&lit_msg, &lit_msg,
suffix_suggestion, suffix_suggestion,
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} else { } else {
// Missing try_into implementation for `{integer}` to `{float}` // Missing try_into implementation for `{integer}` to `{float}`
err.span_suggestion( err.multipart_suggestion_verbose(
expr.span,
&format!( &format!(
"{}, producing the floating point representation of the integer, \ "{}, producing the floating point representation of the integer, \
rounded if necessary", rounded if necessary",

View file

@ -452,9 +452,9 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
let suggestions = vec![ let suggestions = vec![
(lt_sp, sugg), (lt_sp, sugg),
( (
span, span.with_hi(item_segment.ident.span.lo()),
format!( format!(
"{}::{}", "{}::",
// Replace the existing lifetimes with a new named lifetime. // Replace the existing lifetimes with a new named lifetime.
self.tcx self.tcx
.replace_late_bound_regions(poly_trait_ref, |_| { .replace_late_bound_regions(poly_trait_ref, |_| {
@ -467,7 +467,6 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
)) ))
}) })
.0, .0,
item_segment.ident
), ),
), ),
]; ];
@ -489,14 +488,13 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
| hir::Node::ForeignItem(_) | hir::Node::ForeignItem(_)
| hir::Node::TraitItem(_) | hir::Node::TraitItem(_)
| hir::Node::ImplItem(_) => { | hir::Node::ImplItem(_) => {
err.span_suggestion( err.span_suggestion_verbose(
span, span.with_hi(item_segment.ident.span.lo()),
"use a fully qualified path with inferred lifetimes", "use a fully qualified path with inferred lifetimes",
format!( format!(
"{}::{}", "{}::",
// Erase named lt, we want `<A as B<'_>::C`, not `<A as B<'a>::C`. // Erase named lt, we want `<A as B<'_>::C`, not `<A as B<'a>::C`.
self.tcx.anonymize_late_bound_regions(poly_trait_ref).skip_binder(), self.tcx.anonymize_late_bound_regions(poly_trait_ref).skip_binder(),
item_segment.ident
), ),
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );

View file

@ -101,9 +101,9 @@ impl<'a, 'tcx> SyntaxChecker<'a, 'tcx> {
); );
} else if empty_block { } else if empty_block {
diag.span_suggestion( diag.span_suggestion(
sp.from_inner(InnerSpan::new(0, 3)), sp.from_inner(InnerSpan::new(0, 3)).shrink_to_hi(),
explanation, explanation,
String::from("```text"), String::from("text"),
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} }

View file

@ -14,7 +14,7 @@ LL | | /// ```
help: mark blocks that do not contain Rust code as text help: mark blocks that do not contain Rust code as text
| |
LL | /// ```text LL | /// ```text
| ~~~~~~~ | ++++
warning: could not parse code block as Rust code warning: could not parse code block as Rust code
--> $DIR/invalid-syntax.rs:9:5 --> $DIR/invalid-syntax.rs:9:5
@ -32,7 +32,7 @@ LL | | /// ```
help: mark blocks that do not contain Rust code as text help: mark blocks that do not contain Rust code as text
| |
LL | /// ```text LL | /// ```text
| ~~~~~~~ | ++++
warning: could not parse code block as Rust code warning: could not parse code block as Rust code
--> $DIR/invalid-syntax.rs:21:5 --> $DIR/invalid-syntax.rs:21:5
@ -47,7 +47,7 @@ LL | | /// ```
help: mark blocks that do not contain Rust code as text help: mark blocks that do not contain Rust code as text
| |
LL | /// ```text LL | /// ```text
| ~~~~~~~ | ++++
warning: could not parse code block as Rust code warning: could not parse code block as Rust code
--> $DIR/invalid-syntax.rs:35:5 --> $DIR/invalid-syntax.rs:35:5
@ -123,7 +123,7 @@ LL | | /// ```
help: mark blocks that do not contain Rust code as text help: mark blocks that do not contain Rust code as text
| |
LL | /// ```text LL | /// ```text
| ~~~~~~~ | ++++
warning: could not parse code block as Rust code warning: could not parse code block as Rust code
--> $DIR/invalid-syntax.rs:92:9 --> $DIR/invalid-syntax.rs:92:9
@ -148,7 +148,7 @@ LL | | /// ```
help: mark blocks that do not contain Rust code as text help: mark blocks that do not contain Rust code as text
| |
LL | /// ```text LL | /// ```text
| ~~~~~~~ | ++++
warning: 12 warnings emitted warning: 12 warnings emitted

View file

@ -8,15 +8,15 @@ LL | fn foo(i32);
help: if this is a `self` type, give it a parameter name help: if this is a `self` type, give it a parameter name
| |
LL | fn foo(self: i32); LL | fn foo(self: i32);
| ~~~~~~~~~ | +++++
help: if this is a parameter name, give it a type help: if this is a parameter name, give it a type
| |
LL | fn foo(i32: TypeName); LL | fn foo(i32: TypeName);
| ~~~~~~~~~~~~~ | ++++++++++
help: if this is a type, explicitly ignore the parameter name help: if this is a type, explicitly ignore the parameter name
| |
LL | fn foo(_: i32); LL | fn foo(_: i32);
| ~~~~~~ | ++
error: expected one of `:`, `@`, or `|`, found `)` error: expected one of `:`, `@`, or `|`, found `)`
--> $DIR/anon-params-denied-2018.rs:9:29 --> $DIR/anon-params-denied-2018.rs:9:29
@ -28,7 +28,7 @@ LL | fn foo_with_ref(&mut i32);
help: if this is a `self` type, give it a parameter name help: if this is a `self` type, give it a parameter name
| |
LL | fn foo_with_ref(self: &mut i32); LL | fn foo_with_ref(self: &mut i32);
| ~~~~~~~~~~~~~~ | +++++
help: if this is a parameter name, give it a type help: if this is a parameter name, give it a type
| |
LL | fn foo_with_ref(i32: &mut TypeName); LL | fn foo_with_ref(i32: &mut TypeName);
@ -36,7 +36,7 @@ LL | fn foo_with_ref(i32: &mut TypeName);
help: if this is a type, explicitly ignore the parameter name help: if this is a type, explicitly ignore the parameter name
| |
LL | fn foo_with_ref(_: &mut i32); LL | fn foo_with_ref(_: &mut i32);
| ~~~~~~~~~~~ | ++
error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)` error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)`
--> $DIR/anon-params-denied-2018.rs:12:47 --> $DIR/anon-params-denied-2018.rs:12:47
@ -96,15 +96,15 @@ LL | fn bar_with_default_impl(String, String) {}
help: if this is a `self` type, give it a parameter name help: if this is a `self` type, give it a parameter name
| |
LL | fn bar_with_default_impl(self: String, String) {} LL | fn bar_with_default_impl(self: String, String) {}
| ~~~~~~~~~~~~ | +++++
help: if this is a parameter name, give it a type help: if this is a parameter name, give it a type
| |
LL | fn bar_with_default_impl(String: TypeName, String) {} LL | fn bar_with_default_impl(String: TypeName, String) {}
| ~~~~~~~~~~~~~~~~ | ++++++++++
help: if this is a type, explicitly ignore the parameter name help: if this is a type, explicitly ignore the parameter name
| |
LL | fn bar_with_default_impl(_: String, String) {} LL | fn bar_with_default_impl(_: String, String) {}
| ~~~~~~~~~ | ++
error: expected one of `:`, `@`, or `|`, found `)` error: expected one of `:`, `@`, or `|`, found `)`
--> $DIR/anon-params-denied-2018.rs:22:44 --> $DIR/anon-params-denied-2018.rs:22:44
@ -116,11 +116,11 @@ LL | fn bar_with_default_impl(String, String) {}
help: if this is a parameter name, give it a type help: if this is a parameter name, give it a type
| |
LL | fn bar_with_default_impl(String, String: TypeName) {} LL | fn bar_with_default_impl(String, String: TypeName) {}
| ~~~~~~~~~~~~~~~~ | ++++++++++
help: if this is a type, explicitly ignore the parameter name help: if this is a type, explicitly ignore the parameter name
| |
LL | fn bar_with_default_impl(String, _: String) {} LL | fn bar_with_default_impl(String, _: String) {}
| ~~~~~~~~~ | ++
error: expected one of `:`, `@`, or `|`, found `,` error: expected one of `:`, `@`, or `|`, found `,`
--> $DIR/anon-params-denied-2018.rs:27:22 --> $DIR/anon-params-denied-2018.rs:27:22
@ -132,11 +132,11 @@ LL | fn baz(a:usize, b, c: usize) -> usize {
help: if this is a parameter name, give it a type help: if this is a parameter name, give it a type
| |
LL | fn baz(a:usize, b: TypeName, c: usize) -> usize { LL | fn baz(a:usize, b: TypeName, c: usize) -> usize {
| ~~~~~~~~~~~ | ++++++++++
help: if this is a type, explicitly ignore the parameter name help: if this is a type, explicitly ignore the parameter name
| |
LL | fn baz(a:usize, _: b, c: usize) -> usize { LL | fn baz(a:usize, _: b, c: usize) -> usize {
| ~~~~ | ++
error: aborting due to 9 previous errors error: aborting due to 9 previous errors

View file

@ -13,11 +13,11 @@ LL | fn a<C:Vehicle+Box>(_: C::Color) {
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | fn a<C:Vehicle+Box>(_: <C as Box>::Color) { LL | fn a<C:Vehicle+Box>(_: <C as Box>::Color) {
| ~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | fn a<C:Vehicle+Box>(_: <C as Vehicle>::Color) { LL | fn a<C:Vehicle+Box>(_: <C as Vehicle>::Color) {
| ~~~~~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~
error[E0221]: ambiguous associated type `Color` in bounds of `C` error[E0221]: ambiguous associated type `Color` in bounds of `C`
--> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:20:12 --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:20:12
@ -34,11 +34,11 @@ LL | fn b<C>(_: C::Color) where C : Vehicle+Box {
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | fn b<C>(_: <C as Box>::Color) where C : Vehicle+Box { LL | fn b<C>(_: <C as Box>::Color) where C : Vehicle+Box {
| ~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | fn b<C>(_: <C as Vehicle>::Color) where C : Vehicle+Box { LL | fn b<C>(_: <C as Vehicle>::Color) where C : Vehicle+Box {
| ~~~~~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~
error[E0221]: ambiguous associated type `Color` in bounds of `C` error[E0221]: ambiguous associated type `Color` in bounds of `C`
--> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:24:12 --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:24:12
@ -55,11 +55,11 @@ LL | fn c<C>(_: C::Color) where C : Vehicle, C : Box {
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | fn c<C>(_: <C as Box>::Color) where C : Vehicle, C : Box { LL | fn c<C>(_: <C as Box>::Color) where C : Vehicle, C : Box {
| ~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | fn c<C>(_: <C as Vehicle>::Color) where C : Vehicle, C : Box { LL | fn c<C>(_: <C as Vehicle>::Color) where C : Vehicle, C : Box {
| ~~~~~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~
error[E0221]: ambiguous associated type `Color` in bounds of `X` error[E0221]: ambiguous associated type `Color` in bounds of `X`
--> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:35:20 --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:35:20
@ -76,11 +76,11 @@ LL | fn e(&self, _: X::Color) where X : Box;
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | fn e(&self, _: <X as Box>::Color) where X : Box; LL | fn e(&self, _: <X as Box>::Color) where X : Box;
| ~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | fn e(&self, _: <X as Vehicle>::Color) where X : Box; LL | fn e(&self, _: <X as Vehicle>::Color) where X : Box;
| ~~~~~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~
error[E0221]: ambiguous associated type `Color` in bounds of `X` error[E0221]: ambiguous associated type `Color` in bounds of `X`
--> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:38:20 --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:38:20
@ -97,11 +97,11 @@ LL | fn f(&self, _: X::Color) where X : Box { }
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | fn f(&self, _: <X as Box>::Color) where X : Box { } LL | fn f(&self, _: <X as Box>::Color) where X : Box { }
| ~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | fn f(&self, _: <X as Vehicle>::Color) where X : Box { } LL | fn f(&self, _: <X as Vehicle>::Color) where X : Box { }
| ~~~~~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~
error[E0221]: ambiguous associated type `Color` in bounds of `X` error[E0221]: ambiguous associated type `Color` in bounds of `X`
--> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:30:20 --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:30:20
@ -118,11 +118,11 @@ LL | fn d(&self, _: X::Color) where X : Box { }
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | fn d(&self, _: <X as Box>::Color) where X : Box { } LL | fn d(&self, _: <X as Box>::Color) where X : Box { }
| ~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | fn d(&self, _: <X as Vehicle>::Color) where X : Box { } LL | fn d(&self, _: <X as Vehicle>::Color) where X : Box { }
| ~~~~~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~
error: aborting due to 6 previous errors error: aborting due to 6 previous errors

View file

@ -21,11 +21,11 @@ LL | fn dent<C:BoxCar>(c: C, color: C::Color) {
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | fn dent<C:BoxCar>(c: C, color: <C as Vehicle>::Color) { LL | fn dent<C:BoxCar>(c: C, color: <C as Vehicle>::Color) {
| ~~~~~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | fn dent<C:BoxCar>(c: C, color: <C as Box>::Color) { LL | fn dent<C:BoxCar>(c: C, color: <C as Box>::Color) {
| ~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~
error[E0222]: ambiguous associated type `Color` in bounds of `BoxCar` error[E0222]: ambiguous associated type `Color` in bounds of `BoxCar`
--> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:37 --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:37
@ -74,11 +74,11 @@ LL | fn paint<C:BoxCar>(c: C, d: C::Color) {
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | fn paint<C:BoxCar>(c: C, d: <C as Vehicle>::Color) { LL | fn paint<C:BoxCar>(c: C, d: <C as Vehicle>::Color) {
| ~~~~~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | fn paint<C:BoxCar>(c: C, d: <C as Box>::Color) { LL | fn paint<C:BoxCar>(c: C, d: <C as Box>::Color) {
| ~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~
error[E0191]: the value of the associated types `Color` (from trait `Box`), `Color` (from trait `Vehicle`) must be specified error[E0191]: the value of the associated types `Color` (from trait `Box`), `Color` (from trait `Vehicle`) must be specified
--> $DIR/associated-type-projection-from-multiple-supertraits.rs:32:32 --> $DIR/associated-type-projection-from-multiple-supertraits.rs:32:32

View file

@ -19,11 +19,11 @@ LL | pub fn f2<T: Foo + Bar>(a: T, x: T::A) {}
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | pub fn f2<T: Foo + Bar>(a: T, x: <T as Bar>::A) {} LL | pub fn f2<T: Foo + Bar>(a: T, x: <T as Bar>::A) {}
| ~~~~~~~~~~~~~ | ~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | pub fn f2<T: Foo + Bar>(a: T, x: <T as Foo>::A) {} LL | pub fn f2<T: Foo + Bar>(a: T, x: <T as Foo>::A) {}
| ~~~~~~~~~~~~~ | ~~~~~~~~~~~~
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -7,7 +7,7 @@ LL | f1(2i32, 4i32);
help: change the type of the numeric literal from `i32` to `u32` help: change the type of the numeric literal from `i32` to `u32`
| |
LL | f1(2i32, 4u32); LL | f1(2i32, 4u32);
| ~~~~ | ~~~
error[E0277]: the trait bound `u32: Foo` is not satisfied error[E0277]: the trait bound `u32: Foo` is not satisfied
--> $DIR/associated-types-path-2.rs:29:5 --> $DIR/associated-types-path-2.rs:29:5
@ -50,7 +50,7 @@ LL | let _: i32 = f2(2i32);
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
| |
LL | let _: i32 = f2(2i32).try_into().unwrap(); LL | let _: i32 = f2(2i32).try_into().unwrap();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error: aborting due to 6 previous errors error: aborting due to 6 previous errors

View file

@ -2,7 +2,12 @@ error[E0212]: cannot use the associated type of a trait with uninferred generic
--> $DIR/associated-types-project-from-hrtb-in-fn.rs:13:8 --> $DIR/associated-types-project-from-hrtb-in-fn.rs:13:8
| |
LL | x: I::A) LL | x: I::A)
| ^^^^ help: use a fully qualified path with inferred lifetimes: `<I as Foo<&isize>>::A` | ^^^^
|
help: use a fully qualified path with inferred lifetimes
|
LL | x: <I as Foo<&isize>>::A)
| ~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,13 +2,23 @@ error[E0212]: cannot use the associated type of a trait with uninferred generic
--> $DIR/associated-types-project-from-hrtb-in-trait-method.rs:13:32 --> $DIR/associated-types-project-from-hrtb-in-trait-method.rs:13:32
| |
LL | fn some_method(&self, arg: I::A); LL | fn some_method(&self, arg: I::A);
| ^^^^ help: use a fully qualified path with inferred lifetimes: `<I as Foo<&isize>>::A` | ^^^^
|
help: use a fully qualified path with inferred lifetimes
|
LL | fn some_method(&self, arg: <I as Foo<&isize>>::A);
| ~~~~~~~~~~~~~~~~~~~~
error[E0212]: cannot use the associated type of a trait with uninferred generic parameters error[E0212]: cannot use the associated type of a trait with uninferred generic parameters
--> $DIR/associated-types-project-from-hrtb-in-trait-method.rs:32:24 --> $DIR/associated-types-project-from-hrtb-in-trait-method.rs:32:24
| |
LL | fn mango(&self) -> X::Assoc { LL | fn mango(&self) -> X::Assoc {
| ^^^^^^^^ help: use a fully qualified path with inferred lifetimes: `<X as Banana<'_>>::Assoc` | ^^^^^^^^
|
help: use a fully qualified path with inferred lifetimes
|
LL | fn mango(&self) -> <X as Banana<'_>>::Assoc {
| ~~~~~~~~~~~~~~~~~~~
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -7,7 +7,7 @@ LL | assert_eq!(R.method::<1u16>(), 1);
help: change the type of the numeric literal from `u16` to `u8` help: change the type of the numeric literal from `u16` to `u8`
| |
LL | assert_eq!(R.method::<1u8>(), 1); LL | assert_eq!(R.method::<1u8>(), 1);
| ~~~ | ~~
error: aborting due to previous error error: aborting due to previous error

View file

@ -7,7 +7,7 @@ LL | assert_eq!(R.method::<1u16>(), 1);
help: change the type of the numeric literal from `u16` to `u8` help: change the type of the numeric literal from `u16` to `u8`
| |
LL | assert_eq!(R.method::<1u8>(), 1); LL | assert_eq!(R.method::<1u8>(), 1);
| ~~~ | ~~
error: aborting due to previous error error: aborting due to previous error

View file

@ -7,7 +7,7 @@ LL | OhNo = 0_u8,
help: change the type of the numeric literal from `u8` to `i8` help: change the type of the numeric literal from `u8` to `i8`
| |
LL | OhNo = 0_i8, LL | OhNo = 0_i8,
| ~~~~ | ~~
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/discrim-ill-typed.rs:28:16 --> $DIR/discrim-ill-typed.rs:28:16
@ -18,7 +18,7 @@ LL | OhNo = 0_i8,
help: change the type of the numeric literal from `i8` to `u8` help: change the type of the numeric literal from `i8` to `u8`
| |
LL | OhNo = 0_u8, LL | OhNo = 0_u8,
| ~~~~ | ~~
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/discrim-ill-typed.rs:41:16 --> $DIR/discrim-ill-typed.rs:41:16
@ -29,7 +29,7 @@ LL | OhNo = 0_u16,
help: change the type of the numeric literal from `u16` to `i16` help: change the type of the numeric literal from `u16` to `i16`
| |
LL | OhNo = 0_i16, LL | OhNo = 0_i16,
| ~~~~~ | ~~~
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/discrim-ill-typed.rs:54:16 --> $DIR/discrim-ill-typed.rs:54:16
@ -40,7 +40,7 @@ LL | OhNo = 0_i16,
help: change the type of the numeric literal from `i16` to `u16` help: change the type of the numeric literal from `i16` to `u16`
| |
LL | OhNo = 0_u16, LL | OhNo = 0_u16,
| ~~~~~ | ~~~
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/discrim-ill-typed.rs:67:16 --> $DIR/discrim-ill-typed.rs:67:16
@ -51,7 +51,7 @@ LL | OhNo = 0_u32,
help: change the type of the numeric literal from `u32` to `i32` help: change the type of the numeric literal from `u32` to `i32`
| |
LL | OhNo = 0_i32, LL | OhNo = 0_i32,
| ~~~~~ | ~~~
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/discrim-ill-typed.rs:80:16 --> $DIR/discrim-ill-typed.rs:80:16
@ -62,7 +62,7 @@ LL | OhNo = 0_i32,
help: change the type of the numeric literal from `i32` to `u32` help: change the type of the numeric literal from `i32` to `u32`
| |
LL | OhNo = 0_u32, LL | OhNo = 0_u32,
| ~~~~~ | ~~~
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/discrim-ill-typed.rs:93:16 --> $DIR/discrim-ill-typed.rs:93:16
@ -73,7 +73,7 @@ LL | OhNo = 0_u64,
help: change the type of the numeric literal from `u64` to `i64` help: change the type of the numeric literal from `u64` to `i64`
| |
LL | OhNo = 0_i64, LL | OhNo = 0_i64,
| ~~~~~ | ~~~
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/discrim-ill-typed.rs:106:16 --> $DIR/discrim-ill-typed.rs:106:16
@ -84,7 +84,7 @@ LL | OhNo = 0_i64,
help: change the type of the numeric literal from `i64` to `u64` help: change the type of the numeric literal from `i64` to `u64`
| |
LL | OhNo = 0_u64, LL | OhNo = 0_u64,
| ~~~~~ | ~~~
error: aborting due to 8 previous errors error: aborting due to 8 previous errors

View file

@ -13,11 +13,11 @@ LL | let _: Self::A;
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | let _: <Self as Foo>::A; LL | let _: <Self as Foo>::A;
| ~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~
help: use fully qualified syntax to disambiguate help: use fully qualified syntax to disambiguate
| |
LL | let _: <Self as Bar>::A; LL | let _: <Self as Bar>::A;
| ~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~
error[E0221]: ambiguous associated type `Err` in bounds of `Self` error[E0221]: ambiguous associated type `Err` in bounds of `Self`
--> $DIR/E0221.rs:21:16 --> $DIR/E0221.rs:21:16
@ -26,12 +26,13 @@ LL | type Err: T3;
| ------------- ambiguous `Err` from `My` | ------------- ambiguous `Err` from `My`
LL | fn test() { LL | fn test() {
LL | let _: Self::Err; LL | let _: Self::Err;
| ^^^^^^^^^ | ^^^^^^^^^ ambiguous associated type `Err`
| |
| ambiguous associated type `Err`
| help: use fully qualified syntax to disambiguate: `<Self as My>::Err`
| |
= note: associated type `Self` could derive from `FromStr` = note: associated type `Self` could derive from `FromStr`
help: use fully qualified syntax to disambiguate
|
LL | let _: <Self as My>::Err;
| ~~~~~~~~~~~~~~
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -19,7 +19,7 @@ LL | let y: f32 = 1f64;
help: change the type of the numeric literal from `f64` to `f32` help: change the type of the numeric literal from `f64` to `f32`
| |
LL | let y: f32 = 1f32; LL | let y: f32 = 1f32;
| ~~~~ | ~~~
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -16,7 +16,7 @@ LL | bar::<isize>(i); // i should not be re-coerced back to an isize
help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit
| |
LL | bar::<isize>(i.try_into().unwrap()); // i should not be re-coerced back to an isize LL | bar::<isize>(i.try_into().unwrap()); // i should not be re-coerced back to an isize
| ~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -7,7 +7,7 @@ LL | id_i8(a16);
help: you can convert an `i16` to an `i8` and panic if the converted value doesn't fit help: you can convert an `i16` to an `i8` and panic if the converted value doesn't fit
| |
LL | id_i8(a16.try_into().unwrap()); LL | id_i8(a16.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:41:11 --> $DIR/integer-literal-suffix-inference.rs:41:11
@ -18,7 +18,7 @@ LL | id_i8(a32);
help: you can convert an `i32` to an `i8` and panic if the converted value doesn't fit help: you can convert an `i32` to an `i8` and panic if the converted value doesn't fit
| |
LL | id_i8(a32.try_into().unwrap()); LL | id_i8(a32.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:44:11 --> $DIR/integer-literal-suffix-inference.rs:44:11
@ -29,7 +29,7 @@ LL | id_i8(a64);
help: you can convert an `i64` to an `i8` and panic if the converted value doesn't fit help: you can convert an `i64` to an `i8` and panic if the converted value doesn't fit
| |
LL | id_i8(a64.try_into().unwrap()); LL | id_i8(a64.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:47:11 --> $DIR/integer-literal-suffix-inference.rs:47:11
@ -40,16 +40,18 @@ LL | id_i8(asize);
help: you can convert an `isize` to an `i8` and panic if the converted value doesn't fit help: you can convert an `isize` to an `i8` and panic if the converted value doesn't fit
| |
LL | id_i8(asize.try_into().unwrap()); LL | id_i8(asize.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:51:12 --> $DIR/integer-literal-suffix-inference.rs:51:12
| |
LL | id_i16(a8); LL | id_i16(a8);
| ^^ | ^^ expected `i16`, found `i8`
| | |
| expected `i16`, found `i8` help: you can convert an `i8` to an `i16`
| help: you can convert an `i8` to an `i16`: `a8.into()` |
LL | id_i16(a8.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:55:12 --> $DIR/integer-literal-suffix-inference.rs:55:12
@ -60,7 +62,7 @@ LL | id_i16(a32);
help: you can convert an `i32` to an `i16` and panic if the converted value doesn't fit help: you can convert an `i32` to an `i16` and panic if the converted value doesn't fit
| |
LL | id_i16(a32.try_into().unwrap()); LL | id_i16(a32.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:58:12 --> $DIR/integer-literal-suffix-inference.rs:58:12
@ -71,7 +73,7 @@ LL | id_i16(a64);
help: you can convert an `i64` to an `i16` and panic if the converted value doesn't fit help: you can convert an `i64` to an `i16` and panic if the converted value doesn't fit
| |
LL | id_i16(a64.try_into().unwrap()); LL | id_i16(a64.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:61:12 --> $DIR/integer-literal-suffix-inference.rs:61:12
@ -82,25 +84,29 @@ LL | id_i16(asize);
help: you can convert an `isize` to an `i16` and panic if the converted value doesn't fit help: you can convert an `isize` to an `i16` and panic if the converted value doesn't fit
| |
LL | id_i16(asize.try_into().unwrap()); LL | id_i16(asize.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:65:12 --> $DIR/integer-literal-suffix-inference.rs:65:12
| |
LL | id_i32(a8); LL | id_i32(a8);
| ^^ | ^^ expected `i32`, found `i8`
| | |
| expected `i32`, found `i8` help: you can convert an `i8` to an `i32`
| help: you can convert an `i8` to an `i32`: `a8.into()` |
LL | id_i32(a8.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:68:12 --> $DIR/integer-literal-suffix-inference.rs:68:12
| |
LL | id_i32(a16); LL | id_i32(a16);
| ^^^ | ^^^ expected `i32`, found `i16`
| | |
| expected `i32`, found `i16` help: you can convert an `i16` to an `i32`
| help: you can convert an `i16` to an `i32`: `a16.into()` |
LL | id_i32(a16.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:72:12 --> $DIR/integer-literal-suffix-inference.rs:72:12
@ -111,7 +117,7 @@ LL | id_i32(a64);
help: you can convert an `i64` to an `i32` and panic if the converted value doesn't fit help: you can convert an `i64` to an `i32` and panic if the converted value doesn't fit
| |
LL | id_i32(a64.try_into().unwrap()); LL | id_i32(a64.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:75:12 --> $DIR/integer-literal-suffix-inference.rs:75:12
@ -122,34 +128,40 @@ LL | id_i32(asize);
help: you can convert an `isize` to an `i32` and panic if the converted value doesn't fit help: you can convert an `isize` to an `i32` and panic if the converted value doesn't fit
| |
LL | id_i32(asize.try_into().unwrap()); LL | id_i32(asize.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:79:12 --> $DIR/integer-literal-suffix-inference.rs:79:12
| |
LL | id_i64(a8); LL | id_i64(a8);
| ^^ | ^^ expected `i64`, found `i8`
| | |
| expected `i64`, found `i8` help: you can convert an `i8` to an `i64`
| help: you can convert an `i8` to an `i64`: `a8.into()` |
LL | id_i64(a8.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:82:12 --> $DIR/integer-literal-suffix-inference.rs:82:12
| |
LL | id_i64(a16); LL | id_i64(a16);
| ^^^ | ^^^ expected `i64`, found `i16`
| | |
| expected `i64`, found `i16` help: you can convert an `i16` to an `i64`
| help: you can convert an `i16` to an `i64`: `a16.into()` |
LL | id_i64(a16.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:85:12 --> $DIR/integer-literal-suffix-inference.rs:85:12
| |
LL | id_i64(a32); LL | id_i64(a32);
| ^^^ | ^^^ expected `i64`, found `i32`
| | |
| expected `i64`, found `i32` help: you can convert an `i32` to an `i64`
| help: you can convert an `i32` to an `i64`: `a32.into()` |
LL | id_i64(a32.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:89:12 --> $DIR/integer-literal-suffix-inference.rs:89:12
@ -160,25 +172,29 @@ LL | id_i64(asize);
help: you can convert an `isize` to an `i64` and panic if the converted value doesn't fit help: you can convert an `isize` to an `i64` and panic if the converted value doesn't fit
| |
LL | id_i64(asize.try_into().unwrap()); LL | id_i64(asize.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:93:14 --> $DIR/integer-literal-suffix-inference.rs:93:14
| |
LL | id_isize(a8); LL | id_isize(a8);
| ^^ | ^^ expected `isize`, found `i8`
| | |
| expected `isize`, found `i8` help: you can convert an `i8` to an `isize`
| help: you can convert an `i8` to an `isize`: `a8.into()` |
LL | id_isize(a8.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:96:14 --> $DIR/integer-literal-suffix-inference.rs:96:14
| |
LL | id_isize(a16); LL | id_isize(a16);
| ^^^ | ^^^ expected `isize`, found `i16`
| | |
| expected `isize`, found `i16` help: you can convert an `i16` to an `isize`
| help: you can convert an `i16` to an `isize`: `a16.into()` |
LL | id_isize(a16.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:99:14 --> $DIR/integer-literal-suffix-inference.rs:99:14
@ -189,7 +205,7 @@ LL | id_isize(a32);
help: you can convert an `i32` to an `isize` and panic if the converted value doesn't fit help: you can convert an `i32` to an `isize` and panic if the converted value doesn't fit
| |
LL | id_isize(a32.try_into().unwrap()); LL | id_isize(a32.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:102:14 --> $DIR/integer-literal-suffix-inference.rs:102:14
@ -200,7 +216,7 @@ LL | id_isize(a64);
help: you can convert an `i64` to an `isize` and panic if the converted value doesn't fit help: you can convert an `i64` to an `isize` and panic if the converted value doesn't fit
| |
LL | id_isize(a64.try_into().unwrap()); LL | id_isize(a64.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:108:11 --> $DIR/integer-literal-suffix-inference.rs:108:11
@ -211,7 +227,7 @@ LL | id_i8(c16);
help: you can convert an `i16` to an `i8` and panic if the converted value doesn't fit help: you can convert an `i16` to an `i8` and panic if the converted value doesn't fit
| |
LL | id_i8(c16.try_into().unwrap()); LL | id_i8(c16.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:111:11 --> $DIR/integer-literal-suffix-inference.rs:111:11
@ -222,7 +238,7 @@ LL | id_i8(c32);
help: you can convert an `i32` to an `i8` and panic if the converted value doesn't fit help: you can convert an `i32` to an `i8` and panic if the converted value doesn't fit
| |
LL | id_i8(c32.try_into().unwrap()); LL | id_i8(c32.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:114:11 --> $DIR/integer-literal-suffix-inference.rs:114:11
@ -233,16 +249,18 @@ LL | id_i8(c64);
help: you can convert an `i64` to an `i8` and panic if the converted value doesn't fit help: you can convert an `i64` to an `i8` and panic if the converted value doesn't fit
| |
LL | id_i8(c64.try_into().unwrap()); LL | id_i8(c64.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:118:12 --> $DIR/integer-literal-suffix-inference.rs:118:12
| |
LL | id_i16(c8); LL | id_i16(c8);
| ^^ | ^^ expected `i16`, found `i8`
| | |
| expected `i16`, found `i8` help: you can convert an `i8` to an `i16`
| help: you can convert an `i8` to an `i16`: `c8.into()` |
LL | id_i16(c8.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:122:12 --> $DIR/integer-literal-suffix-inference.rs:122:12
@ -253,7 +271,7 @@ LL | id_i16(c32);
help: you can convert an `i32` to an `i16` and panic if the converted value doesn't fit help: you can convert an `i32` to an `i16` and panic if the converted value doesn't fit
| |
LL | id_i16(c32.try_into().unwrap()); LL | id_i16(c32.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:125:12 --> $DIR/integer-literal-suffix-inference.rs:125:12
@ -264,25 +282,29 @@ LL | id_i16(c64);
help: you can convert an `i64` to an `i16` and panic if the converted value doesn't fit help: you can convert an `i64` to an `i16` and panic if the converted value doesn't fit
| |
LL | id_i16(c64.try_into().unwrap()); LL | id_i16(c64.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:129:12 --> $DIR/integer-literal-suffix-inference.rs:129:12
| |
LL | id_i32(c8); LL | id_i32(c8);
| ^^ | ^^ expected `i32`, found `i8`
| | |
| expected `i32`, found `i8` help: you can convert an `i8` to an `i32`
| help: you can convert an `i8` to an `i32`: `c8.into()` |
LL | id_i32(c8.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:132:12 --> $DIR/integer-literal-suffix-inference.rs:132:12
| |
LL | id_i32(c16); LL | id_i32(c16);
| ^^^ | ^^^ expected `i32`, found `i16`
| | |
| expected `i32`, found `i16` help: you can convert an `i16` to an `i32`
| help: you can convert an `i16` to an `i32`: `c16.into()` |
LL | id_i32(c16.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:136:12 --> $DIR/integer-literal-suffix-inference.rs:136:12
@ -293,34 +315,40 @@ LL | id_i32(c64);
help: you can convert an `i64` to an `i32` and panic if the converted value doesn't fit help: you can convert an `i64` to an `i32` and panic if the converted value doesn't fit
| |
LL | id_i32(c64.try_into().unwrap()); LL | id_i32(c64.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:140:12 --> $DIR/integer-literal-suffix-inference.rs:140:12
| |
LL | id_i64(a8); LL | id_i64(a8);
| ^^ | ^^ expected `i64`, found `i8`
| | |
| expected `i64`, found `i8` help: you can convert an `i8` to an `i64`
| help: you can convert an `i8` to an `i64`: `a8.into()` |
LL | id_i64(a8.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:143:12 --> $DIR/integer-literal-suffix-inference.rs:143:12
| |
LL | id_i64(a16); LL | id_i64(a16);
| ^^^ | ^^^ expected `i64`, found `i16`
| | |
| expected `i64`, found `i16` help: you can convert an `i16` to an `i64`
| help: you can convert an `i16` to an `i64`: `a16.into()` |
LL | id_i64(a16.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:146:12 --> $DIR/integer-literal-suffix-inference.rs:146:12
| |
LL | id_i64(a32); LL | id_i64(a32);
| ^^^ | ^^^ expected `i64`, found `i32`
| | |
| expected `i64`, found `i32` help: you can convert an `i32` to an `i64`
| help: you can convert an `i32` to an `i64`: `a32.into()` |
LL | id_i64(a32.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:152:11 --> $DIR/integer-literal-suffix-inference.rs:152:11
@ -331,7 +359,7 @@ LL | id_u8(b16);
help: you can convert a `u16` to a `u8` and panic if the converted value doesn't fit help: you can convert a `u16` to a `u8` and panic if the converted value doesn't fit
| |
LL | id_u8(b16.try_into().unwrap()); LL | id_u8(b16.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:155:11 --> $DIR/integer-literal-suffix-inference.rs:155:11
@ -342,7 +370,7 @@ LL | id_u8(b32);
help: you can convert a `u32` to a `u8` and panic if the converted value doesn't fit help: you can convert a `u32` to a `u8` and panic if the converted value doesn't fit
| |
LL | id_u8(b32.try_into().unwrap()); LL | id_u8(b32.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:158:11 --> $DIR/integer-literal-suffix-inference.rs:158:11
@ -353,7 +381,7 @@ LL | id_u8(b64);
help: you can convert a `u64` to a `u8` and panic if the converted value doesn't fit help: you can convert a `u64` to a `u8` and panic if the converted value doesn't fit
| |
LL | id_u8(b64.try_into().unwrap()); LL | id_u8(b64.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:161:11 --> $DIR/integer-literal-suffix-inference.rs:161:11
@ -364,16 +392,18 @@ LL | id_u8(bsize);
help: you can convert a `usize` to a `u8` and panic if the converted value doesn't fit help: you can convert a `usize` to a `u8` and panic if the converted value doesn't fit
| |
LL | id_u8(bsize.try_into().unwrap()); LL | id_u8(bsize.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:165:12 --> $DIR/integer-literal-suffix-inference.rs:165:12
| |
LL | id_u16(b8); LL | id_u16(b8);
| ^^ | ^^ expected `u16`, found `u8`
| | |
| expected `u16`, found `u8` help: you can convert a `u8` to a `u16`
| help: you can convert a `u8` to a `u16`: `b8.into()` |
LL | id_u16(b8.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:169:12 --> $DIR/integer-literal-suffix-inference.rs:169:12
@ -384,7 +414,7 @@ LL | id_u16(b32);
help: you can convert a `u32` to a `u16` and panic if the converted value doesn't fit help: you can convert a `u32` to a `u16` and panic if the converted value doesn't fit
| |
LL | id_u16(b32.try_into().unwrap()); LL | id_u16(b32.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:172:12 --> $DIR/integer-literal-suffix-inference.rs:172:12
@ -395,7 +425,7 @@ LL | id_u16(b64);
help: you can convert a `u64` to a `u16` and panic if the converted value doesn't fit help: you can convert a `u64` to a `u16` and panic if the converted value doesn't fit
| |
LL | id_u16(b64.try_into().unwrap()); LL | id_u16(b64.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:175:12 --> $DIR/integer-literal-suffix-inference.rs:175:12
@ -406,25 +436,29 @@ LL | id_u16(bsize);
help: you can convert a `usize` to a `u16` and panic if the converted value doesn't fit help: you can convert a `usize` to a `u16` and panic if the converted value doesn't fit
| |
LL | id_u16(bsize.try_into().unwrap()); LL | id_u16(bsize.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:179:12 --> $DIR/integer-literal-suffix-inference.rs:179:12
| |
LL | id_u32(b8); LL | id_u32(b8);
| ^^ | ^^ expected `u32`, found `u8`
| | |
| expected `u32`, found `u8` help: you can convert a `u8` to a `u32`
| help: you can convert a `u8` to a `u32`: `b8.into()` |
LL | id_u32(b8.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:182:12 --> $DIR/integer-literal-suffix-inference.rs:182:12
| |
LL | id_u32(b16); LL | id_u32(b16);
| ^^^ | ^^^ expected `u32`, found `u16`
| | |
| expected `u32`, found `u16` help: you can convert a `u16` to a `u32`
| help: you can convert a `u16` to a `u32`: `b16.into()` |
LL | id_u32(b16.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:186:12 --> $DIR/integer-literal-suffix-inference.rs:186:12
@ -435,7 +469,7 @@ LL | id_u32(b64);
help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit
| |
LL | id_u32(b64.try_into().unwrap()); LL | id_u32(b64.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:189:12 --> $DIR/integer-literal-suffix-inference.rs:189:12
@ -446,34 +480,40 @@ LL | id_u32(bsize);
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
| |
LL | id_u32(bsize.try_into().unwrap()); LL | id_u32(bsize.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:193:12 --> $DIR/integer-literal-suffix-inference.rs:193:12
| |
LL | id_u64(b8); LL | id_u64(b8);
| ^^ | ^^ expected `u64`, found `u8`
| | |
| expected `u64`, found `u8` help: you can convert a `u8` to a `u64`
| help: you can convert a `u8` to a `u64`: `b8.into()` |
LL | id_u64(b8.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:196:12 --> $DIR/integer-literal-suffix-inference.rs:196:12
| |
LL | id_u64(b16); LL | id_u64(b16);
| ^^^ | ^^^ expected `u64`, found `u16`
| | |
| expected `u64`, found `u16` help: you can convert a `u16` to a `u64`
| help: you can convert a `u16` to a `u64`: `b16.into()` |
LL | id_u64(b16.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:199:12 --> $DIR/integer-literal-suffix-inference.rs:199:12
| |
LL | id_u64(b32); LL | id_u64(b32);
| ^^^ | ^^^ expected `u64`, found `u32`
| | |
| expected `u64`, found `u32` help: you can convert a `u32` to a `u64`
| help: you can convert a `u32` to a `u64`: `b32.into()` |
LL | id_u64(b32.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:203:12 --> $DIR/integer-literal-suffix-inference.rs:203:12
@ -484,25 +524,29 @@ LL | id_u64(bsize);
help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit
| |
LL | id_u64(bsize.try_into().unwrap()); LL | id_u64(bsize.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:207:14 --> $DIR/integer-literal-suffix-inference.rs:207:14
| |
LL | id_usize(b8); LL | id_usize(b8);
| ^^ | ^^ expected `usize`, found `u8`
| | |
| expected `usize`, found `u8` help: you can convert a `u8` to a `usize`
| help: you can convert a `u8` to a `usize`: `b8.into()` |
LL | id_usize(b8.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:210:14 --> $DIR/integer-literal-suffix-inference.rs:210:14
| |
LL | id_usize(b16); LL | id_usize(b16);
| ^^^ | ^^^ expected `usize`, found `u16`
| | |
| expected `usize`, found `u16` help: you can convert a `u16` to a `usize`
| help: you can convert a `u16` to a `usize`: `b16.into()` |
LL | id_usize(b16.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:213:14 --> $DIR/integer-literal-suffix-inference.rs:213:14
@ -513,7 +557,7 @@ LL | id_usize(b32);
help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit
| |
LL | id_usize(b32.try_into().unwrap()); LL | id_usize(b32.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/integer-literal-suffix-inference.rs:216:14 --> $DIR/integer-literal-suffix-inference.rs:216:14
@ -524,7 +568,7 @@ LL | id_usize(b64);
help: you can convert a `u64` to a `usize` and panic if the converted value doesn't fit help: you can convert a `u64` to a `usize` and panic if the converted value doesn't fit
| |
LL | id_usize(b64.try_into().unwrap()); LL | id_usize(b64.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error: aborting due to 52 previous errors error: aborting due to 52 previous errors

View file

@ -7,7 +7,7 @@ LL | foo(1*(1 as isize));
help: you can convert an `isize` to an `i16` and panic if the converted value doesn't fit help: you can convert an `isize` to an `i16` and panic if the converted value doesn't fit
| |
LL | foo((1*(1 as isize)).try_into().unwrap()); LL | foo((1*(1 as isize)).try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | + +++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/issue-13359.rs:10:9 --> $DIR/issue-13359.rs:10:9
@ -18,7 +18,7 @@ LL | bar(1*(1 as usize));
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
| |
LL | bar((1*(1 as usize)).try_into().unwrap()); LL | bar((1*(1 as usize)).try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | + +++++++++++++++++++++
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -9,7 +9,7 @@ LL | let x: u32 = 20i32;
help: change the type of the numeric literal from `i32` to `u32` help: change the type of the numeric literal from `i32` to `u32`
| |
LL | let x: u32 = 20u32; LL | let x: u32 = 20u32;
| ~~~~~ | ~~~
error: aborting due to previous error error: aborting due to previous error

View file

@ -7,7 +7,7 @@ LL | println!("{}", foo(10i32));
help: change the type of the numeric literal from `i32` to `u32` help: change the type of the numeric literal from `i32` to `u32`
| |
LL | println!("{}", foo(10u32)); LL | println!("{}", foo(10u32));
| ~~~~~ | ~~~
error: aborting due to previous error error: aborting due to previous error

View file

@ -7,7 +7,7 @@ LL | A = 1i64,
help: change the type of the numeric literal from `i64` to `isize` help: change the type of the numeric literal from `i64` to `isize`
| |
LL | A = 1isize, LL | A = 1isize,
| ~~~~~~ | ~~~~~
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/issue-8761.rs:5:9 --> $DIR/issue-8761.rs:5:9
@ -18,7 +18,7 @@ LL | B = 2u8
help: change the type of the numeric literal from `u8` to `isize` help: change the type of the numeric literal from `u8` to `isize`
| |
LL | B = 2isize LL | B = 2isize
| ~~~~~~ | ~~~~~
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -9,7 +9,7 @@ LL | let x: u32 = 22_usize;
help: change the type of the numeric literal from `usize` to `u32` help: change the type of the numeric literal from `usize` to `u32`
| |
LL | let x: u32 = 22_u32; LL | let x: u32 = 22_u32;
| ~~~~~~ | ~~~
error: aborting due to previous error error: aborting due to previous error

View file

@ -9,7 +9,7 @@ LL | let x: u32 = 22_usize;
help: change the type of the numeric literal from `usize` to `u32` help: change the type of the numeric literal from `usize` to `u32`
| |
LL | let x: u32 = 22_u32; LL | let x: u32 = 22_u32;
| ~~~~~~ | ~~~
error: aborting due to previous error error: aborting due to previous error

View file

@ -17,7 +17,7 @@ LL | let y: usize = x.foo();
help: you can convert an `isize` to a `usize` and panic if the converted value doesn't fit help: you can convert an `isize` to a `usize` and panic if the converted value doesn't fit
| |
LL | let y: usize = x.foo().try_into().unwrap(); LL | let y: usize = x.foo().try_into().unwrap();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -11,7 +11,7 @@ LL | write!(hello);
help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit
| |
LL | ($arr.len() * size_of($arr[0])).try_into().unwrap()); LL | ($arr.len() * size_of($arr[0])).try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | + +++++++++++++++++++++
error[E0605]: non-primitive cast: `{integer}` as `()` error[E0605]: non-primitive cast: `{integer}` as `()`
--> $DIR/issue-26480.rs:22:19 --> $DIR/issue-26480.rs:22:19

View file

@ -7,7 +7,7 @@ LL | foo(1u8);
help: change the type of the numeric literal from `u8` to `u16` help: change the type of the numeric literal from `u8` to `u16`
| |
LL | foo(1u16); LL | foo(1u16);
| ~~~~ | ~~~
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/numeric-literal-cast.rs:8:10 --> $DIR/numeric-literal-cast.rs:8:10
@ -18,7 +18,7 @@ LL | foo1(2f32);
help: change the type of the numeric literal from `f32` to `f64` help: change the type of the numeric literal from `f32` to `f64`
| |
LL | foo1(2f64); LL | foo1(2f64);
| ~~~~ | ~~~
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/numeric-literal-cast.rs:10:10 --> $DIR/numeric-literal-cast.rs:10:10
@ -29,7 +29,7 @@ LL | foo2(3i16);
help: change the type of the numeric literal from `i16` to `i32` help: change the type of the numeric literal from `i16` to `i32`
| |
LL | foo2(3i32); LL | foo2(3i32);
| ~~~~ | ~~~
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View file

@ -7,7 +7,7 @@ LL | const C: i32 = 1i8;
help: change the type of the numeric literal from `i8` to `i32` help: change the type of the numeric literal from `i8` to `i32`
| |
LL | const C: i32 = 1i32; LL | const C: i32 = 1i32;
| ~~~~ | ~~~
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/const-scope.rs:2:15 --> $DIR/const-scope.rs:2:15
@ -26,7 +26,7 @@ LL | let c: i32 = 1i8;
help: change the type of the numeric literal from `i8` to `i32` help: change the type of the numeric literal from `i8` to `i32`
| |
LL | let c: i32 = 1i32; LL | let c: i32 = 1i32;
| ~~~~ | ~~~
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/const-scope.rs:6:17 --> $DIR/const-scope.rs:6:17
@ -47,7 +47,7 @@ LL | let c: i32 = 1i8;
help: change the type of the numeric literal from `i8` to `i32` help: change the type of the numeric literal from `i8` to `i32`
| |
LL | let c: i32 = 1i32; LL | let c: i32 = 1i32;
| ~~~~ | ~~~
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/const-scope.rs:11:17 --> $DIR/const-scope.rs:11:17
@ -60,7 +60,7 @@ LL | let d: i8 = c;
help: you can convert an `i32` to an `i8` and panic if the converted value doesn't fit help: you can convert an `i32` to an `i8` and panic if the converted value doesn't fit
| |
LL | let d: i8 = c.try_into().unwrap(); LL | let d: i8 = c.try_into().unwrap();
| ~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error: aborting due to 6 previous errors error: aborting due to 6 previous errors

View file

@ -7,7 +7,7 @@ LL | test(array.len());
help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit
| |
LL | test(array.len().try_into().unwrap()); LL | test(array.len().try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error: aborting due to previous error error: aborting due to previous error

View file

@ -9,27 +9,33 @@ LL | let x: u16 = foo();
help: you can convert an `i32` to a `u16` and panic if the converted value doesn't fit help: you can convert an `i32` to a `u16` and panic if the converted value doesn't fit
| |
LL | let x: u16 = foo().try_into().unwrap(); LL | let x: u16 = foo().try_into().unwrap();
| ~~~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/numeric-cast-2.rs:7:18 --> $DIR/numeric-cast-2.rs:7:18
| |
LL | let y: i64 = x + x; LL | let y: i64 = x + x;
| --- ^^^^^ | --- ^^^^^ expected `i64`, found `u16`
| | | | |
| | expected `i64`, found `u16`
| | help: you can convert a `u16` to an `i64`: `(x + x).into()`
| expected due to this | expected due to this
|
help: you can convert a `u16` to an `i64`
|
LL | let y: i64 = (x + x).into();
| + ++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/numeric-cast-2.rs:9:18 --> $DIR/numeric-cast-2.rs:9:18
| |
LL | let z: i32 = x + x; LL | let z: i32 = x + x;
| --- ^^^^^ | --- ^^^^^ expected `i32`, found `u16`
| | | | |
| | expected `i32`, found `u16`
| | help: you can convert a `u16` to an `i32`: `(x + x).into()`
| expected due to this | expected due to this
|
help: you can convert a `u16` to an `i32`
|
LL | let z: i32 = (x + x).into();
| + ++++++++
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

File diff suppressed because it is too large Load diff

View file

@ -47,7 +47,7 @@ LL | x_u8 > -1_isize;
help: you can convert `x_u8` from `u8` to `isize`, matching the type of `-1_isize` help: you can convert `x_u8` from `u8` to `isize`, matching the type of `-1_isize`
| |
LL | isize::from(x_u8) > -1_isize; LL | isize::from(x_u8) > -1_isize;
| ~~~~~~~~~~~~~~~~~ | ++++++++++++ +
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/numeric-cast-no-fix.rs:23:15 --> $DIR/numeric-cast-no-fix.rs:23:15
@ -74,7 +74,7 @@ LL | x_u64 > -1_i128;
help: you can convert `x_u64` from `u64` to `i128`, matching the type of `-1_i128` help: you can convert `x_u64` from `u64` to `i128`, matching the type of `-1_i128`
| |
LL | i128::from(x_u64) > -1_i128; LL | i128::from(x_u64) > -1_i128;
| ~~~~~~~~~~~~~~~~~ | +++++++++++ +
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/numeric-cast-no-fix.rs:29:13 --> $DIR/numeric-cast-no-fix.rs:29:13
@ -85,7 +85,7 @@ LL | x_u32 > -1_i128;
help: you can convert `x_u32` from `u32` to `i128`, matching the type of `-1_i128` help: you can convert `x_u32` from `u32` to `i128`, matching the type of `-1_i128`
| |
LL | i128::from(x_u32) > -1_i128; LL | i128::from(x_u32) > -1_i128;
| ~~~~~~~~~~~~~~~~~ | +++++++++++ +
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/numeric-cast-no-fix.rs:31:13 --> $DIR/numeric-cast-no-fix.rs:31:13
@ -96,7 +96,7 @@ LL | x_u16 > -1_i128;
help: you can convert `x_u16` from `u16` to `i128`, matching the type of `-1_i128` help: you can convert `x_u16` from `u16` to `i128`, matching the type of `-1_i128`
| |
LL | i128::from(x_u16) > -1_i128; LL | i128::from(x_u16) > -1_i128;
| ~~~~~~~~~~~~~~~~~ | +++++++++++ +
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/numeric-cast-no-fix.rs:33:12 --> $DIR/numeric-cast-no-fix.rs:33:12
@ -107,7 +107,7 @@ LL | x_u8 > -1_i128;
help: you can convert `x_u8` from `u8` to `i128`, matching the type of `-1_i128` help: you can convert `x_u8` from `u8` to `i128`, matching the type of `-1_i128`
| |
LL | i128::from(x_u8) > -1_i128; LL | i128::from(x_u8) > -1_i128;
| ~~~~~~~~~~~~~~~~ | +++++++++++ +
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/numeric-cast-no-fix.rs:36:15 --> $DIR/numeric-cast-no-fix.rs:36:15
@ -142,7 +142,7 @@ LL | x_u32 > -1_i64;
help: you can convert `x_u32` from `u32` to `i64`, matching the type of `-1_i64` help: you can convert `x_u32` from `u32` to `i64`, matching the type of `-1_i64`
| |
LL | i64::from(x_u32) > -1_i64; LL | i64::from(x_u32) > -1_i64;
| ~~~~~~~~~~~~~~~~ | ++++++++++ +
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/numeric-cast-no-fix.rs:44:13 --> $DIR/numeric-cast-no-fix.rs:44:13
@ -153,7 +153,7 @@ LL | x_u16 > -1_i64;
help: you can convert `x_u16` from `u16` to `i64`, matching the type of `-1_i64` help: you can convert `x_u16` from `u16` to `i64`, matching the type of `-1_i64`
| |
LL | i64::from(x_u16) > -1_i64; LL | i64::from(x_u16) > -1_i64;
| ~~~~~~~~~~~~~~~~ | ++++++++++ +
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/numeric-cast-no-fix.rs:46:12 --> $DIR/numeric-cast-no-fix.rs:46:12
@ -164,7 +164,7 @@ LL | x_u8 > -1_i64;
help: you can convert `x_u8` from `u8` to `i64`, matching the type of `-1_i64` help: you can convert `x_u8` from `u8` to `i64`, matching the type of `-1_i64`
| |
LL | i64::from(x_u8) > -1_i64; LL | i64::from(x_u8) > -1_i64;
| ~~~~~~~~~~~~~~~ | ++++++++++ +
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/numeric-cast-no-fix.rs:49:15 --> $DIR/numeric-cast-no-fix.rs:49:15
@ -207,7 +207,7 @@ LL | x_u16 > -1_i32;
help: you can convert `x_u16` from `u16` to `i32`, matching the type of `-1_i32` help: you can convert `x_u16` from `u16` to `i32`, matching the type of `-1_i32`
| |
LL | i32::from(x_u16) > -1_i32; LL | i32::from(x_u16) > -1_i32;
| ~~~~~~~~~~~~~~~~ | ++++++++++ +
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/numeric-cast-no-fix.rs:59:12 --> $DIR/numeric-cast-no-fix.rs:59:12
@ -218,7 +218,7 @@ LL | x_u8 > -1_i32;
help: you can convert `x_u8` from `u8` to `i32`, matching the type of `-1_i32` help: you can convert `x_u8` from `u8` to `i32`, matching the type of `-1_i32`
| |
LL | i32::from(x_u8) > -1_i32; LL | i32::from(x_u8) > -1_i32;
| ~~~~~~~~~~~~~~~ | ++++++++++ +
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/numeric-cast-no-fix.rs:62:15 --> $DIR/numeric-cast-no-fix.rs:62:15
@ -269,7 +269,7 @@ LL | x_u8 > -1_i16;
help: you can convert `x_u8` from `u8` to `i16`, matching the type of `-1_i16` help: you can convert `x_u8` from `u8` to `i16`, matching the type of `-1_i16`
| |
LL | i16::from(x_u8) > -1_i16; LL | i16::from(x_u8) > -1_i16;
| ~~~~~~~~~~~~~~~ | ++++++++++ +
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/numeric-cast-no-fix.rs:75:15 --> $DIR/numeric-cast-no-fix.rs:75:15

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -38,15 +38,15 @@ LL | fn fizz(i32) {}
help: if this is a `self` type, give it a parameter name help: if this is a `self` type, give it a parameter name
| |
LL | fn fizz(self: i32) {} LL | fn fizz(self: i32) {}
| ~~~~~~~~~ | +++++
help: if this is a parameter name, give it a type help: if this is a parameter name, give it a type
| |
LL | fn fizz(i32: TypeName) {} LL | fn fizz(i32: TypeName) {}
| ~~~~~~~~~~~~~ | ++++++++++
help: if this is a type, explicitly ignore the parameter name help: if this is a type, explicitly ignore the parameter name
| |
LL | fn fizz(_: i32) {} LL | fn fizz(_: i32) {}
| ~~~~~~ | ++
error: expected one of `:`, `@`, or `|`, found `S` error: expected one of `:`, `@`, or `|`, found `S`
--> $DIR/inverted-parameters.rs:27:23 --> $DIR/inverted-parameters.rs:27:23

View file

@ -13,16 +13,16 @@ LL | fn test(&'a str) {
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685) = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
help: if this is a `self` type, give it a parameter name help: if this is a `self` type, give it a parameter name
| |
LL | fn test(self: &str) { LL | fn test(self: &'a str) {
| ~~~~~~~~~~ | +++++
help: if this is a parameter name, give it a type help: if this is a parameter name, give it a type
| |
LL | fn test(str: &TypeName) { LL | fn test(str: &TypeName) {
| ~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~
help: if this is a type, explicitly ignore the parameter name help: if this is a type, explicitly ignore the parameter name
| |
LL | fn test(_: &str) { LL | fn test(_: &'a str) {
| ~~~~~~~ | ++
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -8,15 +8,15 @@ LL | fn foo(x) {
help: if this is a `self` type, give it a parameter name help: if this is a `self` type, give it a parameter name
| |
LL | fn foo(self: x) { LL | fn foo(self: x) {
| ~~~~~~~ | +++++
help: if this is a parameter name, give it a type help: if this is a parameter name, give it a type
| |
LL | fn foo(x: TypeName) { LL | fn foo(x: TypeName) {
| ~~~~~~~~~~~ | ++++++++++
help: if this is a type, explicitly ignore the parameter name help: if this is a type, explicitly ignore the parameter name
| |
LL | fn foo(_: x) { LL | fn foo(_: x) {
| ~~~~ | ++
error: aborting due to previous error error: aborting due to previous error

View file

@ -8,11 +8,11 @@ LL | fn a(B<) {}
help: if this is a `self` type, give it a parameter name help: if this is a `self` type, give it a parameter name
| |
LL | fn a(self: B<) {} LL | fn a(self: B<) {}
| ~~~~~~~ | +++++
help: if this is a type, explicitly ignore the parameter name help: if this is a type, explicitly ignore the parameter name
| |
LL | fn a(_: B<) {} LL | fn a(_: B<) {}
| ~~~~ | ++
error: aborting due to previous error error: aborting due to previous error

View file

@ -7,7 +7,7 @@ LL | let_in(3u32, |i| { assert!(i == 3i32); });
help: change the type of the numeric literal from `i32` to `u32` help: change the type of the numeric literal from `i32` to `u32`
| |
LL | let_in(3u32, |i| { assert!(i == 3u32); }); LL | let_in(3u32, |i| { assert!(i == 3u32); });
| ~~~~ | ~~~
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/pptypedef.rs:8:37 --> $DIR/pptypedef.rs:8:37
@ -18,7 +18,7 @@ LL | let_in(3i32, |i| { assert!(i == 3u32); });
help: change the type of the numeric literal from `u32` to `i32` help: change the type of the numeric literal from `u32` to `i32`
| |
LL | let_in(3i32, |i| { assert!(i == 3i32); }); LL | let_in(3i32, |i| { assert!(i == 3i32); });
| ~~~~ | ~~~
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -18,7 +18,7 @@ LL | Some(x) => { return x },
help: you can convert an `isize` to a `usize` and panic if the converted value doesn't fit help: you can convert an `isize` to a `usize` and panic if the converted value doesn't fit
| |
LL | Some(x) => { return x.try_into().unwrap() }, LL | Some(x) => { return x.try_into().unwrap() },
| ~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/span-preservation.rs:33:22 --> $DIR/span-preservation.rs:33:22

View file

@ -61,7 +61,7 @@ LL | let f = [0; 4u8];
help: change the type of the numeric literal from `u8` to `usize` help: change the type of the numeric literal from `u8` to `usize`
| |
LL | let f = [0; 4usize]; LL | let f = [0; 4usize];
| ~~~~~~ | ~~~~~
error: aborting due to 9 previous errors error: aborting due to 9 previous errors

View file

@ -8,15 +8,15 @@ LL | trait Trait2015 { fn foo(#[allow(C)] i32); }
help: if this is a `self` type, give it a parameter name help: if this is a `self` type, give it a parameter name
| |
LL | trait Trait2015 { fn foo(#[allow(C)] self: i32); } LL | trait Trait2015 { fn foo(#[allow(C)] self: i32); }
| ~~~~~~~~~ | +++++
help: if this is a parameter name, give it a type help: if this is a parameter name, give it a type
| |
LL | trait Trait2015 { fn foo(#[allow(C)] i32: TypeName); } LL | trait Trait2015 { fn foo(#[allow(C)] i32: TypeName); }
| ~~~~~~~~~~~~~ | ++++++++++
help: if this is a type, explicitly ignore the parameter name help: if this is a type, explicitly ignore the parameter name
| |
LL | trait Trait2015 { fn foo(#[allow(C)] _: i32); } LL | trait Trait2015 { fn foo(#[allow(C)] _: i32); }
| ~~~~~~ | ++
error: aborting due to previous error error: aborting due to previous error

View file

@ -33,7 +33,7 @@ LL | let _: i32 = 22_i64 >> 1_i32;
help: you can convert an `i64` to an `i32` and panic if the converted value doesn't fit help: you can convert an `i64` to an `i32` and panic if the converted value doesn't fit
| |
LL | let _: i32 = (22_i64 >> 1_i32).try_into().unwrap(); LL | let _: i32 = (22_i64 >> 1_i32).try_into().unwrap();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | + +++++++++++++++++++++
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View file

@ -8,11 +8,11 @@ LL | fn foo(Option<i32>, String) {}
help: if this is a `self` type, give it a parameter name help: if this is a `self` type, give it a parameter name
| |
LL | fn foo(self: Option<i32>, String) {} LL | fn foo(self: Option<i32>, String) {}
| ~~~~~~~~~~~~ | +++++
help: if this is a type, explicitly ignore the parameter name help: if this is a type, explicitly ignore the parameter name
| |
LL | fn foo(_: Option<i32>, String) {} LL | fn foo(_: Option<i32>, String) {}
| ~~~~~~~~~ | ++
error: expected one of `:`, `@`, or `|`, found `)` error: expected one of `:`, `@`, or `|`, found `)`
--> $DIR/issue-34264.rs:1:27 --> $DIR/issue-34264.rs:1:27
@ -24,11 +24,11 @@ LL | fn foo(Option<i32>, String) {}
help: if this is a parameter name, give it a type help: if this is a parameter name, give it a type
| |
LL | fn foo(Option<i32>, String: TypeName) {} LL | fn foo(Option<i32>, String: TypeName) {}
| ~~~~~~~~~~~~~~~~ | ++++++++++
help: if this is a type, explicitly ignore the parameter name help: if this is a type, explicitly ignore the parameter name
| |
LL | fn foo(Option<i32>, _: String) {} LL | fn foo(Option<i32>, _: String) {}
| ~~~~~~~~~ | ++
error: expected one of `:`, `@`, or `|`, found `,` error: expected one of `:`, `@`, or `|`, found `,`
--> $DIR/issue-34264.rs:3:9 --> $DIR/issue-34264.rs:3:9
@ -40,15 +40,15 @@ LL | fn bar(x, y: usize) {}
help: if this is a `self` type, give it a parameter name help: if this is a `self` type, give it a parameter name
| |
LL | fn bar(self: x, y: usize) {} LL | fn bar(self: x, y: usize) {}
| ~~~~~~~ | +++++
help: if this is a parameter name, give it a type help: if this is a parameter name, give it a type
| |
LL | fn bar(x: TypeName, y: usize) {} LL | fn bar(x: TypeName, y: usize) {}
| ~~~~~~~~~~~ | ++++++++++
help: if this is a type, explicitly ignore the parameter name help: if this is a type, explicitly ignore the parameter name
| |
LL | fn bar(_: x, y: usize) {} LL | fn bar(_: x, y: usize) {}
| ~~~~ | ++
error[E0061]: this function takes 2 arguments but 3 arguments were supplied error[E0061]: this function takes 2 arguments but 3 arguments were supplied
--> $DIR/issue-34264.rs:7:5 --> $DIR/issue-34264.rs:7:5

View file

@ -8,11 +8,11 @@ LL | pub fn foo(Box<Self>) { }
help: if this is a `self` type, give it a parameter name help: if this is a `self` type, give it a parameter name
| |
LL | pub fn foo(self: Box<Self>) { } LL | pub fn foo(self: Box<Self>) { }
| ~~~~~~~~~ | +++++
help: if this is a type, explicitly ignore the parameter name help: if this is a type, explicitly ignore the parameter name
| |
LL | pub fn foo(_: Box<Self>) { } LL | pub fn foo(_: Box<Self>) { }
| ~~~~~~ | ++
error: expected one of `:`, `@`, or `|`, found `<` error: expected one of `:`, `@`, or `|`, found `<`
--> $DIR/issue-64252-self-type.rs:10:15 --> $DIR/issue-64252-self-type.rs:10:15
@ -24,11 +24,11 @@ LL | fn bar(Box<Self>) { }
help: if this is a `self` type, give it a parameter name help: if this is a `self` type, give it a parameter name
| |
LL | fn bar(self: Box<Self>) { } LL | fn bar(self: Box<Self>) { }
| ~~~~~~~~~ | +++++
help: if this is a type, explicitly ignore the parameter name help: if this is a type, explicitly ignore the parameter name
| |
LL | fn bar(_: Box<Self>) { } LL | fn bar(_: Box<Self>) { }
| ~~~~~~ | ++
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -2,19 +2,23 @@ error[E0308]: mismatched types
--> $DIR/type-mismatch-struct-field-shorthand-2.rs:5:19 --> $DIR/type-mismatch-struct-field-shorthand-2.rs:5:19
| |
LL | let _ = RGB { r, g, c }; LL | let _ = RGB { r, g, c };
| ^ | ^ expected `f64`, found `f32`
| | |
| expected `f64`, found `f32` help: you can convert an `f32` to an `f64`
| help: you can convert an `f32` to an `f64`: `r: r.into()` |
LL | let _ = RGB { r: r.into(), g, c };
| ++ +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/type-mismatch-struct-field-shorthand-2.rs:5:22 --> $DIR/type-mismatch-struct-field-shorthand-2.rs:5:22
| |
LL | let _ = RGB { r, g, c }; LL | let _ = RGB { r, g, c };
| ^ | ^ expected `f64`, found `f32`
| | |
| expected `f64`, found `f32` help: you can convert an `f32` to an `f64`
| help: you can convert an `f32` to an `f64`: `g: g.into()` |
LL | let _ = RGB { r, g: g.into(), c };
| ++ +++++++
error[E0560]: struct `RGB` has no field named `c` error[E0560]: struct `RGB` has no field named `c`
--> $DIR/type-mismatch-struct-field-shorthand-2.rs:5:25 --> $DIR/type-mismatch-struct-field-shorthand-2.rs:5:25

View file

@ -2,28 +2,34 @@ error[E0308]: mismatched types
--> $DIR/type-mismatch-struct-field-shorthand.rs:8:19 --> $DIR/type-mismatch-struct-field-shorthand.rs:8:19
| |
LL | let _ = RGB { r, g, b }; LL | let _ = RGB { r, g, b };
| ^ | ^ expected `f64`, found `f32`
| | |
| expected `f64`, found `f32` help: you can convert an `f32` to an `f64`
| help: you can convert an `f32` to an `f64`: `r: r.into()` |
LL | let _ = RGB { r: r.into(), g, b };
| ++ +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/type-mismatch-struct-field-shorthand.rs:8:22 --> $DIR/type-mismatch-struct-field-shorthand.rs:8:22
| |
LL | let _ = RGB { r, g, b }; LL | let _ = RGB { r, g, b };
| ^ | ^ expected `f64`, found `f32`
| | |
| expected `f64`, found `f32` help: you can convert an `f32` to an `f64`
| help: you can convert an `f32` to an `f64`: `g: g.into()` |
LL | let _ = RGB { r, g: g.into(), b };
| ++ +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/type-mismatch-struct-field-shorthand.rs:8:25 --> $DIR/type-mismatch-struct-field-shorthand.rs:8:25
| |
LL | let _ = RGB { r, g, b }; LL | let _ = RGB { r, g, b };
| ^ | ^ expected `f64`, found `f32`
| | |
| expected `f64`, found `f32` help: you can convert an `f32` to an `f64`
| help: you can convert an `f32` to an `f64`: `b: b.into()` |
LL | let _ = RGB { r, g, b: b.into() };
| ++ +++++++
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View file

@ -9,7 +9,7 @@ LL | fn f() -> isize { return g(); }
help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit
| |
LL | fn f() -> isize { return g().try_into().unwrap(); } LL | fn f() -> isize { return g().try_into().unwrap(); }
| ~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error: aborting due to previous error error: aborting due to previous error

View file

@ -7,7 +7,7 @@ LL | test(22i32, 44i32);
help: change the type of the numeric literal from `i32` to `u32` help: change the type of the numeric literal from `i32` to `u32`
| |
LL | test(22i32, 44u32); LL | test(22i32, 44u32);
| ~~~~~ | ~~~
error: aborting due to previous error error: aborting due to previous error

View file

@ -10,7 +10,7 @@ LL | B::get_x()
help: you can convert an `i32` to a `u8` and panic if the converted value doesn't fit help: you can convert an `i32` to a `u8` and panic if the converted value doesn't fit
| |
LL | B::get_x().try_into().unwrap() LL | B::get_x().try_into().unwrap()
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error: aborting due to previous error error: aborting due to previous error

View file

@ -2,10 +2,12 @@ error[E0308]: mismatched types
--> $DIR/tutorial-suffix-inference-test.rs:9:18 --> $DIR/tutorial-suffix-inference-test.rs:9:18
| |
LL | identity_u16(x); LL | identity_u16(x);
| ^ | ^ expected `u16`, found `u8`
| | |
| expected `u16`, found `u8` help: you can convert a `u8` to a `u16`
| help: you can convert a `u8` to a `u16`: `x.into()` |
LL | identity_u16(x.into());
| +++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/tutorial-suffix-inference-test.rs:12:18 --> $DIR/tutorial-suffix-inference-test.rs:12:18
@ -16,7 +18,7 @@ LL | identity_u16(y);
help: you can convert an `i32` to a `u16` and panic if the converted value doesn't fit help: you can convert an `i32` to a `u16` and panic if the converted value doesn't fit
| |
LL | identity_u16(y.try_into().unwrap()); LL | identity_u16(y.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/tutorial-suffix-inference-test.rs:21:18 --> $DIR/tutorial-suffix-inference-test.rs:21:18
@ -27,7 +29,7 @@ LL | identity_u16(a);
help: you can convert an `isize` to a `u16` and panic if the converted value doesn't fit help: you can convert an `isize` to a `u16` and panic if the converted value doesn't fit
| |
LL | identity_u16(a.try_into().unwrap()); LL | identity_u16(a.try_into().unwrap());
| ~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View file

@ -15,7 +15,7 @@ LL | let b: typeof(a) = 1i8;
help: change the type of the numeric literal from `i8` to `u8` help: change the type of the numeric literal from `i8` to `u8`
| |
LL | let b: typeof(a) = 1u8; LL | let b: typeof(a) = 1u8;
| ~~~ | ~~
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -20,7 +20,7 @@ LL | <i32 as Add<i32>>::add(1u32, 2);
help: change the type of the numeric literal from `u32` to `i32` help: change the type of the numeric literal from `u32` to `i32`
| |
LL | <i32 as Add<i32>>::add(1i32, 2); LL | <i32 as Add<i32>>::add(1i32, 2);
| ~~~~ | ~~~
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/ufcs-qpath-self-mismatch.rs:8:31 --> $DIR/ufcs-qpath-self-mismatch.rs:8:31
@ -31,7 +31,7 @@ LL | <i32 as Add<i32>>::add(1, 2u32);
help: change the type of the numeric literal from `u32` to `i32` help: change the type of the numeric literal from `u32` to `i32`
| |
LL | <i32 as Add<i32>>::add(1, 2i32); LL | <i32 as Add<i32>>::add(1, 2i32);
| ~~~~ | ~~~
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View file

@ -7,7 +7,7 @@ LL | let z = f(1_usize, 2);
help: change the type of the numeric literal from `usize` to `isize` help: change the type of the numeric literal from `usize` to `isize`
| |
LL | let z = f(1_isize, 2); LL | let z = f(1_isize, 2);
| ~~~~~~~ | ~~~~~
error: aborting due to previous error error: aborting due to previous error

View file

@ -9,7 +9,7 @@ LL | fn mk_int() -> usize { let i: isize = 3; return i; }
help: you can convert an `isize` to a `usize` and panic if the converted value doesn't fit help: you can convert an `isize` to a `usize` and panic if the converted value doesn't fit
| |
LL | fn mk_int() -> usize { let i: isize = 3; return i.try_into().unwrap(); } LL | fn mk_int() -> usize { let i: isize = 3; return i.try_into().unwrap(); }
| ~~~~~~~~~~~~~~~~~~~~~ | ++++++++++++++++++++
error: aborting due to previous error error: aborting due to previous error