diff --git a/compiler/rustc_ast/src/util/parser.rs b/compiler/rustc_ast/src/util/parser.rs index 3a0af04f9eb98..3893875e9a405 100644 --- a/compiler/rustc_ast/src/util/parser.rs +++ b/compiler/rustc_ast/src/util/parser.rs @@ -259,7 +259,6 @@ pub enum ExprPrecedence { Assign, AssignOp, - Box, AddrOf, Let, Unary, @@ -319,8 +318,7 @@ impl ExprPrecedence { ExprPrecedence::AssignOp => AssocOp::Assign.precedence() as i8, // Unary, prefix - ExprPrecedence::Box - | ExprPrecedence::AddrOf + ExprPrecedence::AddrOf // Here `let pats = expr` has `let pats =` as a "unary" prefix of `expr`. // However, this is not exactly right. When `let _ = a` is the LHS of a binop we // need parens sometimes. E.g. we can print `(let _ = a) && b` as `let _ = a && b` diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs index 592fc5aa6456f..f4cd10e3b86e9 100644 --- a/compiler/rustc_ast_lowering/src/path.rs +++ b/compiler/rustc_ast_lowering/src/path.rs @@ -286,10 +286,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { segment_ident_span.find_ancestor_inside(path_span).unwrap_or(path_span) } else if generic_args.is_empty() { // If there are brackets, but not generic arguments, then use the opening bracket - generic_args.span.with_hi(generic_args.span.lo() + BytePos(1)) + self.tcx + .mark_span_for_resize(generic_args.span) + .with_hi(generic_args.span.lo() + BytePos(1)) } else { // Else use an empty span right after the opening bracket. - generic_args.span.with_lo(generic_args.span.lo() + BytePos(1)).shrink_to_lo() + self.tcx + .mark_span_for_resize(generic_args.span) + .with_lo(generic_args.span.lo() + BytePos(1)) + .shrink_to_lo() }; generic_args.args.insert_many( diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index f43b611f54eda..2a3b8ff7169a0 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -2073,12 +2073,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { Ok(string) => { if string.starts_with("async ") { let pos = args_span.lo() + BytePos(6); - (args_span.with_lo(pos).with_hi(pos), "move ") + ( + self.infcx.tcx.mark_span_for_resize(args_span).with_lo(pos).with_hi(pos), + "move ", + ) } else if string.starts_with("async|") { let pos = args_span.lo() + BytePos(5); - (args_span.with_lo(pos).with_hi(pos), " move") + ( + self.infcx.tcx.mark_span_for_resize(args_span).with_lo(pos).with_hi(pos), + " move", + ) } else { - (args_span.shrink_to_lo(), "move ") + (self.infcx.tcx.mark_span_for_resize(args_span).shrink_to_lo(), "move ") } } Err(_) => (args_span, "move || "), diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index 5e4c7292e590d..c049b3abbd357 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -457,7 +457,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { match self.infcx.tcx.sess.source_map().span_to_snippet(span) { Ok(snippet) if snippet.starts_with('*') => { err.span_suggestion_verbose( - span.with_hi(span.lo() + BytePos(1)), + self.infcx.tcx.mark_span_for_resize(span).with_hi(span.lo() + BytePos(1)), "consider removing the dereference here", String::new(), Applicability::MaybeIncorrect, @@ -465,7 +465,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } _ => { err.span_suggestion_verbose( - span.shrink_to_lo(), + self.infcx.tcx.mark_span_for_resize(span).shrink_to_lo(), "consider borrowing here", '&', Applicability::MaybeIncorrect, diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index 905d8c42b28bc..dbf15a3e05fa9 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -255,7 +255,7 @@ fn sccs_info<'cx, 'tcx>( let var_to_origin = infcx.reg_var_to_origin.borrow(); let mut var_to_origin_sorted = var_to_origin.clone().into_iter().collect::>(); - var_to_origin_sorted.sort_by(|a, b| a.0.cmp(&b.0)); + var_to_origin_sorted.sort_by_key(|vto| vto.0); let mut debug_str = "region variables to origins:\n".to_string(); for (reg_var, origin) in var_to_origin_sorted.into_iter() { debug_str.push_str(&format!("{:?}: {:?}\n", reg_var, origin)); @@ -2216,7 +2216,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // is in the same SCC or something. In that case, find what // appears to be the most interesting point to report to the // user via an even more ad-hoc guess. - categorized_path.sort_by(|p0, p1| p0.category.cmp(&p1.category)); + categorized_path.sort_by_key(|p| p.category); debug!("sorted_path={:#?}", categorized_path); (categorized_path.remove(0), extra_info) diff --git a/compiler/rustc_builtin_macros/src/alloc_error_handler.rs b/compiler/rustc_builtin_macros/src/alloc_error_handler.rs index ac6697232cb82..ff366cc20db60 100644 --- a/compiler/rustc_builtin_macros/src/alloc_error_handler.rs +++ b/compiler/rustc_builtin_macros/src/alloc_error_handler.rs @@ -20,16 +20,16 @@ pub fn expand( // Allow using `#[alloc_error_handler]` on an item statement // FIXME - if we get deref patterns, use them to reduce duplication here - let (item, is_stmt, sig_span) = + let (item, is_stmt, sig) = if let Annotatable::Item(item) = &item && let ItemKind::Fn(fn_kind) = &item.kind { - (item, false, ecx.with_def_site_ctxt(fn_kind.sig.span)) + (item, false, &fn_kind.sig) } else if let Annotatable::Stmt(stmt) = &item && let StmtKind::Item(item) = &stmt.kind && let ItemKind::Fn(fn_kind) = &item.kind { - (item, true, ecx.with_def_site_ctxt(fn_kind.sig.span)) + (item, true, &fn_kind.sig) } else { ecx.sess.parse_sess.span_diagnostic.span_err(item.span(), "alloc_error_handler must be a function"); return vec![orig_item]; @@ -39,10 +39,10 @@ pub fn expand( let span = ecx.with_def_site_ctxt(item.span); // Generate item statements for the allocator methods. - let stmts = thin_vec![generate_handler(ecx, item.ident, span, sig_span)]; + let stmts = thin_vec![generate_handler(ecx, item.ident, span, sig)]; // Generate anonymous constant serving as container for the allocator methods. - let const_ty = ecx.ty(sig_span, TyKind::Tup(ThinVec::new())); + let const_ty = ecx.ty(ecx.with_def_site_ctxt(sig.span), TyKind::Tup(ThinVec::new())); let const_body = ecx.expr_block(ecx.block(span, stmts)); let const_item = ecx.item_const(span, Ident::new(kw::Underscore, span), const_ty, const_body); let const_item = if is_stmt { @@ -59,27 +59,31 @@ pub fn expand( // unsafe fn __rg_oom(size: usize, align: usize) -> ! { // handler(core::alloc::Layout::from_size_align_unchecked(size, align)) // } -fn generate_handler(cx: &ExtCtxt<'_>, handler: Ident, span: Span, sig_span: Span) -> Stmt { +fn generate_handler(cx: &ExtCtxt<'_>, handler: Ident, span: Span, sig: &FnSig) -> Stmt { let usize = cx.path_ident(span, Ident::new(sym::usize, span)); let ty_usize = cx.ty_path(usize); let size = Ident::from_str_and_span("size", span); let align = Ident::from_str_and_span("align", span); + let sig_span = cx.with_def_site_ctxt(sig.span); + let ret_sp = cx.with_def_site_ctxt(sig.decl.output.span()); + + // core::alloc::Layout::from_size_align_unchecked(size, align) let layout_new = cx.std_path(&[sym::alloc, sym::Layout, sym::from_size_align_unchecked]); let layout_new = cx.expr_path(cx.path(span, layout_new)); let layout = cx.expr_call( - span, + cx.with_def_site_ctxt(sig.decl.inputs.get(0).map_or(span, |p| p.span)), layout_new, thin_vec![cx.expr_ident(span, size), cx.expr_ident(span, align)], ); - - let call = cx.expr_call_ident(sig_span, handler, thin_vec![layout]); + let call = + cx.expr(ret_sp, ast::ExprKind::Call(cx.expr_ident(span, handler), thin_vec![layout])); let never = ast::FnRetTy::Ty(cx.ty(span, TyKind::Never)); let params = thin_vec![cx.param(span, size, ty_usize.clone()), cx.param(span, align, ty_usize)]; let decl = cx.fn_decl(params, never); let header = FnHeader { unsafety: Unsafe::Yes(span), ..FnHeader::default() }; - let sig = FnSig { decl, header, span: span }; + let sig = FnSig { decl, header, span }; let body = Some(cx.block_expr(call)); let kind = ItemKind::Fn(Box::new(Fn { diff --git a/compiler/rustc_builtin_macros/src/derive.rs b/compiler/rustc_builtin_macros/src/derive.rs index 2a8dc02849ea7..267d610279e5f 100644 --- a/compiler/rustc_builtin_macros/src/derive.rs +++ b/compiler/rustc_builtin_macros/src/derive.rs @@ -138,7 +138,7 @@ fn report_unexpected_meta_item_lit(sess: &Session, lit: &ast::MetaItemLit) { } _ => "for example, write `#[derive(Debug)]` for `Debug`".to_string(), }; - struct_span_err!(sess, lit.span, E0777, "expected path to a trait, found literal",) + struct_span_err!(sess, lit.span, E0777, "expected path to a trait, found literal") .span_label(lit.span, "not a trait") .help(&help_msg) .emit(); diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 8aa744ce93531..8bb143ed3da8d 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1199,7 +1199,7 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { .and_then(|(lhs, rhs)| rhs.chars().all(char::is_numeric).then_some(lhs)) .unwrap_or(stem); - // GCC can have an optional target prefix. + // GCC/Clang can have an optional target prefix. let flavor = if stem == "emcc" { LinkerFlavor::EmCc } else if stem == "gcc" @@ -1207,7 +1207,9 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { || stem == "g++" || stem.ends_with("-g++") || stem == "clang" + || stem.ends_with("-clang") || stem == "clang++" + || stem.ends_with("-clang++") { LinkerFlavor::from_cli(LinkerFlavorCli::Gcc, &sess.target) } else if stem == "wasm-ld" || stem.ends_with("-wasm-ld") { diff --git a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs index e586720a0d088..6302bf1e2ad02 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs @@ -256,11 +256,17 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> { { let rhs_pos = span.lo() + BytePos::from_usize(eq_idx + 2 + rhs_idx); - let rhs_span = span.with_lo(rhs_pos).with_hi(rhs_pos); + let rhs_span = tcx + .mark_span_for_resize(span) + .with_lo(rhs_pos) + .with_hi(rhs_pos); err.multipart_suggestion( "consider dereferencing here", vec![ - (span.shrink_to_lo(), deref.clone()), + ( + tcx.mark_span_for_resize(span).shrink_to_lo(), + deref.clone(), + ), (rhs_span, deref), ], Applicability::MachineApplicable, diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 9ed8ab67431c0..43718b35c8dc8 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -621,6 +621,10 @@ impl Diagnostic { .map(|(span, snippet)| SubstitutionPart { snippet, span }) .collect::>(); + if !parts.iter().all(|sub| sub.span.can_be_used_for_suggestions()) { + return self; + } + parts.sort_unstable_by_key(|part| part.span); assert!(!parts.is_empty()); @@ -711,6 +715,9 @@ impl Diagnostic { !(sp.is_empty() && suggestion.to_string().is_empty()), "Span must not be empty and have no suggestion" ); + if !sp.can_be_used_for_suggestions() { + return self; + } self.push_suggestion(CodeSuggestion { substitutions: vec![Substitution { parts: vec![SubstitutionPart { snippet: suggestion.to_string(), span: sp }], @@ -774,6 +781,9 @@ impl Diagnostic { !(sp.is_empty() && suggestions.iter().any(|suggestion| suggestion.is_empty())), "Span must not be empty and have no suggestion" ); + if !sp.can_be_used_for_suggestions() { + return self; + } let substitutions = suggestions .into_iter() @@ -799,12 +809,16 @@ impl Diagnostic { ) -> &mut Self { let substitutions = suggestions .into_iter() - .map(|sugg| { + .filter_map(|sugg| { let mut parts = sugg .into_iter() .map(|(span, snippet)| SubstitutionPart { snippet, span }) .collect::>(); + if !parts.iter().all(|sub| sub.span.can_be_used_for_suggestions()) { + return None; + } + parts.sort_unstable_by_key(|part| part.span); assert!(!parts.is_empty()); @@ -819,7 +833,7 @@ impl Diagnostic { "suggestion must not have overlapping parts", ); - Substitution { parts } + Some(Substitution { parts }) }) .collect(); diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 1b2e7b7e083b4..aa835c3f53675 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -10,7 +10,7 @@ use Destination::*; use rustc_span::source_map::SourceMap; -use rustc_span::{FileLines, SourceFile, Span}; +use rustc_span::{DesugaringKind, FileLines, SourceFile, Span}; use crate::snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, Style, StyledString}; use crate::styled_buffer::StyledBuffer; @@ -400,12 +400,13 @@ pub trait Emitter: Translate { // entries we don't want to print, to make sure the indices being // printed are contiguous (or omitted if there's only one entry). let macro_backtrace: Vec<_> = sp.macro_backtrace().collect(); - for (i, trace) in macro_backtrace.iter().rev().enumerate() { - if trace.def_site.is_dummy() { - continue; - } - - if always_backtrace && !matches!(trace.kind, ExpnKind::Inlined) { + for (i, trace) in macro_backtrace.iter().rev().enumerate().filter(|(_, trace)| { + !matches!( + trace.kind, + ExpnKind::Inlined | ExpnKind::Desugaring(DesugaringKind::Resize) + ) && !trace.def_site.is_dummy() + }) { + if always_backtrace { new_labels.push(( trace.def_site, format!( diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index f00a5f24e4545..f4b46b9a131fb 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1673,7 +1673,6 @@ pub struct Expr<'hir> { impl Expr<'_> { pub fn precedence(&self) -> ExprPrecedence { match self.kind { - ExprKind::Box(_) => ExprPrecedence::Box, ExprKind::ConstBlock(_) => ExprPrecedence::ConstBlock, ExprKind::Array(_) => ExprPrecedence::Array, ExprKind::Call(..) => ExprPrecedence::Call, @@ -1763,7 +1762,6 @@ impl Expr<'_> { | ExprKind::Lit(_) | ExprKind::ConstBlock(..) | ExprKind::Unary(..) - | ExprKind::Box(..) | ExprKind::AddrOf(..) | ExprKind::Binary(..) | ExprKind::Yield(..) @@ -1851,7 +1849,6 @@ impl Expr<'_> { | ExprKind::InlineAsm(..) | ExprKind::AssignOp(..) | ExprKind::ConstBlock(..) - | ExprKind::Box(..) | ExprKind::Binary(..) | ExprKind::Yield(..) | ExprKind::DropTemps(..) @@ -1862,8 +1859,7 @@ impl Expr<'_> { /// To a first-order approximation, is this a pattern? pub fn is_approximately_pattern(&self) -> bool { match &self.kind { - ExprKind::Box(_) - | ExprKind::Array(_) + ExprKind::Array(_) | ExprKind::Call(..) | ExprKind::Tup(_) | ExprKind::Lit(_) @@ -1910,8 +1906,6 @@ pub fn is_range_literal(expr: &Expr<'_>) -> bool { #[derive(Debug, HashStable_Generic)] pub enum ExprKind<'hir> { - /// A `box x` expression. - Box(&'hir Expr<'hir>), /// Allow anonymous constants from an inline `const` block ConstBlock(AnonConst), /// An array (e.g., `[a, b, c, d]`). diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index cc0f64017e426..234256ab553c5 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -682,7 +682,6 @@ pub fn walk_anon_const<'v, V: Visitor<'v>>(visitor: &mut V, constant: &'v AnonCo pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>) { visitor.visit_id(expression.hir_id); match expression.kind { - ExprKind::Box(ref subexpression) => visitor.visit_expr(subexpression), ExprKind::Array(subexpressions) => { walk_list!(visitor, visit_expr, subexpressions); } diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 14dc9d8918000..872fec3954b29 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -557,7 +557,7 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) { check_opaque(tcx, id); } DefKind::ImplTraitPlaceholder => { - let parent = tcx.impl_trait_in_trait_parent(id.owner_id.to_def_id()); + let parent = tcx.impl_trait_in_trait_parent_fn(id.owner_id.to_def_id()); // Only check the validity of this opaque type if the function has a default body if let hir::Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Fn(_, hir::TraitFn::Provided(_)), diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index 6e6f8c1533bfe..e1f7a19da071a 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -1351,7 +1351,8 @@ fn compare_number_of_method_arguments<'tcx>( if pos == 0 { arg.span } else { - arg.span.with_lo(trait_m_sig.decl.inputs[0].span.lo()) + tcx.mark_span_for_resize(arg.span) + .with_lo(trait_m_sig.decl.inputs[0].span.lo()) } }) }) @@ -1367,7 +1368,7 @@ fn compare_number_of_method_arguments<'tcx>( if pos == 0 { arg.span } else { - arg.span.with_lo(impl_m_sig.decl.inputs[0].span.lo()) + tcx.mark_span_for_resize(arg.span).with_lo(impl_m_sig.decl.inputs[0].span.lo()) } }) .unwrap_or_else(|| tcx.def_span(impl_m.def_id)); @@ -1464,7 +1465,9 @@ fn compare_synthetic_generics<'tcx>( // in case there are no generics, take the spot between the function name // and the opening paren of the argument list - let new_generics_span = tcx.def_ident_span(impl_def_id)?.shrink_to_hi(); + let new_generics_span = tcx + .mark_span_for_resize(tcx.def_ident_span(impl_def_id)?) + .shrink_to_hi(); // in case there are generics, just replace them let generics_span = impl_m.generics.span.substitute_dummy(new_generics_span); diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index 9acfc1b3d2924..ceca3e634215a 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -220,7 +220,7 @@ fn missing_items_err( let hi = full_impl_span.hi() - BytePos(1); // Point at the place right before the closing brace of the relevant `impl` to suggest // adding the associated item at the end of its body. - let sugg_sp = full_impl_span.with_lo(hi).with_hi(hi); + let sugg_sp = tcx.mark_span_for_resize(full_impl_span).with_lo(hi).with_hi(hi); // Obtain the level of indentation ending in `sugg_sp`. let padding = tcx.sess.source_map().indentation_before(sugg_sp).unwrap_or_else(|| String::new()); diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 71050864ce0c5..4120ad45f6a6b 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1,7 +1,6 @@ use crate::autoderef::Autoderef; use crate::constrained_generic_params::{identify_constrained_generic_params, Parameter}; -use hir::def::DefKind; use rustc_ast as ast; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed}; @@ -1548,16 +1547,27 @@ fn check_return_position_impl_trait_in_trait_bounds<'tcx>( if let Some(assoc_item) = tcx.opt_associated_item(fn_def_id.to_def_id()) && assoc_item.container == ty::AssocItemContainer::TraitContainer { + // FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty): Even with the new lowering + // strategy, we can't just call `check_associated_item` on the new RPITITs, + // because tests like `tests/ui/async-await/in-trait/implied-bounds.rs` will fail. + // That's because we need to check that the bounds of the RPITIT hold using + // the special substs that we create during opaque type lowering, otherwise we're + // getting a bunch of early bound and free regions mixed up... Haven't looked too + // deep into this, though. for arg in fn_output.walk() { if let ty::GenericArgKind::Type(ty) = arg.unpack() - && let ty::Alias(ty::Opaque, proj) = ty.kind() - && tcx.def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder - && tcx.impl_trait_in_trait_parent(proj.def_id) == fn_def_id.to_def_id() + // RPITITs are always eagerly normalized into opaques, so always look for an + // opaque here. + && let ty::Alias(ty::Opaque, opaque_ty) = ty.kind() + && let Some(opaque_def_id) = opaque_ty.def_id.as_local() + && let opaque = tcx.hir().expect_item(opaque_def_id).expect_opaque_ty() + && let hir::OpaqueTyOrigin::FnReturn(source) | hir::OpaqueTyOrigin::AsyncFn(source) = opaque.origin + && source == fn_def_id { - let span = tcx.def_span(proj.def_id); - let bounds = wfcx.tcx().explicit_item_bounds(proj.def_id); + let span = tcx.def_span(opaque_ty.def_id); + let bounds = wfcx.tcx().explicit_item_bounds(opaque_ty.def_id); let wf_obligations = bounds.iter().flat_map(|&(bound, bound_span)| { - let bound = ty::EarlyBinder(bound).subst(tcx, proj.substs); + let bound = ty::EarlyBinder(bound).subst(tcx, opaque_ty.substs); let normalized_bound = wfcx.normalize(span, None, bound); traits::wf::predicate_obligations( wfcx.infcx, diff --git a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs index 7dce29cc0bbe3..df0258ff7a36c 100644 --- a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs +++ b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs @@ -3,7 +3,7 @@ use crate::astconv::AstConv; use rustc_hir as hir; use rustc_infer::traits::util; use rustc_middle::ty::subst::InternalSubsts; -use rustc_middle::ty::{self, ImplTraitInTraitData, Ty, TyCtxt}; +use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::def_id::DefId; use rustc_span::Span; @@ -76,18 +76,26 @@ pub(super) fn explicit_item_bounds( tcx: TyCtxt<'_>, def_id: DefId, ) -> &'_ [(ty::Predicate<'_>, Span)] { - // If the def_id is about an RPITIT, delegate explicit_item_bounds to the opaque_def_id that - // generated the synthesized associate type. - let rpitit_info = if let Some(ImplTraitInTraitData::Trait { opaque_def_id, .. }) = - tcx.opt_rpitit_info(def_id) - { - Some(opaque_def_id) - } else { - None - }; + match tcx.opt_rpitit_info(def_id) { + // RPITIT's bounds are the same as opaque type bounds, but with + // a projection self type. + Some(ty::ImplTraitInTraitData::Trait { opaque_def_id, .. }) => { + let item = tcx.hir().get_by_def_id(opaque_def_id.expect_local()).expect_item(); + let opaque_ty = item.expect_opaque_ty(); + return opaque_type_bounds( + tcx, + opaque_def_id, + opaque_ty.bounds, + tcx.mk_projection(def_id, ty::InternalSubsts::identity_for_item(tcx, def_id)), + item.span, + ); + } + // These should have been fed! + Some(ty::ImplTraitInTraitData::Impl { .. }) => unreachable!(), + None => {} + } - let bounds_def_id = rpitit_info.unwrap_or(def_id); - let hir_id = tcx.hir().local_def_id_to_hir_id(bounds_def_id.expect_local()); + let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local()); match tcx.hir().get(hir_id) { hir::Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Type(bounds, _), @@ -100,12 +108,12 @@ pub(super) fn explicit_item_bounds( .. }) => { let substs = InternalSubsts::identity_for_item(tcx, def_id); - let item_ty = if *in_trait || rpitit_info.is_some() { + let item_ty = if *in_trait && !tcx.lower_impl_trait_in_trait_to_assoc_ty() { tcx.mk_projection(def_id, substs) } else { tcx.mk_opaque(def_id, substs) }; - opaque_type_bounds(tcx, bounds_def_id, bounds, item_ty, *span) + opaque_type_bounds(tcx, def_id, bounds, item_ty, *span) } _ => bug!("item_bounds called on {:?}", def_id), } diff --git a/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs b/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs index cae884ae8fb73..359f3beeaa12b 100644 --- a/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs +++ b/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs @@ -594,7 +594,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { match self.angle_brackets { AngleBrackets::Missing => { - let span = self.path_segment.ident.span; + let span = self.tcx.mark_span_for_resize(self.path_segment.ident.span); // insert a suggestion of the form "Y<'a, 'b>" let sugg = format!("<{}>", suggested_args); @@ -610,11 +610,23 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { AngleBrackets::Available => { let (sugg_span, is_first) = if self.num_provided_lifetime_args() == 0 { - (self.gen_args.span().unwrap().shrink_to_lo(), true) + ( + self.tcx.mark_span_for_resize(self.gen_args.span().unwrap()).shrink_to_lo(), + true, + ) } else { let last_lt = &self.gen_args.args[self.num_provided_lifetime_args() - 1]; - (last_lt.span().shrink_to_hi(), false) + (self.tcx.mark_span_for_resize(last_lt.span()).shrink_to_hi(), false) }; + let path_sp = self.path_segment.ident.span.peel_ctxt(); + if !self.gen_args.args.iter().all(|arg| { + arg.span().can_be_used_for_suggestions() + && arg.span().peel_ctxt().ctxt() == path_sp.ctxt() + }) || !path_sp.can_be_used_for_suggestions() + { + // Do not suggest syntax when macros are involved. (#90557) + return; + } let has_non_lt_args = self.num_provided_type_or_const_args() != 0; let has_bindings = !self.gen_args.bindings.is_empty(); @@ -644,7 +656,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { match self.angle_brackets { AngleBrackets::Missing | AngleBrackets::Implied => { - let span = self.path_segment.ident.span; + let span = self.tcx.mark_span_for_resize(self.path_segment.ident.span); // insert a suggestion of the form "Y" let sugg = format!("<{}>", suggested_args); @@ -658,14 +670,24 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { ); } AngleBrackets::Available => { - let gen_args_span = self.gen_args.span().unwrap(); + let path_sp = self.path_segment.ident.span.peel_ctxt(); + if !self.gen_args.args.iter().all(|arg| { + arg.span().can_be_used_for_suggestions() + && arg.span().peel_ctxt().ctxt() == path_sp.ctxt() + }) || !path_sp.can_be_used_for_suggestions() + { + // Do not suggest syntax when macros are involved. (#90557) + return; + } + let gen_args_span = self.tcx.mark_span_for_resize(self.gen_args.span().unwrap()); let sugg_offset = self.get_lifetime_args_offset() + self.num_provided_type_or_const_args(); let (sugg_span, is_first) = if sugg_offset == 0 { - (gen_args_span.shrink_to_lo(), true) + (self.tcx.mark_span_for_resize(gen_args_span).shrink_to_lo(), true) } else { - let arg_span = self.gen_args.args[sugg_offset - 1].span(); + let arg_span = + self.tcx.mark_span_for_resize(self.gen_args.args[sugg_offset - 1].span()); // If we came here then inferred lifetime's spans can only point // to either the opening bracket or to the space right after. // Both of these spans have an `hi` lower than or equal to the span @@ -770,7 +792,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { && let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) { let sugg = vec![ (self.path_segment.ident.span, format!("{}::{}", snippet, self.path_segment.ident)), - (span.with_lo(self.path_segment.ident.span.hi()), "".to_owned()) + (self.tcx.mark_span_for_resize(span).with_lo(self.path_segment.ident.span.hi()), "".to_owned()) ]; err.multipart_suggestion( @@ -953,11 +975,8 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } } else if remove_entire_generics { let span = self - .path_segment - .args - .unwrap() - .span_ext() - .unwrap() + .tcx + .mark_span_for_resize(self.path_segment.args.unwrap().span_ext().unwrap()) .with_lo(self.path_segment.ident.span.hi()); let msg = format!( diff --git a/compiler/rustc_hir_analysis/src/variance/mod.rs b/compiler/rustc_hir_analysis/src/variance/mod.rs index a8b7699b66750..361e8948e851a 100644 --- a/compiler/rustc_hir_analysis/src/variance/mod.rs +++ b/compiler/rustc_hir_analysis/src/variance/mod.rs @@ -112,10 +112,14 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { match t.kind() { ty::Alias(_, ty::AliasTy { def_id, substs, .. }) - if matches!( - self.tcx.def_kind(*def_id), - DefKind::OpaqueTy | DefKind::ImplTraitPlaceholder - ) => + if matches!(self.tcx.def_kind(*def_id), DefKind::OpaqueTy) => + { + self.visit_opaque(*def_id, substs) + } + // FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty) check whether this is necessary + // at all for RPITITs. + ty::Alias(_, ty::AliasTy { def_id, substs, .. }) + if self.tcx.is_impl_trait_in_trait(*def_id) => { self.visit_opaque(*def_id, substs) } diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index d715b03e40ebf..63ea6c904775f 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -1366,10 +1366,6 @@ impl<'a> State<'a> { self.ibox(INDENT_UNIT); self.ann.pre(self, AnnNode::Expr(expr)); match expr.kind { - hir::ExprKind::Box(expr) => { - self.word_space("Box::new"); - self.print_call_post(std::slice::from_ref(expr)); - } hir::ExprKind::Array(exprs) => { self.print_expr_vec(exprs); } diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs index 6becf4892acb2..ec391ea80f48b 100644 --- a/compiler/rustc_hir_typeck/src/closure.rs +++ b/compiler/rustc_hir_typeck/src/closure.rs @@ -2,7 +2,6 @@ use super::{check_fn, Expectation, FnCtxt, GeneratorTypes}; -use hir::def::DefKind; use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; use rustc_hir::lang_items::LangItem; @@ -715,14 +714,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .subst_iter_copied(self.tcx, substs) .find_map(|(p, s)| get_future_output(p, s))?, ty::Error(_) => return None, - ty::Alias(ty::Projection, proj) - if self.tcx.def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder => - { - self.tcx - .bound_explicit_item_bounds(proj.def_id) - .subst_iter_copied(self.tcx, proj.substs) - .find_map(|(p, s)| get_future_output(p, s))? - } + ty::Alias(ty::Projection, proj) if self.tcx.is_impl_trait_in_trait(proj.def_id) => self + .tcx + .bound_explicit_item_bounds(proj.def_id) + .subst_iter_copied(self.tcx, proj.substs) + .find_map(|(p, s)| get_future_output(p, s))?, _ => span_bug!( self.tcx.def_span(expr_def_id), "async fn generator return type not an inference variable: {ret_ty}" diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index f65f16e317d49..8a7206cecb1ca 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -623,7 +623,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ), ), match &args[..] { - [] => (base.span.shrink_to_hi().with_hi(deref.span.hi()), ")".to_string()), + [] => ( + self.tcx + .mark_span_for_resize(base.span) + .shrink_to_hi() + .with_hi(deref.span.hi()), + ")".to_string(), + ), [first, ..] => (base.span.between(first.span), ", ".to_string()), }, ] @@ -747,8 +753,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "use `?` to coerce and return an appropriate `Err`, and wrap the resulting value \ in `Ok` so the expression remains of type `Result`", vec![ - (expr.span.shrink_to_lo(), "Ok(".to_string()), - (expr.span.shrink_to_hi(), "?)".to_string()), + (self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(), "Ok(".to_string()), + (self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(), "?)".to_string()), ], Applicability::MaybeIncorrect, ); @@ -819,9 +825,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { return false; }; - if let Some(indent) = - self.tcx.sess.source_map().indentation_before(span.shrink_to_lo()) - { + if let Some(indent) = self.tcx.sess.source_map().indentation_before( + self.tcx.mark_span_for_resize(span).shrink_to_lo(), + ) { // Add a semicolon, except after `}`. let semicolon = match self.tcx.sess.source_map().span_to_snippet(span) { @@ -829,7 +835,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { _ => ";", }; err.span_suggestions( - span.shrink_to_hi(), + self.tcx.mark_span_for_resize(span).shrink_to_hi(), "try adding an expression at the end of the block", return_suggestions .into_iter() @@ -907,8 +913,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } vec![ - (expr.span.shrink_to_lo(), format!("{prefix}{variant}{open}")), - (expr.span.shrink_to_hi(), close.to_owned()), + ( + self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(), + format!("{prefix}{variant}{open}"), + ), + (self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(), close.to_owned()), ] }; @@ -992,8 +1001,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.multipart_suggestion( format!("consider calling `{s}::new`"), vec![ - (expr.span.shrink_to_lo(), format!("{path}::new(")), - (expr.span.shrink_to_hi(), format!("){unwrap}")), + (self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(), format!("{path}::new(")), + (self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(), format!("){unwrap}")), ], Applicability::MaybeIncorrect, ); @@ -1247,7 +1256,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { && replace_prefix(&src, "\"", "b\"").is_some() { return Some(( - sp.shrink_to_lo(), + self.tcx.mark_span_for_resize(sp).shrink_to_lo(), "consider adding a leading `b`".to_string(), "b".to_string(), Applicability::MachineApplicable, @@ -1444,7 +1453,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { _ if sp == expr.span => { if let Some(mut steps) = self.deref_steps(checked_ty, expected) { let mut expr = expr.peel_blocks(); - let mut prefix_span = expr.span.shrink_to_lo(); + let mut prefix_span = self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(); let mut remove = String::new(); // Try peeling off any existing `&` and `&mut` to reach our target type @@ -1515,7 +1524,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return None; } else if let Some(expr) = self.maybe_get_block_expr(expr) { // prefix should be empty here.. - (expr.span.shrink_to_lo(), "*".to_string()) + (self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(), "*".to_string()) } else { (prefix_span, format!("{}{}", prefix, "*".repeat(steps))) }; @@ -1572,7 +1581,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // `expr` is a literal field for a struct, only suggest if appropriate if field.is_shorthand { // This is a field literal - sugg.push((field.ident.span.shrink_to_lo(), format!("{}: ", field.ident))); + sugg.push(( + self.tcx.mark_span_for_resize(field.ident.span).shrink_to_lo(), + format!("{}: ", field.ident), + )); } else { // Likely a field was meant, but this field wasn't found. Do not suggest anything. return false; @@ -1628,16 +1640,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); let close_paren = if expr.precedence().order() < PREC_POSTFIX { - sugg.push((expr.span.shrink_to_lo(), "(".to_string())); + sugg.push((self.tcx.mark_span_for_resize(expr.span).shrink_to_lo(), "(".to_string())); ")" } else { "" }; let mut cast_suggestion = sugg.clone(); - cast_suggestion.push((expr.span.shrink_to_hi(), format!("{close_paren} as {expected_ty}"))); + cast_suggestion.push(( + self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(), + format!("{close_paren} as {expected_ty}"), + )); let mut into_suggestion = sugg.clone(); - into_suggestion.push((expr.span.shrink_to_hi(), format!("{close_paren}.into()"))); + into_suggestion.push(( + self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(), + format!("{close_paren}.into()"), + )); let mut suffix_suggestion = sugg.clone(); suffix_suggestion.push(( if matches!( @@ -1691,15 +1709,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "you can convert `{lhs_src}` from `{expected_ty}` to `{checked_ty}`, matching the type of `{src}`", ); let suggestion = vec![ - (lhs_expr.span.shrink_to_lo(), format!("{checked_ty}::from(")), - (lhs_expr.span.shrink_to_hi(), ")".to_string()), + ( + self.tcx.mark_span_for_resize(lhs_expr.span).shrink_to_lo(), + format!("{checked_ty}::from("), + ), + ( + self.tcx.mark_span_for_resize(lhs_expr.span).shrink_to_hi(), + ")".to_string(), + ), ]; (msg, suggestion) } else { let msg = format!("{msg} and panic if the converted value doesn't fit"); let mut suggestion = sugg.clone(); suggestion.push(( - expr.span.shrink_to_hi(), + self.tcx.mark_span_for_resize(expr.span).shrink_to_hi(), format!("{close_paren}.try_into().unwrap()"), )); (msg, suggestion) diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index afef331ec1d93..b2a01ad44a8e5 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -284,7 +284,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let tcx = self.tcx; match expr.kind { - ExprKind::Box(subexpr) => self.check_expr_box(subexpr, expected), ExprKind::Lit(ref lit) => self.check_lit(&lit, expected), ExprKind::Binary(op, lhs, rhs) => self.check_binop(expr, op, lhs, rhs, expected), ExprKind::Assign(lhs, rhs, span) => { @@ -359,16 +358,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - fn check_expr_box(&self, expr: &'tcx hir::Expr<'tcx>, expected: Expectation<'tcx>) -> Ty<'tcx> { - let expected_inner = expected.to_option(self).map_or(NoExpectation, |ty| match ty.kind() { - ty::Adt(def, _) if def.is_box() => Expectation::rvalue_hint(self, ty.boxed_ty()), - _ => NoExpectation, - }); - let referent_ty = self.check_expr_with_expectation(expr, expected_inner); - self.require_type_is_sized(referent_ty, expr.span, traits::SizedBoxType); - self.tcx.mk_box(referent_ty) - } - fn check_expr_unary( &self, unop: hir::UnOp, diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index b9a058d6bba2c..9aa6c7f103f87 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs @@ -356,10 +356,6 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { self.walk_captures(closure); } - hir::ExprKind::Box(ref base) => { - self.consume_expr(base); - } - hir::ExprKind::Yield(value, _) => { self.consume_expr(value); } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 7064ff6538487..33663c4e7dcbe 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -31,7 +31,7 @@ use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::{self, IsSuggestable, Ty}; use rustc_session::Session; use rustc_span::symbol::{kw, Ident}; -use rustc_span::{self, sym, Span}; +use rustc_span::{self, sym, ExpnKind, Span}; use rustc_trait_selection::traits::{self, ObligationCauseCode, SelectionContext}; use std::iter; @@ -496,7 +496,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { hir::ExprKind::MethodCall(path_segment, _, _, span) => { let ident_span = path_segment.ident.span; let ident_span = if let Some(args) = path_segment.args { - ident_span.with_hi(args.span_ext.hi()) + self.tcx.mark_span_for_resize(ident_span).with_hi(args.span_ext.hi()) } else { ident_span }; @@ -706,8 +706,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.multipart_suggestion_verbose( "wrap these arguments in parentheses to construct a tuple", vec![ - (lo.shrink_to_lo(), "(".to_string()), - (hi.shrink_to_hi(), ")".to_string()), + (tcx.mark_span_for_resize(*lo).shrink_to_lo(), "(".to_string()), + (tcx.mark_span_for_resize(*hi).shrink_to_hi(), ")".to_string()), ], Applicability::MachineApplicable, ); @@ -939,12 +939,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut span = provided_span; if span.can_be_used_for_suggestions() { if arg_idx.index() > 0 - && let Some((_, prev)) = provided_arg_tys - .get(ProvidedIdx::from_usize(arg_idx.index() - 1) - ) { - // Include previous comma - span = prev.shrink_to_hi().to(span); - } + && let Some((_, prev)) = provided_arg_tys + .get(ProvidedIdx::from_usize(arg_idx.index() - 1)) + { + // Include previous comma + span = self.tcx.mark_span_for_resize(*prev).shrink_to_hi().to(self.tcx.mark_span_for_resize(span)); + } suggestions.push((span, String::new())); suggestion_text = match suggestion_text { @@ -1186,6 +1186,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Call out where the function is defined self.label_fn_like(&mut err, fn_def_id, callee_ty, None, is_method); + if !suggestions.iter().all(|(sp, _)| { + sp.macro_backtrace().all(|data| !matches!(data.kind, ExpnKind::Macro(..))) + }) { + // We don't want to provide structured suggestions if macros are involved at all. + err.emit(); + return; + } // And add a suggestion block for all of the parameters let suggestion_text = match suggestion_text { SuggestionText::None => None, @@ -1208,7 +1215,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let source_map = self.sess().source_map(); let (mut suggestion, suggestion_span) = if let Some(call_span) = full_call_span.find_ancestor_inside(error_span) { - ("(".to_string(), call_span.shrink_to_hi().to(error_span.shrink_to_hi())) + ( + "(".to_string(), + tcx.mark_span_for_resize(call_span) + .shrink_to_hi() + .to(tcx.mark_span_for_resize(error_span).shrink_to_hi()), + ) } else { ( format!( diff --git a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs index 7c0402b1c7fb8..1eeb7d984ee04 100644 --- a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs +++ b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs @@ -190,7 +190,6 @@ impl<'a, 'tcx> DropRangeVisitor<'a, 'tcx> { // // Some of these may be interesting in the future ExprKind::Path(..) - | ExprKind::Box(..) | ExprKind::ConstBlock(..) | ExprKind::Array(..) | ExprKind::Call(..) @@ -478,7 +477,6 @@ impl<'a, 'tcx> Visitor<'tcx> for DropRangeVisitor<'a, 'tcx> { | ExprKind::AssignOp(..) | ExprKind::Binary(..) | ExprKind::Block(..) - | ExprKind::Box(..) | ExprKind::Cast(..) | ExprKind::Closure { .. } | ExprKind::ConstBlock(..) diff --git a/compiler/rustc_hir_typeck/src/mem_categorization.rs b/compiler/rustc_hir_typeck/src/mem_categorization.rs index 4d3969d28aa2d..9a8d7ca9e3382 100644 --- a/compiler/rustc_hir_typeck/src/mem_categorization.rs +++ b/compiler/rustc_hir_typeck/src/mem_categorization.rs @@ -382,7 +382,6 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { | hir::ExprKind::Struct(..) | hir::ExprKind::Repeat(..) | hir::ExprKind::InlineAsm(..) - | hir::ExprKind::Box(..) | hir::ExprKind::Err(_) => Ok(self.cat_rvalue(expr.hir_id, expr.span, expr_ty)), } } diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index ac4986a577c6d..de1a2e6a577bf 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -359,10 +359,12 @@ impl<'tcx> InferCtxt<'tcx> { pub fn get_impl_future_output_ty(&self, ty: Ty<'tcx>) -> Option> { let (def_id, substs) = match *ty.kind() { ty::Alias(_, ty::AliasTy { def_id, substs, .. }) - if matches!( - self.tcx.def_kind(def_id), - DefKind::OpaqueTy | DefKind::ImplTraitPlaceholder - ) => + if matches!(self.tcx.def_kind(def_id), DefKind::OpaqueTy) => + { + (def_id, substs) + } + ty::Alias(_, ty::AliasTy { def_id, substs, .. }) + if self.tcx.is_impl_trait_in_trait(def_id) => { (def_id, substs) } @@ -1757,8 +1759,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { ) } (true, ty::Alias(ty::Projection, proj)) - if self.tcx.def_kind(proj.def_id) - == DefKind::ImplTraitPlaceholder => + if self.tcx.is_impl_trait_in_trait(proj.def_id) => { let sm = self.tcx.sess.source_map(); let pos = sm.lookup_char_pos(self.tcx.def_span(proj.def_id).lo()); diff --git a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs index b33729d0be5c9..bc1c7e9b33b21 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs @@ -1,7 +1,7 @@ use super::TypeErrCtxt; use rustc_errors::Applicability::{MachineApplicable, MaybeIncorrect}; use rustc_errors::{pluralize, Diagnostic, MultiSpan}; -use rustc_hir::{self as hir, def::DefKind}; +use rustc_hir as hir; use rustc_middle::traits::ObligationCauseCode; use rustc_middle::ty::error::ExpectedFound; use rustc_middle::ty::print::Printer; @@ -75,7 +75,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { diag.note("an associated type was expected, but a different one was found"); } (ty::Param(p), ty::Alias(ty::Projection, proj)) | (ty::Alias(ty::Projection, proj), ty::Param(p)) - if tcx.def_kind(proj.def_id) != DefKind::ImplTraitPlaceholder => + if !tcx.is_impl_trait_in_trait(proj.def_id) => { let p_def_id = tcx .generics_of(body_owner_def_id) @@ -125,7 +125,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { matched_end_of_args = args_span.is_some(); matching_span = args_span .or_else(|| Some(end_of_trait)) - .map(|span| span.shrink_to_hi()); + .map(|span| self.tcx.mark_span_for_resize(span).shrink_to_hi()); break; } } @@ -222,7 +222,7 @@ impl Trait for X { diag.span_label(p_span, "this type parameter"); } } - (ty::Alias(ty::Projection, proj_ty), _) if tcx.def_kind(proj_ty.def_id) != DefKind::ImplTraitPlaceholder => { + (ty::Alias(ty::Projection, proj_ty), _) if !tcx.is_impl_trait_in_trait(proj_ty.def_id) => { self.expected_projection( diag, proj_ty, @@ -231,7 +231,7 @@ impl Trait for X { cause.code(), ); } - (_, ty::Alias(ty::Projection, proj_ty)) if tcx.def_kind(proj_ty.def_id) != DefKind::ImplTraitPlaceholder => { + (_, ty::Alias(ty::Projection, proj_ty)) if !tcx.is_impl_trait_in_trait(proj_ty.def_id) => { let msg = format!( "consider constraining the associated type `{}` to `{}`", values.found, values.expected, diff --git a/compiler/rustc_infer/src/infer/opaque_types.rs b/compiler/rustc_infer/src/infer/opaque_types.rs index ed4bc594d1a54..49f823a47b83d 100644 --- a/compiler/rustc_infer/src/infer/opaque_types.rs +++ b/compiler/rustc_infer/src/infer/opaque_types.rs @@ -3,7 +3,6 @@ use super::{DefineOpaqueTypes, InferResult}; use crate::errors::OpaqueHiddenTypeDiag; use crate::infer::{DefiningAnchor, InferCtxt, InferOk}; use crate::traits; -use hir::def::DefKind; use hir::def_id::{DefId, LocalDefId}; use hir::OpaqueTyOrigin; use rustc_data_structures::sync::Lrc; @@ -478,9 +477,7 @@ where } } - ty::Alias(ty::Projection, proj) - if self.tcx.def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder => - { + ty::Alias(ty::Projection, proj) if self.tcx.is_impl_trait_in_trait(proj.def_id) => { // Skip lifetime parameters that are not captures. let variances = self.tcx.variances_of(proj.def_id); @@ -559,8 +556,7 @@ impl<'tcx> InferCtxt<'tcx> { // FIXME(RPITIT): Don't replace RPITITs with inference vars. ty::Alias(ty::Projection, projection_ty) if !projection_ty.has_escaping_bound_vars() - && tcx.def_kind(projection_ty.def_id) - != DefKind::ImplTraitPlaceholder => + && !tcx.is_impl_trait_in_trait(projection_ty.def_id) => { self.infer_projection( param_env, diff --git a/compiler/rustc_lint/src/methods.rs b/compiler/rustc_lint/src/methods.rs index 3045fc1a4761e..8bd436ff7a9d9 100644 --- a/compiler/rustc_lint/src/methods.rs +++ b/compiler/rustc_lint/src/methods.rs @@ -36,7 +36,7 @@ declare_lint_pass!(TemporaryCStringAsPtr => [TEMPORARY_CSTRING_AS_PTR]); fn in_macro(span: Span) -> bool { if span.from_expansion() { - !matches!(span.ctxt().outer_expn_data().kind, ExpnKind::Desugaring(..)) + !matches!(span.peel_ctxt().ctxt().outer_expn_data().kind, ExpnKind::Desugaring(..)) } else { false } diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 9649ce2c5a771..c778574b2c57b 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1028,7 +1028,7 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) -> | DefKind::InlineConst => true, DefKind::ImplTraitPlaceholder => { - let parent_def_id = tcx.impl_trait_in_trait_parent(def_id.to_def_id()); + let parent_def_id = tcx.impl_trait_in_trait_parent_fn(def_id.to_def_id()); let assoc_item = tcx.associated_item(parent_def_id); match assoc_item.container { // Always encode an RPIT in an impl fn, since it always has a body diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index c61de97d53271..d25dc4c7e0161 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -466,7 +466,7 @@ pub fn struct_lint_level( /// This is used to test whether a lint should not even begin to figure out whether it should /// be reported on the current node. pub fn in_external_macro(sess: &Session, span: Span) -> bool { - let expn_data = span.ctxt().outer_expn_data(); + let expn_data = span.peel_ctxt().ctxt().outer_expn_data(); match expn_data.kind { ExpnKind::Inlined | ExpnKind::Root diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 2cd791574417a..c8860cc55f6b7 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -191,6 +191,7 @@ rustc_queries! { { desc { "determine whether the opaque is a type-alias impl trait" } separate_provide_extern + feedable } query unsizing_params_for_adt(key: DefId) -> &'tcx rustc_index::bit_set::BitSet diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 6231dd9b6f54a..fb3e9cb126317 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -305,8 +305,6 @@ pub enum ObligationCauseCode<'tcx> { SizedReturnType, /// Yield type must be `Sized`. SizedYieldType, - /// Box expression result type must be `Sized`. - SizedBoxType, /// Inline asm operand type must be `Sized`. InlineAsmSized, /// `[expr; N]` requires `type_of(expr): Copy`. diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 04d7de531c26b..e23c0f07e6cff 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -2500,6 +2500,17 @@ impl<'tcx> TyCtxt<'tcx> { .hygienic_eq(def_name.span.ctxt(), self.expn_that_defined(def_parent_def_id)) } + /// This returns a copy of `span` that has a `DesugaringKind::Resize` mark reason. This mark is + /// used to identify `Span`s that have been modified, while also keeping a link to the original + /// `Span` before it was changed. This is used today only to be able to identify `Span`s coming + /// from a proc-macro even when it was modified, to avoid giving spurious suggestions when the + /// `Span` points at an attribute and not user code. + pub fn mark_span_for_resize(self, span: Span) -> Span { + self.with_stable_hashing_context(|hcx| { + span.mark_with_reason(None, rustc_span::DesugaringKind::Resize, span.edition(), hcx) + }) + } + pub fn adjust_ident(self, mut ident: Ident, scope: DefId) -> Ident { ident.span.normalize_to_macros_2_0_and_adjust(self.expn_that_defined(scope)); ident @@ -2552,12 +2563,18 @@ impl<'tcx> TyCtxt<'tcx> { matches!(self.trait_of_item(def_id), Some(trait_id) if self.has_attr(trait_id, sym::const_trait)) } - pub fn impl_trait_in_trait_parent(self, mut def_id: DefId) -> DefId { - while let def_kind = self.def_kind(def_id) && def_kind != DefKind::AssocFn { - debug_assert_eq!(def_kind, DefKind::ImplTraitPlaceholder); - def_id = self.parent(def_id); + pub fn impl_trait_in_trait_parent_fn(self, mut def_id: DefId) -> DefId { + match self.opt_rpitit_info(def_id) { + Some(ImplTraitInTraitData::Trait { fn_def_id, .. }) + | Some(ImplTraitInTraitData::Impl { fn_def_id, .. }) => fn_def_id, + None => { + while let def_kind = self.def_kind(def_id) && def_kind != DefKind::AssocFn { + debug_assert_eq!(def_kind, DefKind::ImplTraitPlaceholder); + def_id = self.parent(def_id); + } + def_id + } } - def_id } pub fn impl_method_has_trait_impl_trait_tys(self, def_id: DefId) -> bool { @@ -2572,6 +2589,10 @@ impl<'tcx> TyCtxt<'tcx> { let Some(trait_item_def_id) = item.trait_item_def_id else { return false; }; + if self.lower_impl_trait_in_trait_to_assoc_ty() { + return !self.associated_items_for_impl_trait_in_trait(trait_item_def_id).is_empty(); + } + // FIXME(RPITIT): This does a somewhat manual walk through the signature // of the trait fn to look for any RPITITs, but that's kinda doing a lot // of work. We can probably remove this when we refactor RPITITs to be diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index b3139d23d36e3..fffdbfc9660bb 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -728,7 +728,7 @@ pub trait PrettyPrinter<'tcx>: } ty::Alias(ty::Projection, ref data) => { if !(self.should_print_verbose() || NO_QUERIES.with(|q| q.get())) - && self.tcx().def_kind(data.def_id) == DefKind::ImplTraitPlaceholder + && self.tcx().is_impl_trait_in_trait(data.def_id) { return self.pretty_print_opaque_impl_type(data.def_id, data.substs); } else { diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 52d114bae3007..4c606b939b25e 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1288,7 +1288,7 @@ impl<'tcx> AliasTy<'tcx> { match tcx.def_kind(self.def_id) { DefKind::AssocTy | DefKind::AssocConst => tcx.parent(self.def_id), DefKind::ImplTraitPlaceholder => { - tcx.parent(tcx.impl_trait_in_trait_parent(self.def_id)) + tcx.parent(tcx.impl_trait_in_trait_parent_fn(self.def_id)) } kind => bug!("expected a projection AliasTy; found {kind:?}"), } diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 9086412c09a1c..cecb8a61aa2f4 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -780,7 +780,6 @@ impl<'tcx> Cx<'tcx> { hir::ExprKind::DropTemps(ref source) => { ExprKind::Use { source: self.mirror_expr(source) } } - hir::ExprKind::Box(ref value) => ExprKind::Box { value: self.mirror_expr(value) }, hir::ExprKind::Array(ref fields) => { ExprKind::Array { fields: self.mirror_exprs(fields) } } diff --git a/compiler/rustc_passes/src/hir_stats.rs b/compiler/rustc_passes/src/hir_stats.rs index 3e0d53029ef99..47e032758f23d 100644 --- a/compiler/rustc_passes/src/hir_stats.rs +++ b/compiler/rustc_passes/src/hir_stats.rs @@ -300,7 +300,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> { record_variants!( (self, e, e.kind, Id::Node(e.hir_id), hir, Expr, ExprKind), [ - Box, ConstBlock, Array, Call, MethodCall, Tup, Binary, Unary, Lit, Cast, Type, + ConstBlock, Array, Call, MethodCall, Tup, Binary, Unary, Lit, Cast, Type, DropTemps, Let, If, Loop, Match, Closure, Block, Assign, AssignOp, Field, Index, Path, AddrOf, Break, Continue, Ret, InlineAsm, Struct, Repeat, Yield, Err ] diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index db9d0dcc30053..36324e6f8da4a 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -473,7 +473,6 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { | hir::ExprKind::Struct(..) | hir::ExprKind::Repeat(..) | hir::ExprKind::InlineAsm(..) - | hir::ExprKind::Box(..) | hir::ExprKind::Type(..) | hir::ExprKind::Err(_) | hir::ExprKind::Path(hir::QPath::TypeRelative(..)) @@ -1059,8 +1058,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.propagate_through_expr(&l, r_succ) } - hir::ExprKind::Box(ref e) - | hir::ExprKind::AddrOf(_, _, ref e) + hir::ExprKind::AddrOf(_, _, ref e) | hir::ExprKind::Cast(ref e, _) | hir::ExprKind::Type(ref e, _) | hir::ExprKind::DropTemps(ref e) @@ -1425,7 +1423,6 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr<'tcx>) { | hir::ExprKind::Closure { .. } | hir::ExprKind::Path(_) | hir::ExprKind::Yield(..) - | hir::ExprKind::Box(..) | hir::ExprKind::Type(..) | hir::ExprKind::Err(_) => {} } diff --git a/compiler/rustc_passes/src/naked_functions.rs b/compiler/rustc_passes/src/naked_functions.rs index c5b5cf7f5a963..f07a64c7c3ca2 100644 --- a/compiler/rustc_passes/src/naked_functions.rs +++ b/compiler/rustc_passes/src/naked_functions.rs @@ -179,8 +179,7 @@ enum ItemKind { impl<'tcx> CheckInlineAssembly<'tcx> { fn check_expr(&mut self, expr: &'tcx hir::Expr<'tcx>, span: Span) { match expr.kind { - ExprKind::Box(..) - | ExprKind::ConstBlock(..) + ExprKind::ConstBlock(..) | ExprKind::Array(..) | ExprKind::Call(..) | ExprKind::MethodCall(..) diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index ef7c68c1a335a..cd67644589846 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -132,7 +132,7 @@ where projection.trait_ref_and_own_substs(tcx) } else { // HACK(RPITIT): Remove this when RPITITs are lowered to regular assoc tys - let def_id = tcx.impl_trait_in_trait_parent(projection.def_id); + let def_id = tcx.impl_trait_in_trait_parent_fn(projection.def_id); let trait_generics = tcx.generics_of(def_id); ( tcx.mk_trait_ref(def_id, projection.substs.truncate_to(tcx, trait_generics)), diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 44a3d4e628ebc..5673fae9e1fdb 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1437,6 +1437,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { suggestion: Option, span: Span, ) -> bool { + if !span.can_be_used_for_suggestions() { + return false; + } let suggestion = match suggestion { None => return false, // We shouldn't suggest underscore. @@ -1444,7 +1447,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { Some(suggestion) => suggestion, }; if let Some(def_span) = suggestion.res.opt_def_id().map(|def_id| self.def_span(def_id)) { - if span.overlaps(def_span) { + if span.overlaps(def_span) || !def_span.can_be_used_for_suggestions() { // Don't suggest typo suggestion for itself like in the following: // error[E0423]: expected function, tuple struct or tuple variant, found struct `X` // --> $DIR/issue-64792-bad-unicode-ctor.rs:3:14 diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index df7681dc4267b..13eb3f99dc047 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -28,7 +28,7 @@ use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::edition::Edition; use rustc_span::hygiene::MacroKind; use rustc_span::symbol::{kw, sym, Ident, Symbol}; -use rustc_span::{BytePos, Span}; +use rustc_span::{BytePos, ExpnKind, Span}; use std::iter; use std::ops::Deref; @@ -212,7 +212,32 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { } } else { let item_span = path.last().unwrap().ident.span; - let (mod_prefix, mod_str, suggestion) = if path.len() == 1 { + let sp = item_span.peel_ctxt(); + let ctxt_kind = sp.ctxt().outer_expn_data().kind; + let (mod_prefix, mod_str, name, mod_label, suggestion) = + if let ExpnKind::Macro(MacroKind::Attr | MacroKind::Bang, name) = ctxt_kind + && sp.parent_callsite().map(|p| (p.lo(), p.hi())) == Some((sp.lo(), sp.hi())) + { + // This span comes from a proc macro and it doesn't point at user code. + ( + String::new(), + format!("the expanded code of procedural macro `{name}`"), + format!("`{path_str}` "), + format!("expanded code of this procedural macro"), + None, + ) + } else if let ExpnKind::Macro(MacroKind::Derive, name) = ctxt_kind + && sp.parent_callsite().map(|p| (p.lo(), p.hi())) == Some((sp.lo(), sp.hi())) + { + // This span comes from a `derive` macro and it doesn't point at user code. + ( + String::new(), + format!("the expanded code of `derive` macro `{name}`"), + format!("`{path_str}` "), + format!("expanded code of this `derive` macro"), + None, + ) + } else if path.len() == 1 { debug!(?self.diagnostic_metadata.current_impl_items); debug!(?self.diagnostic_metadata.current_function); let suggestion = if self.current_trait_ref.is_none() @@ -246,18 +271,22 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { } else { None }; - (String::new(), "this scope".to_string(), suggestion) + let s = "this scope".to_string(); + (String::new(), s.clone(), String::new(), s, suggestion) } else if path.len() == 2 && path[0].ident.name == kw::PathRoot { if self.r.tcx.sess.edition() > Edition::Edition2015 { // In edition 2018 onwards, the `::foo` syntax may only pull from the extern prelude // which overrides all other expectations of item type expected = "crate"; - (String::new(), "the list of imported crates".to_string(), None) + let s = "the list of imported crates".to_string(); + (String::new(), s.clone(), String::new(), s, None) } else { - (String::new(), "the crate root".to_string(), None) + let s = "the crate root".to_string(); + (String::new(), s.clone(), String::new(), s, None) } } else if path.len() == 2 && path[0].ident.name == kw::Crate { - (String::new(), "the crate root".to_string(), None) + let s = "the crate root".to_string(); + (String::new(), s.clone(), String::new(), s, None) } else { let mod_path = &path[..path.len() - 1]; let mod_prefix = match self.resolve_path(mod_path, Some(TypeNS), None) { @@ -265,7 +294,8 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { _ => None, } .map_or_else(String::new, |res| format!("{} ", res.descr())); - (mod_prefix, format!("`{}`", Segment::names_to_string(mod_path)), None) + let s = format!("`{}`", Segment::names_to_string(mod_path)); + (mod_prefix, s.clone(), String::new(), s, None) }; let (fallback_label, suggestion) = if path_str == "async" @@ -289,7 +319,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { } else { suggestion }; - (format!("not found in {mod_str}"), override_suggestion) + (format!("{name}not found in {mod_label}"), override_suggestion) }; BaseError { @@ -454,6 +484,12 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { res: Option, base_error: &BaseError, ) -> (bool, Vec) { + if !span.can_be_used_for_suggestions() { + // If the span comes from a proc-macro, we don't want to provide suggestions for + // importing and using types. We do make it harder on the proc-macro author, but at + // least we don't mislead end-users. + return (false, vec![]); + } // Try to lookup name in more relaxed fashion for better error reporting. let ident = path.last().unwrap().ident; let is_expected = &|res| source.is_expected(res); @@ -2150,7 +2186,9 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { | (Some(Item { kind, .. }), false, _) => { // Likely missing type parameter. if let Some(generics) = kind.generics() { - if span.overlaps(generics.span) { + if span.overlaps(generics.span) + || !generics.span.can_be_used_for_suggestions() + { // Avoid the following: // error[E0405]: cannot find trait `A` in this scope // --> $DIR/typo-suggestion-named-underscore.rs:CC:LL diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index 9f22e9776d4f6..34b4650010074 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -181,7 +181,7 @@ impl LocalExpnId { } pub fn fresh_empty() -> LocalExpnId { - HygieneData::with(|data| { + HygieneData::with_mut(|data| { let expn_id = data.local_expn_data.push(None); let _eid = data.local_expn_hashes.push(ExpnHash(Fingerprint::ZERO)); debug_assert_eq!(expn_id, _eid); @@ -192,7 +192,7 @@ impl LocalExpnId { pub fn fresh(mut expn_data: ExpnData, ctx: impl HashStableContext) -> LocalExpnId { debug_assert_eq!(expn_data.parent.krate, LOCAL_CRATE); let expn_hash = update_disambiguator(&mut expn_data, ctx); - HygieneData::with(|data| { + HygieneData::with_mut(|data| { let expn_id = data.local_expn_data.push(Some(expn_data)); let _eid = data.local_expn_hashes.push(expn_hash); debug_assert_eq!(expn_id, _eid); @@ -221,7 +221,7 @@ impl LocalExpnId { pub fn set_expn_data(self, mut expn_data: ExpnData, ctx: impl HashStableContext) { debug_assert_eq!(expn_data.parent.krate, LOCAL_CRATE); let expn_hash = update_disambiguator(&mut expn_data, ctx); - HygieneData::with(|data| { + HygieneData::with_mut(|data| { let old_expn_data = &mut data.local_expn_data[self]; assert!(old_expn_data.is_none(), "expansion data is reset for an expansion ID"); *old_expn_data = Some(expn_data); @@ -383,10 +383,14 @@ impl HygieneData { } } - pub fn with T>(f: F) -> T { + pub fn with_mut T>(f: F) -> T { with_session_globals(|session_globals| f(&mut session_globals.hygiene_data.borrow_mut())) } + pub fn with T>(f: F) -> T { + with_session_globals(|session_globals| f(&mut session_globals.hygiene_data.borrow())) + } + #[inline] fn local_expn_hash(&self, expn_id: LocalExpnId) -> ExpnHash { self.local_expn_hashes[expn_id] @@ -595,7 +599,7 @@ impl HygieneData { } pub fn clear_syntax_context_map() { - HygieneData::with(|data| data.syntax_context_map = FxHashMap::default()); + HygieneData::with_mut(|data| data.syntax_context_map = FxHashMap::default()); } pub fn walk_chain(span: Span, to: SyntaxContext) -> Span { @@ -619,7 +623,7 @@ pub fn update_dollar_crate_names(mut get_name: impl FnMut(SyntaxContext) -> Symb let range_to_update = len - to_update..len; let names: Vec<_> = range_to_update.clone().map(|idx| get_name(SyntaxContext::from_u32(idx as u32))).collect(); - HygieneData::with(|data| { + HygieneData::with_mut(|data| { range_to_update.zip(names).for_each(|(idx, name)| { data.syntax_context_data[idx].dollar_crate_name = name; }) @@ -683,7 +687,7 @@ impl SyntaxContext { /// Extend a syntax context with a given expansion and transparency. pub(crate) fn apply_mark(self, expn_id: ExpnId, transparency: Transparency) -> SyntaxContext { - HygieneData::with(|data| data.apply_mark(self, expn_id, transparency)) + HygieneData::with_mut(|data| data.apply_mark(self, expn_id, transparency)) } /// Pulls a single mark off of the syntax context. This effectively moves the @@ -802,7 +806,7 @@ impl SyntaxContext { expn_id: ExpnId, glob_span: Span, ) -> Option> { - HygieneData::with(|data| { + HygieneData::with_mut(|data| { if data.adjust(self, expn_id).is_some() { return None; } @@ -878,7 +882,7 @@ impl Span { /// The returned span belongs to the created expansion and has the new properties, /// but its location is inherited from the current span. pub fn fresh_expansion(self, expn_id: LocalExpnId) -> Span { - HygieneData::with(|data| { + HygieneData::with_mut(|data| { self.with_ctxt(data.apply_mark( SyntaxContext::root(), expn_id.to_expn_id(), @@ -1152,6 +1156,10 @@ pub enum DesugaringKind { ForLoop, WhileLoop, Replace, + /// Used to proactively mark `Span`s that have been modified from another `Span`. This allows + /// the diagnostics machinery to be able to detect spans coming from proc-macros that do not + /// point to user code. + Resize, } impl DesugaringKind { @@ -1168,6 +1176,7 @@ impl DesugaringKind { DesugaringKind::ForLoop => "`for` loop", DesugaringKind::WhileLoop => "`while` loop", DesugaringKind::Replace => "drop and replace", + DesugaringKind::Resize => "a resized `Span`", } } } @@ -1253,7 +1262,7 @@ pub struct HygieneDecodeContext { /// Register an expansion which has been decoded from the on-disk-cache for the local crate. pub fn register_local_expn_id(data: ExpnData, hash: ExpnHash) -> ExpnId { - HygieneData::with(|hygiene_data| { + HygieneData::with_mut(|hygiene_data| { let expn_id = hygiene_data.local_expn_data.next_index(); hygiene_data.local_expn_data.push(Some(data)); let _eid = hygiene_data.local_expn_hashes.push(hash); @@ -1276,7 +1285,7 @@ pub fn register_expn_id( ) -> ExpnId { debug_assert!(data.parent == ExpnId::root() || krate == data.parent.krate); let expn_id = ExpnId { krate, local_id }; - HygieneData::with(|hygiene_data| { + HygieneData::with_mut(|hygiene_data| { let _old_data = hygiene_data.foreign_expn_data.insert(expn_id, data); debug_assert!(_old_data.is_none()); let _old_hash = hygiene_data.foreign_expn_hashes.insert(expn_id, hash); @@ -1343,7 +1352,7 @@ pub fn decode_syntax_context SyntaxContext // Allocate and store SyntaxContext id *before* calling the decoder function, // as the SyntaxContextData may reference itself. - let new_ctxt = HygieneData::with(|hygiene_data| { + let new_ctxt = HygieneData::with_mut(|hygiene_data| { let new_ctxt = SyntaxContext(hygiene_data.syntax_context_data.len() as u32); // Push a dummy SyntaxContextData to ensure that nobody else can get the // same ID as us. This will be overwritten after call `decode_Data` @@ -1374,7 +1383,7 @@ pub fn decode_syntax_context SyntaxContext ctxt_data.dollar_crate_name = kw::DollarCrate; // Overwrite the dummy data with our decoded SyntaxContextData - HygieneData::with(|hygiene_data| { + HygieneData::with_mut(|hygiene_data| { let dummy = std::mem::replace( &mut hygiene_data.syntax_context_data[new_ctxt.as_u32() as usize], ctxt_data, @@ -1472,7 +1481,7 @@ fn update_disambiguator(expn_data: &mut ExpnData, mut ctx: impl HashStableContex assert_default_hashing_controls(&ctx, "ExpnData (disambiguator)"); let mut expn_hash = expn_data.hash_expn(&mut ctx); - let disambiguator = HygieneData::with(|data| { + let disambiguator = HygieneData::with_mut(|data| { // If this is the first ExpnData with a given hash, then keep our // disambiguator at 0 (the default u32 value) let disambig = data.expn_data_disambiguators.entry(expn_hash).or_default(); diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 873cd33f6a4f2..c60f6bd49cb98 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -60,7 +60,7 @@ pub mod fatal_error; pub mod profiling; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; -use rustc_data_structures::sync::{Lock, Lrc}; +use rustc_data_structures::sync::{Lock, Lrc, RwLock}; use std::borrow::Cow; use std::cmp::{self, Ordering}; @@ -86,7 +86,7 @@ mod tests; pub struct SessionGlobals { symbol_interner: symbol::Interner, span_interner: Lock, - hygiene_data: Lock, + hygiene_data: RwLock, source_map: Lock>>, } @@ -95,7 +95,7 @@ impl SessionGlobals { SessionGlobals { symbol_interner: symbol::Interner::fresh(), span_interner: Lock::new(span_encoding::SpanInterner::default()), - hygiene_data: Lock::new(hygiene::HygieneData::new(edition)), + hygiene_data: RwLock::new(hygiene::HygieneData::new(edition)), source_map: Lock::new(None), } } @@ -576,7 +576,7 @@ impl Span { /// Returns `true` if this span comes from any kind of macro, desugaring or inlining. #[inline] pub fn from_expansion(self) -> bool { - self.ctxt() != SyntaxContext::root() + self.peel_ctxt().ctxt() != SyntaxContext::root() } /// Returns `true` if `span` originates in a macro's expansion where debuginfo should be @@ -599,12 +599,22 @@ impl Span { /// Gate suggestions that would not be appropriate in a context the user didn't write. pub fn can_be_used_for_suggestions(self) -> bool { - !self.from_expansion() - // FIXME: If this span comes from a `derive` macro but it points at code the user wrote, - // the callsite span and the span will be pointing at different places. It also means that - // we can safely provide suggestions on this span. - || (matches!(self.ctxt().outer_expn_data().kind, ExpnKind::Macro(MacroKind::Derive, _)) - && self.parent_callsite().map(|p| (p.lo(), p.hi())) != Some((self.lo(), self.hi()))) + match self.ctxt().outer_expn_data().kind { + ExpnKind::Root | ExpnKind::AstPass(_) | ExpnKind::Inlined => true, + // FIXME: If this span comes from a `derive` macro but it points at code the user wrote, + // the callsite span and the span will be pointing at different places. It also means that + // we can safely provide suggestions on this span. + ExpnKind::Macro(..) + if self.parent_callsite().map(|p| (p.lo(), p.hi())) + != Some((self.lo(), self.hi())) => + { + true + } + ExpnKind::Desugaring(_) => { + self.parent_callsite().unwrap().can_be_used_for_suggestions() + } + ExpnKind::Macro(..) => false, + } } #[inline] @@ -751,7 +761,7 @@ impl Span { /// Checks if this span arises from a compiler desugaring of kind `kind`. pub fn is_desugaring(self, kind: DesugaringKind) -> bool { - match self.ctxt().outer_expn_data().kind { + match self.peel_ctxt().ctxt().outer_expn_data().kind { ExpnKind::Desugaring(k) => k == kind, _ => false, } @@ -760,7 +770,7 @@ impl Span { /// Returns the compiler desugaring that created this span, or `None` /// if this span is not from a desugaring. pub fn desugaring_kind(self) -> Option { - match self.ctxt().outer_expn_data().kind { + match self.peel_ctxt().ctxt().outer_expn_data().kind { ExpnKind::Desugaring(k) => Some(k), _ => None, } @@ -811,10 +821,10 @@ impl Span { // FIXME(jseyfried): `self.ctxt` should always equal `end.ctxt` here (cf. issue #23480). // Return the macro span on its own to avoid weird diagnostic output. It is preferable to // have an incomplete span than a completely nonsensical one. - if span_data.ctxt != end_data.ctxt { - if span_data.ctxt == SyntaxContext::root() { + if self.peel_ctxt().ctxt() != end.peel_ctxt().ctxt() { + if self.peel_ctxt().ctxt() == SyntaxContext::root() { return end; - } else if end_data.ctxt == SyntaxContext::root() { + } else if end.peel_ctxt().ctxt() == SyntaxContext::root() { return self; } // Both spans fall within a macro. @@ -823,7 +833,11 @@ impl Span { Span::new( cmp::min(span_data.lo, end_data.lo), cmp::max(span_data.hi, end_data.hi), - if span_data.ctxt == SyntaxContext::root() { end_data.ctxt } else { span_data.ctxt }, + if self.peel_ctxt().ctxt() == SyntaxContext::root() { + end_data.ctxt + } else { + span_data.ctxt + }, if span_data.parent == end_data.parent { span_data.parent } else { None }, ) } @@ -836,16 +850,32 @@ impl Span { /// ^^^^^^^^^^^^^ /// ``` pub fn between(self, end: Span) -> Span { - let span = self.data(); - let end = end.data(); + let span_data = self.data(); + let end_data = end.data(); Span::new( - span.hi, - end.lo, - if end.ctxt == SyntaxContext::root() { end.ctxt } else { span.ctxt }, - if span.parent == end.parent { span.parent } else { None }, + span_data.hi, + end_data.lo, + if end.peel_ctxt().ctxt() == SyntaxContext::root() { + end_data.ctxt + } else { + span_data.ctxt + }, + if span_data.parent == end_data.parent { span_data.parent } else { None }, ) } + pub fn peel_ctxt(mut self) -> Span { + loop { + let data = self.data().ctxt.outer_expn_data(); + if let ExpnKind::Desugaring(DesugaringKind::Resize) = data.kind { + self = data.call_site; + } else { + break; + } + } + self + } + /// Returns a `Span` from the beginning of `self` until the beginning of `end`. /// /// ```text @@ -865,9 +895,9 @@ impl Span { // Return the macro span on its own to avoid weird diagnostic output. It is preferable to // have an incomplete span than a completely nonsensical one. if span_data.ctxt != end_data.ctxt { - if span_data.ctxt == SyntaxContext::root() { + if self.peel_ctxt().ctxt() == SyntaxContext::root() { return end; - } else if end_data.ctxt == SyntaxContext::root() { + } else if end.peel_ctxt().ctxt() == SyntaxContext::root() { return self; } // Both spans fall within a macro. @@ -876,7 +906,11 @@ impl Span { Span::new( span_data.lo, end_data.lo, - if end_data.ctxt == SyntaxContext::root() { end_data.ctxt } else { span_data.ctxt }, + if end.peel_ctxt().ctxt() == SyntaxContext::root() { + end_data.ctxt + } else { + span_data.ctxt + }, if span_data.parent == end_data.parent { span_data.parent } else { None }, ) } diff --git a/compiler/rustc_target/src/spec/riscv64gc_unknown_fuchsia.rs b/compiler/rustc_target/src/spec/riscv64gc_unknown_fuchsia.rs index ab7c08958fa88..0585ed76fe815 100644 --- a/compiler/rustc_target/src/spec/riscv64gc_unknown_fuchsia.rs +++ b/compiler/rustc_target/src/spec/riscv64gc_unknown_fuchsia.rs @@ -2,7 +2,7 @@ use crate::spec::{CodeModel, SanitizerSet, Target, TargetOptions}; pub fn target() -> Target { Target { - llvm_target: "riscv64gc-unknown-fuchsia".into(), + llvm_target: "riscv64-unknown-fuchsia".into(), pointer_width: 64, data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(), arch: "riscv64".into(), diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs index 277926688e21d..a9c4e12681635 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs @@ -144,18 +144,22 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { trait_ref: ty::PolyTraitRef<'tcx>, obligation: &PredicateObligation<'tcx>, ) -> OnUnimplementedNote { - if self.tcx.opt_rpitit_info(obligation.cause.body_id.to_def_id()).is_some() { - return OnUnimplementedNote::default(); - } - let (def_id, substs) = self .impl_similar_to(trait_ref, obligation) .unwrap_or_else(|| (trait_ref.def_id(), trait_ref.skip_binder().substs)); let trait_ref = trait_ref.skip_binder(); - let body_hir = self.tcx.hir().local_def_id_to_hir_id(obligation.cause.body_id); - let mut flags = - vec![(sym::ItemContext, self.describe_enclosure(body_hir).map(|s| s.to_owned()))]; + let mut flags = vec![]; + // FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty): HIR is not present for RPITITs, + // but I guess we could synthesize one here. We don't see any errors that rely on + // that yet, though. + let enclosure = + if let Some(body_hir) = self.tcx.opt_local_def_id_to_hir_id(obligation.cause.body_id) { + self.describe_enclosure(body_hir).map(|s| s.to_owned()) + } else { + None + }; + flags.push((sym::ItemContext, enclosure)); match obligation.cause.code() { ObligationCauseCode::BuiltinDerivedObligation(..) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 5541c0850753d..d1efa1f705c57 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -956,7 +956,14 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { .join(", "); if matches!(obligation.cause.code(), ObligationCauseCode::FunctionArgumentObligation { .. }) - && obligation.cause.span.can_be_used_for_suggestions() + && match obligation.cause.span.peel_ctxt().ctxt().outer_expn_data().kind { + ExpnKind::Root + | ExpnKind::AstPass(_) + | ExpnKind::Desugaring(_) + | ExpnKind::Inlined => true, + // When a macro is involved, we don't want to provide a structured suggestion. + ExpnKind::Macro(..) => false, + } { // When the obligation error has been ensured to have been caused by // an argument, the `obligation.cause.span` points at the expression @@ -1242,7 +1249,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { { obligation.cause.code() } else if let ExpnKind::Desugaring(DesugaringKind::ForLoop) = - span.ctxt().outer_expn_data().kind + span.peel_ctxt().ctxt().outer_expn_data().kind { obligation.cause.code() } else { @@ -1317,7 +1324,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // } // ``` if !matches!( - span.ctxt().outer_expn_data().kind, + span.peel_ctxt().ctxt().outer_expn_data().kind, ExpnKind::Root | ExpnKind::Desugaring(DesugaringKind::ForLoop) ) { return false; @@ -2944,9 +2951,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { ObligationCauseCode::SizedYieldType => { err.note("the yield type of a generator must have a statically known size"); } - ObligationCauseCode::SizedBoxType => { - err.note("the type of a box expression must have a statically known size"); - } ObligationCauseCode::AssignmentLhsSized => { err.note("the left-hand-side of an assignment must have a statically known size"); } diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 0f0cccea13075..b8d9cff9c489b 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -1298,7 +1298,7 @@ fn assemble_candidate_for_impl_trait_in_trait<'cx, 'tcx>( ) { let tcx = selcx.tcx(); if tcx.def_kind(obligation.predicate.def_id) == DefKind::ImplTraitPlaceholder { - let trait_fn_def_id = tcx.impl_trait_in_trait_parent(obligation.predicate.def_id); + let trait_fn_def_id = tcx.impl_trait_in_trait_parent_fn(obligation.predicate.def_id); let trait_def_id = tcx.parent(trait_fn_def_id); let trait_substs = @@ -2200,7 +2200,7 @@ fn confirm_impl_trait_in_trait_candidate<'tcx>( let tcx = selcx.tcx(); let mut obligations = data.nested; - let trait_fn_def_id = tcx.impl_trait_in_trait_parent(obligation.predicate.def_id); + let trait_fn_def_id = tcx.impl_trait_in_trait_parent_fn(obligation.predicate.def_id); let leaf_def = match specialization_graph::assoc_def(tcx, data.impl_def_id, trait_fn_def_id) { Ok(assoc_ty) => assoc_ty, Err(guar) => return Progress::error(tcx, guar), diff --git a/compiler/rustc_ty_utils/src/assoc.rs b/compiler/rustc_ty_utils/src/assoc.rs index a28161245384c..68b1086e8e3f5 100644 --- a/compiler/rustc_ty_utils/src/assoc.rs +++ b/compiler/rustc_ty_utils/src/assoc.rs @@ -244,7 +244,7 @@ fn associated_item_for_impl_trait_in_trait( tcx: TyCtxt<'_>, opaque_ty_def_id: LocalDefId, ) -> LocalDefId { - let fn_def_id = tcx.impl_trait_in_trait_parent(opaque_ty_def_id.to_def_id()); + let fn_def_id = tcx.impl_trait_in_trait_parent_fn(opaque_ty_def_id.to_def_id()); let trait_def_id = tcx.parent(fn_def_id); assert_eq!(tcx.def_kind(trait_def_id), DefKind::Trait); @@ -289,8 +289,39 @@ fn associated_item_for_impl_trait_in_trait( InternalSubsts::identity_for_item(tcx, opaque_ty_def_id.to_def_id()), ))); - // Copy generics_of of the opaque. - trait_assoc_ty.generics_of(tcx.generics_of(opaque_ty_def_id).clone()); + trait_assoc_ty.is_type_alias_impl_trait(false); + + // Copy generics_of of the opaque type item but the trait is the parent. + trait_assoc_ty.generics_of({ + let opaque_ty_generics = tcx.generics_of(opaque_ty_def_id); + let opaque_ty_parent_count = opaque_ty_generics.parent_count; + let mut params = opaque_ty_generics.params.clone(); + + let parent_generics = tcx.generics_of(trait_def_id); + let parent_count = parent_generics.parent_count + parent_generics.params.len(); + + let mut trait_fn_params = tcx.generics_of(fn_def_id).params.clone(); + + for param in &mut params { + param.index = param.index + parent_count as u32 + trait_fn_params.len() as u32 + - opaque_ty_parent_count as u32; + } + + trait_fn_params.extend(params); + params = trait_fn_params; + + let param_def_id_to_index = + params.iter().map(|param| (param.def_id, param.index)).collect(); + + ty::Generics { + parent: Some(trait_def_id), + parent_count, + params, + param_def_id_to_index, + has_self: false, + has_late_bound_regions: opaque_ty_generics.has_late_bound_regions, + } + }); // There are no predicates for the synthesized associated type. trait_assoc_ty.explicit_predicates_of(ty::GenericPredicates { diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index d41bf603983c0..9fed1e57c9213 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -117,16 +117,22 @@ fn adt_sized_constraint(tcx: TyCtxt<'_>, def_id: DefId) -> &[Ty<'_>] { /// See `ParamEnv` struct definition for details. fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { - // When computing the param_env of an RPITIT, copy param_env of the containing function. The - // synthesized associated type doesn't have extra predicates to assume. - if let Some(ImplTraitInTraitData::Trait { fn_def_id, .. }) = tcx.opt_rpitit_info(def_id) { - return tcx.param_env(fn_def_id); - } - // Compute the bounds on Self and the type parameters. let ty::InstantiatedPredicates { mut predicates, .. } = tcx.predicates_of(def_id).instantiate_identity(tcx); + // When computing the param_env of an RPITIT, use predicates of the containing function, + // *except* for the additional assumption that the RPITIT normalizes to the trait method's + // default opaque type. This is needed to properly check the item bounds of the assoc + // type hold (`check_type_bounds`), since that method already installs a similar projection + // bound, so they will conflict. + // FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty): I don't like this, we should + // at least be making sure that the generics in RPITITs and their parent fn don't + // get out of alignment, or else we do actually need to substitute these predicates. + if let Some(ImplTraitInTraitData::Trait { fn_def_id, .. }) = tcx.opt_rpitit_info(def_id) { + predicates = tcx.predicates_of(fn_def_id).instantiate_identity(tcx).predicates; + } + // Finally, we have to normalize the bounds in the environment, in // case they contain any associated type projections. This process // can yield errors if the put in illegal associated types, like @@ -160,7 +166,9 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { } let local_did = def_id.as_local(); - let hir_id = local_did.map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id)); + // FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty): This isn't correct for + // RPITITs in const trait fn. + let hir_id = local_did.and_then(|def_id| tcx.opt_local_def_id_to_hir_id(def_id)); // FIXME(consts): This is not exactly in line with the constness query. let constness = match hir_id { @@ -268,8 +276,8 @@ impl<'tcx> TypeVisitor> for ImplTraitInTraitFinder<'_, 'tcx> { fn visit_ty(&mut self, ty: Ty<'tcx>) -> std::ops::ControlFlow { if let ty::Alias(ty::Projection, alias_ty) = *ty.kind() - && self.tcx.def_kind(alias_ty.def_id) == DefKind::ImplTraitPlaceholder - && self.tcx.impl_trait_in_trait_parent(alias_ty.def_id) == self.fn_def_id + && self.tcx.is_impl_trait_in_trait(alias_ty.def_id) + && self.tcx.impl_trait_in_trait_parent_fn(alias_ty.def_id) == self.fn_def_id && self.seen.insert(alias_ty.def_id) { // We have entered some binders as we've walked into the @@ -282,11 +290,24 @@ impl<'tcx> TypeVisitor> for ImplTraitInTraitFinder<'_, 'tcx> { re } }); + + // If we're lowering to associated item, install the opaque type which is just + // the `type_of` of the trait's associated item. If we're using the old lowering + // strategy, then just reinterpret the associated type like an opaque :^) + let default_ty = if self.tcx.lower_impl_trait_in_trait_to_assoc_ty() { + self + .tcx + .type_of(alias_ty.def_id) + .subst(self.tcx, alias_ty.substs) + } else { + self.tcx.mk_alias(ty::Opaque, alias_ty) + }; + self.predicates.push( ty::Binder::bind_with_vars( ty::ProjectionPredicate { projection_ty: alias_ty, - term: self.tcx.mk_alias(ty::Opaque, alias_ty).into(), + term: default_ty.into(), }, self.bound_vars, ) diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 8b80dfc0f9b97..54971af644c28 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -339,6 +339,12 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car "" }; + // `libtest` uses this to know whether or not to support + // `-Zunstable-options`. + if !builder.unstable_features() { + cargo.env("CFG_DISABLE_UNSTABLE_FEATURES", "1"); + } + let mut features = String::new(); // Cranelift doesn't support `asm`. diff --git a/src/doc/unstable-book/src/compiler-flags/sanitizer.md b/src/doc/unstable-book/src/compiler-flags/sanitizer.md index 262cef3454ad3..f2a44840b76b1 100644 --- a/src/doc/unstable-book/src/compiler-flags/sanitizer.md +++ b/src/doc/unstable-book/src/compiler-flags/sanitizer.md @@ -213,7 +213,7 @@ See the [Clang ControlFlowIntegrity documentation][clang-cfi] for more details. ## Example -```text +```rust #![feature(naked_functions)] use std::arch::asm; @@ -223,6 +223,8 @@ fn add_one(x: i32) -> i32 { x + 1 } +# // Only define this function if the assembly works +# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] #[naked] pub extern "C" fn add_two(x: i32) { // x + 2 preceded by a landing pad/nop block @@ -238,7 +240,7 @@ pub extern "C" fn add_two(x: i32) { nop nop nop - lea rax, [rdi+2] + lea eax, [edi+2] ret ", options(noreturn) @@ -250,6 +252,10 @@ fn do_twice(f: fn(i32) -> i32, arg: i32) -> i32 { f(arg) + f(arg) } +# // Can only call add_two on x86/64 +# #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] +# fn main() { println!("this test does not work on this target") } +# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] fn main() { let answer = do_twice(add_one, 5); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 29c3afe0d9560..989e091a0d2d8 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -426,7 +426,7 @@ fn clean_projection<'tcx>( cx: &mut DocContext<'tcx>, def_id: Option, ) -> Type { - if cx.tcx.def_kind(ty.skip_binder().def_id) == DefKind::ImplTraitPlaceholder { + if cx.tcx.is_impl_trait_in_trait(ty.skip_binder().def_id) { let bounds = cx .tcx .explicit_item_bounds(ty.skip_binder().def_id) diff --git a/src/tools/clippy/clippy_lints/src/infinite_iter.rs b/src/tools/clippy/clippy_lints/src/infinite_iter.rs index d1d2db27c6fc0..fe28c526be350 100644 --- a/src/tools/clippy/clippy_lints/src/infinite_iter.rs +++ b/src/tools/clippy/clippy_lints/src/infinite_iter.rs @@ -167,7 +167,7 @@ fn is_infinite(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness { Finite }, ExprKind::Block(block, _) => block.expr.as_ref().map_or(Finite, |e| is_infinite(cx, e)), - ExprKind::Box(e) | ExprKind::AddrOf(BorrowKind::Ref, _, e) => is_infinite(cx, e), + ExprKind::AddrOf(BorrowKind::Ref, _, e) => is_infinite(cx, e), ExprKind::Call(path, _) => { if let ExprKind::Path(ref qpath) = path.kind { cx.qpath_res(qpath, path.hir_id) diff --git a/src/tools/clippy/clippy_lints/src/loops/never_loop.rs b/src/tools/clippy/clippy_lints/src/loops/never_loop.rs index b1bc10802e1b6..f0a1b1dfe5628 100644 --- a/src/tools/clippy/clippy_lints/src/loops/never_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/never_loop.rs @@ -124,8 +124,7 @@ fn stmt_to_expr<'tcx>(stmt: &Stmt<'tcx>) -> Option<(&'tcx Expr<'tcx>, Option<&'t #[allow(clippy::too_many_lines)] fn never_loop_expr(expr: &Expr<'_>, ignore_ids: &mut Vec, main_loop_id: HirId) -> NeverLoopResult { match expr.kind { - ExprKind::Box(e) - | ExprKind::Unary(_, e) + ExprKind::Unary(_, e) | ExprKind::Cast(e, _) | ExprKind::Type(e, _) | ExprKind::Field(e, _) diff --git a/src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs b/src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs index b33a247817292..04225beeb704b 100644 --- a/src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs +++ b/src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs @@ -321,7 +321,6 @@ impl<'a, 'tcx> Visitor<'tcx> for SigDropHelper<'a, 'tcx> { self.has_significant_drop = true; } } - ExprKind::Box(..) | ExprKind::Array(..) | ExprKind::Call(..) | ExprKind::Unary(..) | diff --git a/src/tools/clippy/clippy_lints/src/methods/unnecessary_sort_by.rs b/src/tools/clippy/clippy_lints/src/methods/unnecessary_sort_by.rs index 5201da52bbf1d..67618f7038add 100644 --- a/src/tools/clippy/clippy_lints/src/methods/unnecessary_sort_by.rs +++ b/src/tools/clippy/clippy_lints/src/methods/unnecessary_sort_by.rs @@ -33,10 +33,6 @@ struct SortByKeyDetection { /// contains a and the other replaces it with b) fn mirrored_exprs(a_expr: &Expr<'_>, a_ident: &Ident, b_expr: &Expr<'_>, b_ident: &Ident) -> bool { match (&a_expr.kind, &b_expr.kind) { - // Two boxes with mirrored contents - (ExprKind::Box(left_expr), ExprKind::Box(right_expr)) => { - mirrored_exprs(left_expr, a_ident, right_expr, b_ident) - }, // Two arrays with mirrored contents (ExprKind::Array(left_exprs), ExprKind::Array(right_exprs)) => { iter::zip(*left_exprs, *right_exprs).all(|(left, right)| mirrored_exprs(left, a_ident, right, b_ident)) diff --git a/src/tools/clippy/clippy_lints/src/no_effect.rs b/src/tools/clippy/clippy_lints/src/no_effect.rs index 79c1ae4861e80..e3712190e6722 100644 --- a/src/tools/clippy/clippy_lints/src/no_effect.rs +++ b/src/tools/clippy/clippy_lints/src/no_effect.rs @@ -127,8 +127,7 @@ fn has_no_effect(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { | ExprKind::Type(inner, _) | ExprKind::Unary(_, inner) | ExprKind::Field(inner, _) - | ExprKind::AddrOf(_, _, inner) - | ExprKind::Box(inner) => has_no_effect(cx, inner), + | ExprKind::AddrOf(_, _, inner) => has_no_effect(cx, inner), ExprKind::Struct(_, fields, ref base) => { !has_drop(cx, cx.typeck_results().expr_ty(expr)) && fields.iter().all(|field| has_no_effect(cx, field.expr)) @@ -234,8 +233,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option reduce_expression(cx, inner).or_else(|| Some(vec![inner])), + | ExprKind::AddrOf(_, _, inner) => reduce_expression(cx, inner).or_else(|| Some(vec![inner])), ExprKind::Struct(_, fields, ref base) => { if has_drop(cx, cx.typeck_results().expr_ty(expr)) { None diff --git a/src/tools/clippy/clippy_lints/src/ranges.rs b/src/tools/clippy/clippy_lints/src/ranges.rs index fc655fe2d0bb3..5bf8272dd57e7 100644 --- a/src/tools/clippy/clippy_lints/src/ranges.rs +++ b/src/tools/clippy/clippy_lints/src/ranges.rs @@ -3,7 +3,6 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_the use clippy_utils::higher; use clippy_utils::msrvs::{self, Msrv}; use clippy_utils::source::{snippet, snippet_opt, snippet_with_applicability}; -use clippy_utils::sugg::Sugg; use clippy_utils::{get_parent_expr, in_constant, is_integer_const, path_to_local}; use if_chain::if_chain; use rustc_ast::ast::RangeLimits; @@ -356,6 +355,8 @@ fn check_exclusive_range_plus_one(cx: &LateContext<'_>, expr: &Expr<'_>) { end: Some(end), limits: RangeLimits::HalfOpen }) = higher::Range::hir(expr); + if start.map_or(true, |start| start.span.can_be_used_for_suggestions()); + if end.span.can_be_used_for_suggestions(); if let Some(y) = y_plus_one(cx, end); then { let span = expr.span; @@ -365,25 +366,19 @@ fn check_exclusive_range_plus_one(cx: &LateContext<'_>, expr: &Expr<'_>) { span, "an inclusive range would be more readable", |diag| { - let start = start.map_or(String::new(), |x| Sugg::hir(cx, x, "x").maybe_par().to_string()); - let end = Sugg::hir(cx, y, "y").maybe_par(); - if let Some(is_wrapped) = &snippet_opt(cx, span) { - if is_wrapped.starts_with('(') && is_wrapped.ends_with(')') { - diag.span_suggestion( - span, - "use", - format!("({start}..={end})"), - Applicability::MaybeIncorrect, - ); - } else { - diag.span_suggestion( - span, - "use", - format!("{start}..={end}"), - Applicability::MachineApplicable, // snippet - ); - } - } + diag.multipart_suggestion( + "use an inclusive range instead", + vec![ + ( + start.map(|s| s.span.shrink_to_hi()) + .unwrap_or(expr.span) + .until(end.span), + "..=".to_string(), + ), + (y, String::new()), + ], + Applicability::MachineApplicable, + ); }, ); } @@ -392,9 +387,12 @@ fn check_exclusive_range_plus_one(cx: &LateContext<'_>, expr: &Expr<'_>) { // inclusive range minus one: `x..=(y-1)` fn check_inclusive_range_minus_one(cx: &LateContext<'_>, expr: &Expr<'_>) { + if_chain! { if expr.span.can_be_used_for_suggestions(); if let Some(higher::Range { start, end: Some(end), limits: RangeLimits::Closed }) = higher::Range::hir(expr); + if start.map_or(true, |start| start.span.can_be_used_for_suggestions()); + if end.span.can_be_used_for_suggestions(); if let Some(y) = y_minus_one(cx, end); then { span_lint_and_then( @@ -403,13 +401,18 @@ fn check_inclusive_range_minus_one(cx: &LateContext<'_>, expr: &Expr<'_>) { expr.span, "an exclusive range would be more readable", |diag| { - let start = start.map_or(String::new(), |x| Sugg::hir(cx, x, "x").maybe_par().to_string()); - let end = Sugg::hir(cx, y, "y").maybe_par(); - diag.span_suggestion( - expr.span, - "use", - format!("{start}..{end}"), - Applicability::MachineApplicable, // snippet + diag.multipart_suggestion( + "use an exclusive range instead", + vec![ + ( + start.map(|s| s.span.shrink_to_hi()) + .unwrap_or(expr.span) + .until(end.span), + "..".to_string(), + ), + (y, String::new()), + ], + Applicability::MachineApplicable, ); }, ); @@ -497,19 +500,24 @@ fn check_reversed_empty_range(cx: &LateContext<'_>, expr: &Expr<'_>) { } } -fn y_plus_one<'t>(cx: &LateContext<'_>, expr: &'t Expr<'_>) -> Option<&'t Expr<'t>> { +fn y_plus_one<'t>(cx: &LateContext<'_>, expr: &'t Expr<'_>) -> Option { match expr.kind { ExprKind::Binary( Spanned { - node: BinOpKind::Add, .. + node: BinOpKind::Add, + span, }, lhs, rhs, ) => { - if is_integer_const(cx, lhs, 1) { - Some(rhs) - } else if is_integer_const(cx, rhs, 1) { - Some(lhs) + if is_integer_const(cx, lhs, 1) + && lhs.span.peel_ctxt().ctxt() == span.peel_ctxt().ctxt() + { + Some(lhs.span.to(span)) + } else if is_integer_const(cx, rhs, 1) + && rhs.span.peel_ctxt().ctxt() == span.peel_ctxt().ctxt() + { + Some(span.to(rhs.span)) } else { None } @@ -518,15 +526,18 @@ fn y_plus_one<'t>(cx: &LateContext<'_>, expr: &'t Expr<'_>) -> Option<&'t Expr<' } } -fn y_minus_one<'t>(cx: &LateContext<'_>, expr: &'t Expr<'_>) -> Option<&'t Expr<'t>> { +fn y_minus_one<'t>(cx: &LateContext<'_>, expr: &'t Expr<'_>) -> Option { match expr.kind { ExprKind::Binary( Spanned { - node: BinOpKind::Sub, .. + node: BinOpKind::Sub, + span, }, - lhs, + _, rhs, - ) if is_integer_const(cx, rhs, 1) => Some(lhs), + ) if is_integer_const(cx, rhs, 1) + && rhs.span.peel_ctxt().ctxt() == span.peel_ctxt().ctxt() + => Some(span.to(rhs.span)), _ => None, } } diff --git a/src/tools/clippy/clippy_lints/src/shadow.rs b/src/tools/clippy/clippy_lints/src/shadow.rs index 87f966ced0df1..ae7d19624ba61 100644 --- a/src/tools/clippy/clippy_lints/src/shadow.rs +++ b/src/tools/clippy/clippy_lints/src/shadow.rs @@ -213,8 +213,7 @@ fn is_self_shadow(cx: &LateContext<'_>, pat: &Pat<'_>, mut expr: &Expr<'_>, hir_ } loop { expr = match expr.kind { - ExprKind::Box(e) - | ExprKind::AddrOf(_, _, e) + ExprKind::AddrOf(_, _, e) | ExprKind::Block( &Block { stmts: [], diff --git a/src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs b/src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs index e2d90edec5a4c..e12681c0a0ca6 100644 --- a/src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs +++ b/src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs @@ -380,7 +380,6 @@ impl<'cx, 'sdt, 'tcx> Visitor<'tcx> for SigDropFinder<'cx, 'sdt, 'tcx> { | hir::ExprKind::Assign(..) | hir::ExprKind::AssignOp(..) | hir::ExprKind::Binary(..) - | hir::ExprKind::Box(..) | hir::ExprKind::Call(..) | hir::ExprKind::Field(..) | hir::ExprKind::If(..) diff --git a/src/tools/clippy/clippy_lints/src/utils/author.rs b/src/tools/clippy/clippy_lints/src/utils/author.rs index f31c3fdb0959c..bc4adf1596d44 100644 --- a/src/tools/clippy/clippy_lints/src/utils/author.rs +++ b/src/tools/clippy/clippy_lints/src/utils/author.rs @@ -395,11 +395,6 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> { } self.expr(field!(let_expr.init)); }, - ExprKind::Box(inner) => { - bind!(self, inner); - kind!("Box({inner})"); - self.expr(inner); - }, ExprKind::Array(elements) => { bind!(self, elements); kind!("Array({elements})"); diff --git a/src/tools/clippy/clippy_utils/src/check_proc_macro.rs b/src/tools/clippy/clippy_utils/src/check_proc_macro.rs index 43f0df145f0ec..d3a6929f67e2c 100644 --- a/src/tools/clippy/clippy_utils/src/check_proc_macro.rs +++ b/src/tools/clippy/clippy_utils/src/check_proc_macro.rs @@ -112,7 +112,6 @@ fn qpath_search_pat(path: &QPath<'_>) -> (Pat, Pat) { /// Get the search patterns to use for the given expression fn expr_search_pat(tcx: TyCtxt<'_>, e: &Expr<'_>) -> (Pat, Pat) { match e.kind { - ExprKind::Box(e) => (Pat::Str("box"), expr_search_pat(tcx, e).1), ExprKind::ConstBlock(_) => (Pat::Str("const"), Pat::Str("}")), ExprKind::Tup([]) => (Pat::Str(")"), Pat::Str("(")), ExprKind::Unary(UnOp::Deref, e) => (Pat::Str("*"), expr_search_pat(tcx, e).1), diff --git a/src/tools/clippy/clippy_utils/src/eager_or_lazy.rs b/src/tools/clippy/clippy_utils/src/eager_or_lazy.rs index ee2f816f181ba..babbc7294a173 100644 --- a/src/tools/clippy/clippy_utils/src/eager_or_lazy.rs +++ b/src/tools/clippy/clippy_utils/src/eager_or_lazy.rs @@ -199,8 +199,7 @@ fn expr_eagerness<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> EagernessS }, // Memory allocation, custom operator, loop, or call to an unknown function - ExprKind::Box(_) - | ExprKind::Unary(..) + ExprKind::Unary(..) | ExprKind::Binary(..) | ExprKind::Loop(..) | ExprKind::Call(..) => self.eagerness = Lazy, diff --git a/src/tools/clippy/clippy_utils/src/hir_utils.rs b/src/tools/clippy/clippy_utils/src/hir_utils.rs index 0603755f8a941..3a6d23ca5c102 100644 --- a/src/tools/clippy/clippy_utils/src/hir_utils.rs +++ b/src/tools/clippy/clippy_utils/src/hir_utils.rs @@ -249,7 +249,6 @@ impl HirEqInterExpr<'_, '_, '_> { both(&li.label, &ri.label, |l, r| l.ident.name == r.ident.name) && both(le, re, |l, r| self.eq_expr(l, r)) }, - (&ExprKind::Box(l), &ExprKind::Box(r)) => self.eq_expr(l, r), (&ExprKind::Call(l_fun, l_args), &ExprKind::Call(r_fun, r_args)) => { self.inner.allow_side_effects && self.eq_expr(l_fun, r_fun) && self.eq_exprs(l_args, r_args) }, @@ -628,7 +627,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { self.hash_expr(j); } }, - ExprKind::Box(e) | ExprKind::DropTemps(e) | ExprKind::Yield(e, _) => { + ExprKind::DropTemps(e) | ExprKind::Yield(e, _) => { self.hash_expr(e); }, ExprKind::Call(fun, args) => { diff --git a/src/tools/clippy/clippy_utils/src/sugg.rs b/src/tools/clippy/clippy_utils/src/sugg.rs index 85bf28b708b7c..44cb5d5756ada 100644 --- a/src/tools/clippy/clippy_utils/src/sugg.rs +++ b/src/tools/clippy/clippy_utils/src/sugg.rs @@ -133,7 +133,6 @@ impl<'a> Sugg<'a> { match expr.kind { hir::ExprKind::AddrOf(..) - | hir::ExprKind::Box(..) | hir::ExprKind::If(..) | hir::ExprKind::Let(..) | hir::ExprKind::Closure { .. } diff --git a/src/tools/clippy/clippy_utils/src/visitors.rs b/src/tools/clippy/clippy_utils/src/visitors.rs index d27a20bd4dfa7..86a93f64fb71e 100644 --- a/src/tools/clippy/clippy_utils/src/visitors.rs +++ b/src/tools/clippy/clippy_utils/src/visitors.rs @@ -600,7 +600,6 @@ pub fn for_each_unconsumed_temporary<'tcx, B>( helper(typeck, false, e, f)?; }, ExprKind::Block(&Block { expr: Some(e), .. }, _) - | ExprKind::Box(e) | ExprKind::Cast(e, _) | ExprKind::Unary(_, e) => { helper(typeck, true, e, f)?; diff --git a/src/tools/clippy/tests/ui/range_plus_minus_one.fixed b/src/tools/clippy/tests/ui/range_plus_minus_one.fixed index a16a3e54d45ea..faed306656876 100644 --- a/src/tools/clippy/tests/ui/range_plus_minus_one.fixed +++ b/src/tools/clippy/tests/ui/range_plus_minus_one.fixed @@ -1,14 +1,14 @@ // run-rustfix #![allow(unused_parens)] -#![allow(clippy::iter_with_drain)] +#![allow(clippy::iter_with_drain, clippy::needless_parens_on_range_literals)] fn f() -> usize { 42 } macro_rules! macro_plus_one { ($m: literal) => { - for i in 0..$m + 1 { + for i in 0..=$m { println!("{}", i); } }; @@ -16,7 +16,7 @@ macro_rules! macro_plus_one { macro_rules! macro_minus_one { ($m: literal) => { - for i in 0..=$m - 1 { + for i in 0..$m { println!("{}", i); } }; @@ -28,30 +28,30 @@ fn main() { for _ in 0..2 {} for _ in 0..=2 {} - for _ in 0..=3 {} + for _ in 0..=3 {} for _ in 0..=3 + 1 {} - for _ in 0..=5 {} + for _ in 0..= 5 {} for _ in 0..=1 + 5 {} - for _ in 1..=1 {} + for _ in 1..= 1 {} for _ in 1..=1 + 1 {} for _ in 0..13 + 13 {} for _ in 0..=13 - 7 {} - for _ in 0..=f() {} + for _ in 0..=( f()) {} for _ in 0..=(1 + f()) {} let _ = ..11 - 1; - let _ = ..11; - let _ = ..11; - let _ = (1..=11); - let _ = ((f() + 1)..=f()); + let _ = ..11 ; + let _ = ..(11 ); + let _ = (1..=11 ); + let _ = (f() + 1)..=(f() ); const ONE: usize = 1; // integer consts are linted, too - for _ in 1..=ONE {} + for _ in 1..= ONE {} let mut vec: Vec<()> = std::vec::Vec::new(); vec.drain(..); diff --git a/src/tools/clippy/tests/ui/range_plus_minus_one.rs b/src/tools/clippy/tests/ui/range_plus_minus_one.rs index bd6cb4d21be51..d91fd9bfd82b1 100644 --- a/src/tools/clippy/tests/ui/range_plus_minus_one.rs +++ b/src/tools/clippy/tests/ui/range_plus_minus_one.rs @@ -1,7 +1,7 @@ // run-rustfix #![allow(unused_parens)] -#![allow(clippy::iter_with_drain)] +#![allow(clippy::iter_with_drain, clippy::needless_parens_on_range_literals)] fn f() -> usize { 42 } diff --git a/src/tools/clippy/tests/ui/range_plus_minus_one.stderr b/src/tools/clippy/tests/ui/range_plus_minus_one.stderr index 0223696243b20..64cc2169d9050 100644 --- a/src/tools/clippy/tests/ui/range_plus_minus_one.stderr +++ b/src/tools/clippy/tests/ui/range_plus_minus_one.stderr @@ -2,59 +2,143 @@ error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:31:14 | LL | for _ in 0..3 + 1 {} - | ^^^^^^^^ help: use: `0..=3` + | ^^^^^^^^ | = note: `-D clippy::range-plus-one` implied by `-D warnings` +help: use an inclusive range instead + | +LL - for _ in 0..3 + 1 {} +LL + for _ in 0..=3 {} + | error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:34:14 | LL | for _ in 0..1 + 5 {} - | ^^^^^^^^ help: use: `0..=5` + | ^^^^^^^^ + | +help: use an inclusive range instead + | +LL - for _ in 0..1 + 5 {} +LL + for _ in 0..= 5 {} + | error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:37:14 | LL | for _ in 1..1 + 1 {} - | ^^^^^^^^ help: use: `1..=1` + | ^^^^^^^^ + | +help: use an inclusive range instead + | +LL - for _ in 1..1 + 1 {} +LL + for _ in 1..= 1 {} + | error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:43:14 | LL | for _ in 0..(1 + f()) {} - | ^^^^^^^^^^^^ help: use: `0..=f()` + | ^^^^^^^^^^^^ + | +help: use an inclusive range instead + | +LL - for _ in 0..(1 + f()) {} +LL + for _ in 0..=( f()) {} + | error: an exclusive range would be more readable --> $DIR/range_plus_minus_one.rs:47:13 | LL | let _ = ..=11 - 1; - | ^^^^^^^^^ help: use: `..11` + | ^^^^^^^^^ | = note: `-D clippy::range-minus-one` implied by `-D warnings` +help: use an exclusive range instead + | +LL - let _ = ..=11 - 1; +LL + let _ = ..11 ; + | error: an exclusive range would be more readable --> $DIR/range_plus_minus_one.rs:48:13 | LL | let _ = ..=(11 - 1); - | ^^^^^^^^^^^ help: use: `..11` + | ^^^^^^^^^^^ + | +help: use an exclusive range instead + | +LL - let _ = ..=(11 - 1); +LL + let _ = ..(11 ); + | error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:49:13 | LL | let _ = (1..11 + 1); - | ^^^^^^^^^^^ help: use: `(1..=11)` + | ^^^^^^^^^^^ + | +help: use an inclusive range instead + | +LL - let _ = (1..11 + 1); +LL + let _ = (1..=11 ); + | error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:50:13 | LL | let _ = (f() + 1)..(f() + 1); - | ^^^^^^^^^^^^^^^^^^^^ help: use: `((f() + 1)..=f())` + | ^^^^^^^^^^^^^^^^^^^^ + | +help: use an inclusive range instead + | +LL - let _ = (f() + 1)..(f() + 1); +LL + let _ = (f() + 1)..=(f() ); + | error: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:54:14 | LL | for _ in 1..ONE + ONE {} - | ^^^^^^^^^^^^ help: use: `1..=ONE` + | ^^^^^^^^^^^^ + | +help: use an inclusive range instead + | +LL - for _ in 1..ONE + ONE {} +LL + for _ in 1..= ONE {} + | + +error: an inclusive range would be more readable + --> $DIR/range_plus_minus_one.rs:11:18 + | +LL | for i in 0..$m + 1 { + | ^^^^^^^^^ +... +LL | macro_plus_one!(5); + | ------------------ in this macro invocation + | + = note: this error originates in the macro `macro_plus_one` (in Nightly builds, run with -Z macro-backtrace for more info) +help: use an inclusive range instead + | +LL - for i in 0..$m + 1 { +LL + for i in 0..=$m { + | + +error: an exclusive range would be more readable + --> $DIR/range_plus_minus_one.rs:19:18 + | +LL | for i in 0..=$m - 1 { + | ^^^^^^^^^^ +... +LL | macro_minus_one!(5); + | ------------------- in this macro invocation + | + = note: this error originates in the macro `macro_minus_one` (in Nightly builds, run with -Z macro-backtrace for more info) +help: use an exclusive range instead + | +LL - for i in 0..=$m - 1 { +LL + for i in 0..$m { + | -error: aborting due to 9 previous errors +error: aborting due to 11 previous errors diff --git a/src/tools/rustfmt/src/imports.rs b/src/tools/rustfmt/src/imports.rs index 339e5cef5af91..0bb5e66a162ec 100644 --- a/src/tools/rustfmt/src/imports.rs +++ b/src/tools/rustfmt/src/imports.rs @@ -718,7 +718,7 @@ impl UseTree { } if let Some(new_path) = merge_rest(&self.path, &other.path, prefix, merge_by) { self.path = new_path; - self.span = self.span.to(other.span); + self.span = self.span.with_hi(other.span.hi()); } } diff --git a/tests/codegen/inherit_overflow.rs b/tests/codegen/inherit_overflow.rs index 0b0b890b2c99a..39909d7abfd40 100644 --- a/tests/codegen/inherit_overflow.rs +++ b/tests/codegen/inherit_overflow.rs @@ -4,7 +4,7 @@ //[NOASSERT] compile-flags: -Coverflow-checks=off // CHECK-LABEL: define{{.*}} @assertion -// ASSERT: call void @_ZN4core9panicking5panic17h +// ASSERT: call void @{{.*4core9panicking5panic}} // NOASSERT: ret i8 0 #[no_mangle] pub fn assertion() -> u8 { diff --git a/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.rs b/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.rs index cd06423e3a557..5d856fb6c1d7a 100644 --- a/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.rs +++ b/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.rs @@ -8,8 +8,8 @@ use core::alloc::Layout; #[alloc_error_handler] fn oom( - info: &Layout, //~^ ERROR mismatched types -) -> () //~^^ ERROR mismatched types + info: &Layout, //~ ERROR mismatched types +) -> () //~ ERROR mismatched types { loop {} } diff --git a/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr b/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr index de92841d7f18e..4b92c577a23cb 100644 --- a/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr +++ b/tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr @@ -1,16 +1,16 @@ error[E0308]: mismatched types - --> $DIR/alloc-error-handler-bad-signature-1.rs:10:1 + --> $DIR/alloc-error-handler-bad-signature-1.rs:11:5 | -LL | #[alloc_error_handler] - | ---------------------- in this procedural macro expansion -LL | // fn oom( -LL | || info: &Layout, -LL | || ) -> () - | ||_______- arguments to this function are incorrect -LL | | { -LL | | loop {} -LL | | } - | |__^ expected `&Layout`, found `Layout` +LL | #[alloc_error_handler] + | ---------------------- in this procedural macro expansion +LL | / fn oom( +LL | | info: &Layout, + | | ^^^^^^^^^^^^^ expected `&Layout`, found `Layout` +LL | | ) -> () +LL | | { +LL | | loop {} +LL | | } + | |_- arguments to this function are incorrect | note: function defined here --> $DIR/alloc-error-handler-bad-signature-1.rs:10:4 @@ -22,18 +22,18 @@ LL | info: &Layout, = note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types - --> $DIR/alloc-error-handler-bad-signature-1.rs:10:1 + --> $DIR/alloc-error-handler-bad-signature-1.rs:12:6 | -LL | #[alloc_error_handler] - | ---------------------- in this procedural macro expansion -LL | // fn oom( -LL | || info: &Layout, -LL | || ) -> () - | ||_______^ expected `!`, found `()` -LL | | { -LL | | loop {} -LL | | } - | |__- expected `!` because of return type +LL | #[alloc_error_handler] + | ---------------------- in this procedural macro expansion +LL | / fn oom( +LL | | info: &Layout, +LL | | ) -> () + | | ^^ expected `!`, found `()` +LL | | { +LL | | loop {} +LL | | } + | |_- expected `!` because of return type | = note: expected type `!` found unit type `()` diff --git a/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.rs b/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.rs index 4f76257fc7267..a9114431dadb1 100644 --- a/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.rs +++ b/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.rs @@ -8,8 +8,8 @@ struct Layout; #[alloc_error_handler] fn oom( - info: Layout, //~^ ERROR mismatched types -) { //~^^ ERROR mismatched types + info: Layout, //~ ERROR mismatched types +) { //~ ERROR mismatched types loop {} } diff --git a/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr b/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr index 7a495380f2ba1..9ef1b8dd2c01c 100644 --- a/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr +++ b/tests/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr @@ -1,15 +1,15 @@ error[E0308]: mismatched types - --> $DIR/alloc-error-handler-bad-signature-2.rs:10:1 + --> $DIR/alloc-error-handler-bad-signature-2.rs:11:5 | -LL | #[alloc_error_handler] - | ---------------------- in this procedural macro expansion -LL | // fn oom( -LL | || info: Layout, -LL | || ) { - | ||_- arguments to this function are incorrect -LL | | loop {} -LL | | } - | |__^ expected `Layout`, found `core::alloc::Layout` +LL | #[alloc_error_handler] + | ---------------------- in this procedural macro expansion +LL | / fn oom( +LL | | info: Layout, + | | ^^^^^^^^^^^^ expected `Layout`, found `core::alloc::Layout` +LL | | ) { +LL | | loop {} +LL | | } + | |_- arguments to this function are incorrect | = note: `core::alloc::Layout` and `Layout` have similar names, but are actually distinct types note: `core::alloc::Layout` is defined in crate `core` @@ -29,17 +29,17 @@ LL | info: Layout, = note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types - --> $DIR/alloc-error-handler-bad-signature-2.rs:10:1 + --> $DIR/alloc-error-handler-bad-signature-2.rs:12:3 | -LL | #[alloc_error_handler] - | ---------------------- in this procedural macro expansion -LL | // fn oom( -LL | || info: Layout, -LL | || ) { - | ||_^ expected `!`, found `()` -LL | | loop {} -LL | | } - | |__- expected `!` because of return type +LL | #[alloc_error_handler] + | ---------------------- in this procedural macro expansion +LL | / fn oom( +LL | | info: Layout, +LL | | ) { + | | ^ expected `!`, found `()` +LL | | loop {} +LL | | } + | |_- expected `!` because of return type | = note: expected type `!` found unit type `()` diff --git a/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr b/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr index eb739b149a103..becfcf0690a16 100644 --- a/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr +++ b/tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr @@ -3,11 +3,10 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied | LL | #[alloc_error_handler] | ---------------------- in this procedural macro expansion -LL | fn oom() -> ! { - | _-^^^^^^^^^^^^ +LL | / fn oom() -> ! { LL | | loop {} LL | | } - | |_- unexpected argument of type `core::alloc::Layout` + | |_^ unexpected argument of type `core::alloc::Layout` | note: function defined here --> $DIR/alloc-error-handler-bad-signature-3.rs:10:4 diff --git a/tests/ui/argument-suggestions/extra_arguments.stderr b/tests/ui/argument-suggestions/extra_arguments.stderr index 11c7109974355..b3bb4c302949a 100644 --- a/tests/ui/argument-suggestions/extra_arguments.stderr +++ b/tests/ui/argument-suggestions/extra_arguments.stderr @@ -258,7 +258,6 @@ LL | foo!(1); | ------- | | | | | unexpected argument of type `{integer}` - | | help: remove the extra argument | in this macro invocation | note: function defined here diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.stderr b/tests/ui/async-await/in-trait/async-default-fn-overridden.current.stderr similarity index 88% rename from tests/ui/async-await/in-trait/async-default-fn-overridden.stderr rename to tests/ui/async-await/in-trait/async-default-fn-overridden.current.stderr index 61a826258d09f..2142ee232ca5c 100644 --- a/tests/ui/async-await/in-trait/async-default-fn-overridden.stderr +++ b/tests/ui/async-await/in-trait/async-default-fn-overridden.current.stderr @@ -1,5 +1,5 @@ warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/async-default-fn-overridden.rs:4:12 + --> $DIR/async-default-fn-overridden.rs:6:12 | LL | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.next.stderr b/tests/ui/async-await/in-trait/async-default-fn-overridden.next.stderr new file mode 100644 index 0000000000000..2142ee232ca5c --- /dev/null +++ b/tests/ui/async-await/in-trait/async-default-fn-overridden.next.stderr @@ -0,0 +1,11 @@ +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/async-default-fn-overridden.rs:6:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs index 0fd1a2703db99..dd1af93d706c4 100644 --- a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs +++ b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs @@ -1,5 +1,7 @@ // run-pass // edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] //~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr b/tests/ui/async-await/in-trait/async-generics-and-bounds.current.stderr similarity index 82% rename from tests/ui/async-await/in-trait/async-generics-and-bounds.stderr rename to tests/ui/async-await/in-trait/async-generics-and-bounds.current.stderr index f1f0d7e5907d3..780da06896296 100644 --- a/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.current.stderr @@ -1,33 +1,33 @@ error[E0311]: the parameter type `U` may not live long enough - --> $DIR/async-generics-and-bounds.rs:12:28 + --> $DIR/async-generics-and-bounds.rs:14:28 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^ | note: the parameter type `U` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics-and-bounds.rs:12:18 + --> $DIR/async-generics-and-bounds.rs:14:18 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics-and-bounds.rs:12:28 + --> $DIR/async-generics-and-bounds.rs:14:28 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/async-generics-and-bounds.rs:12:28 + --> $DIR/async-generics-and-bounds.rs:14:28 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^ | note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics-and-bounds.rs:12:18 + --> $DIR/async-generics-and-bounds.rs:14:18 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics-and-bounds.rs:12:28 + --> $DIR/async-generics-and-bounds.rs:14:28 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.next.stderr b/tests/ui/async-await/in-trait/async-generics-and-bounds.next.stderr new file mode 100644 index 0000000000000..780da06896296 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.next.stderr @@ -0,0 +1,37 @@ +error[E0311]: the parameter type `U` may not live long enough + --> $DIR/async-generics-and-bounds.rs:14:28 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^^^^^^^ + | +note: the parameter type `U` must be valid for the anonymous lifetime defined here... + --> $DIR/async-generics-and-bounds.rs:14:18 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^^^^^ +note: ...so that the reference type `&(T, U)` does not outlive the data it points at + --> $DIR/async-generics-and-bounds.rs:14:28 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^^^^^^^ + +error[E0311]: the parameter type `T` may not live long enough + --> $DIR/async-generics-and-bounds.rs:14:28 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^^^^^^^ + | +note: the parameter type `T` must be valid for the anonymous lifetime defined here... + --> $DIR/async-generics-and-bounds.rs:14:18 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^^^^^ +note: ...so that the reference type `&(T, U)` does not outlive the data it points at + --> $DIR/async-generics-and-bounds.rs:14:28 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0311`. diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.rs b/tests/ui/async-await/in-trait/async-generics-and-bounds.rs index a73d55adfeced..146e74ec2d03b 100644 --- a/tests/ui/async-await/in-trait/async-generics-and-bounds.rs +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.rs @@ -1,6 +1,8 @@ // check-fail // known-bug: #102682 // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/async-generics.stderr b/tests/ui/async-await/in-trait/async-generics.current.stderr similarity index 83% rename from tests/ui/async-await/in-trait/async-generics.stderr rename to tests/ui/async-await/in-trait/async-generics.current.stderr index 2f05564564cd2..04e1ab6d76978 100644 --- a/tests/ui/async-await/in-trait/async-generics.stderr +++ b/tests/ui/async-await/in-trait/async-generics.current.stderr @@ -1,33 +1,33 @@ error[E0311]: the parameter type `U` may not live long enough - --> $DIR/async-generics.rs:9:28 + --> $DIR/async-generics.rs:11:28 | LL | async fn foo(&self) -> &(T, U); | ^^^^^^^ | note: the parameter type `U` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics.rs:9:18 + --> $DIR/async-generics.rs:11:18 | LL | async fn foo(&self) -> &(T, U); | ^^^^^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics.rs:9:28 + --> $DIR/async-generics.rs:11:28 | LL | async fn foo(&self) -> &(T, U); | ^^^^^^^ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/async-generics.rs:9:28 + --> $DIR/async-generics.rs:11:28 | LL | async fn foo(&self) -> &(T, U); | ^^^^^^^ | note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics.rs:9:18 + --> $DIR/async-generics.rs:11:18 | LL | async fn foo(&self) -> &(T, U); | ^^^^^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics.rs:9:28 + --> $DIR/async-generics.rs:11:28 | LL | async fn foo(&self) -> &(T, U); | ^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-generics.next.stderr b/tests/ui/async-await/in-trait/async-generics.next.stderr new file mode 100644 index 0000000000000..04e1ab6d76978 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-generics.next.stderr @@ -0,0 +1,37 @@ +error[E0311]: the parameter type `U` may not live long enough + --> $DIR/async-generics.rs:11:28 + | +LL | async fn foo(&self) -> &(T, U); + | ^^^^^^^ + | +note: the parameter type `U` must be valid for the anonymous lifetime defined here... + --> $DIR/async-generics.rs:11:18 + | +LL | async fn foo(&self) -> &(T, U); + | ^^^^^ +note: ...so that the reference type `&(T, U)` does not outlive the data it points at + --> $DIR/async-generics.rs:11:28 + | +LL | async fn foo(&self) -> &(T, U); + | ^^^^^^^ + +error[E0311]: the parameter type `T` may not live long enough + --> $DIR/async-generics.rs:11:28 + | +LL | async fn foo(&self) -> &(T, U); + | ^^^^^^^ + | +note: the parameter type `T` must be valid for the anonymous lifetime defined here... + --> $DIR/async-generics.rs:11:18 + | +LL | async fn foo(&self) -> &(T, U); + | ^^^^^ +note: ...so that the reference type `&(T, U)` does not outlive the data it points at + --> $DIR/async-generics.rs:11:28 + | +LL | async fn foo(&self) -> &(T, U); + | ^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0311`. diff --git a/tests/ui/async-await/in-trait/async-generics.rs b/tests/ui/async-await/in-trait/async-generics.rs index 67000e5770ee8..507500abf4e1c 100644 --- a/tests/ui/async-await/in-trait/async-generics.rs +++ b/tests/ui/async-await/in-trait/async-generics.rs @@ -1,6 +1,8 @@ // check-fail // known-bug: #102682 // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs b/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs index 127a3f5b2dc97..30ccf3f856c71 100644 --- a/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs +++ b/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs @@ -49,6 +49,7 @@ fn c() { //~| NOTE cannot move out of here //~| NOTE move occurs because //~| HELP consider borrowing here + //~| NOTE in this expansion of desugaring of a resized `Span` } fn d() { @@ -68,6 +69,7 @@ fn d() { //~| NOTE cannot move out of here //~| NOTE move occurs because //~| HELP consider borrowing here + //~| NOTE in this expansion of desugaring of a resized `Span` } fn e() { @@ -88,6 +90,7 @@ fn e() { //~| NOTE cannot move out of here //~| NOTE move occurs because //~| HELP consider borrowing here + //~| NOTE in this expansion of desugaring of a resized `Span` } fn main() {} diff --git a/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr b/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr index 5e1251b059093..9a9a719fa4bf8 100644 --- a/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr +++ b/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr @@ -55,7 +55,7 @@ LL | let a = &vec[0]; | + error[E0508]: cannot move out of type `[Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:57:11 + --> $DIR/borrowck-vec-pattern-nesting.rs:58:11 | LL | match vec { | ^^^ cannot move out of here @@ -73,7 +73,7 @@ LL + [ | error[E0508]: cannot move out of type `[Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:67:13 + --> $DIR/borrowck-vec-pattern-nesting.rs:68:13 | LL | let a = vec[0]; | ^^^^^^ @@ -87,7 +87,7 @@ LL | let a = &vec[0]; | + error[E0508]: cannot move out of type `[Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:76:11 + --> $DIR/borrowck-vec-pattern-nesting.rs:78:11 | LL | match vec { | ^^^ cannot move out of here @@ -106,7 +106,7 @@ LL + [_a, _b, _c] => {} | error[E0508]: cannot move out of type `[Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:87:13 + --> $DIR/borrowck-vec-pattern-nesting.rs:89:13 | LL | let a = vec[0]; | ^^^^^^ diff --git a/tests/ui/borrowck/issue-87456-point-to-closure.rs b/tests/ui/borrowck/issue-87456-point-to-closure.rs index 9fc12ba749042..39ecf0b901b80 100644 --- a/tests/ui/borrowck/issue-87456-point-to-closure.rs +++ b/tests/ui/borrowck/issue-87456-point-to-closure.rs @@ -10,5 +10,6 @@ fn main() { let _foo: String = val; //~^ ERROR: cannot move out of `val`, a captured variable in an `FnMut` closure [E0507] //~| NOTE: move occurs because + //~| NOTE in this expansion of desugaring of a resized `Span` }) } diff --git a/tests/ui/feature-gates/feature-gate-concat_idents2.rs b/tests/ui/feature-gates/feature-gate-concat_idents2.rs index 9660ffeafa518..9465824f99475 100644 --- a/tests/ui/feature-gates/feature-gate-concat_idents2.rs +++ b/tests/ui/feature-gates/feature-gate-concat_idents2.rs @@ -1,4 +1,4 @@ fn main() { concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough - //~| ERROR cannot find value `ab` in this scope + //~| ERROR cannot find value `ab` in } diff --git a/tests/ui/feature-gates/feature-gate-concat_idents2.stderr b/tests/ui/feature-gates/feature-gate-concat_idents2.stderr index 8663bc7ca7e77..2f9ff916170f1 100644 --- a/tests/ui/feature-gates/feature-gate-concat_idents2.stderr +++ b/tests/ui/feature-gates/feature-gate-concat_idents2.stderr @@ -7,11 +7,11 @@ LL | concat_idents!(a, b); = note: see issue #29599 for more information = help: add `#![feature(concat_idents)]` to the crate attributes to enable -error[E0425]: cannot find value `ab` in this scope +error[E0425]: cannot find value `ab` in the expanded code of procedural macro `concat_idents` --> $DIR/feature-gate-concat_idents2.rs:2:5 | LL | concat_idents!(a, b); - | ^^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^ `ab` not found in expanded code of this procedural macro | = note: this error originates in the macro `concat_idents` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/fully-qualified-type/fully-qualified-type-name1.rs b/tests/ui/fully-qualified-type/fully-qualified-type-name1.rs index bbca22ad2e69d..2d1d5b183d9b0 100644 --- a/tests/ui/fully-qualified-type/fully-qualified-type-name1.rs +++ b/tests/ui/fully-qualified-type/fully-qualified-type-name1.rs @@ -7,4 +7,5 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected enum `Option` //~| NOTE expected `Option`, found integer + //~| NOTE in this expansion of desugaring of a resized `Span` } diff --git a/tests/ui/hygiene/arguments.stderr b/tests/ui/hygiene/arguments.stderr index d072086e086d6..0178dab11d0a5 100644 --- a/tests/ui/hygiene/arguments.stderr +++ b/tests/ui/hygiene/arguments.stderr @@ -3,6 +3,11 @@ error[E0412]: cannot find type `S` in this scope | LL | m!(S, S); | ^ not found in this scope + | +help: you might be missing a type parameter + | +LL | pub(super) fn f(_: $t) {} + | +++ error: aborting due to previous error diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.stderr b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.current.stderr similarity index 90% rename from tests/ui/impl-trait/in-trait/box-coerce-span-in-default.stderr rename to tests/ui/impl-trait/in-trait/box-coerce-span-in-default.current.stderr index d681ecf25e8af..05c025cc169ff 100644 --- a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.stderr +++ b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.current.stderr @@ -1,5 +1,5 @@ warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/box-coerce-span-in-default.rs:3:12 + --> $DIR/box-coerce-span-in-default.rs:5:12 | LL | #![feature(return_position_impl_trait_in_trait)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.next.stderr b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.next.stderr new file mode 100644 index 0000000000000..05c025cc169ff --- /dev/null +++ b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.next.stderr @@ -0,0 +1,11 @@ +warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/box-coerce-span-in-default.rs:5:12 + | +LL | #![feature(return_position_impl_trait_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs index a4d483dee7a53..163bb4fcf773d 100644 --- a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs +++ b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs @@ -1,4 +1,6 @@ // check-pass +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(return_position_impl_trait_in_trait)] //~^ WARN the feature `return_position_impl_trait_in_trait` is incomplete diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err-2.current.stderr similarity index 87% rename from tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr rename to tests/ui/impl-trait/in-trait/default-body-type-err-2.current.stderr index cc3bdf0e5717e..85450e3b0a0b8 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr +++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.current.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/default-body-type-err-2.rs:8:9 + --> $DIR/default-body-type-err-2.rs:10:9 | LL | 42 | ^^- help: try using a conversion method: `.to_string()` diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.next.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err-2.next.stderr new file mode 100644 index 0000000000000..85450e3b0a0b8 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.next.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/default-body-type-err-2.rs:10:9 + | +LL | 42 + | ^^- help: try using a conversion method: `.to_string()` + | | + | expected `String`, found integer + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs b/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs index 45ae2b8ad3a69..623237763100d 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs +++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs @@ -1,4 +1,6 @@ // edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![allow(incomplete_features)] #![feature(async_fn_in_trait)] diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err.current.stderr similarity index 90% rename from tests/ui/impl-trait/in-trait/default-body-type-err.stderr rename to tests/ui/impl-trait/in-trait/default-body-type-err.current.stderr index 4742eb37d3e4d..c949168a37789 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err.stderr +++ b/tests/ui/impl-trait/in-trait/default-body-type-err.current.stderr @@ -1,5 +1,5 @@ error[E0271]: type mismatch resolving `<&i32 as Deref>::Target == String` - --> $DIR/default-body-type-err.rs:7:22 + --> $DIR/default-body-type-err.rs:10:22 | LL | fn lol(&self) -> impl Deref { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `String` diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.next.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err.next.stderr new file mode 100644 index 0000000000000..c949168a37789 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/default-body-type-err.next.stderr @@ -0,0 +1,12 @@ +error[E0271]: type mismatch resolving `<&i32 as Deref>::Target == String` + --> $DIR/default-body-type-err.rs:10:22 + | +LL | fn lol(&self) -> impl Deref { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `String` +LL | +LL | &1i32 + | ----- return type was inferred to be `&i32` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.rs b/tests/ui/impl-trait/in-trait/default-body-type-err.rs index ac9baf91cae37..9bd5b7779898b 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err.rs +++ b/tests/ui/impl-trait/in-trait/default-body-type-err.rs @@ -1,3 +1,6 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + #![allow(incomplete_features)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/impl-trait/in-trait/default-body.rs b/tests/ui/impl-trait/in-trait/default-body.rs index b0baf5bb10dd2..ab6a51c6bcb84 100644 --- a/tests/ui/impl-trait/in-trait/default-body.rs +++ b/tests/ui/impl-trait/in-trait/default-body.rs @@ -1,5 +1,7 @@ // check-pass // edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.stderr b/tests/ui/impl-trait/in-trait/default-method-constraint.current.stderr similarity index 90% rename from tests/ui/impl-trait/in-trait/default-method-constraint.stderr rename to tests/ui/impl-trait/in-trait/default-method-constraint.current.stderr index 5e18605aa4cb2..7bb79911f56f8 100644 --- a/tests/ui/impl-trait/in-trait/default-method-constraint.stderr +++ b/tests/ui/impl-trait/in-trait/default-method-constraint.current.stderr @@ -1,5 +1,5 @@ warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/default-method-constraint.rs:5:12 + --> $DIR/default-method-constraint.rs:7:12 | LL | #![feature(return_position_impl_trait_in_trait)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.next.stderr b/tests/ui/impl-trait/in-trait/default-method-constraint.next.stderr new file mode 100644 index 0000000000000..7bb79911f56f8 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/default-method-constraint.next.stderr @@ -0,0 +1,11 @@ +warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/default-method-constraint.rs:7:12 + | +LL | #![feature(return_position_impl_trait_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.rs b/tests/ui/impl-trait/in-trait/default-method-constraint.rs index 8c50cc2958645..e85fe3c8626f4 100644 --- a/tests/ui/impl-trait/in-trait/default-method-constraint.rs +++ b/tests/ui/impl-trait/in-trait/default-method-constraint.rs @@ -1,4 +1,6 @@ // check-pass +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next // This didn't work in the previous default RPITIT method hack attempt diff --git a/tests/ui/impl-trait/in-trait/issue-102571.stderr b/tests/ui/impl-trait/in-trait/issue-102571.current.stderr similarity index 93% rename from tests/ui/impl-trait/in-trait/issue-102571.stderr rename to tests/ui/impl-trait/in-trait/issue-102571.current.stderr index 87219941d9161..cac9a29f6440f 100644 --- a/tests/ui/impl-trait/in-trait/issue-102571.stderr +++ b/tests/ui/impl-trait/in-trait/issue-102571.current.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-102571.rs:20:9 + --> $DIR/issue-102571.rs:23:9 | LL | let () = t.bar(); | ^^ ------- this expression has type `impl Deref` diff --git a/tests/ui/impl-trait/in-trait/issue-102571.next.stderr b/tests/ui/impl-trait/in-trait/issue-102571.next.stderr new file mode 100644 index 0000000000000..cac9a29f6440f --- /dev/null +++ b/tests/ui/impl-trait/in-trait/issue-102571.next.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/issue-102571.rs:23:9 + | +LL | let () = t.bar(); + | ^^ ------- this expression has type `impl Deref` + | | + | expected associated type, found `()` + | + = note: expected associated type `impl Deref` + found unit type `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/issue-102571.rs b/tests/ui/impl-trait/in-trait/issue-102571.rs index 61c91e64417b3..f0ddab5e7f227 100644 --- a/tests/ui/impl-trait/in-trait/issue-102571.rs +++ b/tests/ui/impl-trait/in-trait/issue-102571.rs @@ -1,3 +1,6 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.current.stderr similarity index 88% rename from tests/ui/impl-trait/in-trait/specialization-broken.stderr rename to tests/ui/impl-trait/in-trait/specialization-broken.current.stderr index dc621d6b8a848..f48e7a1ed1407 100644 --- a/tests/ui/impl-trait/in-trait/specialization-broken.stderr +++ b/tests/ui/impl-trait/in-trait/specialization-broken.current.stderr @@ -1,5 +1,5 @@ error[E0053]: method `bar` has an incompatible type for trait - --> $DIR/specialization-broken.rs:16:22 + --> $DIR/specialization-broken.rs:19:22 | LL | default impl Foo for U | - this type parameter @@ -11,7 +11,7 @@ LL | fn bar(&self) -> U { | help: change the output type to match the trait: `impl Sized` | note: type in trait - --> $DIR/specialization-broken.rs:9:22 + --> $DIR/specialization-broken.rs:12:22 | LL | fn bar(&self) -> impl Sized; | ^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | fn bar(&self) -> impl Sized; found signature `fn(&U) -> U` error: method with return-position `impl Trait` in trait cannot be specialized - --> $DIR/specialization-broken.rs:16:5 + --> $DIR/specialization-broken.rs:19:5 | LL | fn bar(&self) -> U { | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.next.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.next.stderr new file mode 100644 index 0000000000000..f48e7a1ed1407 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/specialization-broken.next.stderr @@ -0,0 +1,31 @@ +error[E0053]: method `bar` has an incompatible type for trait + --> $DIR/specialization-broken.rs:19:22 + | +LL | default impl Foo for U + | - this type parameter +... +LL | fn bar(&self) -> U { + | ^ + | | + | expected associated type, found type parameter `U` + | help: change the output type to match the trait: `impl Sized` + | +note: type in trait + --> $DIR/specialization-broken.rs:12:22 + | +LL | fn bar(&self) -> impl Sized; + | ^^^^^^^^^^ + = note: expected signature `fn(&U) -> impl Sized` + found signature `fn(&U) -> U` + +error: method with return-position `impl Trait` in trait cannot be specialized + --> $DIR/specialization-broken.rs:19:5 + | +LL | fn bar(&self) -> U { + | ^^^^^^^^^^^^^^^^^^ + | + = note: specialization behaves in inconsistent and surprising ways with `#![feature(return_position_impl_trait_in_trait)]`, and for now is disallowed + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.rs b/tests/ui/impl-trait/in-trait/specialization-broken.rs index 2fcffdf3f9a29..658d0709717a1 100644 --- a/tests/ui/impl-trait/in-trait/specialization-broken.rs +++ b/tests/ui/impl-trait/in-trait/specialization-broken.rs @@ -1,3 +1,6 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + // FIXME(compiler-errors): I'm not exactly sure if this is expected to pass or not. // But we fixed an ICE anyways. diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.stderr b/tests/ui/impl-trait/in-trait/wf-bounds.current.stderr similarity index 91% rename from tests/ui/impl-trait/in-trait/wf-bounds.stderr rename to tests/ui/impl-trait/in-trait/wf-bounds.current.stderr index 03cc4c2b93bed..8392f26e7c8ca 100644 --- a/tests/ui/impl-trait/in-trait/wf-bounds.stderr +++ b/tests/ui/impl-trait/in-trait/wf-bounds.current.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:9:22 + --> $DIR/wf-bounds.rs:11:22 | LL | fn nya() -> impl Wf>; | ^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -9,14 +9,14 @@ note: required by a bound in `Vec` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:12:23 + --> $DIR/wf-bounds.rs:14:23 | LL | fn nya2() -> impl Wf<[u8]>; | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `Wf` - --> $DIR/wf-bounds.rs:6:10 + --> $DIR/wf-bounds.rs:8:10 | LL | trait Wf {} | ^ required by this bound in `Wf` diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr b/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr new file mode 100644 index 0000000000000..8392f26e7c8ca --- /dev/null +++ b/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr @@ -0,0 +1,30 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/wf-bounds.rs:11:22 + | +LL | fn nya() -> impl Wf>; + | ^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +note: required by a bound in `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/wf-bounds.rs:14:23 + | +LL | fn nya2() -> impl Wf<[u8]>; + | ^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +note: required by a bound in `Wf` + --> $DIR/wf-bounds.rs:8:10 + | +LL | trait Wf {} + | ^ required by this bound in `Wf` +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Wf {} + | ++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.rs b/tests/ui/impl-trait/in-trait/wf-bounds.rs index 2c71583b31236..39f412753159e 100644 --- a/tests/ui/impl-trait/in-trait/wf-bounds.rs +++ b/tests/ui/impl-trait/in-trait/wf-bounds.rs @@ -1,4 +1,6 @@ // issue #101663 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/issues/issue-32950.rs b/tests/ui/issues/issue-32950.rs index 27d68a11c1f16..18b45ca632bc1 100644 --- a/tests/ui/issues/issue-32950.rs +++ b/tests/ui/issues/issue-32950.rs @@ -3,7 +3,7 @@ #[derive(Debug)] struct Baz( concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros - //~^ ERROR cannot find type `FooBar` in this scope + //~^ ERROR cannot find type `FooBar` ); fn main() {} diff --git a/tests/ui/issues/issue-32950.stderr b/tests/ui/issues/issue-32950.stderr index f6635d982e4ec..c0ad29450161b 100644 --- a/tests/ui/issues/issue-32950.stderr +++ b/tests/ui/issues/issue-32950.stderr @@ -4,11 +4,11 @@ error: `derive` cannot be used on items with type macros LL | concat_idents!(Foo, Bar) | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0412]: cannot find type `FooBar` in this scope +error[E0412]: cannot find type `FooBar` in the expanded code of procedural macro `concat_idents` --> $DIR/issue-32950.rs:5:5 | LL | concat_idents!(Foo, Bar) - | ^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^ `FooBar` not found in expanded code of this procedural macro | = note: this error originates in the macro `concat_idents` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr b/tests/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr index b30bcfb776c8c..8dd2aec95223b 100644 --- a/tests/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr +++ b/tests/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr @@ -13,10 +13,10 @@ error[E0308]: mismatched types --> $DIR/issue-70724-add_type_neq_err_label-unwrap.rs:6:5 | LL | assert_eq!(a, 0); - | ^^^^^^^^^^^^^^^^ expected fn item, found integer + | ^^^^^^^^^^^^^^^^ expected fn item, found `i32` | = note: expected fn item `fn() -> i32 {a}` - found type `{integer}` + found type `i32` = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `fn() -> i32 {a}` doesn't implement `Debug` diff --git a/tests/ui/lifetimes/missing-lifetime-in-alias.rs b/tests/ui/lifetimes/missing-lifetime-in-alias.rs index 51c564c011a86..44be06e1fef7c 100644 --- a/tests/ui/lifetimes/missing-lifetime-in-alias.rs +++ b/tests/ui/lifetimes/missing-lifetime-in-alias.rs @@ -27,5 +27,6 @@ type C<'a, 'b> = as Trait>::Bar; //~| NOTE expected named lifetime parameter //~| NOTE these named lifetimes are available to use //~| NOTE expected 1 lifetime argument +//~| NOTE in this expansion of desugaring of a resized `Span` fn main() {} diff --git a/tests/ui/macros/issue-100199.rs b/tests/ui/macros/issue-100199.rs index 6e50afa075984..0ee657c549a4e 100644 --- a/tests/ui/macros/issue-100199.rs +++ b/tests/ui/macros/issue-100199.rs @@ -1,4 +1,4 @@ -#[issue_100199::struct_with_bound] //~ ERROR cannot find trait `MyTrait` in the crate root +#[issue_100199::struct_with_bound] //~ ERROR cannot find trait `MyTrait` in struct Foo {} // The above must be on the first line so that it's span points to pos 0. // This used to trigger an ICE because the diagnostic emitter would get diff --git a/tests/ui/macros/issue-100199.stderr b/tests/ui/macros/issue-100199.stderr index 2cb45dc12473e..e79b63302000d 100644 --- a/tests/ui/macros/issue-100199.stderr +++ b/tests/ui/macros/issue-100199.stderr @@ -1,14 +1,10 @@ -error[E0405]: cannot find trait `MyTrait` in the crate root +error[E0405]: cannot find trait `MyTrait` in the expanded code of procedural macro `issue_100199::struct_with_bound` --> $DIR/issue-100199.rs:1:1 | LL | #[issue_100199::struct_with_bound] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in the crate root + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `crate::MyTrait` not found in expanded code of this procedural macro | = note: this error originates in the attribute macro `issue_100199::struct_with_bound` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider importing this trait - | -LL | use traits::MyTrait; - | error: aborting due to previous error diff --git a/tests/ui/macros/issue-90557.rs b/tests/ui/macros/issue-90557.rs new file mode 100644 index 0000000000000..5a9aa5dabb70c --- /dev/null +++ b/tests/ui/macros/issue-90557.rs @@ -0,0 +1,18 @@ +struct Example { + foo: T, + bar: U, +} + +macro_rules! impl_example { + ($($t:ty)+) => {$( + impl Example<$t> { //~ ERROR struct takes 2 generic arguments but 1 generic argument was supplied + fn baz() { + println!(":)"); + } + } + )+} +} + +impl_example! { u8 } + +fn main() {} diff --git a/tests/ui/macros/issue-90557.stderr b/tests/ui/macros/issue-90557.stderr new file mode 100644 index 0000000000000..f28521efe75c1 --- /dev/null +++ b/tests/ui/macros/issue-90557.stderr @@ -0,0 +1,22 @@ +error[E0107]: struct takes 2 generic arguments but 1 generic argument was supplied + --> $DIR/issue-90557.rs:8:14 + | +LL | impl Example<$t> { + | ^^^^^^^ expected 2 generic arguments +... +LL | impl_example! { u8 } + | -------------------- + | | | + | | supplied 1 generic argument + | in this macro invocation + | +note: struct defined here, with 2 generic parameters: `T`, `U` + --> $DIR/issue-90557.rs:1:8 + | +LL | struct Example { + | ^^^^^^^ - - + = note: this error originates in the macro `impl_example` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/match/match-type-err-first-arm.rs b/tests/ui/match/match-type-err-first-arm.rs index e9027eb24897f..63e723ee3ddbc 100644 --- a/tests/ui/match/match-type-err-first-arm.rs +++ b/tests/ui/match/match-type-err-first-arm.rs @@ -8,6 +8,7 @@ fn test_func1(n: i32) -> i32 { //~ NOTE expected `i32` because of return type 12 => 'b', //~^ ERROR mismatched types //~| NOTE expected `i32`, found `char` + //~| NOTE in this expansion of desugaring of a resized `Span` _ => 42, } } diff --git a/tests/ui/match/match-type-err-first-arm.stderr b/tests/ui/match/match-type-err-first-arm.stderr index 1cfe7ce1ed726..6ede2fb470334 100644 --- a/tests/ui/match/match-type-err-first-arm.stderr +++ b/tests/ui/match/match-type-err-first-arm.stderr @@ -13,7 +13,7 @@ LL | 12 => 'b' as i32, | ++++++ error[E0308]: `match` arms have incompatible types - --> $DIR/match-type-err-first-arm.rs:18:14 + --> $DIR/match-type-err-first-arm.rs:19:14 | LL | let x = match n { | _____________- @@ -27,7 +27,7 @@ LL | | }; | |_____- `match` arms have incompatible types error[E0308]: `match` arms have incompatible types - --> $DIR/match-type-err-first-arm.rs:34:14 + --> $DIR/match-type-err-first-arm.rs:35:14 | LL | let x = match n { | _____________- @@ -46,7 +46,7 @@ LL | | }; | |_____- `match` arms have incompatible types error[E0308]: `match` arms have incompatible types - --> $DIR/match-type-err-first-arm.rs:46:17 + --> $DIR/match-type-err-first-arm.rs:47:17 | LL | / match Some(0u32) { LL | | Some(x) => { diff --git a/tests/ui/numeric/numeric-cast-3.fixed b/tests/ui/numeric/numeric-cast-3.fixed new file mode 100644 index 0000000000000..d8edf562a0a61 --- /dev/null +++ b/tests/ui/numeric/numeric-cast-3.fixed @@ -0,0 +1,151 @@ +// run-rustfix + +// The `try_into` suggestion doesn't include this, but we do suggest it after applying it +use std::convert::TryInto; + +fn foo(_x: N) {} + +fn main() { + let x_usize: usize = 1; + let x_u64: u64 = 2; + let x_u32: u32 = 3; + let x_u16: u16 = 4; + let x_u8: u8 = 5; + let x_isize: isize = 6; + let x_i64: i64 = 7; + let x_i32: i32 = 8; + let x_i16: i16 = 9; + let x_i8: i8 = 10; + + foo::(x_usize); + foo::(x_u64.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_u32.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_u16.into()); + //~^ ERROR mismatched types + foo::(x_u8.into()); + //~^ ERROR mismatched types + foo::(x_isize.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i64.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i32.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i16.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i8.try_into().unwrap()); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); + + foo::(x_usize.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_u64.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_u32.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_u16.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_u8.into()); + //~^ ERROR mismatched types + foo::(x_isize); + foo::(x_i64.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i32.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i16.into()); + //~^ ERROR mismatched types + foo::(x_i8.into()); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); + + foo::(x_usize.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_u64); + foo::(x_u32.into()); + //~^ ERROR mismatched types + foo::(x_u16.into()); + //~^ ERROR mismatched types + foo::(x_u8.into()); + //~^ ERROR mismatched types + foo::(x_isize.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i64.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i32.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i16.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i8.try_into().unwrap()); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); + + foo::(x_usize.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_u64.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_u32.into()); + //~^ ERROR mismatched types + foo::(x_u16.into()); + //~^ ERROR mismatched types + foo::(x_u8.into()); + //~^ ERROR mismatched types + foo::(x_isize.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i64); + foo::(x_i32.into()); + //~^ ERROR mismatched types + foo::(x_i16.into()); + //~^ ERROR mismatched types + foo::(x_i8.into()); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); + + foo::(x_usize.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_u64.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_u32); + foo::(x_u16.into()); + //~^ ERROR mismatched types + foo::(x_u8.into()); + //~^ ERROR mismatched types + foo::(x_isize.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i64.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i32.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i16.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i8.try_into().unwrap()); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); + + foo::(x_usize.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_u64.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_u32.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_u16.into()); + //~^ ERROR mismatched types + foo::(x_u8.into()); + //~^ ERROR mismatched types + foo::(x_isize.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i64.try_into().unwrap()); + //~^ ERROR mismatched types + foo::(x_i32); + foo::(x_i16.into()); + //~^ ERROR mismatched types + foo::(x_i8.into()); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); +} diff --git a/tests/ui/numeric/numeric-cast-3.rs b/tests/ui/numeric/numeric-cast-3.rs new file mode 100644 index 0000000000000..990320cf2aa99 --- /dev/null +++ b/tests/ui/numeric/numeric-cast-3.rs @@ -0,0 +1,151 @@ +// run-rustfix + +// The `try_into` suggestion doesn't include this, but we do suggest it after applying it +use std::convert::TryInto; + +fn foo(_x: N) {} + +fn main() { + let x_usize: usize = 1; + let x_u64: u64 = 2; + let x_u32: u32 = 3; + let x_u16: u16 = 4; + let x_u8: u8 = 5; + let x_isize: isize = 6; + let x_i64: i64 = 7; + let x_i32: i32 = 8; + let x_i16: i16 = 9; + let x_i8: i8 = 10; + + foo::(x_usize); + foo::(x_u64); + //~^ ERROR mismatched types + foo::(x_u32); + //~^ ERROR mismatched types + foo::(x_u16); + //~^ ERROR mismatched types + foo::(x_u8); + //~^ ERROR mismatched types + foo::(x_isize); + //~^ ERROR mismatched types + foo::(x_i64); + //~^ ERROR mismatched types + foo::(x_i32); + //~^ ERROR mismatched types + foo::(x_i16); + //~^ ERROR mismatched types + foo::(x_i8); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); + + foo::(x_usize); + //~^ ERROR mismatched types + foo::(x_u64); + //~^ ERROR mismatched types + foo::(x_u32); + //~^ ERROR mismatched types + foo::(x_u16); + //~^ ERROR mismatched types + foo::(x_u8); + //~^ ERROR mismatched types + foo::(x_isize); + foo::(x_i64); + //~^ ERROR mismatched types + foo::(x_i32); + //~^ ERROR mismatched types + foo::(x_i16); + //~^ ERROR mismatched types + foo::(x_i8); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); + + foo::(x_usize); + //~^ ERROR mismatched types + foo::(x_u64); + foo::(x_u32); + //~^ ERROR mismatched types + foo::(x_u16); + //~^ ERROR mismatched types + foo::(x_u8); + //~^ ERROR mismatched types + foo::(x_isize); + //~^ ERROR mismatched types + foo::(x_i64); + //~^ ERROR mismatched types + foo::(x_i32); + //~^ ERROR mismatched types + foo::(x_i16); + //~^ ERROR mismatched types + foo::(x_i8); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); + + foo::(x_usize); + //~^ ERROR mismatched types + foo::(x_u64); + //~^ ERROR mismatched types + foo::(x_u32); + //~^ ERROR mismatched types + foo::(x_u16); + //~^ ERROR mismatched types + foo::(x_u8); + //~^ ERROR mismatched types + foo::(x_isize); + //~^ ERROR mismatched types + foo::(x_i64); + foo::(x_i32); + //~^ ERROR mismatched types + foo::(x_i16); + //~^ ERROR mismatched types + foo::(x_i8); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); + + foo::(x_usize); + //~^ ERROR mismatched types + foo::(x_u64); + //~^ ERROR mismatched types + foo::(x_u32); + foo::(x_u16); + //~^ ERROR mismatched types + foo::(x_u8); + //~^ ERROR mismatched types + foo::(x_isize); + //~^ ERROR mismatched types + foo::(x_i64); + //~^ ERROR mismatched types + foo::(x_i32); + //~^ ERROR mismatched types + foo::(x_i16); + //~^ ERROR mismatched types + foo::(x_i8); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); + + foo::(x_usize); + //~^ ERROR mismatched types + foo::(x_u64); + //~^ ERROR mismatched types + foo::(x_u32); + //~^ ERROR mismatched types + foo::(x_u16); + //~^ ERROR mismatched types + foo::(x_u8); + //~^ ERROR mismatched types + foo::(x_isize); + //~^ ERROR mismatched types + foo::(x_i64); + //~^ ERROR mismatched types + foo::(x_i32); + foo::(x_i16); + //~^ ERROR mismatched types + foo::(x_i8); + //~^ ERROR mismatched types + // foo::(x_f64); + // foo::(x_f32); +} diff --git a/tests/ui/numeric/numeric-cast-3.stderr b/tests/ui/numeric/numeric-cast-3.stderr new file mode 100644 index 0000000000000..d086fea4788f6 --- /dev/null +++ b/tests/ui/numeric/numeric-cast-3.stderr @@ -0,0 +1,975 @@ +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:21:18 + | +LL | foo::(x_u64); + | ------------ ^^^^^ expected `usize`, found `u64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u64` to a `usize` and panic if the converted value doesn't fit + | +LL | foo::(x_u64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:23:18 + | +LL | foo::(x_u32); + | ------------ ^^^^^ expected `usize`, found `u32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit + | +LL | foo::(x_u32.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:25:18 + | +LL | foo::(x_u16); + | ------------ ^^^^^ expected `usize`, found `u16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u16` to a `usize` + | +LL | foo::(x_u16.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:27:18 + | +LL | foo::(x_u8); + | ------------ ^^^^ expected `usize`, found `u8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u8` to a `usize` + | +LL | foo::(x_u8.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:29:18 + | +LL | foo::(x_isize); + | ------------ ^^^^^^^ expected `usize`, found `isize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `isize` to a `usize` and panic if the converted value doesn't fit + | +LL | foo::(x_isize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:31:18 + | +LL | foo::(x_i64); + | ------------ ^^^^^ expected `usize`, found `i64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i64` to a `usize` and panic if the converted value doesn't fit + | +LL | foo::(x_i64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:33:18 + | +LL | foo::(x_i32); + | ------------ ^^^^^ expected `usize`, found `i32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i32` to a `usize` and panic if the converted value doesn't fit + | +LL | foo::(x_i32.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:35:18 + | +LL | foo::(x_i16); + | ------------ ^^^^^ expected `usize`, found `i16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i16` to a `usize` and panic if the converted value doesn't fit + | +LL | foo::(x_i16.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:37:18 + | +LL | foo::(x_i8); + | ------------ ^^^^ expected `usize`, found `i8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i8` to a `usize` and panic if the converted value doesn't fit + | +LL | foo::(x_i8.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:42:18 + | +LL | foo::(x_usize); + | ------------ ^^^^^^^ expected `isize`, found `usize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit + | +LL | foo::(x_usize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:44:18 + | +LL | foo::(x_u64); + | ------------ ^^^^^ expected `isize`, found `u64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u64` to an `isize` and panic if the converted value doesn't fit + | +LL | foo::(x_u64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:46:18 + | +LL | foo::(x_u32); + | ------------ ^^^^^ expected `isize`, found `u32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u32` to an `isize` and panic if the converted value doesn't fit + | +LL | foo::(x_u32.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:48:18 + | +LL | foo::(x_u16); + | ------------ ^^^^^ expected `isize`, found `u16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u16` to an `isize` and panic if the converted value doesn't fit + | +LL | foo::(x_u16.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:50:18 + | +LL | foo::(x_u8); + | ------------ ^^^^ expected `isize`, found `u8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u8` to an `isize` + | +LL | foo::(x_u8.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:53:18 + | +LL | foo::(x_i64); + | ------------ ^^^^^ expected `isize`, found `i64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i64` to an `isize` and panic if the converted value doesn't fit + | +LL | foo::(x_i64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:55:18 + | +LL | foo::(x_i32); + | ------------ ^^^^^ expected `isize`, found `i32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i32` to an `isize` and panic if the converted value doesn't fit + | +LL | foo::(x_i32.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:57:18 + | +LL | foo::(x_i16); + | ------------ ^^^^^ expected `isize`, found `i16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i16` to an `isize` + | +LL | foo::(x_i16.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:59:18 + | +LL | foo::(x_i8); + | ------------ ^^^^ expected `isize`, found `i8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i8` to an `isize` + | +LL | foo::(x_i8.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:64:16 + | +LL | foo::(x_usize); + | ---------- ^^^^^^^ expected `u64`, found `usize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit + | +LL | foo::(x_usize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:67:16 + | +LL | foo::(x_u32); + | ---------- ^^^^^ expected `u64`, found `u32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u32` to a `u64` + | +LL | foo::(x_u32.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:69:16 + | +LL | foo::(x_u16); + | ---------- ^^^^^ expected `u64`, found `u16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u16` to a `u64` + | +LL | foo::(x_u16.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:71:16 + | +LL | foo::(x_u8); + | ---------- ^^^^ expected `u64`, found `u8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u8` to a `u64` + | +LL | foo::(x_u8.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:73:16 + | +LL | foo::(x_isize); + | ---------- ^^^^^^^ expected `u64`, found `isize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `isize` to a `u64` and panic if the converted value doesn't fit + | +LL | foo::(x_isize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:75:16 + | +LL | foo::(x_i64); + | ---------- ^^^^^ expected `u64`, found `i64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i64` to a `u64` and panic if the converted value doesn't fit + | +LL | foo::(x_i64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:77:16 + | +LL | foo::(x_i32); + | ---------- ^^^^^ expected `u64`, found `i32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i32` to a `u64` and panic if the converted value doesn't fit + | +LL | foo::(x_i32.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:79:16 + | +LL | foo::(x_i16); + | ---------- ^^^^^ expected `u64`, found `i16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i16` to a `u64` and panic if the converted value doesn't fit + | +LL | foo::(x_i16.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:81:16 + | +LL | foo::(x_i8); + | ---------- ^^^^ expected `u64`, found `i8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i8` to a `u64` and panic if the converted value doesn't fit + | +LL | foo::(x_i8.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:86:16 + | +LL | foo::(x_usize); + | ---------- ^^^^^^^ expected `i64`, found `usize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `usize` to an `i64` and panic if the converted value doesn't fit + | +LL | foo::(x_usize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:88:16 + | +LL | foo::(x_u64); + | ---------- ^^^^^ expected `i64`, found `u64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u64` to an `i64` and panic if the converted value doesn't fit + | +LL | foo::(x_u64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:90:16 + | +LL | foo::(x_u32); + | ---------- ^^^^^ expected `i64`, found `u32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u32` to an `i64` + | +LL | foo::(x_u32.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:92:16 + | +LL | foo::(x_u16); + | ---------- ^^^^^ expected `i64`, found `u16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u16` to an `i64` + | +LL | foo::(x_u16.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:94:16 + | +LL | foo::(x_u8); + | ---------- ^^^^ expected `i64`, found `u8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u8` to an `i64` + | +LL | foo::(x_u8.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:96:16 + | +LL | foo::(x_isize); + | ---------- ^^^^^^^ expected `i64`, found `isize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `isize` to an `i64` and panic if the converted value doesn't fit + | +LL | foo::(x_isize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:99:16 + | +LL | foo::(x_i32); + | ---------- ^^^^^ expected `i64`, found `i32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i32` to an `i64` + | +LL | foo::(x_i32.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:101:16 + | +LL | foo::(x_i16); + | ---------- ^^^^^ expected `i64`, found `i16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i16` to an `i64` + | +LL | foo::(x_i16.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:103:16 + | +LL | foo::(x_i8); + | ---------- ^^^^ expected `i64`, found `i8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i8` to an `i64` + | +LL | foo::(x_i8.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:108:16 + | +LL | foo::(x_usize); + | ---------- ^^^^^^^ expected `u32`, found `usize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit + | +LL | foo::(x_usize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:110:16 + | +LL | foo::(x_u64); + | ---------- ^^^^^ expected `u32`, found `u64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit + | +LL | foo::(x_u64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:113:16 + | +LL | foo::(x_u16); + | ---------- ^^^^^ expected `u32`, found `u16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u16` to a `u32` + | +LL | foo::(x_u16.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:115:16 + | +LL | foo::(x_u8); + | ---------- ^^^^ expected `u32`, found `u8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u8` to a `u32` + | +LL | foo::(x_u8.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:117:16 + | +LL | foo::(x_isize); + | ---------- ^^^^^^^ expected `u32`, found `isize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `isize` to a `u32` and panic if the converted value doesn't fit + | +LL | foo::(x_isize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:119:16 + | +LL | foo::(x_i64); + | ---------- ^^^^^ expected `u32`, found `i64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i64` to a `u32` and panic if the converted value doesn't fit + | +LL | foo::(x_i64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:121:16 + | +LL | foo::(x_i32); + | ---------- ^^^^^ expected `u32`, found `i32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i32` to a `u32` and panic if the converted value doesn't fit + | +LL | foo::(x_i32.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:123:16 + | +LL | foo::(x_i16); + | ---------- ^^^^^ expected `u32`, found `i16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i16` to a `u32` and panic if the converted value doesn't fit + | +LL | foo::(x_i16.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:125:16 + | +LL | foo::(x_i8); + | ---------- ^^^^ expected `u32`, found `i8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i8` to a `u32` and panic if the converted value doesn't fit + | +LL | foo::(x_i8.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:130:16 + | +LL | foo::(x_usize); + | ---------- ^^^^^^^ expected `i32`, found `usize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `usize` to an `i32` and panic if the converted value doesn't fit + | +LL | foo::(x_usize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:132:16 + | +LL | foo::(x_u64); + | ---------- ^^^^^ expected `i32`, found `u64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u64` to an `i32` and panic if the converted value doesn't fit + | +LL | foo::(x_u64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:134:16 + | +LL | foo::(x_u32); + | ---------- ^^^^^ expected `i32`, found `u32` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit + | +LL | foo::(x_u32.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:136:16 + | +LL | foo::(x_u16); + | ---------- ^^^^^ expected `i32`, found `u16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u16` to an `i32` + | +LL | foo::(x_u16.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:138:16 + | +LL | foo::(x_u8); + | ---------- ^^^^ expected `i32`, found `u8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert a `u8` to an `i32` + | +LL | foo::(x_u8.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:140:16 + | +LL | foo::(x_isize); + | ---------- ^^^^^^^ expected `i32`, found `isize` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `isize` to an `i32` and panic if the converted value doesn't fit + | +LL | foo::(x_isize.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:142:16 + | +LL | foo::(x_i64); + | ---------- ^^^^^ expected `i32`, found `i64` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i64` to an `i32` and panic if the converted value doesn't fit + | +LL | foo::(x_i64.try_into().unwrap()); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:145:16 + | +LL | foo::(x_i16); + | ---------- ^^^^^ expected `i32`, found `i16` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i16` to an `i32` + | +LL | foo::(x_i16.into()); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-3.rs:147:16 + | +LL | foo::(x_i8); + | ---------- ^^^^ expected `i32`, found `i8` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/numeric-cast-3.rs:6:4 + | +LL | fn foo(_x: N) {} + | ^^^ ----- +help: you can convert an `i8` to an `i32` + | +LL | foo::(x_i8.into()); + | +++++++ + +error: aborting due to 54 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/numeric/numeric-cast-binop-2.fixed b/tests/ui/numeric/numeric-cast-binop-2.fixed new file mode 100644 index 0000000000000..61cf2795537a6 --- /dev/null +++ b/tests/ui/numeric/numeric-cast-binop-2.fixed @@ -0,0 +1,158 @@ +// run-rustfix + +// The `try_into` suggestion doesn't include this, but we do suggest it after applying it +use std::convert::TryInto; + +#[allow(unused_must_use)] +fn main() { + let x_usize: usize = 1; + let x_u128: u128 = 2; + let x_u64: u64 = 3; + let x_u32: u32 = 4; + let x_u16: u16 = 5; + let x_u8: u8 = 6; + let x_isize: isize = 7; + let x_i64: i64 = 8; + let x_i32: i32 = 9; + let x_i16: i16 = 10; + let x_i8: i8 = 11; + let x_i128: i128 = 12; + + /* u<->u */ + { + u16::from(x_u8) > x_u16; + //~^ ERROR mismatched types + u32::from(x_u8) > x_u32; + //~^ ERROR mismatched types + u64::from(x_u8) > x_u64; + //~^ ERROR mismatched types + u128::from(x_u8) > x_u128; + //~^ ERROR mismatched types + usize::from(x_u8) > x_usize; + //~^ ERROR mismatched types + + x_u16 > x_u8.into(); + //~^ ERROR mismatched types + u32::from(x_u16) > x_u32; + //~^ ERROR mismatched types + u64::from(x_u16) > x_u64; + //~^ ERROR mismatched types + u128::from(x_u16) > x_u128; + //~^ ERROR mismatched types + usize::from(x_u16) > x_usize; + //~^ ERROR mismatched types + + x_u32 > x_u8.into(); + //~^ ERROR mismatched types + x_u32 > x_u16.into(); + //~^ ERROR mismatched types + u64::from(x_u32) > x_u64; + //~^ ERROR mismatched types + u128::from(x_u32) > x_u128; + //~^ ERROR mismatched types + x_u32 > x_usize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_u64 > x_u8.into(); + //~^ ERROR mismatched types + x_u64 > x_u16.into(); + //~^ ERROR mismatched types + x_u64 > x_u32.into(); + //~^ ERROR mismatched types + u128::from(x_u64) > x_u128; + //~^ ERROR mismatched types + x_u64 > x_usize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_u128 > x_u8.into(); + //~^ ERROR mismatched types + x_u128 > x_u16.into(); + //~^ ERROR mismatched types + x_u128 > x_u32.into(); + //~^ ERROR mismatched types + x_u128 > x_u64.into(); + //~^ ERROR mismatched types + x_u128 > x_usize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_usize > x_u8.into(); + //~^ ERROR mismatched types + x_usize > x_u16.into(); + //~^ ERROR mismatched types + x_usize > x_u32.try_into().unwrap(); + //~^ ERROR mismatched types + x_usize > x_u64.try_into().unwrap(); + //~^ ERROR mismatched types + x_usize > x_u128.try_into().unwrap(); + //~^ ERROR mismatched types + } + + /* i<->i */ + { + i16::from(x_i8) > x_i16; + //~^ ERROR mismatched types + i32::from(x_i8) > x_i32; + //~^ ERROR mismatched types + i64::from(x_i8) > x_i64; + //~^ ERROR mismatched types + i128::from(x_i8) > x_i128; + //~^ ERROR mismatched types + isize::from(x_i8) > x_isize; + //~^ ERROR mismatched types + + x_i16 > x_i8.into(); + //~^ ERROR mismatched types + i32::from(x_i16) > x_i32; + //~^ ERROR mismatched types + i64::from(x_i16) > x_i64; + //~^ ERROR mismatched types + i128::from(x_i16) > x_i128; + //~^ ERROR mismatched types + isize::from(x_i16) > x_isize; + //~^ ERROR mismatched types + + x_i32 > x_i8.into(); + //~^ ERROR mismatched types + x_i32 > x_i16.into(); + //~^ ERROR mismatched types + i64::from(x_i32) > x_i64; + //~^ ERROR mismatched types + i128::from(x_i32) > x_i128; + //~^ ERROR mismatched types + x_i32 > x_isize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_i64 > x_i8.into(); + //~^ ERROR mismatched types + x_i64 > x_i16.into(); + //~^ ERROR mismatched types + x_i64 > x_i32.into(); + //~^ ERROR mismatched types + i128::from(x_i64) > x_i128; + //~^ ERROR mismatched types + x_i64 > x_isize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_i128 > x_i8.into(); + //~^ ERROR mismatched types + x_i128 > x_i16.into(); + //~^ ERROR mismatched types + x_i128 > x_i32.into(); + //~^ ERROR mismatched types + x_i128 > x_i64.into(); + //~^ ERROR mismatched types + x_i128 > x_isize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_isize > x_i8.into(); + //~^ ERROR mismatched types + x_isize > x_i16.into(); + //~^ ERROR mismatched types + x_isize > x_i32.try_into().unwrap(); + //~^ ERROR mismatched types + x_isize > x_i64.try_into().unwrap(); + //~^ ERROR mismatched types + x_isize > x_i128.try_into().unwrap(); + //~^ ERROR mismatched types + } +} diff --git a/tests/ui/numeric/numeric-cast-binop-2.rs b/tests/ui/numeric/numeric-cast-binop-2.rs new file mode 100644 index 0000000000000..37329bbb4cb1d --- /dev/null +++ b/tests/ui/numeric/numeric-cast-binop-2.rs @@ -0,0 +1,158 @@ +// run-rustfix + +// The `try_into` suggestion doesn't include this, but we do suggest it after applying it +use std::convert::TryInto; + +#[allow(unused_must_use)] +fn main() { + let x_usize: usize = 1; + let x_u128: u128 = 2; + let x_u64: u64 = 3; + let x_u32: u32 = 4; + let x_u16: u16 = 5; + let x_u8: u8 = 6; + let x_isize: isize = 7; + let x_i64: i64 = 8; + let x_i32: i32 = 9; + let x_i16: i16 = 10; + let x_i8: i8 = 11; + let x_i128: i128 = 12; + + /* u<->u */ + { + x_u8 > x_u16; + //~^ ERROR mismatched types + x_u8 > x_u32; + //~^ ERROR mismatched types + x_u8 > x_u64; + //~^ ERROR mismatched types + x_u8 > x_u128; + //~^ ERROR mismatched types + x_u8 > x_usize; + //~^ ERROR mismatched types + + x_u16 > x_u8; + //~^ ERROR mismatched types + x_u16 > x_u32; + //~^ ERROR mismatched types + x_u16 > x_u64; + //~^ ERROR mismatched types + x_u16 > x_u128; + //~^ ERROR mismatched types + x_u16 > x_usize; + //~^ ERROR mismatched types + + x_u32 > x_u8; + //~^ ERROR mismatched types + x_u32 > x_u16; + //~^ ERROR mismatched types + x_u32 > x_u64; + //~^ ERROR mismatched types + x_u32 > x_u128; + //~^ ERROR mismatched types + x_u32 > x_usize; + //~^ ERROR mismatched types + + x_u64 > x_u8; + //~^ ERROR mismatched types + x_u64 > x_u16; + //~^ ERROR mismatched types + x_u64 > x_u32; + //~^ ERROR mismatched types + x_u64 > x_u128; + //~^ ERROR mismatched types + x_u64 > x_usize; + //~^ ERROR mismatched types + + x_u128 > x_u8; + //~^ ERROR mismatched types + x_u128 > x_u16; + //~^ ERROR mismatched types + x_u128 > x_u32; + //~^ ERROR mismatched types + x_u128 > x_u64; + //~^ ERROR mismatched types + x_u128 > x_usize; + //~^ ERROR mismatched types + + x_usize > x_u8; + //~^ ERROR mismatched types + x_usize > x_u16; + //~^ ERROR mismatched types + x_usize > x_u32; + //~^ ERROR mismatched types + x_usize > x_u64; + //~^ ERROR mismatched types + x_usize > x_u128; + //~^ ERROR mismatched types + } + + /* i<->i */ + { + x_i8 > x_i16; + //~^ ERROR mismatched types + x_i8 > x_i32; + //~^ ERROR mismatched types + x_i8 > x_i64; + //~^ ERROR mismatched types + x_i8 > x_i128; + //~^ ERROR mismatched types + x_i8 > x_isize; + //~^ ERROR mismatched types + + x_i16 > x_i8; + //~^ ERROR mismatched types + x_i16 > x_i32; + //~^ ERROR mismatched types + x_i16 > x_i64; + //~^ ERROR mismatched types + x_i16 > x_i128; + //~^ ERROR mismatched types + x_i16 > x_isize; + //~^ ERROR mismatched types + + x_i32 > x_i8; + //~^ ERROR mismatched types + x_i32 > x_i16; + //~^ ERROR mismatched types + x_i32 > x_i64; + //~^ ERROR mismatched types + x_i32 > x_i128; + //~^ ERROR mismatched types + x_i32 > x_isize; + //~^ ERROR mismatched types + + x_i64 > x_i8; + //~^ ERROR mismatched types + x_i64 > x_i16; + //~^ ERROR mismatched types + x_i64 > x_i32; + //~^ ERROR mismatched types + x_i64 > x_i128; + //~^ ERROR mismatched types + x_i64 > x_isize; + //~^ ERROR mismatched types + + x_i128 > x_i8; + //~^ ERROR mismatched types + x_i128 > x_i16; + //~^ ERROR mismatched types + x_i128 > x_i32; + //~^ ERROR mismatched types + x_i128 > x_i64; + //~^ ERROR mismatched types + x_i128 > x_isize; + //~^ ERROR mismatched types + + x_isize > x_i8; + //~^ ERROR mismatched types + x_isize > x_i16; + //~^ ERROR mismatched types + x_isize > x_i32; + //~^ ERROR mismatched types + x_isize > x_i64; + //~^ ERROR mismatched types + x_isize > x_i128; + //~^ ERROR mismatched types + } +} diff --git a/tests/ui/numeric/numeric-cast-binop-2.stderr b/tests/ui/numeric/numeric-cast-binop-2.stderr new file mode 100644 index 0000000000000..7050969d55165 --- /dev/null +++ b/tests/ui/numeric/numeric-cast-binop-2.stderr @@ -0,0 +1,783 @@ +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:23:16 + | +LL | x_u8 > x_u16; + | ---- ^^^^^ expected `u8`, found `u16` + | | + | expected because this is `u8` + | +help: you can convert `x_u8` from `u8` to `u16`, matching the type of `x_u16` + | +LL | u16::from(x_u8) > x_u16; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:25:16 + | +LL | x_u8 > x_u32; + | ---- ^^^^^ expected `u8`, found `u32` + | | + | expected because this is `u8` + | +help: you can convert `x_u8` from `u8` to `u32`, matching the type of `x_u32` + | +LL | u32::from(x_u8) > x_u32; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:27:16 + | +LL | x_u8 > x_u64; + | ---- ^^^^^ expected `u8`, found `u64` + | | + | expected because this is `u8` + | +help: you can convert `x_u8` from `u8` to `u64`, matching the type of `x_u64` + | +LL | u64::from(x_u8) > x_u64; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:29:16 + | +LL | x_u8 > x_u128; + | ---- ^^^^^^ expected `u8`, found `u128` + | | + | expected because this is `u8` + | +help: you can convert `x_u8` from `u8` to `u128`, matching the type of `x_u128` + | +LL | u128::from(x_u8) > x_u128; + | +++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:31:16 + | +LL | x_u8 > x_usize; + | ---- ^^^^^^^ expected `u8`, found `usize` + | | + | expected because this is `u8` + | +help: you can convert `x_u8` from `u8` to `usize`, matching the type of `x_usize` + | +LL | usize::from(x_u8) > x_usize; + | ++++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:34:17 + | +LL | x_u16 > x_u8; + | ----- ^^^^ expected `u16`, found `u8` + | | + | expected because this is `u16` + | +help: you can convert a `u8` to a `u16` + | +LL | x_u16 > x_u8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:36:17 + | +LL | x_u16 > x_u32; + | ----- ^^^^^ expected `u16`, found `u32` + | | + | expected because this is `u16` + | +help: you can convert `x_u16` from `u16` to `u32`, matching the type of `x_u32` + | +LL | u32::from(x_u16) > x_u32; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:38:17 + | +LL | x_u16 > x_u64; + | ----- ^^^^^ expected `u16`, found `u64` + | | + | expected because this is `u16` + | +help: you can convert `x_u16` from `u16` to `u64`, matching the type of `x_u64` + | +LL | u64::from(x_u16) > x_u64; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:40:17 + | +LL | x_u16 > x_u128; + | ----- ^^^^^^ expected `u16`, found `u128` + | | + | expected because this is `u16` + | +help: you can convert `x_u16` from `u16` to `u128`, matching the type of `x_u128` + | +LL | u128::from(x_u16) > x_u128; + | +++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:42:17 + | +LL | x_u16 > x_usize; + | ----- ^^^^^^^ expected `u16`, found `usize` + | | + | expected because this is `u16` + | +help: you can convert `x_u16` from `u16` to `usize`, matching the type of `x_usize` + | +LL | usize::from(x_u16) > x_usize; + | ++++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:45:17 + | +LL | x_u32 > x_u8; + | ----- ^^^^ expected `u32`, found `u8` + | | + | expected because this is `u32` + | +help: you can convert a `u8` to a `u32` + | +LL | x_u32 > x_u8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:47:17 + | +LL | x_u32 > x_u16; + | ----- ^^^^^ expected `u32`, found `u16` + | | + | expected because this is `u32` + | +help: you can convert a `u16` to a `u32` + | +LL | x_u32 > x_u16.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:49:17 + | +LL | x_u32 > x_u64; + | ----- ^^^^^ expected `u32`, found `u64` + | | + | expected because this is `u32` + | +help: you can convert `x_u32` from `u32` to `u64`, matching the type of `x_u64` + | +LL | u64::from(x_u32) > x_u64; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:51:17 + | +LL | x_u32 > x_u128; + | ----- ^^^^^^ expected `u32`, found `u128` + | | + | expected because this is `u32` + | +help: you can convert `x_u32` from `u32` to `u128`, matching the type of `x_u128` + | +LL | u128::from(x_u32) > x_u128; + | +++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:53:17 + | +LL | x_u32 > x_usize; + | ----- ^^^^^^^ expected `u32`, found `usize` + | | + | expected because this is `u32` + | +help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit + | +LL | x_u32 > x_usize.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:56:17 + | +LL | x_u64 > x_u8; + | ----- ^^^^ expected `u64`, found `u8` + | | + | expected because this is `u64` + | +help: you can convert a `u8` to a `u64` + | +LL | x_u64 > x_u8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:58:17 + | +LL | x_u64 > x_u16; + | ----- ^^^^^ expected `u64`, found `u16` + | | + | expected because this is `u64` + | +help: you can convert a `u16` to a `u64` + | +LL | x_u64 > x_u16.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:60:17 + | +LL | x_u64 > x_u32; + | ----- ^^^^^ expected `u64`, found `u32` + | | + | expected because this is `u64` + | +help: you can convert a `u32` to a `u64` + | +LL | x_u64 > x_u32.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:62:17 + | +LL | x_u64 > x_u128; + | ----- ^^^^^^ expected `u64`, found `u128` + | | + | expected because this is `u64` + | +help: you can convert `x_u64` from `u64` to `u128`, matching the type of `x_u128` + | +LL | u128::from(x_u64) > x_u128; + | +++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:64:17 + | +LL | x_u64 > x_usize; + | ----- ^^^^^^^ expected `u64`, found `usize` + | | + | expected because this is `u64` + | +help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit + | +LL | x_u64 > x_usize.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:67:18 + | +LL | x_u128 > x_u8; + | ------ ^^^^ expected `u128`, found `u8` + | | + | expected because this is `u128` + | +help: you can convert a `u8` to a `u128` + | +LL | x_u128 > x_u8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:69:18 + | +LL | x_u128 > x_u16; + | ------ ^^^^^ expected `u128`, found `u16` + | | + | expected because this is `u128` + | +help: you can convert a `u16` to a `u128` + | +LL | x_u128 > x_u16.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:71:18 + | +LL | x_u128 > x_u32; + | ------ ^^^^^ expected `u128`, found `u32` + | | + | expected because this is `u128` + | +help: you can convert a `u32` to a `u128` + | +LL | x_u128 > x_u32.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:73:18 + | +LL | x_u128 > x_u64; + | ------ ^^^^^ expected `u128`, found `u64` + | | + | expected because this is `u128` + | +help: you can convert a `u64` to a `u128` + | +LL | x_u128 > x_u64.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:75:18 + | +LL | x_u128 > x_usize; + | ------ ^^^^^^^ expected `u128`, found `usize` + | | + | expected because this is `u128` + | +help: you can convert a `usize` to a `u128` and panic if the converted value doesn't fit + | +LL | x_u128 > x_usize.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:78:19 + | +LL | x_usize > x_u8; + | ------- ^^^^ expected `usize`, found `u8` + | | + | expected because this is `usize` + | +help: you can convert a `u8` to a `usize` + | +LL | x_usize > x_u8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:80:19 + | +LL | x_usize > x_u16; + | ------- ^^^^^ expected `usize`, found `u16` + | | + | expected because this is `usize` + | +help: you can convert a `u16` to a `usize` + | +LL | x_usize > x_u16.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:82:19 + | +LL | x_usize > x_u32; + | ------- ^^^^^ expected `usize`, found `u32` + | | + | expected because this is `usize` + | +help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit + | +LL | x_usize > x_u32.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:84:19 + | +LL | x_usize > x_u64; + | ------- ^^^^^ expected `usize`, found `u64` + | | + | expected because this is `usize` + | +help: you can convert a `u64` to a `usize` and panic if the converted value doesn't fit + | +LL | x_usize > x_u64.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:86:19 + | +LL | x_usize > x_u128; + | ------- ^^^^^^ expected `usize`, found `u128` + | | + | expected because this is `usize` + | +help: you can convert a `u128` to a `usize` and panic if the converted value doesn't fit + | +LL | x_usize > x_u128.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:92:16 + | +LL | x_i8 > x_i16; + | ---- ^^^^^ expected `i8`, found `i16` + | | + | expected because this is `i8` + | +help: you can convert `x_i8` from `i8` to `i16`, matching the type of `x_i16` + | +LL | i16::from(x_i8) > x_i16; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:94:16 + | +LL | x_i8 > x_i32; + | ---- ^^^^^ expected `i8`, found `i32` + | | + | expected because this is `i8` + | +help: you can convert `x_i8` from `i8` to `i32`, matching the type of `x_i32` + | +LL | i32::from(x_i8) > x_i32; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:96:16 + | +LL | x_i8 > x_i64; + | ---- ^^^^^ expected `i8`, found `i64` + | | + | expected because this is `i8` + | +help: you can convert `x_i8` from `i8` to `i64`, matching the type of `x_i64` + | +LL | i64::from(x_i8) > x_i64; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:98:16 + | +LL | x_i8 > x_i128; + | ---- ^^^^^^ expected `i8`, found `i128` + | | + | expected because this is `i8` + | +help: you can convert `x_i8` from `i8` to `i128`, matching the type of `x_i128` + | +LL | i128::from(x_i8) > x_i128; + | +++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:100:16 + | +LL | x_i8 > x_isize; + | ---- ^^^^^^^ expected `i8`, found `isize` + | | + | expected because this is `i8` + | +help: you can convert `x_i8` from `i8` to `isize`, matching the type of `x_isize` + | +LL | isize::from(x_i8) > x_isize; + | ++++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:103:17 + | +LL | x_i16 > x_i8; + | ----- ^^^^ expected `i16`, found `i8` + | | + | expected because this is `i16` + | +help: you can convert an `i8` to an `i16` + | +LL | x_i16 > x_i8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:105:17 + | +LL | x_i16 > x_i32; + | ----- ^^^^^ expected `i16`, found `i32` + | | + | expected because this is `i16` + | +help: you can convert `x_i16` from `i16` to `i32`, matching the type of `x_i32` + | +LL | i32::from(x_i16) > x_i32; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:107:17 + | +LL | x_i16 > x_i64; + | ----- ^^^^^ expected `i16`, found `i64` + | | + | expected because this is `i16` + | +help: you can convert `x_i16` from `i16` to `i64`, matching the type of `x_i64` + | +LL | i64::from(x_i16) > x_i64; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:109:17 + | +LL | x_i16 > x_i128; + | ----- ^^^^^^ expected `i16`, found `i128` + | | + | expected because this is `i16` + | +help: you can convert `x_i16` from `i16` to `i128`, matching the type of `x_i128` + | +LL | i128::from(x_i16) > x_i128; + | +++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:111:17 + | +LL | x_i16 > x_isize; + | ----- ^^^^^^^ expected `i16`, found `isize` + | | + | expected because this is `i16` + | +help: you can convert `x_i16` from `i16` to `isize`, matching the type of `x_isize` + | +LL | isize::from(x_i16) > x_isize; + | ++++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:114:17 + | +LL | x_i32 > x_i8; + | ----- ^^^^ expected `i32`, found `i8` + | | + | expected because this is `i32` + | +help: you can convert an `i8` to an `i32` + | +LL | x_i32 > x_i8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:116:17 + | +LL | x_i32 > x_i16; + | ----- ^^^^^ expected `i32`, found `i16` + | | + | expected because this is `i32` + | +help: you can convert an `i16` to an `i32` + | +LL | x_i32 > x_i16.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:118:17 + | +LL | x_i32 > x_i64; + | ----- ^^^^^ expected `i32`, found `i64` + | | + | expected because this is `i32` + | +help: you can convert `x_i32` from `i32` to `i64`, matching the type of `x_i64` + | +LL | i64::from(x_i32) > x_i64; + | ++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:120:17 + | +LL | x_i32 > x_i128; + | ----- ^^^^^^ expected `i32`, found `i128` + | | + | expected because this is `i32` + | +help: you can convert `x_i32` from `i32` to `i128`, matching the type of `x_i128` + | +LL | i128::from(x_i32) > x_i128; + | +++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:122:17 + | +LL | x_i32 > x_isize; + | ----- ^^^^^^^ expected `i32`, found `isize` + | | + | expected because this is `i32` + | +help: you can convert an `isize` to an `i32` and panic if the converted value doesn't fit + | +LL | x_i32 > x_isize.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:125:17 + | +LL | x_i64 > x_i8; + | ----- ^^^^ expected `i64`, found `i8` + | | + | expected because this is `i64` + | +help: you can convert an `i8` to an `i64` + | +LL | x_i64 > x_i8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:127:17 + | +LL | x_i64 > x_i16; + | ----- ^^^^^ expected `i64`, found `i16` + | | + | expected because this is `i64` + | +help: you can convert an `i16` to an `i64` + | +LL | x_i64 > x_i16.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:129:17 + | +LL | x_i64 > x_i32; + | ----- ^^^^^ expected `i64`, found `i32` + | | + | expected because this is `i64` + | +help: you can convert an `i32` to an `i64` + | +LL | x_i64 > x_i32.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:131:17 + | +LL | x_i64 > x_i128; + | ----- ^^^^^^ expected `i64`, found `i128` + | | + | expected because this is `i64` + | +help: you can convert `x_i64` from `i64` to `i128`, matching the type of `x_i128` + | +LL | i128::from(x_i64) > x_i128; + | +++++++++++ + + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:133:17 + | +LL | x_i64 > x_isize; + | ----- ^^^^^^^ expected `i64`, found `isize` + | | + | expected because this is `i64` + | +help: you can convert an `isize` to an `i64` and panic if the converted value doesn't fit + | +LL | x_i64 > x_isize.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:136:18 + | +LL | x_i128 > x_i8; + | ------ ^^^^ expected `i128`, found `i8` + | | + | expected because this is `i128` + | +help: you can convert an `i8` to an `i128` + | +LL | x_i128 > x_i8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:138:18 + | +LL | x_i128 > x_i16; + | ------ ^^^^^ expected `i128`, found `i16` + | | + | expected because this is `i128` + | +help: you can convert an `i16` to an `i128` + | +LL | x_i128 > x_i16.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:140:18 + | +LL | x_i128 > x_i32; + | ------ ^^^^^ expected `i128`, found `i32` + | | + | expected because this is `i128` + | +help: you can convert an `i32` to an `i128` + | +LL | x_i128 > x_i32.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:142:18 + | +LL | x_i128 > x_i64; + | ------ ^^^^^ expected `i128`, found `i64` + | | + | expected because this is `i128` + | +help: you can convert an `i64` to an `i128` + | +LL | x_i128 > x_i64.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:144:18 + | +LL | x_i128 > x_isize; + | ------ ^^^^^^^ expected `i128`, found `isize` + | | + | expected because this is `i128` + | +help: you can convert an `isize` to an `i128` and panic if the converted value doesn't fit + | +LL | x_i128 > x_isize.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:147:19 + | +LL | x_isize > x_i8; + | ------- ^^^^ expected `isize`, found `i8` + | | + | expected because this is `isize` + | +help: you can convert an `i8` to an `isize` + | +LL | x_isize > x_i8.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:149:19 + | +LL | x_isize > x_i16; + | ------- ^^^^^ expected `isize`, found `i16` + | | + | expected because this is `isize` + | +help: you can convert an `i16` to an `isize` + | +LL | x_isize > x_i16.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:151:19 + | +LL | x_isize > x_i32; + | ------- ^^^^^ expected `isize`, found `i32` + | | + | expected because this is `isize` + | +help: you can convert an `i32` to an `isize` and panic if the converted value doesn't fit + | +LL | x_isize > x_i32.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:153:19 + | +LL | x_isize > x_i64; + | ------- ^^^^^ expected `isize`, found `i64` + | | + | expected because this is `isize` + | +help: you can convert an `i64` to an `isize` and panic if the converted value doesn't fit + | +LL | x_isize > x_i64.try_into().unwrap(); + | ++++++++++++++++++++ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop-2.rs:155:19 + | +LL | x_isize > x_i128; + | ------- ^^^^^^ expected `isize`, found `i128` + | | + | expected because this is `isize` + | +help: you can convert an `i128` to an `isize` and panic if the converted value doesn't fit + | +LL | x_isize > x_i128.try_into().unwrap(); + | ++++++++++++++++++++ + +error: aborting due to 60 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/numeric/numeric-cast-binop.fixed b/tests/ui/numeric/numeric-cast-binop.fixed index edb085e71d324..252c7ab0de3e4 100644 --- a/tests/ui/numeric/numeric-cast-binop.fixed +++ b/tests/ui/numeric/numeric-cast-binop.fixed @@ -18,144 +18,6 @@ fn main() { let x_i8: i8 = 11; let x_i128: i128 = 12; - /* u<->u */ - { - u16::from(x_u8) > x_u16; - //~^ ERROR mismatched types - u32::from(x_u8) > x_u32; - //~^ ERROR mismatched types - u64::from(x_u8) > x_u64; - //~^ ERROR mismatched types - u128::from(x_u8) > x_u128; - //~^ ERROR mismatched types - usize::from(x_u8) > x_usize; - //~^ ERROR mismatched types - - x_u16 > x_u8.into(); - //~^ ERROR mismatched types - u32::from(x_u16) > x_u32; - //~^ ERROR mismatched types - u64::from(x_u16) > x_u64; - //~^ ERROR mismatched types - u128::from(x_u16) > x_u128; - //~^ ERROR mismatched types - usize::from(x_u16) > x_usize; - //~^ ERROR mismatched types - - x_u32 > x_u8.into(); - //~^ ERROR mismatched types - x_u32 > x_u16.into(); - //~^ ERROR mismatched types - u64::from(x_u32) > x_u64; - //~^ ERROR mismatched types - u128::from(x_u32) > x_u128; - //~^ ERROR mismatched types - x_u32 > x_usize.try_into().unwrap(); - //~^ ERROR mismatched types - - x_u64 > x_u8.into(); - //~^ ERROR mismatched types - x_u64 > x_u16.into(); - //~^ ERROR mismatched types - x_u64 > x_u32.into(); - //~^ ERROR mismatched types - u128::from(x_u64) > x_u128; - //~^ ERROR mismatched types - x_u64 > x_usize.try_into().unwrap(); - //~^ ERROR mismatched types - - x_u128 > x_u8.into(); - //~^ ERROR mismatched types - x_u128 > x_u16.into(); - //~^ ERROR mismatched types - x_u128 > x_u32.into(); - //~^ ERROR mismatched types - x_u128 > x_u64.into(); - //~^ ERROR mismatched types - x_u128 > x_usize.try_into().unwrap(); - //~^ ERROR mismatched types - - x_usize > x_u8.into(); - //~^ ERROR mismatched types - x_usize > x_u16.into(); - //~^ ERROR mismatched types - x_usize > x_u32.try_into().unwrap(); - //~^ ERROR mismatched types - x_usize > x_u64.try_into().unwrap(); - //~^ ERROR mismatched types - x_usize > x_u128.try_into().unwrap(); - //~^ ERROR mismatched types - } - - /* i<->i */ - { - i16::from(x_i8) > x_i16; - //~^ ERROR mismatched types - i32::from(x_i8) > x_i32; - //~^ ERROR mismatched types - i64::from(x_i8) > x_i64; - //~^ ERROR mismatched types - i128::from(x_i8) > x_i128; - //~^ ERROR mismatched types - isize::from(x_i8) > x_isize; - //~^ ERROR mismatched types - - x_i16 > x_i8.into(); - //~^ ERROR mismatched types - i32::from(x_i16) > x_i32; - //~^ ERROR mismatched types - i64::from(x_i16) > x_i64; - //~^ ERROR mismatched types - i128::from(x_i16) > x_i128; - //~^ ERROR mismatched types - isize::from(x_i16) > x_isize; - //~^ ERROR mismatched types - - x_i32 > x_i8.into(); - //~^ ERROR mismatched types - x_i32 > x_i16.into(); - //~^ ERROR mismatched types - i64::from(x_i32) > x_i64; - //~^ ERROR mismatched types - i128::from(x_i32) > x_i128; - //~^ ERROR mismatched types - x_i32 > x_isize.try_into().unwrap(); - //~^ ERROR mismatched types - - x_i64 > x_i8.into(); - //~^ ERROR mismatched types - x_i64 > x_i16.into(); - //~^ ERROR mismatched types - x_i64 > x_i32.into(); - //~^ ERROR mismatched types - i128::from(x_i64) > x_i128; - //~^ ERROR mismatched types - x_i64 > x_isize.try_into().unwrap(); - //~^ ERROR mismatched types - - x_i128 > x_i8.into(); - //~^ ERROR mismatched types - x_i128 > x_i16.into(); - //~^ ERROR mismatched types - x_i128 > x_i32.into(); - //~^ ERROR mismatched types - x_i128 > x_i64.into(); - //~^ ERROR mismatched types - x_i128 > x_isize.try_into().unwrap(); - //~^ ERROR mismatched types - - x_isize > x_i8.into(); - //~^ ERROR mismatched types - x_isize > x_i16.into(); - //~^ ERROR mismatched types - x_isize > x_i32.try_into().unwrap(); - //~^ ERROR mismatched types - x_isize > x_i64.try_into().unwrap(); - //~^ ERROR mismatched types - x_isize > x_i128.try_into().unwrap(); - //~^ ERROR mismatched types - } - /* u<->i */ { x_u8 > x_i8.try_into().unwrap(); diff --git a/tests/ui/numeric/numeric-cast-binop.rs b/tests/ui/numeric/numeric-cast-binop.rs index c1ed8de8ad8c3..e77b696fce359 100644 --- a/tests/ui/numeric/numeric-cast-binop.rs +++ b/tests/ui/numeric/numeric-cast-binop.rs @@ -18,144 +18,6 @@ fn main() { let x_i8: i8 = 11; let x_i128: i128 = 12; - /* u<->u */ - { - x_u8 > x_u16; - //~^ ERROR mismatched types - x_u8 > x_u32; - //~^ ERROR mismatched types - x_u8 > x_u64; - //~^ ERROR mismatched types - x_u8 > x_u128; - //~^ ERROR mismatched types - x_u8 > x_usize; - //~^ ERROR mismatched types - - x_u16 > x_u8; - //~^ ERROR mismatched types - x_u16 > x_u32; - //~^ ERROR mismatched types - x_u16 > x_u64; - //~^ ERROR mismatched types - x_u16 > x_u128; - //~^ ERROR mismatched types - x_u16 > x_usize; - //~^ ERROR mismatched types - - x_u32 > x_u8; - //~^ ERROR mismatched types - x_u32 > x_u16; - //~^ ERROR mismatched types - x_u32 > x_u64; - //~^ ERROR mismatched types - x_u32 > x_u128; - //~^ ERROR mismatched types - x_u32 > x_usize; - //~^ ERROR mismatched types - - x_u64 > x_u8; - //~^ ERROR mismatched types - x_u64 > x_u16; - //~^ ERROR mismatched types - x_u64 > x_u32; - //~^ ERROR mismatched types - x_u64 > x_u128; - //~^ ERROR mismatched types - x_u64 > x_usize; - //~^ ERROR mismatched types - - x_u128 > x_u8; - //~^ ERROR mismatched types - x_u128 > x_u16; - //~^ ERROR mismatched types - x_u128 > x_u32; - //~^ ERROR mismatched types - x_u128 > x_u64; - //~^ ERROR mismatched types - x_u128 > x_usize; - //~^ ERROR mismatched types - - x_usize > x_u8; - //~^ ERROR mismatched types - x_usize > x_u16; - //~^ ERROR mismatched types - x_usize > x_u32; - //~^ ERROR mismatched types - x_usize > x_u64; - //~^ ERROR mismatched types - x_usize > x_u128; - //~^ ERROR mismatched types - } - - /* i<->i */ - { - x_i8 > x_i16; - //~^ ERROR mismatched types - x_i8 > x_i32; - //~^ ERROR mismatched types - x_i8 > x_i64; - //~^ ERROR mismatched types - x_i8 > x_i128; - //~^ ERROR mismatched types - x_i8 > x_isize; - //~^ ERROR mismatched types - - x_i16 > x_i8; - //~^ ERROR mismatched types - x_i16 > x_i32; - //~^ ERROR mismatched types - x_i16 > x_i64; - //~^ ERROR mismatched types - x_i16 > x_i128; - //~^ ERROR mismatched types - x_i16 > x_isize; - //~^ ERROR mismatched types - - x_i32 > x_i8; - //~^ ERROR mismatched types - x_i32 > x_i16; - //~^ ERROR mismatched types - x_i32 > x_i64; - //~^ ERROR mismatched types - x_i32 > x_i128; - //~^ ERROR mismatched types - x_i32 > x_isize; - //~^ ERROR mismatched types - - x_i64 > x_i8; - //~^ ERROR mismatched types - x_i64 > x_i16; - //~^ ERROR mismatched types - x_i64 > x_i32; - //~^ ERROR mismatched types - x_i64 > x_i128; - //~^ ERROR mismatched types - x_i64 > x_isize; - //~^ ERROR mismatched types - - x_i128 > x_i8; - //~^ ERROR mismatched types - x_i128 > x_i16; - //~^ ERROR mismatched types - x_i128 > x_i32; - //~^ ERROR mismatched types - x_i128 > x_i64; - //~^ ERROR mismatched types - x_i128 > x_isize; - //~^ ERROR mismatched types - - x_isize > x_i8; - //~^ ERROR mismatched types - x_isize > x_i16; - //~^ ERROR mismatched types - x_isize > x_i32; - //~^ ERROR mismatched types - x_isize > x_i64; - //~^ ERROR mismatched types - x_isize > x_i128; - //~^ ERROR mismatched types - } - /* u<->i */ { x_u8 > x_i8; diff --git a/tests/ui/numeric/numeric-cast-binop.stderr b/tests/ui/numeric/numeric-cast-binop.stderr index d5213e3f5b690..2f7bdc37a337b 100644 --- a/tests/ui/numeric/numeric-cast-binop.stderr +++ b/tests/ui/numeric/numeric-cast-binop.stderr @@ -1,786 +1,6 @@ error[E0308]: mismatched types --> $DIR/numeric-cast-binop.rs:23:16 | -LL | x_u8 > x_u16; - | ---- ^^^^^ expected `u8`, found `u16` - | | - | expected because this is `u8` - | -help: you can convert `x_u8` from `u8` to `u16`, matching the type of `x_u16` - | -LL | u16::from(x_u8) > x_u16; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:25:16 - | -LL | x_u8 > x_u32; - | ---- ^^^^^ expected `u8`, found `u32` - | | - | expected because this is `u8` - | -help: you can convert `x_u8` from `u8` to `u32`, matching the type of `x_u32` - | -LL | u32::from(x_u8) > x_u32; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:27:16 - | -LL | x_u8 > x_u64; - | ---- ^^^^^ expected `u8`, found `u64` - | | - | expected because this is `u8` - | -help: you can convert `x_u8` from `u8` to `u64`, matching the type of `x_u64` - | -LL | u64::from(x_u8) > x_u64; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:29:16 - | -LL | x_u8 > x_u128; - | ---- ^^^^^^ expected `u8`, found `u128` - | | - | expected because this is `u8` - | -help: you can convert `x_u8` from `u8` to `u128`, matching the type of `x_u128` - | -LL | u128::from(x_u8) > x_u128; - | +++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:31:16 - | -LL | x_u8 > x_usize; - | ---- ^^^^^^^ expected `u8`, found `usize` - | | - | expected because this is `u8` - | -help: you can convert `x_u8` from `u8` to `usize`, matching the type of `x_usize` - | -LL | usize::from(x_u8) > x_usize; - | ++++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:34:17 - | -LL | x_u16 > x_u8; - | ----- ^^^^ expected `u16`, found `u8` - | | - | expected because this is `u16` - | -help: you can convert a `u8` to a `u16` - | -LL | x_u16 > x_u8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:36:17 - | -LL | x_u16 > x_u32; - | ----- ^^^^^ expected `u16`, found `u32` - | | - | expected because this is `u16` - | -help: you can convert `x_u16` from `u16` to `u32`, matching the type of `x_u32` - | -LL | u32::from(x_u16) > x_u32; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:38:17 - | -LL | x_u16 > x_u64; - | ----- ^^^^^ expected `u16`, found `u64` - | | - | expected because this is `u16` - | -help: you can convert `x_u16` from `u16` to `u64`, matching the type of `x_u64` - | -LL | u64::from(x_u16) > x_u64; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:40:17 - | -LL | x_u16 > x_u128; - | ----- ^^^^^^ expected `u16`, found `u128` - | | - | expected because this is `u16` - | -help: you can convert `x_u16` from `u16` to `u128`, matching the type of `x_u128` - | -LL | u128::from(x_u16) > x_u128; - | +++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:42:17 - | -LL | x_u16 > x_usize; - | ----- ^^^^^^^ expected `u16`, found `usize` - | | - | expected because this is `u16` - | -help: you can convert `x_u16` from `u16` to `usize`, matching the type of `x_usize` - | -LL | usize::from(x_u16) > x_usize; - | ++++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:45:17 - | -LL | x_u32 > x_u8; - | ----- ^^^^ expected `u32`, found `u8` - | | - | expected because this is `u32` - | -help: you can convert a `u8` to a `u32` - | -LL | x_u32 > x_u8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:47:17 - | -LL | x_u32 > x_u16; - | ----- ^^^^^ expected `u32`, found `u16` - | | - | expected because this is `u32` - | -help: you can convert a `u16` to a `u32` - | -LL | x_u32 > x_u16.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:49:17 - | -LL | x_u32 > x_u64; - | ----- ^^^^^ expected `u32`, found `u64` - | | - | expected because this is `u32` - | -help: you can convert `x_u32` from `u32` to `u64`, matching the type of `x_u64` - | -LL | u64::from(x_u32) > x_u64; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:51:17 - | -LL | x_u32 > x_u128; - | ----- ^^^^^^ expected `u32`, found `u128` - | | - | expected because this is `u32` - | -help: you can convert `x_u32` from `u32` to `u128`, matching the type of `x_u128` - | -LL | u128::from(x_u32) > x_u128; - | +++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:53:17 - | -LL | x_u32 > x_usize; - | ----- ^^^^^^^ expected `u32`, found `usize` - | | - | expected because this is `u32` - | -help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit - | -LL | x_u32 > x_usize.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:56:17 - | -LL | x_u64 > x_u8; - | ----- ^^^^ expected `u64`, found `u8` - | | - | expected because this is `u64` - | -help: you can convert a `u8` to a `u64` - | -LL | x_u64 > x_u8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:58:17 - | -LL | x_u64 > x_u16; - | ----- ^^^^^ expected `u64`, found `u16` - | | - | expected because this is `u64` - | -help: you can convert a `u16` to a `u64` - | -LL | x_u64 > x_u16.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:60:17 - | -LL | x_u64 > x_u32; - | ----- ^^^^^ expected `u64`, found `u32` - | | - | expected because this is `u64` - | -help: you can convert a `u32` to a `u64` - | -LL | x_u64 > x_u32.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:62:17 - | -LL | x_u64 > x_u128; - | ----- ^^^^^^ expected `u64`, found `u128` - | | - | expected because this is `u64` - | -help: you can convert `x_u64` from `u64` to `u128`, matching the type of `x_u128` - | -LL | u128::from(x_u64) > x_u128; - | +++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:64:17 - | -LL | x_u64 > x_usize; - | ----- ^^^^^^^ expected `u64`, found `usize` - | | - | expected because this is `u64` - | -help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit - | -LL | x_u64 > x_usize.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:67:18 - | -LL | x_u128 > x_u8; - | ------ ^^^^ expected `u128`, found `u8` - | | - | expected because this is `u128` - | -help: you can convert a `u8` to a `u128` - | -LL | x_u128 > x_u8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:69:18 - | -LL | x_u128 > x_u16; - | ------ ^^^^^ expected `u128`, found `u16` - | | - | expected because this is `u128` - | -help: you can convert a `u16` to a `u128` - | -LL | x_u128 > x_u16.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:71:18 - | -LL | x_u128 > x_u32; - | ------ ^^^^^ expected `u128`, found `u32` - | | - | expected because this is `u128` - | -help: you can convert a `u32` to a `u128` - | -LL | x_u128 > x_u32.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:73:18 - | -LL | x_u128 > x_u64; - | ------ ^^^^^ expected `u128`, found `u64` - | | - | expected because this is `u128` - | -help: you can convert a `u64` to a `u128` - | -LL | x_u128 > x_u64.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:75:18 - | -LL | x_u128 > x_usize; - | ------ ^^^^^^^ expected `u128`, found `usize` - | | - | expected because this is `u128` - | -help: you can convert a `usize` to a `u128` and panic if the converted value doesn't fit - | -LL | x_u128 > x_usize.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:78:19 - | -LL | x_usize > x_u8; - | ------- ^^^^ expected `usize`, found `u8` - | | - | expected because this is `usize` - | -help: you can convert a `u8` to a `usize` - | -LL | x_usize > x_u8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:80:19 - | -LL | x_usize > x_u16; - | ------- ^^^^^ expected `usize`, found `u16` - | | - | expected because this is `usize` - | -help: you can convert a `u16` to a `usize` - | -LL | x_usize > x_u16.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:82:19 - | -LL | x_usize > x_u32; - | ------- ^^^^^ expected `usize`, found `u32` - | | - | expected because this is `usize` - | -help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit - | -LL | x_usize > x_u32.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:84:19 - | -LL | x_usize > x_u64; - | ------- ^^^^^ expected `usize`, found `u64` - | | - | expected because this is `usize` - | -help: you can convert a `u64` to a `usize` and panic if the converted value doesn't fit - | -LL | x_usize > x_u64.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:86:19 - | -LL | x_usize > x_u128; - | ------- ^^^^^^ expected `usize`, found `u128` - | | - | expected because this is `usize` - | -help: you can convert a `u128` to a `usize` and panic if the converted value doesn't fit - | -LL | x_usize > x_u128.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:92:16 - | -LL | x_i8 > x_i16; - | ---- ^^^^^ expected `i8`, found `i16` - | | - | expected because this is `i8` - | -help: you can convert `x_i8` from `i8` to `i16`, matching the type of `x_i16` - | -LL | i16::from(x_i8) > x_i16; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:94:16 - | -LL | x_i8 > x_i32; - | ---- ^^^^^ expected `i8`, found `i32` - | | - | expected because this is `i8` - | -help: you can convert `x_i8` from `i8` to `i32`, matching the type of `x_i32` - | -LL | i32::from(x_i8) > x_i32; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:96:16 - | -LL | x_i8 > x_i64; - | ---- ^^^^^ expected `i8`, found `i64` - | | - | expected because this is `i8` - | -help: you can convert `x_i8` from `i8` to `i64`, matching the type of `x_i64` - | -LL | i64::from(x_i8) > x_i64; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:98:16 - | -LL | x_i8 > x_i128; - | ---- ^^^^^^ expected `i8`, found `i128` - | | - | expected because this is `i8` - | -help: you can convert `x_i8` from `i8` to `i128`, matching the type of `x_i128` - | -LL | i128::from(x_i8) > x_i128; - | +++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:100:16 - | -LL | x_i8 > x_isize; - | ---- ^^^^^^^ expected `i8`, found `isize` - | | - | expected because this is `i8` - | -help: you can convert `x_i8` from `i8` to `isize`, matching the type of `x_isize` - | -LL | isize::from(x_i8) > x_isize; - | ++++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:103:17 - | -LL | x_i16 > x_i8; - | ----- ^^^^ expected `i16`, found `i8` - | | - | expected because this is `i16` - | -help: you can convert an `i8` to an `i16` - | -LL | x_i16 > x_i8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:105:17 - | -LL | x_i16 > x_i32; - | ----- ^^^^^ expected `i16`, found `i32` - | | - | expected because this is `i16` - | -help: you can convert `x_i16` from `i16` to `i32`, matching the type of `x_i32` - | -LL | i32::from(x_i16) > x_i32; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:107:17 - | -LL | x_i16 > x_i64; - | ----- ^^^^^ expected `i16`, found `i64` - | | - | expected because this is `i16` - | -help: you can convert `x_i16` from `i16` to `i64`, matching the type of `x_i64` - | -LL | i64::from(x_i16) > x_i64; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:109:17 - | -LL | x_i16 > x_i128; - | ----- ^^^^^^ expected `i16`, found `i128` - | | - | expected because this is `i16` - | -help: you can convert `x_i16` from `i16` to `i128`, matching the type of `x_i128` - | -LL | i128::from(x_i16) > x_i128; - | +++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:111:17 - | -LL | x_i16 > x_isize; - | ----- ^^^^^^^ expected `i16`, found `isize` - | | - | expected because this is `i16` - | -help: you can convert `x_i16` from `i16` to `isize`, matching the type of `x_isize` - | -LL | isize::from(x_i16) > x_isize; - | ++++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:114:17 - | -LL | x_i32 > x_i8; - | ----- ^^^^ expected `i32`, found `i8` - | | - | expected because this is `i32` - | -help: you can convert an `i8` to an `i32` - | -LL | x_i32 > x_i8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:116:17 - | -LL | x_i32 > x_i16; - | ----- ^^^^^ expected `i32`, found `i16` - | | - | expected because this is `i32` - | -help: you can convert an `i16` to an `i32` - | -LL | x_i32 > x_i16.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:118:17 - | -LL | x_i32 > x_i64; - | ----- ^^^^^ expected `i32`, found `i64` - | | - | expected because this is `i32` - | -help: you can convert `x_i32` from `i32` to `i64`, matching the type of `x_i64` - | -LL | i64::from(x_i32) > x_i64; - | ++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:120:17 - | -LL | x_i32 > x_i128; - | ----- ^^^^^^ expected `i32`, found `i128` - | | - | expected because this is `i32` - | -help: you can convert `x_i32` from `i32` to `i128`, matching the type of `x_i128` - | -LL | i128::from(x_i32) > x_i128; - | +++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:122:17 - | -LL | x_i32 > x_isize; - | ----- ^^^^^^^ expected `i32`, found `isize` - | | - | expected because this is `i32` - | -help: you can convert an `isize` to an `i32` and panic if the converted value doesn't fit - | -LL | x_i32 > x_isize.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:125:17 - | -LL | x_i64 > x_i8; - | ----- ^^^^ expected `i64`, found `i8` - | | - | expected because this is `i64` - | -help: you can convert an `i8` to an `i64` - | -LL | x_i64 > x_i8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:127:17 - | -LL | x_i64 > x_i16; - | ----- ^^^^^ expected `i64`, found `i16` - | | - | expected because this is `i64` - | -help: you can convert an `i16` to an `i64` - | -LL | x_i64 > x_i16.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:129:17 - | -LL | x_i64 > x_i32; - | ----- ^^^^^ expected `i64`, found `i32` - | | - | expected because this is `i64` - | -help: you can convert an `i32` to an `i64` - | -LL | x_i64 > x_i32.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:131:17 - | -LL | x_i64 > x_i128; - | ----- ^^^^^^ expected `i64`, found `i128` - | | - | expected because this is `i64` - | -help: you can convert `x_i64` from `i64` to `i128`, matching the type of `x_i128` - | -LL | i128::from(x_i64) > x_i128; - | +++++++++++ + - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:133:17 - | -LL | x_i64 > x_isize; - | ----- ^^^^^^^ expected `i64`, found `isize` - | | - | expected because this is `i64` - | -help: you can convert an `isize` to an `i64` and panic if the converted value doesn't fit - | -LL | x_i64 > x_isize.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:136:18 - | -LL | x_i128 > x_i8; - | ------ ^^^^ expected `i128`, found `i8` - | | - | expected because this is `i128` - | -help: you can convert an `i8` to an `i128` - | -LL | x_i128 > x_i8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:138:18 - | -LL | x_i128 > x_i16; - | ------ ^^^^^ expected `i128`, found `i16` - | | - | expected because this is `i128` - | -help: you can convert an `i16` to an `i128` - | -LL | x_i128 > x_i16.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:140:18 - | -LL | x_i128 > x_i32; - | ------ ^^^^^ expected `i128`, found `i32` - | | - | expected because this is `i128` - | -help: you can convert an `i32` to an `i128` - | -LL | x_i128 > x_i32.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:142:18 - | -LL | x_i128 > x_i64; - | ------ ^^^^^ expected `i128`, found `i64` - | | - | expected because this is `i128` - | -help: you can convert an `i64` to an `i128` - | -LL | x_i128 > x_i64.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:144:18 - | -LL | x_i128 > x_isize; - | ------ ^^^^^^^ expected `i128`, found `isize` - | | - | expected because this is `i128` - | -help: you can convert an `isize` to an `i128` and panic if the converted value doesn't fit - | -LL | x_i128 > x_isize.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:147:19 - | -LL | x_isize > x_i8; - | ------- ^^^^ expected `isize`, found `i8` - | | - | expected because this is `isize` - | -help: you can convert an `i8` to an `isize` - | -LL | x_isize > x_i8.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:149:19 - | -LL | x_isize > x_i16; - | ------- ^^^^^ expected `isize`, found `i16` - | | - | expected because this is `isize` - | -help: you can convert an `i16` to an `isize` - | -LL | x_isize > x_i16.into(); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:151:19 - | -LL | x_isize > x_i32; - | ------- ^^^^^ expected `isize`, found `i32` - | | - | expected because this is `isize` - | -help: you can convert an `i32` to an `isize` and panic if the converted value doesn't fit - | -LL | x_isize > x_i32.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:153:19 - | -LL | x_isize > x_i64; - | ------- ^^^^^ expected `isize`, found `i64` - | | - | expected because this is `isize` - | -help: you can convert an `i64` to an `isize` and panic if the converted value doesn't fit - | -LL | x_isize > x_i64.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:155:19 - | -LL | x_isize > x_i128; - | ------- ^^^^^^ expected `isize`, found `i128` - | | - | expected because this is `isize` - | -help: you can convert an `i128` to an `isize` and panic if the converted value doesn't fit - | -LL | x_isize > x_i128.try_into().unwrap(); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:161:16 - | LL | x_u8 > x_i8; | ---- ^^^^ expected `u8`, found `i8` | | @@ -792,7 +12,7 @@ LL | x_u8 > x_i8.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:163:16 + --> $DIR/numeric-cast-binop.rs:25:16 | LL | x_u8 > x_i16; | ---- ^^^^^ expected `u8`, found `i16` @@ -805,7 +25,7 @@ LL | i16::from(x_u8) > x_i16; | ++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:165:16 + --> $DIR/numeric-cast-binop.rs:27:16 | LL | x_u8 > x_i32; | ---- ^^^^^ expected `u8`, found `i32` @@ -818,7 +38,7 @@ LL | i32::from(x_u8) > x_i32; | ++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:167:16 + --> $DIR/numeric-cast-binop.rs:29:16 | LL | x_u8 > x_i64; | ---- ^^^^^ expected `u8`, found `i64` @@ -831,7 +51,7 @@ LL | i64::from(x_u8) > x_i64; | ++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:169:16 + --> $DIR/numeric-cast-binop.rs:31:16 | LL | x_u8 > x_i128; | ---- ^^^^^^ expected `u8`, found `i128` @@ -844,7 +64,7 @@ LL | i128::from(x_u8) > x_i128; | +++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:171:16 + --> $DIR/numeric-cast-binop.rs:33:16 | LL | x_u8 > x_isize; | ---- ^^^^^^^ expected `u8`, found `isize` @@ -857,7 +77,7 @@ LL | isize::from(x_u8) > x_isize; | ++++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:174:17 + --> $DIR/numeric-cast-binop.rs:36:17 | LL | x_u16 > x_i8; | ----- ^^^^ expected `u16`, found `i8` @@ -870,7 +90,7 @@ LL | x_u16 > x_i8.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:176:17 + --> $DIR/numeric-cast-binop.rs:38:17 | LL | x_u16 > x_i16; | ----- ^^^^^ expected `u16`, found `i16` @@ -883,7 +103,7 @@ LL | x_u16 > x_i16.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:178:17 + --> $DIR/numeric-cast-binop.rs:40:17 | LL | x_u16 > x_i32; | ----- ^^^^^ expected `u16`, found `i32` @@ -896,7 +116,7 @@ LL | i32::from(x_u16) > x_i32; | ++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:180:17 + --> $DIR/numeric-cast-binop.rs:42:17 | LL | x_u16 > x_i64; | ----- ^^^^^ expected `u16`, found `i64` @@ -909,7 +129,7 @@ LL | i64::from(x_u16) > x_i64; | ++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:182:17 + --> $DIR/numeric-cast-binop.rs:44:17 | LL | x_u16 > x_i128; | ----- ^^^^^^ expected `u16`, found `i128` @@ -922,7 +142,7 @@ LL | i128::from(x_u16) > x_i128; | +++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:184:17 + --> $DIR/numeric-cast-binop.rs:46:17 | LL | x_u16 > x_isize; | ----- ^^^^^^^ expected `u16`, found `isize` @@ -935,7 +155,7 @@ LL | x_u16 > x_isize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:187:17 + --> $DIR/numeric-cast-binop.rs:49:17 | LL | x_u32 > x_i8; | ----- ^^^^ expected `u32`, found `i8` @@ -948,7 +168,7 @@ LL | x_u32 > x_i8.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:189:17 + --> $DIR/numeric-cast-binop.rs:51:17 | LL | x_u32 > x_i16; | ----- ^^^^^ expected `u32`, found `i16` @@ -961,7 +181,7 @@ LL | x_u32 > x_i16.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:191:17 + --> $DIR/numeric-cast-binop.rs:53:17 | LL | x_u32 > x_i32; | ----- ^^^^^ expected `u32`, found `i32` @@ -974,7 +194,7 @@ LL | x_u32 > x_i32.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:193:17 + --> $DIR/numeric-cast-binop.rs:55:17 | LL | x_u32 > x_i64; | ----- ^^^^^ expected `u32`, found `i64` @@ -987,7 +207,7 @@ LL | i64::from(x_u32) > x_i64; | ++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:195:17 + --> $DIR/numeric-cast-binop.rs:57:17 | LL | x_u32 > x_i128; | ----- ^^^^^^ expected `u32`, found `i128` @@ -1000,7 +220,7 @@ LL | i128::from(x_u32) > x_i128; | +++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:197:17 + --> $DIR/numeric-cast-binop.rs:59:17 | LL | x_u32 > x_isize; | ----- ^^^^^^^ expected `u32`, found `isize` @@ -1013,7 +233,7 @@ LL | x_u32 > x_isize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:200:17 + --> $DIR/numeric-cast-binop.rs:62:17 | LL | x_u64 > x_i8; | ----- ^^^^ expected `u64`, found `i8` @@ -1026,7 +246,7 @@ LL | x_u64 > x_i8.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:202:17 + --> $DIR/numeric-cast-binop.rs:64:17 | LL | x_u64 > x_i16; | ----- ^^^^^ expected `u64`, found `i16` @@ -1039,7 +259,7 @@ LL | x_u64 > x_i16.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:204:17 + --> $DIR/numeric-cast-binop.rs:66:17 | LL | x_u64 > x_i32; | ----- ^^^^^ expected `u64`, found `i32` @@ -1052,7 +272,7 @@ LL | x_u64 > x_i32.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:206:17 + --> $DIR/numeric-cast-binop.rs:68:17 | LL | x_u64 > x_i64; | ----- ^^^^^ expected `u64`, found `i64` @@ -1065,7 +285,7 @@ LL | x_u64 > x_i64.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:208:17 + --> $DIR/numeric-cast-binop.rs:70:17 | LL | x_u64 > x_i128; | ----- ^^^^^^ expected `u64`, found `i128` @@ -1078,7 +298,7 @@ LL | i128::from(x_u64) > x_i128; | +++++++++++ + error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:210:17 + --> $DIR/numeric-cast-binop.rs:72:17 | LL | x_u64 > x_isize; | ----- ^^^^^^^ expected `u64`, found `isize` @@ -1091,7 +311,7 @@ LL | x_u64 > x_isize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:213:18 + --> $DIR/numeric-cast-binop.rs:75:18 | LL | x_u128 > x_i8; | ------ ^^^^ expected `u128`, found `i8` @@ -1104,7 +324,7 @@ LL | x_u128 > x_i8.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:215:18 + --> $DIR/numeric-cast-binop.rs:77:18 | LL | x_u128 > x_i16; | ------ ^^^^^ expected `u128`, found `i16` @@ -1117,7 +337,7 @@ LL | x_u128 > x_i16.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:217:18 + --> $DIR/numeric-cast-binop.rs:79:18 | LL | x_u128 > x_i32; | ------ ^^^^^ expected `u128`, found `i32` @@ -1130,7 +350,7 @@ LL | x_u128 > x_i32.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:219:18 + --> $DIR/numeric-cast-binop.rs:81:18 | LL | x_u128 > x_i64; | ------ ^^^^^ expected `u128`, found `i64` @@ -1143,7 +363,7 @@ LL | x_u128 > x_i64.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:221:18 + --> $DIR/numeric-cast-binop.rs:83:18 | LL | x_u128 > x_i128; | ------ ^^^^^^ expected `u128`, found `i128` @@ -1156,7 +376,7 @@ LL | x_u128 > x_i128.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:223:18 + --> $DIR/numeric-cast-binop.rs:85:18 | LL | x_u128 > x_isize; | ------ ^^^^^^^ expected `u128`, found `isize` @@ -1169,7 +389,7 @@ LL | x_u128 > x_isize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:226:19 + --> $DIR/numeric-cast-binop.rs:88:19 | LL | x_usize > x_i8; | ------- ^^^^ expected `usize`, found `i8` @@ -1182,7 +402,7 @@ LL | x_usize > x_i8.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:228:19 + --> $DIR/numeric-cast-binop.rs:90:19 | LL | x_usize > x_i16; | ------- ^^^^^ expected `usize`, found `i16` @@ -1195,7 +415,7 @@ LL | x_usize > x_i16.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:230:19 + --> $DIR/numeric-cast-binop.rs:92:19 | LL | x_usize > x_i32; | ------- ^^^^^ expected `usize`, found `i32` @@ -1208,7 +428,7 @@ LL | x_usize > x_i32.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:232:19 + --> $DIR/numeric-cast-binop.rs:94:19 | LL | x_usize > x_i64; | ------- ^^^^^ expected `usize`, found `i64` @@ -1221,7 +441,7 @@ LL | x_usize > x_i64.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:234:19 + --> $DIR/numeric-cast-binop.rs:96:19 | LL | x_usize > x_i128; | ------- ^^^^^^ expected `usize`, found `i128` @@ -1234,7 +454,7 @@ LL | x_usize > x_i128.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:236:19 + --> $DIR/numeric-cast-binop.rs:98:19 | LL | x_usize > x_isize; | ------- ^^^^^^^ expected `usize`, found `isize` @@ -1247,7 +467,7 @@ LL | x_usize > x_isize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:242:16 + --> $DIR/numeric-cast-binop.rs:104:16 | LL | x_i8 > x_u8; | ---- ^^^^ expected `i8`, found `u8` @@ -1260,7 +480,7 @@ LL | x_i8 > x_u8.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:244:16 + --> $DIR/numeric-cast-binop.rs:106:16 | LL | x_i8 > x_u16; | ---- ^^^^^ expected `i8`, found `u16` @@ -1273,7 +493,7 @@ LL | x_i8 > x_u16.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:246:16 + --> $DIR/numeric-cast-binop.rs:108:16 | LL | x_i8 > x_u32; | ---- ^^^^^ expected `i8`, found `u32` @@ -1286,7 +506,7 @@ LL | x_i8 > x_u32.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:248:16 + --> $DIR/numeric-cast-binop.rs:110:16 | LL | x_i8 > x_u64; | ---- ^^^^^ expected `i8`, found `u64` @@ -1299,7 +519,7 @@ LL | x_i8 > x_u64.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:250:16 + --> $DIR/numeric-cast-binop.rs:112:16 | LL | x_i8 > x_u128; | ---- ^^^^^^ expected `i8`, found `u128` @@ -1312,7 +532,7 @@ LL | x_i8 > x_u128.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:252:16 + --> $DIR/numeric-cast-binop.rs:114:16 | LL | x_i8 > x_usize; | ---- ^^^^^^^ expected `i8`, found `usize` @@ -1325,7 +545,7 @@ LL | x_i8 > x_usize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:255:17 + --> $DIR/numeric-cast-binop.rs:117:17 | LL | x_i16 > x_u8; | ----- ^^^^ expected `i16`, found `u8` @@ -1338,7 +558,7 @@ LL | x_i16 > x_u8.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:257:17 + --> $DIR/numeric-cast-binop.rs:119:17 | LL | x_i16 > x_u16; | ----- ^^^^^ expected `i16`, found `u16` @@ -1351,7 +571,7 @@ LL | x_i16 > x_u16.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:259:17 + --> $DIR/numeric-cast-binop.rs:121:17 | LL | x_i16 > x_u32; | ----- ^^^^^ expected `i16`, found `u32` @@ -1364,7 +584,7 @@ LL | x_i16 > x_u32.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:261:17 + --> $DIR/numeric-cast-binop.rs:123:17 | LL | x_i16 > x_u64; | ----- ^^^^^ expected `i16`, found `u64` @@ -1377,7 +597,7 @@ LL | x_i16 > x_u64.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:263:17 + --> $DIR/numeric-cast-binop.rs:125:17 | LL | x_i16 > x_u128; | ----- ^^^^^^ expected `i16`, found `u128` @@ -1390,7 +610,7 @@ LL | x_i16 > x_u128.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:265:17 + --> $DIR/numeric-cast-binop.rs:127:17 | LL | x_i16 > x_usize; | ----- ^^^^^^^ expected `i16`, found `usize` @@ -1403,7 +623,7 @@ LL | x_i16 > x_usize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:268:17 + --> $DIR/numeric-cast-binop.rs:130:17 | LL | x_i32 > x_u8; | ----- ^^^^ expected `i32`, found `u8` @@ -1416,7 +636,7 @@ LL | x_i32 > x_u8.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:270:17 + --> $DIR/numeric-cast-binop.rs:132:17 | LL | x_i32 > x_u16; | ----- ^^^^^ expected `i32`, found `u16` @@ -1429,7 +649,7 @@ LL | x_i32 > x_u16.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:272:17 + --> $DIR/numeric-cast-binop.rs:134:17 | LL | x_i32 > x_u32; | ----- ^^^^^ expected `i32`, found `u32` @@ -1442,7 +662,7 @@ LL | x_i32 > x_u32.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:274:17 + --> $DIR/numeric-cast-binop.rs:136:17 | LL | x_i32 > x_u64; | ----- ^^^^^ expected `i32`, found `u64` @@ -1455,7 +675,7 @@ LL | x_i32 > x_u64.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:276:17 + --> $DIR/numeric-cast-binop.rs:138:17 | LL | x_i32 > x_u128; | ----- ^^^^^^ expected `i32`, found `u128` @@ -1468,7 +688,7 @@ LL | x_i32 > x_u128.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:278:17 + --> $DIR/numeric-cast-binop.rs:140:17 | LL | x_i32 > x_usize; | ----- ^^^^^^^ expected `i32`, found `usize` @@ -1481,7 +701,7 @@ LL | x_i32 > x_usize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:281:17 + --> $DIR/numeric-cast-binop.rs:143:17 | LL | x_i64 > x_u8; | ----- ^^^^ expected `i64`, found `u8` @@ -1494,7 +714,7 @@ LL | x_i64 > x_u8.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:283:17 + --> $DIR/numeric-cast-binop.rs:145:17 | LL | x_i64 > x_u16; | ----- ^^^^^ expected `i64`, found `u16` @@ -1507,7 +727,7 @@ LL | x_i64 > x_u16.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:285:17 + --> $DIR/numeric-cast-binop.rs:147:17 | LL | x_i64 > x_u32; | ----- ^^^^^ expected `i64`, found `u32` @@ -1520,7 +740,7 @@ LL | x_i64 > x_u32.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:287:17 + --> $DIR/numeric-cast-binop.rs:149:17 | LL | x_i64 > x_u64; | ----- ^^^^^ expected `i64`, found `u64` @@ -1533,7 +753,7 @@ LL | x_i64 > x_u64.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:289:17 + --> $DIR/numeric-cast-binop.rs:151:17 | LL | x_i64 > x_u128; | ----- ^^^^^^ expected `i64`, found `u128` @@ -1546,7 +766,7 @@ LL | x_i64 > x_u128.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:291:17 + --> $DIR/numeric-cast-binop.rs:153:17 | LL | x_i64 > x_usize; | ----- ^^^^^^^ expected `i64`, found `usize` @@ -1559,7 +779,7 @@ LL | x_i64 > x_usize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:294:18 + --> $DIR/numeric-cast-binop.rs:156:18 | LL | x_i128 > x_u8; | ------ ^^^^ expected `i128`, found `u8` @@ -1572,7 +792,7 @@ LL | x_i128 > x_u8.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:296:18 + --> $DIR/numeric-cast-binop.rs:158:18 | LL | x_i128 > x_u16; | ------ ^^^^^ expected `i128`, found `u16` @@ -1585,7 +805,7 @@ LL | x_i128 > x_u16.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:298:18 + --> $DIR/numeric-cast-binop.rs:160:18 | LL | x_i128 > x_u32; | ------ ^^^^^ expected `i128`, found `u32` @@ -1598,7 +818,7 @@ LL | x_i128 > x_u32.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:300:18 + --> $DIR/numeric-cast-binop.rs:162:18 | LL | x_i128 > x_u64; | ------ ^^^^^ expected `i128`, found `u64` @@ -1611,7 +831,7 @@ LL | x_i128 > x_u64.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:302:18 + --> $DIR/numeric-cast-binop.rs:164:18 | LL | x_i128 > x_u128; | ------ ^^^^^^ expected `i128`, found `u128` @@ -1624,7 +844,7 @@ LL | x_i128 > x_u128.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:304:18 + --> $DIR/numeric-cast-binop.rs:166:18 | LL | x_i128 > x_usize; | ------ ^^^^^^^ expected `i128`, found `usize` @@ -1637,7 +857,7 @@ LL | x_i128 > x_usize.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:307:19 + --> $DIR/numeric-cast-binop.rs:169:19 | LL | x_isize > x_u8; | ------- ^^^^ expected `isize`, found `u8` @@ -1650,7 +870,7 @@ LL | x_isize > x_u8.into(); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:309:19 + --> $DIR/numeric-cast-binop.rs:171:19 | LL | x_isize > x_u16; | ------- ^^^^^ expected `isize`, found `u16` @@ -1663,7 +883,7 @@ LL | x_isize > x_u16.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:311:19 + --> $DIR/numeric-cast-binop.rs:173:19 | LL | x_isize > x_u32; | ------- ^^^^^ expected `isize`, found `u32` @@ -1676,7 +896,7 @@ LL | x_isize > x_u32.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:313:19 + --> $DIR/numeric-cast-binop.rs:175:19 | LL | x_isize > x_u64; | ------- ^^^^^ expected `isize`, found `u64` @@ -1689,7 +909,7 @@ LL | x_isize > x_u64.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:315:19 + --> $DIR/numeric-cast-binop.rs:177:19 | LL | x_isize > x_u128; | ------- ^^^^^^ expected `isize`, found `u128` @@ -1702,7 +922,7 @@ LL | x_isize > x_u128.try_into().unwrap(); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:317:19 + --> $DIR/numeric-cast-binop.rs:179:19 | LL | x_isize > x_usize; | ------- ^^^^^^^ expected `isize`, found `usize` @@ -1714,6 +934,6 @@ help: you can convert a `usize` to an `isize` and panic if the converted value d LL | x_isize > x_usize.try_into().unwrap(); | ++++++++++++++++++++ -error: aborting due to 132 previous errors +error: aborting due to 72 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/numeric/numeric-cast.fixed b/tests/ui/numeric/numeric-cast.fixed index cf0560a107772..537116400ce2e 100644 --- a/tests/ui/numeric/numeric-cast.fixed +++ b/tests/ui/numeric/numeric-cast.fixed @@ -19,138 +19,6 @@ fn main() { let x_f64: f64 = 11.0; let x_f32: f32 = 12.0; - foo::(x_usize); - foo::(x_u64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u16.into()); - //~^ ERROR mismatched types - foo::(x_u8.into()); - //~^ ERROR mismatched types - foo::(x_isize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i16.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i8.try_into().unwrap()); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - - foo::(x_usize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u16.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u8.into()); - //~^ ERROR mismatched types - foo::(x_isize); - foo::(x_i64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i16.into()); - //~^ ERROR mismatched types - foo::(x_i8.into()); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - - foo::(x_usize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u64); - foo::(x_u32.into()); - //~^ ERROR mismatched types - foo::(x_u16.into()); - //~^ ERROR mismatched types - foo::(x_u8.into()); - //~^ ERROR mismatched types - foo::(x_isize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i16.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i8.try_into().unwrap()); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - - foo::(x_usize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u32.into()); - //~^ ERROR mismatched types - foo::(x_u16.into()); - //~^ ERROR mismatched types - foo::(x_u8.into()); - //~^ ERROR mismatched types - foo::(x_isize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i64); - foo::(x_i32.into()); - //~^ ERROR mismatched types - foo::(x_i16.into()); - //~^ ERROR mismatched types - foo::(x_i8.into()); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - - foo::(x_usize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u32); - foo::(x_u16.into()); - //~^ ERROR mismatched types - foo::(x_u8.into()); - //~^ ERROR mismatched types - foo::(x_isize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i16.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i8.try_into().unwrap()); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - - foo::(x_usize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u32.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_u16.into()); - //~^ ERROR mismatched types - foo::(x_u8.into()); - //~^ ERROR mismatched types - foo::(x_isize.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i64.try_into().unwrap()); - //~^ ERROR mismatched types - foo::(x_i32); - foo::(x_i16.into()); - //~^ ERROR mismatched types - foo::(x_i8.into()); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - foo::(x_usize.try_into().unwrap()); //~^ ERROR mismatched types foo::(x_u64.try_into().unwrap()); diff --git a/tests/ui/numeric/numeric-cast.rs b/tests/ui/numeric/numeric-cast.rs index 7bddfc5090535..9ba283668c2d0 100644 --- a/tests/ui/numeric/numeric-cast.rs +++ b/tests/ui/numeric/numeric-cast.rs @@ -19,138 +19,6 @@ fn main() { let x_f64: f64 = 11.0; let x_f32: f32 = 12.0; - foo::(x_usize); - foo::(x_u64); - //~^ ERROR mismatched types - foo::(x_u32); - //~^ ERROR mismatched types - foo::(x_u16); - //~^ ERROR mismatched types - foo::(x_u8); - //~^ ERROR mismatched types - foo::(x_isize); - //~^ ERROR mismatched types - foo::(x_i64); - //~^ ERROR mismatched types - foo::(x_i32); - //~^ ERROR mismatched types - foo::(x_i16); - //~^ ERROR mismatched types - foo::(x_i8); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - - foo::(x_usize); - //~^ ERROR mismatched types - foo::(x_u64); - //~^ ERROR mismatched types - foo::(x_u32); - //~^ ERROR mismatched types - foo::(x_u16); - //~^ ERROR mismatched types - foo::(x_u8); - //~^ ERROR mismatched types - foo::(x_isize); - foo::(x_i64); - //~^ ERROR mismatched types - foo::(x_i32); - //~^ ERROR mismatched types - foo::(x_i16); - //~^ ERROR mismatched types - foo::(x_i8); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - - foo::(x_usize); - //~^ ERROR mismatched types - foo::(x_u64); - foo::(x_u32); - //~^ ERROR mismatched types - foo::(x_u16); - //~^ ERROR mismatched types - foo::(x_u8); - //~^ ERROR mismatched types - foo::(x_isize); - //~^ ERROR mismatched types - foo::(x_i64); - //~^ ERROR mismatched types - foo::(x_i32); - //~^ ERROR mismatched types - foo::(x_i16); - //~^ ERROR mismatched types - foo::(x_i8); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - - foo::(x_usize); - //~^ ERROR mismatched types - foo::(x_u64); - //~^ ERROR mismatched types - foo::(x_u32); - //~^ ERROR mismatched types - foo::(x_u16); - //~^ ERROR mismatched types - foo::(x_u8); - //~^ ERROR mismatched types - foo::(x_isize); - //~^ ERROR mismatched types - foo::(x_i64); - foo::(x_i32); - //~^ ERROR mismatched types - foo::(x_i16); - //~^ ERROR mismatched types - foo::(x_i8); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - - foo::(x_usize); - //~^ ERROR mismatched types - foo::(x_u64); - //~^ ERROR mismatched types - foo::(x_u32); - foo::(x_u16); - //~^ ERROR mismatched types - foo::(x_u8); - //~^ ERROR mismatched types - foo::(x_isize); - //~^ ERROR mismatched types - foo::(x_i64); - //~^ ERROR mismatched types - foo::(x_i32); - //~^ ERROR mismatched types - foo::(x_i16); - //~^ ERROR mismatched types - foo::(x_i8); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - - foo::(x_usize); - //~^ ERROR mismatched types - foo::(x_u64); - //~^ ERROR mismatched types - foo::(x_u32); - //~^ ERROR mismatched types - foo::(x_u16); - //~^ ERROR mismatched types - foo::(x_u8); - //~^ ERROR mismatched types - foo::(x_isize); - //~^ ERROR mismatched types - foo::(x_i64); - //~^ ERROR mismatched types - foo::(x_i32); - foo::(x_i16); - //~^ ERROR mismatched types - foo::(x_i8); - //~^ ERROR mismatched types - // foo::(x_f64); - // foo::(x_f32); - foo::(x_usize); //~^ ERROR mismatched types foo::(x_u64); diff --git a/tests/ui/numeric/numeric-cast.stderr b/tests/ui/numeric/numeric-cast.stderr index d347875d5a947..5d4e06c94e8db 100644 --- a/tests/ui/numeric/numeric-cast.stderr +++ b/tests/ui/numeric/numeric-cast.stderr @@ -1,977 +1,5 @@ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:23:18 - | -LL | foo::(x_u64); - | ------------ ^^^^^ expected `usize`, found `u64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u64` to a `usize` and panic if the converted value doesn't fit - | -LL | foo::(x_u64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:25:18 - | -LL | foo::(x_u32); - | ------------ ^^^^^ expected `usize`, found `u32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u32` to a `usize` and panic if the converted value doesn't fit - | -LL | foo::(x_u32.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:27:18 - | -LL | foo::(x_u16); - | ------------ ^^^^^ expected `usize`, found `u16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u16` to a `usize` - | -LL | foo::(x_u16.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:29:18 - | -LL | foo::(x_u8); - | ------------ ^^^^ expected `usize`, found `u8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u8` to a `usize` - | -LL | foo::(x_u8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:31:18 - | -LL | foo::(x_isize); - | ------------ ^^^^^^^ expected `usize`, found `isize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `isize` to a `usize` and panic if the converted value doesn't fit - | -LL | foo::(x_isize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:33:18 - | -LL | foo::(x_i64); - | ------------ ^^^^^ expected `usize`, found `i64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i64` to a `usize` and panic if the converted value doesn't fit - | -LL | foo::(x_i64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:35:18 - | -LL | foo::(x_i32); - | ------------ ^^^^^ expected `usize`, found `i32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i32` to a `usize` and panic if the converted value doesn't fit - | -LL | foo::(x_i32.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:37:18 - | -LL | foo::(x_i16); - | ------------ ^^^^^ expected `usize`, found `i16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i16` to a `usize` and panic if the converted value doesn't fit - | -LL | foo::(x_i16.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:39:18 - | -LL | foo::(x_i8); - | ------------ ^^^^ expected `usize`, found `i8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i8` to a `usize` and panic if the converted value doesn't fit - | -LL | foo::(x_i8.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:44:18 - | -LL | foo::(x_usize); - | ------------ ^^^^^^^ expected `isize`, found `usize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `usize` to an `isize` and panic if the converted value doesn't fit - | -LL | foo::(x_usize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:46:18 - | -LL | foo::(x_u64); - | ------------ ^^^^^ expected `isize`, found `u64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u64` to an `isize` and panic if the converted value doesn't fit - | -LL | foo::(x_u64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:48:18 - | -LL | foo::(x_u32); - | ------------ ^^^^^ expected `isize`, found `u32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u32` to an `isize` and panic if the converted value doesn't fit - | -LL | foo::(x_u32.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:50:18 - | -LL | foo::(x_u16); - | ------------ ^^^^^ expected `isize`, found `u16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u16` to an `isize` and panic if the converted value doesn't fit - | -LL | foo::(x_u16.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:52:18 - | -LL | foo::(x_u8); - | ------------ ^^^^ expected `isize`, found `u8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u8` to an `isize` - | -LL | foo::(x_u8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:55:18 - | -LL | foo::(x_i64); - | ------------ ^^^^^ expected `isize`, found `i64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i64` to an `isize` and panic if the converted value doesn't fit - | -LL | foo::(x_i64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:57:18 - | -LL | foo::(x_i32); - | ------------ ^^^^^ expected `isize`, found `i32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i32` to an `isize` and panic if the converted value doesn't fit - | -LL | foo::(x_i32.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:59:18 - | -LL | foo::(x_i16); - | ------------ ^^^^^ expected `isize`, found `i16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i16` to an `isize` - | -LL | foo::(x_i16.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:61:18 - | -LL | foo::(x_i8); - | ------------ ^^^^ expected `isize`, found `i8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i8` to an `isize` - | -LL | foo::(x_i8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:66:16 - | -LL | foo::(x_usize); - | ---------- ^^^^^^^ expected `u64`, found `usize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit - | -LL | foo::(x_usize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:69:16 - | -LL | foo::(x_u32); - | ---------- ^^^^^ expected `u64`, found `u32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u32` to a `u64` - | -LL | foo::(x_u32.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:71:16 - | -LL | foo::(x_u16); - | ---------- ^^^^^ expected `u64`, found `u16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u16` to a `u64` - | -LL | foo::(x_u16.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:73:16 - | -LL | foo::(x_u8); - | ---------- ^^^^ expected `u64`, found `u8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u8` to a `u64` - | -LL | foo::(x_u8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:75:16 - | -LL | foo::(x_isize); - | ---------- ^^^^^^^ expected `u64`, found `isize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `isize` to a `u64` and panic if the converted value doesn't fit - | -LL | foo::(x_isize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:77:16 - | -LL | foo::(x_i64); - | ---------- ^^^^^ expected `u64`, found `i64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i64` to a `u64` and panic if the converted value doesn't fit - | -LL | foo::(x_i64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:79:16 - | -LL | foo::(x_i32); - | ---------- ^^^^^ expected `u64`, found `i32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i32` to a `u64` and panic if the converted value doesn't fit - | -LL | foo::(x_i32.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:81:16 - | -LL | foo::(x_i16); - | ---------- ^^^^^ expected `u64`, found `i16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i16` to a `u64` and panic if the converted value doesn't fit - | -LL | foo::(x_i16.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:83:16 - | -LL | foo::(x_i8); - | ---------- ^^^^ expected `u64`, found `i8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i8` to a `u64` and panic if the converted value doesn't fit - | -LL | foo::(x_i8.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:88:16 - | -LL | foo::(x_usize); - | ---------- ^^^^^^^ expected `i64`, found `usize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `usize` to an `i64` and panic if the converted value doesn't fit - | -LL | foo::(x_usize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:90:16 - | -LL | foo::(x_u64); - | ---------- ^^^^^ expected `i64`, found `u64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u64` to an `i64` and panic if the converted value doesn't fit - | -LL | foo::(x_u64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:92:16 - | -LL | foo::(x_u32); - | ---------- ^^^^^ expected `i64`, found `u32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u32` to an `i64` - | -LL | foo::(x_u32.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:94:16 - | -LL | foo::(x_u16); - | ---------- ^^^^^ expected `i64`, found `u16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u16` to an `i64` - | -LL | foo::(x_u16.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:96:16 - | -LL | foo::(x_u8); - | ---------- ^^^^ expected `i64`, found `u8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u8` to an `i64` - | -LL | foo::(x_u8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:98:16 - | -LL | foo::(x_isize); - | ---------- ^^^^^^^ expected `i64`, found `isize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `isize` to an `i64` and panic if the converted value doesn't fit - | -LL | foo::(x_isize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:101:16 - | -LL | foo::(x_i32); - | ---------- ^^^^^ expected `i64`, found `i32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i32` to an `i64` - | -LL | foo::(x_i32.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:103:16 - | -LL | foo::(x_i16); - | ---------- ^^^^^ expected `i64`, found `i16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i16` to an `i64` - | -LL | foo::(x_i16.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:105:16 - | -LL | foo::(x_i8); - | ---------- ^^^^ expected `i64`, found `i8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i8` to an `i64` - | -LL | foo::(x_i8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:110:16 - | -LL | foo::(x_usize); - | ---------- ^^^^^^^ expected `u32`, found `usize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `usize` to a `u32` and panic if the converted value doesn't fit - | -LL | foo::(x_usize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:112:16 - | -LL | foo::(x_u64); - | ---------- ^^^^^ expected `u32`, found `u64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit - | -LL | foo::(x_u64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:115:16 - | -LL | foo::(x_u16); - | ---------- ^^^^^ expected `u32`, found `u16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u16` to a `u32` - | -LL | foo::(x_u16.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:117:16 - | -LL | foo::(x_u8); - | ---------- ^^^^ expected `u32`, found `u8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u8` to a `u32` - | -LL | foo::(x_u8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:119:16 - | -LL | foo::(x_isize); - | ---------- ^^^^^^^ expected `u32`, found `isize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `isize` to a `u32` and panic if the converted value doesn't fit - | -LL | foo::(x_isize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:121:16 - | -LL | foo::(x_i64); - | ---------- ^^^^^ expected `u32`, found `i64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i64` to a `u32` and panic if the converted value doesn't fit - | -LL | foo::(x_i64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:123:16 - | -LL | foo::(x_i32); - | ---------- ^^^^^ expected `u32`, found `i32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i32` to a `u32` and panic if the converted value doesn't fit - | -LL | foo::(x_i32.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:125:16 - | -LL | foo::(x_i16); - | ---------- ^^^^^ expected `u32`, found `i16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i16` to a `u32` and panic if the converted value doesn't fit - | -LL | foo::(x_i16.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:127:16 - | -LL | foo::(x_i8); - | ---------- ^^^^ expected `u32`, found `i8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i8` to a `u32` and panic if the converted value doesn't fit - | -LL | foo::(x_i8.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:132:16 - | -LL | foo::(x_usize); - | ---------- ^^^^^^^ expected `i32`, found `usize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `usize` to an `i32` and panic if the converted value doesn't fit - | -LL | foo::(x_usize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:134:16 - | -LL | foo::(x_u64); - | ---------- ^^^^^ expected `i32`, found `u64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u64` to an `i32` and panic if the converted value doesn't fit - | -LL | foo::(x_u64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:136:16 - | -LL | foo::(x_u32); - | ---------- ^^^^^ expected `i32`, found `u32` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit - | -LL | foo::(x_u32.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:138:16 - | -LL | foo::(x_u16); - | ---------- ^^^^^ expected `i32`, found `u16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u16` to an `i32` - | -LL | foo::(x_u16.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:140:16 - | -LL | foo::(x_u8); - | ---------- ^^^^ expected `i32`, found `u8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert a `u8` to an `i32` - | -LL | foo::(x_u8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:142:16 - | -LL | foo::(x_isize); - | ---------- ^^^^^^^ expected `i32`, found `isize` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `isize` to an `i32` and panic if the converted value doesn't fit - | -LL | foo::(x_isize.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:144:16 - | -LL | foo::(x_i64); - | ---------- ^^^^^ expected `i32`, found `i64` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i64` to an `i32` and panic if the converted value doesn't fit - | -LL | foo::(x_i64.try_into().unwrap()); - | ++++++++++++++++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:147:16 - | -LL | foo::(x_i16); - | ---------- ^^^^^ expected `i32`, found `i16` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i16` to an `i32` - | -LL | foo::(x_i16.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:149:16 - | -LL | foo::(x_i8); - | ---------- ^^^^ expected `i32`, found `i8` - | | - | arguments to this function are incorrect - | -note: function defined here - --> $DIR/numeric-cast.rs:6:4 - | -LL | fn foo(_x: N) {} - | ^^^ ----- -help: you can convert an `i8` to an `i32` - | -LL | foo::(x_i8.into()); - | +++++++ - -error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:154:16 + --> $DIR/numeric-cast.rs:22:16 | LL | foo::(x_usize); | ---------- ^^^^^^^ expected `u16`, found `usize` @@ -989,7 +17,7 @@ LL | foo::(x_usize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:156:16 + --> $DIR/numeric-cast.rs:24:16 | LL | foo::(x_u64); | ---------- ^^^^^ expected `u16`, found `u64` @@ -1007,7 +35,7 @@ LL | foo::(x_u64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:158:16 + --> $DIR/numeric-cast.rs:26:16 | LL | foo::(x_u32); | ---------- ^^^^^ expected `u16`, found `u32` @@ -1025,7 +53,7 @@ LL | foo::(x_u32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:161:16 + --> $DIR/numeric-cast.rs:29:16 | LL | foo::(x_u8); | ---------- ^^^^ expected `u16`, found `u8` @@ -1043,7 +71,7 @@ LL | foo::(x_u8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:163:16 + --> $DIR/numeric-cast.rs:31:16 | LL | foo::(x_isize); | ---------- ^^^^^^^ expected `u16`, found `isize` @@ -1061,7 +89,7 @@ LL | foo::(x_isize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:165:16 + --> $DIR/numeric-cast.rs:33:16 | LL | foo::(x_i64); | ---------- ^^^^^ expected `u16`, found `i64` @@ -1079,7 +107,7 @@ LL | foo::(x_i64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:167:16 + --> $DIR/numeric-cast.rs:35:16 | LL | foo::(x_i32); | ---------- ^^^^^ expected `u16`, found `i32` @@ -1097,7 +125,7 @@ LL | foo::(x_i32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:169:16 + --> $DIR/numeric-cast.rs:37:16 | LL | foo::(x_i16); | ---------- ^^^^^ expected `u16`, found `i16` @@ -1115,7 +143,7 @@ LL | foo::(x_i16.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:171:16 + --> $DIR/numeric-cast.rs:39:16 | LL | foo::(x_i8); | ---------- ^^^^ expected `u16`, found `i8` @@ -1133,7 +161,7 @@ LL | foo::(x_i8.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:176:16 + --> $DIR/numeric-cast.rs:44:16 | LL | foo::(x_usize); | ---------- ^^^^^^^ expected `i16`, found `usize` @@ -1151,7 +179,7 @@ LL | foo::(x_usize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:178:16 + --> $DIR/numeric-cast.rs:46:16 | LL | foo::(x_u64); | ---------- ^^^^^ expected `i16`, found `u64` @@ -1169,7 +197,7 @@ LL | foo::(x_u64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:180:16 + --> $DIR/numeric-cast.rs:48:16 | LL | foo::(x_u32); | ---------- ^^^^^ expected `i16`, found `u32` @@ -1187,7 +215,7 @@ LL | foo::(x_u32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:182:16 + --> $DIR/numeric-cast.rs:50:16 | LL | foo::(x_u16); | ---------- ^^^^^ expected `i16`, found `u16` @@ -1205,7 +233,7 @@ LL | foo::(x_u16.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:184:16 + --> $DIR/numeric-cast.rs:52:16 | LL | foo::(x_u8); | ---------- ^^^^ expected `i16`, found `u8` @@ -1223,7 +251,7 @@ LL | foo::(x_u8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:186:16 + --> $DIR/numeric-cast.rs:54:16 | LL | foo::(x_isize); | ---------- ^^^^^^^ expected `i16`, found `isize` @@ -1241,7 +269,7 @@ LL | foo::(x_isize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:188:16 + --> $DIR/numeric-cast.rs:56:16 | LL | foo::(x_i64); | ---------- ^^^^^ expected `i16`, found `i64` @@ -1259,7 +287,7 @@ LL | foo::(x_i64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:190:16 + --> $DIR/numeric-cast.rs:58:16 | LL | foo::(x_i32); | ---------- ^^^^^ expected `i16`, found `i32` @@ -1277,7 +305,7 @@ LL | foo::(x_i32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:193:16 + --> $DIR/numeric-cast.rs:61:16 | LL | foo::(x_i8); | ---------- ^^^^ expected `i16`, found `i8` @@ -1295,7 +323,7 @@ LL | foo::(x_i8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:198:15 + --> $DIR/numeric-cast.rs:66:15 | LL | foo::(x_usize); | --------- ^^^^^^^ expected `u8`, found `usize` @@ -1313,7 +341,7 @@ LL | foo::(x_usize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:200:15 + --> $DIR/numeric-cast.rs:68:15 | LL | foo::(x_u64); | --------- ^^^^^ expected `u8`, found `u64` @@ -1331,7 +359,7 @@ LL | foo::(x_u64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:202:15 + --> $DIR/numeric-cast.rs:70:15 | LL | foo::(x_u32); | --------- ^^^^^ expected `u8`, found `u32` @@ -1349,7 +377,7 @@ LL | foo::(x_u32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:204:15 + --> $DIR/numeric-cast.rs:72:15 | LL | foo::(x_u16); | --------- ^^^^^ expected `u8`, found `u16` @@ -1367,7 +395,7 @@ LL | foo::(x_u16.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:207:15 + --> $DIR/numeric-cast.rs:75:15 | LL | foo::(x_isize); | --------- ^^^^^^^ expected `u8`, found `isize` @@ -1385,7 +413,7 @@ LL | foo::(x_isize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:209:15 + --> $DIR/numeric-cast.rs:77:15 | LL | foo::(x_i64); | --------- ^^^^^ expected `u8`, found `i64` @@ -1403,7 +431,7 @@ LL | foo::(x_i64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:211:15 + --> $DIR/numeric-cast.rs:79:15 | LL | foo::(x_i32); | --------- ^^^^^ expected `u8`, found `i32` @@ -1421,7 +449,7 @@ LL | foo::(x_i32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:213:15 + --> $DIR/numeric-cast.rs:81:15 | LL | foo::(x_i16); | --------- ^^^^^ expected `u8`, found `i16` @@ -1439,7 +467,7 @@ LL | foo::(x_i16.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:215:15 + --> $DIR/numeric-cast.rs:83:15 | LL | foo::(x_i8); | --------- ^^^^ expected `u8`, found `i8` @@ -1457,7 +485,7 @@ LL | foo::(x_i8.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:220:15 + --> $DIR/numeric-cast.rs:88:15 | LL | foo::(x_usize); | --------- ^^^^^^^ expected `i8`, found `usize` @@ -1475,7 +503,7 @@ LL | foo::(x_usize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:222:15 + --> $DIR/numeric-cast.rs:90:15 | LL | foo::(x_u64); | --------- ^^^^^ expected `i8`, found `u64` @@ -1493,7 +521,7 @@ LL | foo::(x_u64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:224:15 + --> $DIR/numeric-cast.rs:92:15 | LL | foo::(x_u32); | --------- ^^^^^ expected `i8`, found `u32` @@ -1511,7 +539,7 @@ LL | foo::(x_u32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:226:15 + --> $DIR/numeric-cast.rs:94:15 | LL | foo::(x_u16); | --------- ^^^^^ expected `i8`, found `u16` @@ -1529,7 +557,7 @@ LL | foo::(x_u16.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:228:15 + --> $DIR/numeric-cast.rs:96:15 | LL | foo::(x_u8); | --------- ^^^^ expected `i8`, found `u8` @@ -1547,7 +575,7 @@ LL | foo::(x_u8.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:230:15 + --> $DIR/numeric-cast.rs:98:15 | LL | foo::(x_isize); | --------- ^^^^^^^ expected `i8`, found `isize` @@ -1565,7 +593,7 @@ LL | foo::(x_isize.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:232:15 + --> $DIR/numeric-cast.rs:100:15 | LL | foo::(x_i64); | --------- ^^^^^ expected `i8`, found `i64` @@ -1583,7 +611,7 @@ LL | foo::(x_i64.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:234:15 + --> $DIR/numeric-cast.rs:102:15 | LL | foo::(x_i32); | --------- ^^^^^ expected `i8`, found `i32` @@ -1601,7 +629,7 @@ LL | foo::(x_i32.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:236:15 + --> $DIR/numeric-cast.rs:104:15 | LL | foo::(x_i16); | --------- ^^^^^ expected `i8`, found `i16` @@ -1619,7 +647,7 @@ LL | foo::(x_i16.try_into().unwrap()); | ++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:242:16 + --> $DIR/numeric-cast.rs:110:16 | LL | foo::(x_usize); | ---------- ^^^^^^^ expected `f64`, found `usize` @@ -1637,7 +665,7 @@ LL | foo::(x_usize as f64); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:244:16 + --> $DIR/numeric-cast.rs:112:16 | LL | foo::(x_u64); | ---------- ^^^^^ expected `f64`, found `u64` @@ -1655,7 +683,7 @@ LL | foo::(x_u64 as f64); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:246:16 + --> $DIR/numeric-cast.rs:114:16 | LL | foo::(x_u32); | ---------- ^^^^^ expected `f64`, found `u32` @@ -1673,7 +701,7 @@ LL | foo::(x_u32.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:248:16 + --> $DIR/numeric-cast.rs:116:16 | LL | foo::(x_u16); | ---------- ^^^^^ expected `f64`, found `u16` @@ -1691,7 +719,7 @@ LL | foo::(x_u16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:250:16 + --> $DIR/numeric-cast.rs:118:16 | LL | foo::(x_u8); | ---------- ^^^^ expected `f64`, found `u8` @@ -1709,7 +737,7 @@ LL | foo::(x_u8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:252:16 + --> $DIR/numeric-cast.rs:120:16 | LL | foo::(x_isize); | ---------- ^^^^^^^ expected `f64`, found `isize` @@ -1727,7 +755,7 @@ LL | foo::(x_isize as f64); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:254:16 + --> $DIR/numeric-cast.rs:122:16 | LL | foo::(x_i64); | ---------- ^^^^^ expected `f64`, found `i64` @@ -1745,7 +773,7 @@ LL | foo::(x_i64 as f64); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:256:16 + --> $DIR/numeric-cast.rs:124:16 | LL | foo::(x_i32); | ---------- ^^^^^ expected `f64`, found `i32` @@ -1763,7 +791,7 @@ LL | foo::(x_i32.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:258:16 + --> $DIR/numeric-cast.rs:126:16 | LL | foo::(x_i16); | ---------- ^^^^^ expected `f64`, found `i16` @@ -1781,7 +809,7 @@ LL | foo::(x_i16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:260:16 + --> $DIR/numeric-cast.rs:128:16 | LL | foo::(x_i8); | ---------- ^^^^ expected `f64`, found `i8` @@ -1799,7 +827,7 @@ LL | foo::(x_i8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:263:16 + --> $DIR/numeric-cast.rs:131:16 | LL | foo::(x_f32); | ---------- ^^^^^ expected `f64`, found `f32` @@ -1817,7 +845,7 @@ LL | foo::(x_f32.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:266:16 + --> $DIR/numeric-cast.rs:134:16 | LL | foo::(x_usize); | ---------- ^^^^^^^ expected `f32`, found `usize` @@ -1835,7 +863,7 @@ LL | foo::(x_usize as f32); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:268:16 + --> $DIR/numeric-cast.rs:136:16 | LL | foo::(x_u64); | ---------- ^^^^^ expected `f32`, found `u64` @@ -1853,7 +881,7 @@ LL | foo::(x_u64 as f32); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:270:16 + --> $DIR/numeric-cast.rs:138:16 | LL | foo::(x_u32); | ---------- ^^^^^ expected `f32`, found `u32` @@ -1871,7 +899,7 @@ LL | foo::(x_u32 as f32); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:272:16 + --> $DIR/numeric-cast.rs:140:16 | LL | foo::(x_u16); | ---------- ^^^^^ expected `f32`, found `u16` @@ -1889,7 +917,7 @@ LL | foo::(x_u16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:274:16 + --> $DIR/numeric-cast.rs:142:16 | LL | foo::(x_u8); | ---------- ^^^^ expected `f32`, found `u8` @@ -1907,7 +935,7 @@ LL | foo::(x_u8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:276:16 + --> $DIR/numeric-cast.rs:144:16 | LL | foo::(x_isize); | ---------- ^^^^^^^ expected `f32`, found `isize` @@ -1925,7 +953,7 @@ LL | foo::(x_isize as f32); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:278:16 + --> $DIR/numeric-cast.rs:146:16 | LL | foo::(x_i64); | ---------- ^^^^^ expected `f32`, found `i64` @@ -1943,7 +971,7 @@ LL | foo::(x_i64 as f32); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:280:16 + --> $DIR/numeric-cast.rs:148:16 | LL | foo::(x_i32); | ---------- ^^^^^ expected `f32`, found `i32` @@ -1961,7 +989,7 @@ LL | foo::(x_i32 as f32); | ++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:282:16 + --> $DIR/numeric-cast.rs:150:16 | LL | foo::(x_i16); | ---------- ^^^^^ expected `f32`, found `i16` @@ -1979,7 +1007,7 @@ LL | foo::(x_i16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:284:16 + --> $DIR/numeric-cast.rs:152:16 | LL | foo::(x_i8); | ---------- ^^^^ expected `f32`, found `i8` @@ -1997,7 +1025,7 @@ LL | foo::(x_i8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:289:16 + --> $DIR/numeric-cast.rs:157:16 | LL | foo::(x_u8 as u16); | ---------- ^^^^^^^^^^^ expected `u32`, found `u16` @@ -2015,7 +1043,7 @@ LL | foo::((x_u8 as u16).into()); | + ++++++++ error[E0308]: mismatched types - --> $DIR/numeric-cast.rs:291:16 + --> $DIR/numeric-cast.rs:159:16 | LL | foo::(-x_i8); | ---------- ^^^^^ expected `i32`, found `i8` @@ -2032,6 +1060,6 @@ help: you can convert an `i8` to an `i32` LL | foo::((-x_i8).into()); | + ++++++++ -error: aborting due to 113 previous errors +error: aborting due to 59 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/numeric/numeric-suffix/numeric-suffix.fixed b/tests/ui/numeric/numeric-suffix/numeric-suffix.fixed index 69934db217b62..24596a847a18f 100644 --- a/tests/ui/numeric/numeric-suffix/numeric-suffix.fixed +++ b/tests/ui/numeric/numeric-suffix/numeric-suffix.fixed @@ -336,14 +336,17 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_u16.into()); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_u8.into()); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_f64); //~^ ERROR mismatched types //~| NOTE expected @@ -356,14 +359,17 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_i16.into()); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_i8.into()); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42.0_f64); foo::(42.0_f64); //~^ ERROR mismatched types @@ -386,10 +392,12 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_u8.into()); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_f32); //~^ ERROR mismatched types //~| NOTE expected @@ -406,10 +414,12 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_i8.into()); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42.0_f32); //~^ ERROR mismatched types //~| NOTE expected @@ -420,8 +430,10 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::((-42_i8).into()); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` } diff --git a/tests/ui/numeric/numeric-suffix/numeric-suffix.rs b/tests/ui/numeric/numeric-suffix/numeric-suffix.rs index dabf43f82046f..d201c1d8d46ff 100644 --- a/tests/ui/numeric/numeric-suffix/numeric-suffix.rs +++ b/tests/ui/numeric/numeric-suffix/numeric-suffix.rs @@ -336,14 +336,17 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_u16); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_u8); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_isize); //~^ ERROR mismatched types //~| NOTE expected @@ -356,14 +359,17 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_i16); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_i8); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42.0_f64); foo::(42.0_f32); //~^ ERROR mismatched types @@ -386,10 +392,12 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_u8); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_isize); //~^ ERROR mismatched types //~| NOTE expected @@ -406,10 +414,12 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42_i8); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(42.0_f64); //~^ ERROR mismatched types //~| NOTE expected @@ -420,8 +430,10 @@ fn main() { //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` foo::(-42_i8); //~^ ERROR mismatched types //~| NOTE expected //~| NOTE arguments + //~| NOTE in this expansion of desugaring of a resized `Span` } diff --git a/tests/ui/numeric/numeric-suffix/numeric-suffix.stderr b/tests/ui/numeric/numeric-suffix/numeric-suffix.stderr index e05913b9c621c..eb6c749c9e01c 100644 --- a/tests/ui/numeric/numeric-suffix/numeric-suffix.stderr +++ b/tests/ui/numeric/numeric-suffix/numeric-suffix.stderr @@ -845,7 +845,7 @@ LL | foo::(42_u32.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:339:16 + --> $DIR/numeric-suffix.rs:340:16 | LL | foo::(42_u16); | ---------- ^^^^^^ expected `f64`, found `u16` @@ -863,7 +863,7 @@ LL | foo::(42_u16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:343:16 + --> $DIR/numeric-suffix.rs:345:16 | LL | foo::(42_u8); | ---------- ^^^^^ expected `f64`, found `u8` @@ -881,7 +881,7 @@ LL | foo::(42_u8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:347:16 + --> $DIR/numeric-suffix.rs:350:16 | LL | foo::(42_isize); | ---------- ^^^^^^^^ expected `f64`, found `isize` @@ -899,7 +899,7 @@ LL | foo::(42_f64); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:351:16 + --> $DIR/numeric-suffix.rs:354:16 | LL | foo::(42_i64); | ---------- ^^^^^^ expected `f64`, found `i64` @@ -917,7 +917,7 @@ LL | foo::(42_f64); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:355:16 + --> $DIR/numeric-suffix.rs:358:16 | LL | foo::(42_i32); | ---------- ^^^^^^ expected `f64`, found `i32` @@ -935,7 +935,7 @@ LL | foo::(42_i32.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:359:16 + --> $DIR/numeric-suffix.rs:363:16 | LL | foo::(42_i16); | ---------- ^^^^^^ expected `f64`, found `i16` @@ -953,7 +953,7 @@ LL | foo::(42_i16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:363:16 + --> $DIR/numeric-suffix.rs:368:16 | LL | foo::(42_i8); | ---------- ^^^^^ expected `f64`, found `i8` @@ -971,7 +971,7 @@ LL | foo::(42_i8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:368:16 + --> $DIR/numeric-suffix.rs:374:16 | LL | foo::(42.0_f32); | ---------- ^^^^^^^^ expected `f64`, found `f32` @@ -989,7 +989,7 @@ LL | foo::(42.0_f64); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:373:16 + --> $DIR/numeric-suffix.rs:379:16 | LL | foo::(42_usize); | ---------- ^^^^^^^^ expected `f32`, found `usize` @@ -1007,7 +1007,7 @@ LL | foo::(42_f32); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:377:16 + --> $DIR/numeric-suffix.rs:383:16 | LL | foo::(42_u64); | ---------- ^^^^^^ expected `f32`, found `u64` @@ -1025,7 +1025,7 @@ LL | foo::(42_f32); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:381:16 + --> $DIR/numeric-suffix.rs:387:16 | LL | foo::(42_u32); | ---------- ^^^^^^ expected `f32`, found `u32` @@ -1043,7 +1043,7 @@ LL | foo::(42_f32); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:385:16 + --> $DIR/numeric-suffix.rs:391:16 | LL | foo::(42_u16); | ---------- ^^^^^^ expected `f32`, found `u16` @@ -1061,7 +1061,7 @@ LL | foo::(42_u16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:389:16 + --> $DIR/numeric-suffix.rs:396:16 | LL | foo::(42_u8); | ---------- ^^^^^ expected `f32`, found `u8` @@ -1079,7 +1079,7 @@ LL | foo::(42_u8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:393:16 + --> $DIR/numeric-suffix.rs:401:16 | LL | foo::(42_isize); | ---------- ^^^^^^^^ expected `f32`, found `isize` @@ -1097,7 +1097,7 @@ LL | foo::(42_f32); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:397:16 + --> $DIR/numeric-suffix.rs:405:16 | LL | foo::(42_i64); | ---------- ^^^^^^ expected `f32`, found `i64` @@ -1115,7 +1115,7 @@ LL | foo::(42_f32); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:401:16 + --> $DIR/numeric-suffix.rs:409:16 | LL | foo::(42_i32); | ---------- ^^^^^^ expected `f32`, found `i32` @@ -1133,7 +1133,7 @@ LL | foo::(42_f32); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:405:16 + --> $DIR/numeric-suffix.rs:413:16 | LL | foo::(42_i16); | ---------- ^^^^^^ expected `f32`, found `i16` @@ -1151,7 +1151,7 @@ LL | foo::(42_i16.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:409:16 + --> $DIR/numeric-suffix.rs:418:16 | LL | foo::(42_i8); | ---------- ^^^^^ expected `f32`, found `i8` @@ -1169,7 +1169,7 @@ LL | foo::(42_i8.into()); | +++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:413:16 + --> $DIR/numeric-suffix.rs:423:16 | LL | foo::(42.0_f64); | ---------- ^^^^^^^^ expected `f32`, found `f64` @@ -1187,7 +1187,7 @@ LL | foo::(42.0_f32); | ~~~ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:419:16 + --> $DIR/numeric-suffix.rs:429:16 | LL | foo::(42_u8 as u16); | ---------- ^^^^^^^^^^^^ expected `u32`, found `u16` @@ -1205,7 +1205,7 @@ LL | foo::((42_u8 as u16).into()); | + ++++++++ error[E0308]: mismatched types - --> $DIR/numeric-suffix.rs:423:16 + --> $DIR/numeric-suffix.rs:434:16 | LL | foo::(-42_i8); | ---------- ^^^^^^ expected `i32`, found `i8` diff --git a/tests/ui/proc-macro/generate-mod.rs b/tests/ui/proc-macro/generate-mod.rs index 471f317edf964..85b2b530fb318 100644 --- a/tests/ui/proc-macro/generate-mod.rs +++ b/tests/ui/proc-macro/generate-mod.rs @@ -6,22 +6,22 @@ extern crate generate_mod; struct FromOutside; -generate_mod::check!(); //~ ERROR cannot find type `FromOutside` in this scope - //~| ERROR cannot find type `Outer` in this scope +generate_mod::check!(); //~ ERROR cannot find type `FromOutside` in + //~| ERROR cannot find type `Outer` in -#[generate_mod::check_attr] //~ ERROR cannot find type `FromOutside` in this scope - //~| ERROR cannot find type `OuterAttr` in this scope +#[generate_mod::check_attr] //~ ERROR cannot find type `FromOutside` in + //~| ERROR cannot find type `OuterAttr` in struct S; -#[derive(generate_mod::CheckDerive)] //~ ERROR cannot find type `FromOutside` in this scope - //~| ERROR cannot find type `OuterDerive` in this scope +#[derive(generate_mod::CheckDerive)] //~ ERROR cannot find type `FromOutside` in + //~| ERROR cannot find type `OuterDerive` in //~| WARN this was previously accepted //~| WARN this was previously accepted struct Z; fn inner_block() { - #[derive(generate_mod::CheckDerive)] //~ ERROR cannot find type `FromOutside` in this scope - //~| ERROR cannot find type `OuterDerive` in this scope + #[derive(generate_mod::CheckDerive)] //~ ERROR cannot find type `FromOutside` in + //~| ERROR cannot find type `OuterDerive` in //~| WARN this was previously accepted //~| WARN this was previously accepted struct InnerZ; diff --git a/tests/ui/proc-macro/generate-mod.stderr b/tests/ui/proc-macro/generate-mod.stderr index db629b5b5e239..0059e64f4664c 100644 --- a/tests/ui/proc-macro/generate-mod.stderr +++ b/tests/ui/proc-macro/generate-mod.stderr @@ -1,41 +1,33 @@ -error[E0412]: cannot find type `FromOutside` in this scope +error[E0412]: cannot find type `FromOutside` in the expanded code of procedural macro `generate_mod::check` --> $DIR/generate-mod.rs:9:1 | LL | generate_mod::check!(); - | ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^^^ `FromOutside` not found in expanded code of this procedural macro | - = help: consider importing this struct: - FromOutside = note: this error originates in the macro `generate_mod::check` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0412]: cannot find type `Outer` in this scope +error[E0412]: cannot find type `Outer` in the expanded code of procedural macro `generate_mod::check` --> $DIR/generate-mod.rs:9:1 | LL | generate_mod::check!(); - | ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^^^ `Outer` not found in expanded code of this procedural macro | - = help: consider importing this struct: - Outer = note: this error originates in the macro `generate_mod::check` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0412]: cannot find type `FromOutside` in this scope +error[E0412]: cannot find type `FromOutside` in the expanded code of procedural macro `generate_mod::check_attr` --> $DIR/generate-mod.rs:12:1 | LL | #[generate_mod::check_attr] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `FromOutside` not found in expanded code of this procedural macro | - = help: consider importing this struct: - FromOutside = note: this error originates in the attribute macro `generate_mod::check_attr` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0412]: cannot find type `OuterAttr` in this scope +error[E0412]: cannot find type `OuterAttr` in the expanded code of procedural macro `generate_mod::check_attr` --> $DIR/generate-mod.rs:12:1 | LL | #[generate_mod::check_attr] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `OuterAttr` not found in expanded code of this procedural macro | - = help: consider importing this struct: - OuterAttr = note: this error originates in the attribute macro `generate_mod::check_attr` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot find type `FromOutside` in this scope diff --git a/tests/ui/proc-macro/issue-38586.stderr b/tests/ui/proc-macro/issue-38586.stderr index ddd0a0874dd3e..d3fce750343f4 100644 --- a/tests/ui/proc-macro/issue-38586.stderr +++ b/tests/ui/proc-macro/issue-38586.stderr @@ -1,8 +1,8 @@ -error[E0425]: cannot find value `foo` in this scope +error[E0425]: cannot find value `foo` in the expanded code of `derive` macro `A` --> $DIR/issue-38586.rs:6:10 | LL | #[derive(A)] - | ^ not found in this scope + | ^ `foo` not found in expanded code of this `derive` macro | = note: this error originates in the derive macro `A` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/proc-macro/issue-83510.rs b/tests/ui/proc-macro/issue-83510.rs index 2b1aec4df0be3..4c89dc98bcb41 100644 --- a/tests/ui/proc-macro/issue-83510.rs +++ b/tests/ui/proc-macro/issue-83510.rs @@ -3,9 +3,9 @@ extern crate issue_83510; issue_83510::dance_like_you_want_to_ice!(); -//~^ ERROR: cannot find type `Foo` in this scope +//~^ ERROR: cannot find type `Foo` //~| ERROR: expected trait, found struct `Box` -//~| ERROR: cannot find trait `Baz` in this scope +//~| ERROR: cannot find trait `Baz` //~| ERROR: inherent associated types are unstable fn main() {} diff --git a/tests/ui/proc-macro/issue-83510.stderr b/tests/ui/proc-macro/issue-83510.stderr index e0628a317918b..ed4c1c9b8d44a 100644 --- a/tests/ui/proc-macro/issue-83510.stderr +++ b/tests/ui/proc-macro/issue-83510.stderr @@ -1,8 +1,8 @@ -error[E0412]: cannot find type `Foo` in this scope +error[E0412]: cannot find type `Foo` in the expanded code of procedural macro `issue_83510::dance_like_you_want_to_ice` --> $DIR/issue-83510.rs:5:1 | LL | issue_83510::dance_like_you_want_to_ice!(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` not found in expanded code of this procedural macro | = note: this error originates in the macro `issue_83510::dance_like_you_want_to_ice` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -14,11 +14,11 @@ LL | issue_83510::dance_like_you_want_to_ice!(); | = note: this error originates in the macro `issue_83510::dance_like_you_want_to_ice` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0405]: cannot find trait `Baz` in this scope +error[E0405]: cannot find trait `Baz` in the expanded code of procedural macro `issue_83510::dance_like_you_want_to_ice` --> $DIR/issue-83510.rs:5:1 | LL | issue_83510::dance_like_you_want_to_ice!(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Baz` not found in expanded code of this procedural macro | = note: this error originates in the macro `issue_83510::dance_like_you_want_to_ice` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/proc-macro/lints_in_proc_macros.rs b/tests/ui/proc-macro/lints_in_proc_macros.rs index 377a1f25b635c..5f163f17a19db 100644 --- a/tests/ui/proc-macro/lints_in_proc_macros.rs +++ b/tests/ui/proc-macro/lints_in_proc_macros.rs @@ -7,8 +7,6 @@ use bang_proc_macro2::bang_proc_macro2; fn main() { let foobar = 42; bang_proc_macro2!(); - //~^ ERROR cannot find value `foobar2` in this scope - //~| HELP a local variable with a similar name exists - //~| SUGGESTION foobar + //~^ ERROR cannot find value `foobar2` println!("{}", x); } diff --git a/tests/ui/proc-macro/lints_in_proc_macros.stderr b/tests/ui/proc-macro/lints_in_proc_macros.stderr index 4dd8be7d9b6ef..9381bee36ca2b 100644 --- a/tests/ui/proc-macro/lints_in_proc_macros.stderr +++ b/tests/ui/proc-macro/lints_in_proc_macros.stderr @@ -1,8 +1,8 @@ -error[E0425]: cannot find value `foobar2` in this scope +error[E0425]: cannot find value `foobar2` in the expanded code of procedural macro `bang_proc_macro2` --> $DIR/lints_in_proc_macros.rs:9:5 | LL | bang_proc_macro2!(); - | ^^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `foobar` + | ^^^^^^^^^^^^^^^^^^^ `foobar2` not found in expanded code of this procedural macro | = note: this error originates in the macro `bang_proc_macro2` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/proc-macro/mixed-site-span.rs b/tests/ui/proc-macro/mixed-site-span.rs index 0083846568e29..2f0a93629dd82 100644 --- a/tests/ui/proc-macro/mixed-site-span.rs +++ b/tests/ui/proc-macro/mixed-site-span.rs @@ -12,9 +12,9 @@ fn main() { let local_use = 1; proc_macro_rules!(); //~^ ERROR use of undeclared label `'label_use` - //~| ERROR cannot find value `local_use` in this scope + //~| ERROR cannot find value `local_use` ItemDef; // OK - local_def; //~ ERROR cannot find value `local_def` in this scope + local_def; //~ ERROR cannot find value `local_def` } } diff --git a/tests/ui/proc-macro/mixed-site-span.stderr b/tests/ui/proc-macro/mixed-site-span.stderr index 1378608012464..982f57d4182a9 100644 --- a/tests/ui/proc-macro/mixed-site-span.stderr +++ b/tests/ui/proc-macro/mixed-site-span.stderr @@ -6,11 +6,11 @@ LL | proc_macro_rules!(); | = note: this error originates in the macro `proc_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0425]: cannot find value `local_use` in this scope +error[E0425]: cannot find value `local_use` in the expanded code of procedural macro `proc_macro_rules` --> $DIR/mixed-site-span.rs:13:9 | LL | proc_macro_rules!(); - | ^^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `local_def` + | ^^^^^^^^^^^^^^^^^^^ `local_use` not found in expanded code of this procedural macro | = note: this error originates in the macro `proc_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/proc-macro/parent-source-spans.rs b/tests/ui/proc-macro/parent-source-spans.rs index 354657db4db38..c4c38f065120e 100644 --- a/tests/ui/proc-macro/parent-source-spans.rs +++ b/tests/ui/proc-macro/parent-source-spans.rs @@ -27,9 +27,9 @@ macro three($($tokens:tt)*) { macro four($($tokens:tt)*) { parent_source_spans!($($tokens)*); - //~^ ERROR cannot find value `ok` in this scope - //~| ERROR cannot find value `ok` in this scope - //~| ERROR cannot find value `ok` in this scope + //~^ ERROR cannot find value `ok` + //~| ERROR cannot find value `ok` + //~| ERROR cannot find value `ok` } fn main() { diff --git a/tests/ui/proc-macro/parent-source-spans.stderr b/tests/ui/proc-macro/parent-source-spans.stderr index a3b27fd7bcc1b..2a75686805ea2 100644 --- a/tests/ui/proc-macro/parent-source-spans.stderr +++ b/tests/ui/proc-macro/parent-source-spans.stderr @@ -136,45 +136,36 @@ error: second source: "hop" LL | three!("hip", "hop"); | ^^^^^ -error[E0425]: cannot find value `ok` in this scope +error[E0425]: cannot find value `ok` in the expanded code of procedural macro `parent_source_spans` --> $DIR/parent-source-spans.rs:29:5 | LL | parent_source_spans!($($tokens)*); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a tuple variant with a similar name exists: `Ok` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ok` not found in expanded code of this procedural macro ... LL | one!("hello", "world"); | ---------------------- in this macro invocation - --> $SRC_DIR/core/src/result.rs:LL:COL - | - = note: similarly named tuple variant `Ok` defined here | = note: this error originates in the macro `parent_source_spans` which comes from the expansion of the macro `one` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0425]: cannot find value `ok` in this scope +error[E0425]: cannot find value `ok` in the expanded code of procedural macro `parent_source_spans` --> $DIR/parent-source-spans.rs:29:5 | LL | parent_source_spans!($($tokens)*); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a tuple variant with a similar name exists: `Ok` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ok` not found in expanded code of this procedural macro ... LL | two!("yay", "rust"); | ------------------- in this macro invocation - --> $SRC_DIR/core/src/result.rs:LL:COL - | - = note: similarly named tuple variant `Ok` defined here | = note: this error originates in the macro `parent_source_spans` which comes from the expansion of the macro `two` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0425]: cannot find value `ok` in this scope +error[E0425]: cannot find value `ok` in the expanded code of procedural macro `parent_source_spans` --> $DIR/parent-source-spans.rs:29:5 | LL | parent_source_spans!($($tokens)*); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a tuple variant with a similar name exists: `Ok` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ok` not found in expanded code of this procedural macro ... LL | three!("hip", "hop"); | -------------------- in this macro invocation - --> $SRC_DIR/core/src/result.rs:LL:COL - | - = note: similarly named tuple variant `Ok` defined here | = note: this error originates in the macro `parent_source_spans` which comes from the expansion of the macro `three` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/type/type-check/point-at-inference-4.rs b/tests/ui/type/type-check/point-at-inference-4.rs index aea9b2c6c14ee..65b54ff66f3a7 100644 --- a/tests/ui/type/type-check/point-at-inference-4.rs +++ b/tests/ui/type/type-check/point-at-inference-4.rs @@ -13,6 +13,7 @@ fn main() { //~^ ERROR this method takes 2 arguments but 1 argument was supplied //~| NOTE an argument is missing //~| HELP provide the argument + //~| NOTE in this expansion of desugaring of a resized `Span` let t: S = s; //~^ ERROR mismatched types //~| NOTE expected `S`, found `S` diff --git a/tests/ui/type/type-check/point-at-inference-4.stderr b/tests/ui/type/type-check/point-at-inference-4.stderr index 28833d2ed1c92..f13116d256cd0 100644 --- a/tests/ui/type/type-check/point-at-inference-4.stderr +++ b/tests/ui/type/type-check/point-at-inference-4.stderr @@ -15,7 +15,7 @@ LL | s.infer(0i32, /* b */); | ~~~~~~~~~~~~~~~ error[E0308]: mismatched types - --> $DIR/point-at-inference-4.rs:16:24 + --> $DIR/point-at-inference-4.rs:17:24 | LL | let t: S = s; | --------- ^ expected `S`, found `S`