From 05b2d3f7dc623fc5304fa0edc9efeaf08ea1db26 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 5 Jun 2020 10:14:53 -0700 Subject: [PATCH 1/8] std: Enable atomic.fence emission on wasm32 This commit removes the `#[cfg]` guards in `atomic::fence` on wasm targets. Since these guards were originally added the upstream wasm specification for threads gained an `atomic.fence` instruction, so LLVM no longer panics on these intrinsics. Although there aren't a ton of tests in-repo for this right now I've tested locally and all of these fences generate `atomic.fence` instructions in wasm. Closes #72997 --- src/libcore/sync/atomic.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index 449aac85bc7..d3196017848 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -2536,15 +2536,7 @@ unsafe fn atomic_umin(dst: *mut T, val: T, order: Ordering) -> T { /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed #[inline] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(target_arch = "wasm32", allow(unused_variables))] pub fn fence(order: Ordering) { - // On wasm32 it looks like fences aren't implemented in LLVM yet in that - // they will cause LLVM to abort. The wasm instruction set doesn't have - // fences right now. There's discussion online about the best way for tools - // to conventionally implement fences at - // https://github.com/WebAssembly/tool-conventions/issues/59. We should - // follow that discussion and implement a solution when one comes about! - #[cfg(not(target_arch = "wasm32"))] // SAFETY: using an atomic fence is safe. unsafe { match order { From 74befd955bfe23418369064888dc0f08f59c024f Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Fri, 5 Jun 2020 15:52:38 +0100 Subject: [PATCH 2/8] Fix #[thread_local] statics as asm! sym operands --- src/librustc_codegen_ssa/mir/block.rs | 8 +-- src/librustc_middle/mir/mod.rs | 10 ++-- src/librustc_middle/mir/visit.rs | 4 +- src/librustc_mir/borrow_check/invalidation.rs | 2 +- src/librustc_mir/borrow_check/mod.rs | 2 +- .../dataflow/move_paths/builder.rs | 2 +- src/librustc_mir/monomorphize/collector.rs | 16 ++++-- src/librustc_mir_build/build/expr/into.rs | 4 +- src/librustc_mir_build/hair/cx/expr.rs | 21 +------- src/librustc_mir_build/hair/mod.rs | 2 +- src/test/ui/asm/sym.rs | 52 +++++++++++++++++-- 11 files changed, 78 insertions(+), 45 deletions(-) diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index 6c18e753d79..c8038e5e0fc 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -921,12 +921,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { span_bug!(span, "invalid type for asm sym (fn)"); } } - mir::InlineAsmOperand::SymStatic { ref value } => { - if let Some(def_id) = value.check_static_ptr(bx.tcx()) { - InlineAsmOperandRef::SymStatic { def_id } - } else { - span_bug!(span, "invalid type for asm sym (static)"); - } + mir::InlineAsmOperand::SymStatic { def_id } => { + InlineAsmOperandRef::SymStatic { def_id } } }) .collect(); diff --git a/src/librustc_middle/mir/mod.rs b/src/librustc_middle/mir/mod.rs index 904424462bf..9df42679ade 100644 --- a/src/librustc_middle/mir/mod.rs +++ b/src/librustc_middle/mir/mod.rs @@ -1240,7 +1240,7 @@ pub enum InlineAsmOperand<'tcx> { value: Box>, }, SymStatic { - value: Box>, + def_id: DefId, }, } @@ -1636,9 +1636,11 @@ impl<'tcx> TerminatorKind<'tcx> { InlineAsmOperand::Const { value } => { write!(fmt, "const {:?}", value)?; } - InlineAsmOperand::SymFn { value } - | InlineAsmOperand::SymStatic { value } => { - write!(fmt, "sym {:?}", value)?; + InlineAsmOperand::SymFn { value } => { + write!(fmt, "sym_fn {:?}", value)?; + } + InlineAsmOperand::SymStatic { def_id } => { + write!(fmt, "sym_static {:?}", def_id)?; } } } diff --git a/src/librustc_middle/mir/visit.rs b/src/librustc_middle/mir/visit.rs index 351dc33dbe3..220dfa80f06 100644 --- a/src/librustc_middle/mir/visit.rs +++ b/src/librustc_middle/mir/visit.rs @@ -563,10 +563,10 @@ macro_rules! make_mir_visitor { ); } } - InlineAsmOperand::SymFn { value } - | InlineAsmOperand::SymStatic { value } => { + InlineAsmOperand::SymFn { value } => { self.visit_constant(value, source_location); } + InlineAsmOperand::SymStatic { def_id: _ } => {} } } } diff --git a/src/librustc_mir/borrow_check/invalidation.rs b/src/librustc_mir/borrow_check/invalidation.rs index 9c23ee74413..a0935517aaa 100644 --- a/src/librustc_mir/borrow_check/invalidation.rs +++ b/src/librustc_mir/borrow_check/invalidation.rs @@ -208,7 +208,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> { } } InlineAsmOperand::SymFn { value: _ } - | InlineAsmOperand::SymStatic { value: _ } => {} + | InlineAsmOperand::SymStatic { def_id: _ } => {} } } } diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index d17c111d0c4..8f297703928 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -759,7 +759,7 @@ impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tc } } InlineAsmOperand::SymFn { value: _ } - | InlineAsmOperand::SymStatic { value: _ } => {} + | InlineAsmOperand::SymStatic { def_id: _ } => {} } } } diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index da02211d002..4e8b796d500 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -439,7 +439,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { } } InlineAsmOperand::SymFn { value: _ } - | InlineAsmOperand::SymStatic { value: _ } => {} + | InlineAsmOperand::SymStatic { def_id: _ } => {} } } } diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 297b899ef0b..c4dadf0938b 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -634,9 +634,19 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { } mir::TerminatorKind::InlineAsm { ref operands, .. } => { for op in operands { - if let mir::InlineAsmOperand::SymFn { value } = op { - let fn_ty = self.monomorphize(value.literal.ty); - visit_fn_use(self.tcx, fn_ty, false, &mut self.output); + match *op { + mir::InlineAsmOperand::SymFn { ref value } => { + let fn_ty = self.monomorphize(value.literal.ty); + visit_fn_use(self.tcx, fn_ty, false, &mut self.output); + } + mir::InlineAsmOperand::SymStatic { def_id } => { + let instance = Instance::mono(self.tcx, def_id); + if should_monomorphize_locally(self.tcx, &instance) { + trace!("collecting asm sym static {:?}", def_id); + self.output.push(MonoItem::Static(def_id)); + } + } + _ => {} } } } diff --git a/src/librustc_mir_build/build/expr/into.rs b/src/librustc_mir_build/build/expr/into.rs index d5d1ddc5b7d..6b8d13de96a 100644 --- a/src/librustc_mir_build/build/expr/into.rs +++ b/src/librustc_mir_build/build/expr/into.rs @@ -353,8 +353,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { hair::InlineAsmOperand::SymFn { expr } => { mir::InlineAsmOperand::SymFn { value: box this.as_constant(expr) } } - hair::InlineAsmOperand::SymStatic { expr } => { - mir::InlineAsmOperand::SymStatic { value: box this.as_constant(expr) } + hair::InlineAsmOperand::SymStatic { def_id } => { + mir::InlineAsmOperand::SymStatic { def_id } } }) .collect(); diff --git a/src/librustc_mir_build/hair/cx/expr.rs b/src/librustc_mir_build/hair/cx/expr.rs index d0b35f32122..ef038a132d9 100644 --- a/src/librustc_mir_build/hair/cx/expr.rs +++ b/src/librustc_mir_build/hair/cx/expr.rs @@ -465,25 +465,8 @@ fn make_mirror_unadjusted<'a, 'tcx>( } } - Res::Def(DefKind::Static, id) => { - ty = cx.tcx.static_ptr_ty(id); - let ptr = cx.tcx.create_static_alloc(id); - InlineAsmOperand::SymStatic { - expr: Expr { - ty, - temp_lifetime, - span: expr.span, - kind: ExprKind::StaticRef { - literal: ty::Const::from_scalar( - cx.tcx, - Scalar::Ptr(ptr.into()), - ty, - ), - def_id: id, - }, - } - .to_ref(), - } + Res::Def(DefKind::Static, def_id) => { + InlineAsmOperand::SymStatic { def_id } } _ => { diff --git a/src/librustc_mir_build/hair/mod.rs b/src/librustc_mir_build/hair/mod.rs index c869699bb20..5f280e8568c 100644 --- a/src/librustc_mir_build/hair/mod.rs +++ b/src/librustc_mir_build/hair/mod.rs @@ -374,7 +374,7 @@ crate enum InlineAsmOperand<'tcx> { expr: ExprRef<'tcx>, }, SymStatic { - expr: ExprRef<'tcx>, + def_id: DefId, }, } diff --git a/src/test/ui/asm/sym.rs b/src/test/ui/asm/sym.rs index 83a3672af49..8cff16aa75f 100644 --- a/src/test/ui/asm/sym.rs +++ b/src/test/ui/asm/sym.rs @@ -1,8 +1,9 @@ // no-system-llvm // only-x86_64 +// only-linux // run-pass -#![feature(asm, track_caller)] +#![feature(asm, track_caller, thread_local)] extern "C" fn f1() -> i32 { 111 @@ -15,9 +16,9 @@ fn f2() -> i32 { } macro_rules! call { - ($func:path) => {{ - let result: i32; + ($func:path) => { unsafe { + let result: i32; asm!("call {}", sym $func, out("rax") result, out("rcx") _, out("rdx") _, out("rdi") _, out("rsi") _, @@ -27,12 +28,53 @@ macro_rules! call { out("xmm8") _, out("xmm9") _, out("xmm10") _, out("xmm11") _, out("xmm12") _, out("xmm13") _, out("xmm14") _, out("xmm15") _, ); + result } - result - }} + } } +macro_rules! static_addr { + ($s:expr) => { + unsafe { + let result: *const u32; + // LEA performs a RIP-relative address calculation and returns the address + asm!("lea {}, [rip + {}]", out(reg) result, sym $s); + result + } + } +} +macro_rules! static_tls_addr { + ($s:expr) => { + unsafe { + let result: *const u32; + asm!( + " + # Load TLS base address + mov {out}, qword ptr fs:[0] + # Calculate the address of sym in the TLS block. The @tpoff + # relocation gives the offset of the symbol from the start + # of the TLS block. + lea {out}, [{out} + {sym}@tpoff] + ", + out = out(reg) result, + sym = sym $s + ); + result + } + } +} + +static S1: u32 = 111; +#[thread_local] +static S2: u32 = 222; + fn main() { assert_eq!(call!(f1), 111); assert_eq!(call!(f2), 222); + assert_eq!(static_addr!(S1), &S1 as *const u32); + assert_eq!(static_tls_addr!(S2), &S2 as *const u32); + std::thread::spawn(|| { + assert_eq!(static_addr!(S1), &S1 as *const u32); + assert_eq!(static_tls_addr!(S2), &S2 as *const u32); + }); } From 377c55039ac4dad6e75782434fbdc38046601524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Wed, 10 Jun 2020 00:24:15 +0200 Subject: [PATCH 3/8] Remove missed `cfg(bootstrap)` --- src/libunwind/build.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/libunwind/build.rs b/src/libunwind/build.rs index 1462639259c..87ab32156c1 100644 --- a/src/libunwind/build.rs +++ b/src/libunwind/build.rs @@ -36,12 +36,6 @@ fn main() { println!("cargo:rustc-link-lib=gcc_pic"); } else if target.contains("pc-windows-gnu") { // This is handled in the target spec with late_link_args_[static|dynamic] - - // cfg!(bootstrap) doesn't work in build scripts - if env::var("RUSTC_STAGE").ok() == Some("0".to_string()) { - println!("cargo:rustc-link-lib=static-nobundle=gcc_eh"); - println!("cargo:rustc-link-lib=static-nobundle=pthread"); - } } else if target.contains("uwp-windows-gnu") { println!("cargo:rustc-link-lib=unwind"); } else if target.contains("fuchsia") { From e243f623174e661e7e2392eb234a0af9ce9129cd Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Tue, 9 Jun 2020 11:45:40 -0700 Subject: [PATCH 4/8] Provide suggestion to convert numeric op LHS rather than unwrapping RHS Given a code ```rust fn foo(x: u8, y: u32) -> bool { x > y } fn main() {} ``` it could be more helpful to provide a suggestion to do "u32::from(x)" rather than "y.try_into().unwrap()", since the latter may panic. We do this by passing the LHS of a binary expression up the stack into the coercion checker. Closes #73145 --- src/librustc_typeck/check/coercion.rs | 2 +- src/librustc_typeck/check/demand.rs | 109 +- src/librustc_typeck/check/expr.rs | 23 +- src/librustc_typeck/check/mod.rs | 9 +- src/librustc_typeck/check/op.rs | 8 +- src/test/ui/numeric/numeric-cast-binop.rs | 315 ++++ src/test/ui/numeric/numeric-cast-binop.stderr | 1385 +++++++++++++++++ 7 files changed, 1801 insertions(+), 50 deletions(-) create mode 100644 src/test/ui/numeric/numeric-cast-binop.rs create mode 100644 src/test/ui/numeric/numeric-cast-binop.stderr diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index efafb05c040..96c0d98ab06 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -1377,7 +1377,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { } if let Some(expr) = expression { - fcx.emit_coerce_suggestions(&mut err, expr, found, expected); + fcx.emit_coerce_suggestions(&mut err, expr, found, expected, None); } // Error possibly reported in `check_assign` so avoid emitting error again. diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 7ac88698985..cc2244ccf40 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -24,10 +24,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expr: &hir::Expr<'_>, expr_ty: Ty<'tcx>, expected: Ty<'tcx>, + expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>, ) { self.annotate_expected_due_to_let_ty(err, expr); self.suggest_compatible_variants(err, expr, expected, expr_ty); - self.suggest_deref_ref_or_into(err, expr, expected, expr_ty); + self.suggest_deref_ref_or_into(err, expr, expected, expr_ty, expected_ty_expr); if self.suggest_calling_boxed_future_when_appropriate(err, expr, expected, expr_ty) { return; } @@ -102,9 +103,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expr: &hir::Expr<'_>, checked_ty: Ty<'tcx>, expected: Ty<'tcx>, + expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>, allow_two_phase: AllowTwoPhase, ) -> Ty<'tcx> { - let (ty, err) = self.demand_coerce_diag(expr, checked_ty, expected, allow_two_phase); + let (ty, err) = + self.demand_coerce_diag(expr, checked_ty, expected, expected_ty_expr, allow_two_phase); if let Some(mut err) = err { err.emit(); } @@ -121,6 +124,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expr: &hir::Expr<'_>, checked_ty: Ty<'tcx>, expected: Ty<'tcx>, + expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>, allow_two_phase: AllowTwoPhase, ) -> (Ty<'tcx>, Option>) { let expected = self.resolve_vars_with_obligations(expected); @@ -141,7 +145,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return (expected, None); } - self.emit_coerce_suggestions(&mut err, expr, expr_ty, expected); + self.emit_coerce_suggestions(&mut err, expr, expr_ty, expected, expected_ty_expr); (expected, Some(err)) } @@ -671,6 +675,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expr: &hir::Expr<'_>, checked_ty: Ty<'tcx>, expected_ty: Ty<'tcx>, + expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>, ) -> bool { if self.tcx.sess.source_map().is_imported(expr.span) { // Ignore if span is from within a macro. @@ -747,7 +752,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let msg = format!("you can convert an `{}` to `{}`", checked_ty, expected_ty); let cast_msg = format!("you can cast an `{} to `{}`", checked_ty, expected_ty); - let try_msg = format!("{} and panic if the converted value wouldn't fit", msg); let lit_msg = format!( "change the type of the numeric literal from `{}` to `{}`", checked_ty, expected_ty, @@ -761,7 +765,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; let cast_suggestion = format!("{}{} as {}", prefix, with_opt_paren(&src), expected_ty); - let try_into_suggestion = format!("{}{}.try_into().unwrap()", prefix, with_opt_paren(&src)); let into_suggestion = format!("{}{}.into()", prefix, with_opt_paren(&src)); let suffix_suggestion = with_opt_paren(&format_args!( "{}{}", @@ -782,22 +785,55 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; let in_const_context = self.tcx.hir().is_inside_const_context(expr.hir_id); + + let suggest_fallible_into_or_lhs_from = + |err: &mut DiagnosticBuilder<'_>, exp_to_found_is_fallible: bool| { + // If we know the expression the expected type is derived from, we might be able + // to suggest a widening conversion rather than a narrowing one (which may + // panic). For example, given x: u8 and y: u32, if we know the span of "x", + // x > y + // can be given the suggestion "u32::from(x) > y" rather than + // "x > y.try_into().unwrap()". + let lhs_expr_and_src = expected_ty_expr.and_then(|expr| { + match self.tcx.sess.source_map().span_to_snippet(expr.span).ok() { + Some(src) => Some((expr, src)), + None => None, + } + }); + let (span, msg, suggestion) = if let (Some((lhs_expr, lhs_src)), false) = + (lhs_expr_and_src, exp_to_found_is_fallible) + { + let msg = format!( + "you can convert `{}` from `{}` to `{}`, matching the type of `{}`", + lhs_src, expected_ty, checked_ty, src + ); + let suggestion = format!("{}::from({})", checked_ty, lhs_src,); + (lhs_expr.span, msg, suggestion) + } else { + let msg = format!("{} and panic if the converted value wouldn't fit", msg); + let suggestion = + format!("{}{}.try_into().unwrap()", prefix, with_opt_paren(&src)); + (expr.span, msg, suggestion) + }; + err.span_suggestion(span, &msg, suggestion, Applicability::MachineApplicable); + }; + let suggest_to_change_suffix_or_into = - |err: &mut DiagnosticBuilder<'_>, is_fallible: bool| { + |err: &mut DiagnosticBuilder<'_>, + found_to_exp_is_fallible: bool, + exp_to_found_is_fallible: bool| { let msg = if literal_is_ty_suffixed(expr) { &lit_msg } else if in_const_context { // Do not recommend `into` or `try_into` in const contexts. return; - } else if is_fallible { - &try_msg + } else if found_to_exp_is_fallible { + return suggest_fallible_into_or_lhs_from(err, exp_to_found_is_fallible); } else { &msg }; let suggestion = if literal_is_ty_suffixed(expr) { suffix_suggestion.clone() - } else if is_fallible { - try_into_suggestion } else { into_suggestion.clone() }; @@ -806,41 +842,54 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match (&expected_ty.kind, &checked_ty.kind) { (&ty::Int(ref exp), &ty::Int(ref found)) => { - let is_fallible = match (exp.bit_width(), found.bit_width()) { - (Some(exp), Some(found)) if exp < found => true, - (None, Some(8 | 16)) => false, - (None, _) | (_, None) => true, - _ => false, + let (f2e_is_fallible, e2f_is_fallible) = match (exp.bit_width(), found.bit_width()) + { + (Some(exp), Some(found)) if exp < found => (true, false), + (Some(exp), Some(found)) if exp > found => (false, true), + (None, Some(8 | 16)) => (false, true), + (Some(8 | 16), None) => (true, false), + (None, _) | (_, None) => (true, true), + _ => (false, false), }; - suggest_to_change_suffix_or_into(err, is_fallible); + suggest_to_change_suffix_or_into(err, f2e_is_fallible, e2f_is_fallible); true } (&ty::Uint(ref exp), &ty::Uint(ref found)) => { - let is_fallible = match (exp.bit_width(), found.bit_width()) { - (Some(exp), Some(found)) if exp < found => true, - (None, Some(8 | 16)) => false, - (None, _) | (_, None) => true, - _ => false, + let (f2e_is_fallible, e2f_is_fallible) = match (exp.bit_width(), found.bit_width()) + { + (Some(exp), Some(found)) if exp < found => (true, false), + (Some(exp), Some(found)) if exp > found => (false, true), + (None, Some(8 | 16)) => (false, true), + (Some(8 | 16), None) => (true, false), + (None, _) | (_, None) => (true, true), + _ => (false, false), }; - suggest_to_change_suffix_or_into(err, is_fallible); + suggest_to_change_suffix_or_into(err, f2e_is_fallible, e2f_is_fallible); true } (&ty::Int(exp), &ty::Uint(found)) => { - let is_fallible = match (exp.bit_width(), found.bit_width()) { - (Some(exp), Some(found)) if found < exp => false, - (None, Some(8)) => false, - _ => true, + let (f2e_is_fallible, e2f_is_fallible) = match (exp.bit_width(), found.bit_width()) + { + (Some(exp), Some(found)) if found < exp => (false, true), + (None, Some(8)) => (false, true), + _ => (true, true), }; - suggest_to_change_suffix_or_into(err, is_fallible); + suggest_to_change_suffix_or_into(err, f2e_is_fallible, e2f_is_fallible); true } - (&ty::Uint(_), &ty::Int(_)) => { - suggest_to_change_suffix_or_into(err, true); + (&ty::Uint(exp), &ty::Int(found)) => { + let (f2e_is_fallible, e2f_is_fallible) = match (exp.bit_width(), found.bit_width()) + { + (Some(exp), Some(found)) if found > exp => (true, false), + (Some(8), None) => (true, false), + _ => (true, true), + }; + suggest_to_change_suffix_or_into(err, f2e_is_fallible, e2f_is_fallible); true } (&ty::Float(ref exp), &ty::Float(ref found)) => { if found.bit_width() < exp.bit_width() { - suggest_to_change_suffix_or_into(err, false); + suggest_to_change_suffix_or_into(err, false, true); } else if literal_is_ty_suffixed(expr) { err.span_suggestion( expr.span, diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs index 266e9b21d69..902fae9dcd4 100644 --- a/src/librustc_typeck/check/expr.rs +++ b/src/librustc_typeck/check/expr.rs @@ -86,7 +86,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(mut err) = self.demand_suptype_diag(expr.span, expected_ty, ty) { let expr = expr.peel_drop_temps(); - self.suggest_deref_ref_or_into(&mut err, expr, expected_ty, ty); + self.suggest_deref_ref_or_into(&mut err, expr, expected_ty, ty, None); extend_err(&mut err); // Error possibly reported in `check_assign` so avoid emitting error again. err.emit_unless(self.is_assign_to_bool(expr, expected_ty)); @@ -98,10 +98,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, expr: &'tcx hir::Expr<'tcx>, expected: Ty<'tcx>, + expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>, ) -> Ty<'tcx> { let ty = self.check_expr_with_hint(expr, expected); // checks don't need two phase - self.demand_coerce(expr, ty, expected, AllowTwoPhase::No) + self.demand_coerce(expr, ty, expected, expected_ty_expr, AllowTwoPhase::No) } pub(super) fn check_expr_with_hint( @@ -776,7 +777,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { span: &Span, ) -> Ty<'tcx> { let lhs_ty = self.check_expr_with_needs(&lhs, Needs::MutPlace); - let rhs_ty = self.check_expr_coercable_to_type(&rhs, lhs_ty); + let rhs_ty = self.check_expr_coercable_to_type(&rhs, lhs_ty, Some(lhs)); let expected_ty = expected.coercion_target_type(self, expr.span); if expected_ty == self.tcx.types.bool { @@ -1026,7 +1027,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let (element_ty, t) = match uty { Some(uty) => { - self.check_expr_coercable_to_type(&element, uty); + self.check_expr_coercable_to_type(&element, uty, None); (uty, uty) } None => { @@ -1063,7 +1064,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let elt_ts_iter = elts.iter().enumerate().map(|(i, e)| match flds { Some(ref fs) if i < fs.len() => { let ety = fs[i].expect_ty(); - self.check_expr_coercable_to_type(&e, ety); + self.check_expr_coercable_to_type(&e, ety, None); ety } _ => self.check_expr_with_expectation(&e, NoExpectation), @@ -1237,7 +1238,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Make sure to give a type to the field even if there's // an error, so we can continue type-checking. - self.check_expr_coercable_to_type(&field.expr, field_type); + self.check_expr_coercable_to_type(&field.expr, field_type, None); } // Make sure the programmer specified correct number of fields. @@ -1735,7 +1736,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match self.lookup_indexing(expr, base, base_t, idx_t, needs) { Some((index_ty, element_ty)) => { // two-phase not needed because index_ty is never mutable - self.demand_coerce(idx, idx_t, index_ty, AllowTwoPhase::No); + self.demand_coerce(idx, idx_t, index_ty, None, AllowTwoPhase::No); element_ty } None => { @@ -1788,7 +1789,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> Ty<'tcx> { match self.resume_yield_tys { Some((resume_ty, yield_ty)) => { - self.check_expr_coercable_to_type(&value, yield_ty); + self.check_expr_coercable_to_type(&value, yield_ty, None); resume_ty } @@ -1797,7 +1798,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // information. Hence, we check the source of the yield expression here and check its // value's type against `()` (this check should always hold). None if src.is_await() => { - self.check_expr_coercable_to_type(&value, self.tcx.mk_unit()); + self.check_expr_coercable_to_type(&value, self.tcx.mk_unit(), None); self.tcx.mk_unit() } _ => { @@ -1836,11 +1837,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match ty.kind { ty::FnDef(..) => { let fnptr_ty = self.tcx.mk_fn_ptr(ty.fn_sig(self.tcx)); - self.demand_coerce(expr, ty, fnptr_ty, AllowTwoPhase::No); + self.demand_coerce(expr, ty, fnptr_ty, None, AllowTwoPhase::No); } ty::Ref(_, base_ty, mutbl) => { let ptr_ty = self.tcx.mk_ptr(ty::TypeAndMut { ty: base_ty, mutbl }); - self.demand_coerce(expr, ty, ptr_ty, AllowTwoPhase::No); + self.demand_coerce(expr, ty, ptr_ty, None, AllowTwoPhase::No); } _ => {} } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 18846813c45..657565949fe 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1046,7 +1046,7 @@ fn typeck_tables_of_with_fallback<'tcx>( // Gather locals in statics (because of block expressions). GatherLocalsVisitor { fcx: &fcx, parent_id: id }.visit_body(body); - fcx.check_expr_coercable_to_type(&body.value, revealed_ty); + fcx.check_expr_coercable_to_type(&body.value, revealed_ty, None); fcx.write_ty(id, revealed_ty); @@ -4123,7 +4123,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let coerce_ty = expected.only_has_type(self).unwrap_or(formal_ty); // We're processing function arguments so we definitely want to use // two-phase borrows. - self.demand_coerce(&arg, checked_ty, coerce_ty, AllowTwoPhase::Yes); + self.demand_coerce(&arg, checked_ty, coerce_ty, None, AllowTwoPhase::Yes); final_arg_types.push((i, checked_ty, coerce_ty)); // 3. Relate the expected type and the formal one, @@ -4541,7 +4541,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.demand_eqtype(init.span, local_ty, init_ty); init_ty } else { - self.check_expr_coercable_to_type(init, local_ty) + self.check_expr_coercable_to_type(init, local_ty, None) } } @@ -5027,6 +5027,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expr: &hir::Expr<'_>, expected: Ty<'tcx>, found: Ty<'tcx>, + expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>, ) { if let Some((sp, msg, suggestion, applicability)) = self.check_ref(expr, found, expected) { err.span_suggestion(sp, msg, suggestion, applicability); @@ -5037,7 +5038,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let sp = self.sess().source_map().guess_head_span(sp); err.span_label(sp, &format!("{} defined here", found)); } - } else if !self.check_for_cast(err, expr, found, expected) { + } else if !self.check_for_cast(err, expr, found, expected, expected_ty_expr) { let is_struct_pat_shorthand_field = self.is_hir_id_from_struct_pattern_shorthand_field(expr.hir_id, expr.span); let methods = self.get_conversion_methods(expr.span, expected, found, expr.hir_id); diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index d89993e3547..a3a27dc138b 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -57,9 +57,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match BinOpCategory::from(op) { BinOpCategory::Shortcircuit => { // && and || are a simple case. - self.check_expr_coercable_to_type(lhs_expr, tcx.types.bool); + self.check_expr_coercable_to_type(lhs_expr, tcx.types.bool, None); let lhs_diverges = self.diverges.get(); - self.check_expr_coercable_to_type(rhs_expr, tcx.types.bool); + self.check_expr_coercable_to_type(rhs_expr, tcx.types.bool, None); // Depending on the LHS' value, the RHS can never execute. self.diverges.set(lhs_diverges); @@ -170,7 +170,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { kind: TypeVariableOriginKind::MiscVariable, span: lhs_expr.span, }); - self.demand_coerce(lhs_expr, lhs_ty, fresh_var, AllowTwoPhase::No) + self.demand_coerce(lhs_expr, lhs_ty, fresh_var, Some(rhs_expr), AllowTwoPhase::No) } IsAssign::Yes => { // rust-lang/rust#52126: We have to use strict @@ -196,7 +196,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let result = self.lookup_op_method(lhs_ty, &[rhs_ty_var], Op::Binary(op, is_assign)); // see `NB` above - let rhs_ty = self.check_expr_coercable_to_type(rhs_expr, rhs_ty_var); + let rhs_ty = self.check_expr_coercable_to_type(rhs_expr, rhs_ty_var, Some(lhs_expr)); let rhs_ty = self.resolve_vars_with_obligations(rhs_ty); let return_ty = match result { diff --git a/src/test/ui/numeric/numeric-cast-binop.rs b/src/test/ui/numeric/numeric-cast-binop.rs new file mode 100644 index 00000000000..3cecdf18c5b --- /dev/null +++ b/src/test/ui/numeric/numeric-cast-binop.rs @@ -0,0 +1,315 @@ +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_i128: i128 = 8; + let x_i64: i64 = 9; + let x_i32: i32 = 10; + let x_i16: i16 = 11; + let x_i8: i8 = 12; + let x_i128: i128 = 13; + + /* 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; + //~^ ERROR mismatched types + x_u8 > x_i16; + //~^ ERROR mismatched types + x_u8 > x_i32; + //~^ ERROR mismatched types + x_u8 > x_i64; + //~^ ERROR mismatched types + x_u8 > x_i128; + //~^ ERROR mismatched types + x_u8 > x_isize; + //~^ ERROR mismatched types + + x_u16 > x_i8; + //~^ ERROR mismatched types + x_u16 > x_i16; + //~^ ERROR mismatched types + x_u16 > x_i32; + //~^ ERROR mismatched types + x_u16 > x_i64; + //~^ ERROR mismatched types + x_u16 > x_i128; + //~^ ERROR mismatched types + x_u16 > x_isize; + //~^ ERROR mismatched types + + x_u32 > x_i8; + //~^ ERROR mismatched types + x_u32 > x_i16; + //~^ ERROR mismatched types + x_u32 > x_i32; + //~^ ERROR mismatched types + x_u32 > x_i64; + //~^ ERROR mismatched types + x_u32 > x_i128; + //~^ ERROR mismatched types + x_u32 > x_isize; + //~^ ERROR mismatched types + + x_u64 > x_i8; + //~^ ERROR mismatched types + x_u64 > x_i16; + //~^ ERROR mismatched types + x_u64 > x_i32; + //~^ ERROR mismatched types + x_u64 > x_i64; + //~^ ERROR mismatched types + x_u64 > x_i128; + //~^ ERROR mismatched types + x_u64 > x_isize; + //~^ ERROR mismatched types + + x_u128 > x_i8; + //~^ ERROR mismatched types + x_u128 > x_i16; + //~^ ERROR mismatched types + x_u128 > x_i32; + //~^ ERROR mismatched types + x_u128 > x_i64; + //~^ ERROR mismatched types + x_u128 > x_i128; + //~^ ERROR mismatched types + x_u128 > x_isize; + //~^ ERROR mismatched types + + x_usize > x_i8; + //~^ ERROR mismatched types + x_usize > x_i16; + //~^ ERROR mismatched types + x_usize > x_i32; + //~^ ERROR mismatched types + x_usize > x_i64; + //~^ ERROR mismatched types + x_usize > x_i128; + //~^ ERROR mismatched types + x_usize > x_isize; + //~^ ERROR mismatched types + } + + /* i<->u */ + { + x_i8 > x_u8; + //~^ ERROR mismatched types + x_i8 > x_u16; + //~^ ERROR mismatched types + x_i8 > x_u32; + //~^ ERROR mismatched types + x_i8 > x_u64; + //~^ ERROR mismatched types + x_i8 > x_u128; + //~^ ERROR mismatched types + x_i8 > x_usize; + //~^ ERROR mismatched types + + x_i16 > x_u8; + //~^ ERROR mismatched types + x_i16 > x_u16; + //~^ ERROR mismatched types + x_i16 > x_u32; + //~^ ERROR mismatched types + x_i16 > x_u64; + //~^ ERROR mismatched types + x_i16 > x_u128; + //~^ ERROR mismatched types + x_i16 > x_usize; + //~^ ERROR mismatched types + + x_i32 > x_u8; + //~^ ERROR mismatched types + x_i32 > x_u16; + //~^ ERROR mismatched types + x_i32 > x_u32; + //~^ ERROR mismatched types + x_i32 > x_u64; + //~^ ERROR mismatched types + x_i32 > x_u128; + //~^ ERROR mismatched types + x_i32 > x_usize; + //~^ ERROR mismatched types + + x_i64 > x_u8; + //~^ ERROR mismatched types + x_i64 > x_u16; + //~^ ERROR mismatched types + x_i64 > x_u32; + //~^ ERROR mismatched types + x_i64 > x_u64; + //~^ ERROR mismatched types + x_i64 > x_u128; + //~^ ERROR mismatched types + x_i64 > x_usize; + //~^ ERROR mismatched types + + x_i128 > x_u8; + //~^ ERROR mismatched types + x_i128 > x_u16; + //~^ ERROR mismatched types + x_i128 > x_u32; + //~^ ERROR mismatched types + x_i128 > x_u64; + //~^ ERROR mismatched types + x_i128 > x_u128; + //~^ ERROR mismatched types + x_i128 > x_usize; + //~^ ERROR mismatched types + + x_isize > x_u8; + //~^ ERROR mismatched types + x_isize > x_u16; + //~^ ERROR mismatched types + x_isize > x_u32; + //~^ ERROR mismatched types + x_isize > x_u64; + //~^ ERROR mismatched types + x_isize > x_u128; + //~^ ERROR mismatched types + x_isize > x_usize; + //~^ ERROR mismatched types + } +} diff --git a/src/test/ui/numeric/numeric-cast-binop.stderr b/src/test/ui/numeric/numeric-cast-binop.stderr new file mode 100644 index 00000000000..f305c272558 --- /dev/null +++ b/src/test/ui/numeric/numeric-cast-binop.stderr @@ -0,0 +1,1385 @@ +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:18:16 + | +LL | x_u8 > x_u16; + | ^^^^^ expected `u8`, found `u16` + | +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:20:16 + | +LL | x_u8 > x_u32; + | ^^^^^ expected `u8`, found `u32` + | +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:22:16 + | +LL | x_u8 > x_u64; + | ^^^^^ expected `u8`, found `u64` + | +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:24:16 + | +LL | x_u8 > x_u128; + | ^^^^^^ expected `u8`, found `u128` + | +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:26:16 + | +LL | x_u8 > x_usize; + | ^^^^^^^ expected `u8`, found `usize` + | +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:29:17 + | +LL | x_u16 > x_u8; + | ^^^^ + | | + | expected `u16`, found `u8` + | help: you can convert an `u8` to `u16`: `x_u8.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:31:17 + | +LL | x_u16 > x_u32; + | ^^^^^ expected `u16`, found `u32` + | +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:33:17 + | +LL | x_u16 > x_u64; + | ^^^^^ expected `u16`, found `u64` + | +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:35:17 + | +LL | x_u16 > x_u128; + | ^^^^^^ expected `u16`, found `u128` + | +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:37:17 + | +LL | x_u16 > x_usize; + | ^^^^^^^ expected `u16`, found `usize` + | +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:40:17 + | +LL | x_u32 > x_u8; + | ^^^^ + | | + | expected `u32`, found `u8` + | help: you can convert an `u8` to `u32`: `x_u8.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:42:17 + | +LL | x_u32 > x_u16; + | ^^^^^ + | | + | expected `u32`, found `u16` + | help: you can convert an `u16` to `u32`: `x_u16.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:44:17 + | +LL | x_u32 > x_u64; + | ^^^^^ expected `u32`, found `u64` + | +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:46:17 + | +LL | x_u32 > x_u128; + | ^^^^^^ expected `u32`, found `u128` + | +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:48:17 + | +LL | x_u32 > x_usize; + | ^^^^^^^ expected `u32`, found `usize` + | +help: you can convert an `usize` to `u32` and panic if the converted value wouldn't fit + | +LL | x_u32 > x_usize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:51:17 + | +LL | x_u64 > x_u8; + | ^^^^ + | | + | expected `u64`, found `u8` + | help: you can convert an `u8` to `u64`: `x_u8.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:53:17 + | +LL | x_u64 > x_u16; + | ^^^^^ + | | + | expected `u64`, found `u16` + | help: you can convert an `u16` to `u64`: `x_u16.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:55:17 + | +LL | x_u64 > x_u32; + | ^^^^^ + | | + | expected `u64`, found `u32` + | help: you can convert an `u32` to `u64`: `x_u32.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:57:17 + | +LL | x_u64 > x_u128; + | ^^^^^^ expected `u64`, found `u128` + | +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:59:17 + | +LL | x_u64 > x_usize; + | ^^^^^^^ expected `u64`, found `usize` + | +help: you can convert an `usize` to `u64` and panic if the converted value wouldn't fit + | +LL | x_u64 > x_usize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:62:18 + | +LL | x_u128 > x_u8; + | ^^^^ + | | + | expected `u128`, found `u8` + | help: you can convert an `u8` to `u128`: `x_u8.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:64:18 + | +LL | x_u128 > x_u16; + | ^^^^^ + | | + | expected `u128`, found `u16` + | help: you can convert an `u16` to `u128`: `x_u16.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:66:18 + | +LL | x_u128 > x_u32; + | ^^^^^ + | | + | expected `u128`, found `u32` + | help: you can convert an `u32` to `u128`: `x_u32.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:68:18 + | +LL | x_u128 > x_u64; + | ^^^^^ + | | + | expected `u128`, found `u64` + | help: you can convert an `u64` to `u128`: `x_u64.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:70:18 + | +LL | x_u128 > x_usize; + | ^^^^^^^ expected `u128`, found `usize` + | +help: you can convert an `usize` to `u128` and panic if the converted value wouldn't fit + | +LL | x_u128 > x_usize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:73:19 + | +LL | x_usize > x_u8; + | ^^^^ + | | + | expected `usize`, found `u8` + | help: you can convert an `u8` to `usize`: `x_u8.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:75:19 + | +LL | x_usize > x_u16; + | ^^^^^ + | | + | expected `usize`, found `u16` + | help: you can convert an `u16` to `usize`: `x_u16.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:77:19 + | +LL | x_usize > x_u32; + | ^^^^^ expected `usize`, found `u32` + | +help: you can convert an `u32` to `usize` and panic if the converted value wouldn't fit + | +LL | x_usize > x_u32.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:79:19 + | +LL | x_usize > x_u64; + | ^^^^^ expected `usize`, found `u64` + | +help: you can convert an `u64` to `usize` and panic if the converted value wouldn't fit + | +LL | x_usize > x_u64.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:81:19 + | +LL | x_usize > x_u128; + | ^^^^^^ expected `usize`, found `u128` + | +help: you can convert an `u128` to `usize` and panic if the converted value wouldn't fit + | +LL | x_usize > x_u128.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:87:16 + | +LL | x_i8 > x_i16; + | ^^^^^ expected `i8`, found `i16` + | +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:89:16 + | +LL | x_i8 > x_i32; + | ^^^^^ expected `i8`, found `i32` + | +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:91:16 + | +LL | x_i8 > x_i64; + | ^^^^^ expected `i8`, found `i64` + | +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:93:16 + | +LL | x_i8 > x_i128; + | ^^^^^^ expected `i8`, found `i128` + | +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:95:16 + | +LL | x_i8 > x_isize; + | ^^^^^^^ expected `i8`, found `isize` + | +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:98:17 + | +LL | x_i16 > x_i8; + | ^^^^ + | | + | expected `i16`, found `i8` + | help: you can convert an `i8` to `i16`: `x_i8.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:100:17 + | +LL | x_i16 > x_i32; + | ^^^^^ expected `i16`, found `i32` + | +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:102:17 + | +LL | x_i16 > x_i64; + | ^^^^^ expected `i16`, found `i64` + | +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:104:17 + | +LL | x_i16 > x_i128; + | ^^^^^^ expected `i16`, found `i128` + | +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:106:17 + | +LL | x_i16 > x_isize; + | ^^^^^^^ expected `i16`, found `isize` + | +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:109:17 + | +LL | x_i32 > x_i8; + | ^^^^ + | | + | expected `i32`, found `i8` + | help: you can convert an `i8` to `i32`: `x_i8.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:111:17 + | +LL | x_i32 > x_i16; + | ^^^^^ + | | + | expected `i32`, found `i16` + | help: you can convert an `i16` to `i32`: `x_i16.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:113:17 + | +LL | x_i32 > x_i64; + | ^^^^^ expected `i32`, found `i64` + | +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:115:17 + | +LL | x_i32 > x_i128; + | ^^^^^^ expected `i32`, found `i128` + | +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:117:17 + | +LL | x_i32 > x_isize; + | ^^^^^^^ expected `i32`, found `isize` + | +help: you can convert an `isize` to `i32` and panic if the converted value wouldn't fit + | +LL | x_i32 > x_isize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:120:17 + | +LL | x_i64 > x_i8; + | ^^^^ + | | + | expected `i64`, found `i8` + | help: you can convert an `i8` to `i64`: `x_i8.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:122:17 + | +LL | x_i64 > x_i16; + | ^^^^^ + | | + | expected `i64`, found `i16` + | help: you can convert an `i16` to `i64`: `x_i16.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:124:17 + | +LL | x_i64 > x_i32; + | ^^^^^ + | | + | expected `i64`, found `i32` + | help: you can convert an `i32` to `i64`: `x_i32.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:126:17 + | +LL | x_i64 > x_i128; + | ^^^^^^ expected `i64`, found `i128` + | +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:128:17 + | +LL | x_i64 > x_isize; + | ^^^^^^^ expected `i64`, found `isize` + | +help: you can convert an `isize` to `i64` and panic if the converted value wouldn't fit + | +LL | x_i64 > x_isize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:131:18 + | +LL | x_i128 > x_i8; + | ^^^^ + | | + | expected `i128`, found `i8` + | help: you can convert an `i8` to `i128`: `x_i8.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:133:18 + | +LL | x_i128 > x_i16; + | ^^^^^ + | | + | expected `i128`, found `i16` + | help: you can convert an `i16` to `i128`: `x_i16.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:135:18 + | +LL | x_i128 > x_i32; + | ^^^^^ + | | + | expected `i128`, found `i32` + | help: you can convert an `i32` to `i128`: `x_i32.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:137:18 + | +LL | x_i128 > x_i64; + | ^^^^^ + | | + | expected `i128`, found `i64` + | help: you can convert an `i64` to `i128`: `x_i64.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:139:18 + | +LL | x_i128 > x_isize; + | ^^^^^^^ expected `i128`, found `isize` + | +help: you can convert an `isize` to `i128` and panic if the converted value wouldn't fit + | +LL | x_i128 > x_isize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:142:19 + | +LL | x_isize > x_i8; + | ^^^^ + | | + | expected `isize`, found `i8` + | help: you can convert an `i8` to `isize`: `x_i8.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:144:19 + | +LL | x_isize > x_i16; + | ^^^^^ + | | + | expected `isize`, found `i16` + | help: you can convert an `i16` to `isize`: `x_i16.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:146:19 + | +LL | x_isize > x_i32; + | ^^^^^ expected `isize`, found `i32` + | +help: you can convert an `i32` to `isize` and panic if the converted value wouldn't fit + | +LL | x_isize > x_i32.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:148:19 + | +LL | x_isize > x_i64; + | ^^^^^ expected `isize`, found `i64` + | +help: you can convert an `i64` to `isize` and panic if the converted value wouldn't fit + | +LL | x_isize > x_i64.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:150:19 + | +LL | x_isize > x_i128; + | ^^^^^^ expected `isize`, found `i128` + | +help: you can convert an `i128` to `isize` and panic if the converted value wouldn't fit + | +LL | x_isize > x_i128.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:156:16 + | +LL | x_u8 > x_i8; + | ^^^^ expected `u8`, found `i8` + | +help: you can convert an `i8` to `u8` and panic if the converted value wouldn't fit + | +LL | x_u8 > x_i8.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:158:16 + | +LL | x_u8 > x_i16; + | ^^^^^ expected `u8`, found `i16` + | +help: you can convert `x_u8` from `u8` to `i16`, matching the type of `x_i16` + | +LL | i16::from(x_u8) > x_i16; + | ^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:160:16 + | +LL | x_u8 > x_i32; + | ^^^^^ expected `u8`, found `i32` + | +help: you can convert `x_u8` from `u8` to `i32`, matching the type of `x_i32` + | +LL | i32::from(x_u8) > x_i32; + | ^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:162:16 + | +LL | x_u8 > x_i64; + | ^^^^^ expected `u8`, found `i64` + | +help: you can convert `x_u8` from `u8` to `i64`, matching the type of `x_i64` + | +LL | i64::from(x_u8) > x_i64; + | ^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:164:16 + | +LL | x_u8 > x_i128; + | ^^^^^^ expected `u8`, found `i128` + | +help: you can convert `x_u8` from `u8` to `i128`, matching the type of `x_i128` + | +LL | i128::from(x_u8) > x_i128; + | ^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:166:16 + | +LL | x_u8 > x_isize; + | ^^^^^^^ expected `u8`, found `isize` + | +help: you can convert `x_u8` from `u8` to `isize`, matching the type of `x_isize` + | +LL | isize::from(x_u8) > x_isize; + | ^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:169:17 + | +LL | x_u16 > x_i8; + | ^^^^ expected `u16`, found `i8` + | +help: you can convert an `i8` to `u16` and panic if the converted value wouldn't fit + | +LL | x_u16 > x_i8.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:171:17 + | +LL | x_u16 > x_i16; + | ^^^^^ expected `u16`, found `i16` + | +help: you can convert an `i16` to `u16` and panic if the converted value wouldn't fit + | +LL | x_u16 > x_i16.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:173:17 + | +LL | x_u16 > x_i32; + | ^^^^^ expected `u16`, found `i32` + | +help: you can convert `x_u16` from `u16` to `i32`, matching the type of `x_i32` + | +LL | i32::from(x_u16) > x_i32; + | ^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:175:17 + | +LL | x_u16 > x_i64; + | ^^^^^ expected `u16`, found `i64` + | +help: you can convert `x_u16` from `u16` to `i64`, matching the type of `x_i64` + | +LL | i64::from(x_u16) > x_i64; + | ^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:177:17 + | +LL | x_u16 > x_i128; + | ^^^^^^ expected `u16`, found `i128` + | +help: you can convert `x_u16` from `u16` to `i128`, matching the type of `x_i128` + | +LL | i128::from(x_u16) > x_i128; + | ^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:179:17 + | +LL | x_u16 > x_isize; + | ^^^^^^^ expected `u16`, found `isize` + | +help: you can convert an `isize` to `u16` and panic if the converted value wouldn't fit + | +LL | x_u16 > x_isize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:182:17 + | +LL | x_u32 > x_i8; + | ^^^^ expected `u32`, found `i8` + | +help: you can convert an `i8` to `u32` and panic if the converted value wouldn't fit + | +LL | x_u32 > x_i8.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:184:17 + | +LL | x_u32 > x_i16; + | ^^^^^ expected `u32`, found `i16` + | +help: you can convert an `i16` to `u32` and panic if the converted value wouldn't fit + | +LL | x_u32 > x_i16.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:186:17 + | +LL | x_u32 > x_i32; + | ^^^^^ expected `u32`, found `i32` + | +help: you can convert an `i32` to `u32` and panic if the converted value wouldn't fit + | +LL | x_u32 > x_i32.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:188:17 + | +LL | x_u32 > x_i64; + | ^^^^^ expected `u32`, found `i64` + | +help: you can convert `x_u32` from `u32` to `i64`, matching the type of `x_i64` + | +LL | i64::from(x_u32) > x_i64; + | ^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:190:17 + | +LL | x_u32 > x_i128; + | ^^^^^^ expected `u32`, found `i128` + | +help: you can convert `x_u32` from `u32` to `i128`, matching the type of `x_i128` + | +LL | i128::from(x_u32) > x_i128; + | ^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:192:17 + | +LL | x_u32 > x_isize; + | ^^^^^^^ expected `u32`, found `isize` + | +help: you can convert an `isize` to `u32` and panic if the converted value wouldn't fit + | +LL | x_u32 > x_isize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:195:17 + | +LL | x_u64 > x_i8; + | ^^^^ expected `u64`, found `i8` + | +help: you can convert an `i8` to `u64` and panic if the converted value wouldn't fit + | +LL | x_u64 > x_i8.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:197:17 + | +LL | x_u64 > x_i16; + | ^^^^^ expected `u64`, found `i16` + | +help: you can convert an `i16` to `u64` and panic if the converted value wouldn't fit + | +LL | x_u64 > x_i16.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:199:17 + | +LL | x_u64 > x_i32; + | ^^^^^ expected `u64`, found `i32` + | +help: you can convert an `i32` to `u64` and panic if the converted value wouldn't fit + | +LL | x_u64 > x_i32.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:201:17 + | +LL | x_u64 > x_i64; + | ^^^^^ expected `u64`, found `i64` + | +help: you can convert an `i64` to `u64` and panic if the converted value wouldn't fit + | +LL | x_u64 > x_i64.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:203:17 + | +LL | x_u64 > x_i128; + | ^^^^^^ expected `u64`, found `i128` + | +help: you can convert `x_u64` from `u64` to `i128`, matching the type of `x_i128` + | +LL | i128::from(x_u64) > x_i128; + | ^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:205:17 + | +LL | x_u64 > x_isize; + | ^^^^^^^ expected `u64`, found `isize` + | +help: you can convert an `isize` to `u64` and panic if the converted value wouldn't fit + | +LL | x_u64 > x_isize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:208:18 + | +LL | x_u128 > x_i8; + | ^^^^ expected `u128`, found `i8` + | +help: you can convert an `i8` to `u128` and panic if the converted value wouldn't fit + | +LL | x_u128 > x_i8.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:210:18 + | +LL | x_u128 > x_i16; + | ^^^^^ expected `u128`, found `i16` + | +help: you can convert an `i16` to `u128` and panic if the converted value wouldn't fit + | +LL | x_u128 > x_i16.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:212:18 + | +LL | x_u128 > x_i32; + | ^^^^^ expected `u128`, found `i32` + | +help: you can convert an `i32` to `u128` and panic if the converted value wouldn't fit + | +LL | x_u128 > x_i32.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:214:18 + | +LL | x_u128 > x_i64; + | ^^^^^ expected `u128`, found `i64` + | +help: you can convert an `i64` to `u128` and panic if the converted value wouldn't fit + | +LL | x_u128 > x_i64.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:216:18 + | +LL | x_u128 > x_i128; + | ^^^^^^ expected `u128`, found `i128` + | +help: you can convert an `i128` to `u128` and panic if the converted value wouldn't fit + | +LL | x_u128 > x_i128.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:218:18 + | +LL | x_u128 > x_isize; + | ^^^^^^^ expected `u128`, found `isize` + | +help: you can convert an `isize` to `u128` and panic if the converted value wouldn't fit + | +LL | x_u128 > x_isize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:221:19 + | +LL | x_usize > x_i8; + | ^^^^ expected `usize`, found `i8` + | +help: you can convert an `i8` to `usize` and panic if the converted value wouldn't fit + | +LL | x_usize > x_i8.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:223:19 + | +LL | x_usize > x_i16; + | ^^^^^ expected `usize`, found `i16` + | +help: you can convert an `i16` to `usize` and panic if the converted value wouldn't fit + | +LL | x_usize > x_i16.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:225:19 + | +LL | x_usize > x_i32; + | ^^^^^ expected `usize`, found `i32` + | +help: you can convert an `i32` to `usize` and panic if the converted value wouldn't fit + | +LL | x_usize > x_i32.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:227:19 + | +LL | x_usize > x_i64; + | ^^^^^ expected `usize`, found `i64` + | +help: you can convert an `i64` to `usize` and panic if the converted value wouldn't fit + | +LL | x_usize > x_i64.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:229:19 + | +LL | x_usize > x_i128; + | ^^^^^^ expected `usize`, found `i128` + | +help: you can convert an `i128` to `usize` and panic if the converted value wouldn't fit + | +LL | x_usize > x_i128.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:231:19 + | +LL | x_usize > x_isize; + | ^^^^^^^ expected `usize`, found `isize` + | +help: you can convert an `isize` to `usize` and panic if the converted value wouldn't fit + | +LL | x_usize > x_isize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:237:16 + | +LL | x_i8 > x_u8; + | ^^^^ expected `i8`, found `u8` + | +help: you can convert an `u8` to `i8` and panic if the converted value wouldn't fit + | +LL | x_i8 > x_u8.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:239:16 + | +LL | x_i8 > x_u16; + | ^^^^^ expected `i8`, found `u16` + | +help: you can convert an `u16` to `i8` and panic if the converted value wouldn't fit + | +LL | x_i8 > x_u16.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:241:16 + | +LL | x_i8 > x_u32; + | ^^^^^ expected `i8`, found `u32` + | +help: you can convert an `u32` to `i8` and panic if the converted value wouldn't fit + | +LL | x_i8 > x_u32.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:243:16 + | +LL | x_i8 > x_u64; + | ^^^^^ expected `i8`, found `u64` + | +help: you can convert an `u64` to `i8` and panic if the converted value wouldn't fit + | +LL | x_i8 > x_u64.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:245:16 + | +LL | x_i8 > x_u128; + | ^^^^^^ expected `i8`, found `u128` + | +help: you can convert an `u128` to `i8` and panic if the converted value wouldn't fit + | +LL | x_i8 > x_u128.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:247:16 + | +LL | x_i8 > x_usize; + | ^^^^^^^ expected `i8`, found `usize` + | +help: you can convert an `usize` to `i8` and panic if the converted value wouldn't fit + | +LL | x_i8 > x_usize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:250:17 + | +LL | x_i16 > x_u8; + | ^^^^ + | | + | expected `i16`, found `u8` + | help: you can convert an `u8` to `i16`: `x_u8.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:252:17 + | +LL | x_i16 > x_u16; + | ^^^^^ expected `i16`, found `u16` + | +help: you can convert an `u16` to `i16` and panic if the converted value wouldn't fit + | +LL | x_i16 > x_u16.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:254:17 + | +LL | x_i16 > x_u32; + | ^^^^^ expected `i16`, found `u32` + | +help: you can convert an `u32` to `i16` and panic if the converted value wouldn't fit + | +LL | x_i16 > x_u32.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:256:17 + | +LL | x_i16 > x_u64; + | ^^^^^ expected `i16`, found `u64` + | +help: you can convert an `u64` to `i16` and panic if the converted value wouldn't fit + | +LL | x_i16 > x_u64.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:258:17 + | +LL | x_i16 > x_u128; + | ^^^^^^ expected `i16`, found `u128` + | +help: you can convert an `u128` to `i16` and panic if the converted value wouldn't fit + | +LL | x_i16 > x_u128.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:260:17 + | +LL | x_i16 > x_usize; + | ^^^^^^^ expected `i16`, found `usize` + | +help: you can convert an `usize` to `i16` and panic if the converted value wouldn't fit + | +LL | x_i16 > x_usize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:263:17 + | +LL | x_i32 > x_u8; + | ^^^^ + | | + | expected `i32`, found `u8` + | help: you can convert an `u8` to `i32`: `x_u8.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:265:17 + | +LL | x_i32 > x_u16; + | ^^^^^ + | | + | expected `i32`, found `u16` + | help: you can convert an `u16` to `i32`: `x_u16.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:267:17 + | +LL | x_i32 > x_u32; + | ^^^^^ expected `i32`, found `u32` + | +help: you can convert an `u32` to `i32` and panic if the converted value wouldn't fit + | +LL | x_i32 > x_u32.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:269:17 + | +LL | x_i32 > x_u64; + | ^^^^^ expected `i32`, found `u64` + | +help: you can convert an `u64` to `i32` and panic if the converted value wouldn't fit + | +LL | x_i32 > x_u64.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:271:17 + | +LL | x_i32 > x_u128; + | ^^^^^^ expected `i32`, found `u128` + | +help: you can convert an `u128` to `i32` and panic if the converted value wouldn't fit + | +LL | x_i32 > x_u128.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:273:17 + | +LL | x_i32 > x_usize; + | ^^^^^^^ expected `i32`, found `usize` + | +help: you can convert an `usize` to `i32` and panic if the converted value wouldn't fit + | +LL | x_i32 > x_usize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:276:17 + | +LL | x_i64 > x_u8; + | ^^^^ + | | + | expected `i64`, found `u8` + | help: you can convert an `u8` to `i64`: `x_u8.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:278:17 + | +LL | x_i64 > x_u16; + | ^^^^^ + | | + | expected `i64`, found `u16` + | help: you can convert an `u16` to `i64`: `x_u16.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:280:17 + | +LL | x_i64 > x_u32; + | ^^^^^ + | | + | expected `i64`, found `u32` + | help: you can convert an `u32` to `i64`: `x_u32.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:282:17 + | +LL | x_i64 > x_u64; + | ^^^^^ expected `i64`, found `u64` + | +help: you can convert an `u64` to `i64` and panic if the converted value wouldn't fit + | +LL | x_i64 > x_u64.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:284:17 + | +LL | x_i64 > x_u128; + | ^^^^^^ expected `i64`, found `u128` + | +help: you can convert an `u128` to `i64` and panic if the converted value wouldn't fit + | +LL | x_i64 > x_u128.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:286:17 + | +LL | x_i64 > x_usize; + | ^^^^^^^ expected `i64`, found `usize` + | +help: you can convert an `usize` to `i64` and panic if the converted value wouldn't fit + | +LL | x_i64 > x_usize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:289:18 + | +LL | x_i128 > x_u8; + | ^^^^ + | | + | expected `i128`, found `u8` + | help: you can convert an `u8` to `i128`: `x_u8.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:291:18 + | +LL | x_i128 > x_u16; + | ^^^^^ + | | + | expected `i128`, found `u16` + | help: you can convert an `u16` to `i128`: `x_u16.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:293:18 + | +LL | x_i128 > x_u32; + | ^^^^^ + | | + | expected `i128`, found `u32` + | help: you can convert an `u32` to `i128`: `x_u32.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:295:18 + | +LL | x_i128 > x_u64; + | ^^^^^ + | | + | expected `i128`, found `u64` + | help: you can convert an `u64` to `i128`: `x_u64.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:297:18 + | +LL | x_i128 > x_u128; + | ^^^^^^ expected `i128`, found `u128` + | +help: you can convert an `u128` to `i128` and panic if the converted value wouldn't fit + | +LL | x_i128 > x_u128.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:299:18 + | +LL | x_i128 > x_usize; + | ^^^^^^^ expected `i128`, found `usize` + | +help: you can convert an `usize` to `i128` and panic if the converted value wouldn't fit + | +LL | x_i128 > x_usize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:302:19 + | +LL | x_isize > x_u8; + | ^^^^ + | | + | expected `isize`, found `u8` + | help: you can convert an `u8` to `isize`: `x_u8.into()` + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:304:19 + | +LL | x_isize > x_u16; + | ^^^^^ expected `isize`, found `u16` + | +help: you can convert an `u16` to `isize` and panic if the converted value wouldn't fit + | +LL | x_isize > x_u16.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:306:19 + | +LL | x_isize > x_u32; + | ^^^^^ expected `isize`, found `u32` + | +help: you can convert an `u32` to `isize` and panic if the converted value wouldn't fit + | +LL | x_isize > x_u32.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:308:19 + | +LL | x_isize > x_u64; + | ^^^^^ expected `isize`, found `u64` + | +help: you can convert an `u64` to `isize` and panic if the converted value wouldn't fit + | +LL | x_isize > x_u64.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:310:19 + | +LL | x_isize > x_u128; + | ^^^^^^ expected `isize`, found `u128` + | +help: you can convert an `u128` to `isize` and panic if the converted value wouldn't fit + | +LL | x_isize > x_u128.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-cast-binop.rs:312:19 + | +LL | x_isize > x_usize; + | ^^^^^^^ expected `isize`, found `usize` + | +help: you can convert an `usize` to `isize` and panic if the converted value wouldn't fit + | +LL | x_isize > x_usize.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 132 previous errors + +For more information about this error, try `rustc --explain E0308`. From 0c02f8aea9d8b26ad0e02a8ba1333a794844e146 Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Thu, 11 Jun 2020 08:34:12 -0700 Subject: [PATCH 5/8] fixup! Provide suggestion to convert numeric op LHS rather than unwrapping RHS --- src/test/ui/numeric/numeric-cast-binop.fixed | 320 ++++++++++++++++++ src/test/ui/numeric/numeric-cast-binop.rs | 17 +- src/test/ui/numeric/numeric-cast-binop.stderr | 264 +++++++-------- 3 files changed, 463 insertions(+), 138 deletions(-) create mode 100644 src/test/ui/numeric/numeric-cast-binop.fixed diff --git a/src/test/ui/numeric/numeric-cast-binop.fixed b/src/test/ui/numeric/numeric-cast-binop.fixed new file mode 100644 index 00000000000..edb085e71d3 --- /dev/null +++ b/src/test/ui/numeric/numeric-cast-binop.fixed @@ -0,0 +1,320 @@ +// 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 + } + + /* u<->i */ + { + x_u8 > x_i8.try_into().unwrap(); + //~^ ERROR mismatched types + i16::from(x_u8) > x_i16; + //~^ ERROR mismatched types + i32::from(x_u8) > x_i32; + //~^ ERROR mismatched types + i64::from(x_u8) > x_i64; + //~^ ERROR mismatched types + i128::from(x_u8) > x_i128; + //~^ ERROR mismatched types + isize::from(x_u8) > x_isize; + //~^ ERROR mismatched types + + x_u16 > x_i8.try_into().unwrap(); + //~^ ERROR mismatched types + x_u16 > x_i16.try_into().unwrap(); + //~^ ERROR mismatched types + i32::from(x_u16) > x_i32; + //~^ ERROR mismatched types + i64::from(x_u16) > x_i64; + //~^ ERROR mismatched types + i128::from(x_u16) > x_i128; + //~^ ERROR mismatched types + x_u16 > x_isize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_u32 > x_i8.try_into().unwrap(); + //~^ ERROR mismatched types + x_u32 > x_i16.try_into().unwrap(); + //~^ ERROR mismatched types + x_u32 > x_i32.try_into().unwrap(); + //~^ ERROR mismatched types + i64::from(x_u32) > x_i64; + //~^ ERROR mismatched types + i128::from(x_u32) > x_i128; + //~^ ERROR mismatched types + x_u32 > x_isize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_u64 > x_i8.try_into().unwrap(); + //~^ ERROR mismatched types + x_u64 > x_i16.try_into().unwrap(); + //~^ ERROR mismatched types + x_u64 > x_i32.try_into().unwrap(); + //~^ ERROR mismatched types + x_u64 > x_i64.try_into().unwrap(); + //~^ ERROR mismatched types + i128::from(x_u64) > x_i128; + //~^ ERROR mismatched types + x_u64 > x_isize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_u128 > x_i8.try_into().unwrap(); + //~^ ERROR mismatched types + x_u128 > x_i16.try_into().unwrap(); + //~^ ERROR mismatched types + x_u128 > x_i32.try_into().unwrap(); + //~^ ERROR mismatched types + x_u128 > x_i64.try_into().unwrap(); + //~^ ERROR mismatched types + x_u128 > x_i128.try_into().unwrap(); + //~^ ERROR mismatched types + x_u128 > x_isize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_usize > x_i8.try_into().unwrap(); + //~^ ERROR mismatched types + x_usize > x_i16.try_into().unwrap(); + //~^ ERROR mismatched types + x_usize > x_i32.try_into().unwrap(); + //~^ ERROR mismatched types + x_usize > x_i64.try_into().unwrap(); + //~^ ERROR mismatched types + x_usize > x_i128.try_into().unwrap(); + //~^ ERROR mismatched types + x_usize > x_isize.try_into().unwrap(); + //~^ ERROR mismatched types + } + + /* i<->u */ + { + x_i8 > x_u8.try_into().unwrap(); + //~^ ERROR mismatched types + x_i8 > x_u16.try_into().unwrap(); + //~^ ERROR mismatched types + x_i8 > x_u32.try_into().unwrap(); + //~^ ERROR mismatched types + x_i8 > x_u64.try_into().unwrap(); + //~^ ERROR mismatched types + x_i8 > x_u128.try_into().unwrap(); + //~^ ERROR mismatched types + x_i8 > x_usize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_i16 > x_u8.into(); + //~^ ERROR mismatched types + x_i16 > x_u16.try_into().unwrap(); + //~^ ERROR mismatched types + x_i16 > x_u32.try_into().unwrap(); + //~^ ERROR mismatched types + x_i16 > x_u64.try_into().unwrap(); + //~^ ERROR mismatched types + x_i16 > x_u128.try_into().unwrap(); + //~^ ERROR mismatched types + x_i16 > x_usize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_i32 > x_u8.into(); + //~^ ERROR mismatched types + x_i32 > x_u16.into(); + //~^ ERROR mismatched types + x_i32 > x_u32.try_into().unwrap(); + //~^ ERROR mismatched types + x_i32 > x_u64.try_into().unwrap(); + //~^ ERROR mismatched types + x_i32 > x_u128.try_into().unwrap(); + //~^ ERROR mismatched types + x_i32 > x_usize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_i64 > x_u8.into(); + //~^ ERROR mismatched types + x_i64 > x_u16.into(); + //~^ ERROR mismatched types + x_i64 > x_u32.into(); + //~^ ERROR mismatched types + x_i64 > x_u64.try_into().unwrap(); + //~^ ERROR mismatched types + x_i64 > x_u128.try_into().unwrap(); + //~^ ERROR mismatched types + x_i64 > x_usize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_i128 > x_u8.into(); + //~^ ERROR mismatched types + x_i128 > x_u16.into(); + //~^ ERROR mismatched types + x_i128 > x_u32.into(); + //~^ ERROR mismatched types + x_i128 > x_u64.into(); + //~^ ERROR mismatched types + x_i128 > x_u128.try_into().unwrap(); + //~^ ERROR mismatched types + x_i128 > x_usize.try_into().unwrap(); + //~^ ERROR mismatched types + + x_isize > x_u8.into(); + //~^ ERROR mismatched types + x_isize > x_u16.try_into().unwrap(); + //~^ ERROR mismatched types + x_isize > x_u32.try_into().unwrap(); + //~^ ERROR mismatched types + x_isize > x_u64.try_into().unwrap(); + //~^ ERROR mismatched types + x_isize > x_u128.try_into().unwrap(); + //~^ ERROR mismatched types + x_isize > x_usize.try_into().unwrap(); + //~^ ERROR mismatched types + } +} diff --git a/src/test/ui/numeric/numeric-cast-binop.rs b/src/test/ui/numeric/numeric-cast-binop.rs index 3cecdf18c5b..c1ed8de8ad8 100644 --- a/src/test/ui/numeric/numeric-cast-binop.rs +++ b/src/test/ui/numeric/numeric-cast-binop.rs @@ -1,3 +1,9 @@ +// 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; @@ -6,12 +12,11 @@ fn main() { let x_u16: u16 = 5; let x_u8: u8 = 6; let x_isize: isize = 7; - let x_i128: i128 = 8; - let x_i64: i64 = 9; - let x_i32: i32 = 10; - let x_i16: i16 = 11; - let x_i8: i8 = 12; - let x_i128: i128 = 13; + 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 */ { diff --git a/src/test/ui/numeric/numeric-cast-binop.stderr b/src/test/ui/numeric/numeric-cast-binop.stderr index f305c272558..47be817b789 100644 --- a/src/test/ui/numeric/numeric-cast-binop.stderr +++ b/src/test/ui/numeric/numeric-cast-binop.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:18:16 + --> $DIR/numeric-cast-binop.rs:23:16 | LL | x_u8 > x_u16; | ^^^^^ expected `u8`, found `u16` @@ -10,7 +10,7 @@ LL | u16::from(x_u8) > x_u16; | ^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:20:16 + --> $DIR/numeric-cast-binop.rs:25:16 | LL | x_u8 > x_u32; | ^^^^^ expected `u8`, found `u32` @@ -21,7 +21,7 @@ LL | u32::from(x_u8) > x_u32; | ^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:22:16 + --> $DIR/numeric-cast-binop.rs:27:16 | LL | x_u8 > x_u64; | ^^^^^ expected `u8`, found `u64` @@ -32,7 +32,7 @@ LL | u64::from(x_u8) > x_u64; | ^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:24:16 + --> $DIR/numeric-cast-binop.rs:29:16 | LL | x_u8 > x_u128; | ^^^^^^ expected `u8`, found `u128` @@ -43,7 +43,7 @@ LL | u128::from(x_u8) > x_u128; | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:26:16 + --> $DIR/numeric-cast-binop.rs:31:16 | LL | x_u8 > x_usize; | ^^^^^^^ expected `u8`, found `usize` @@ -54,7 +54,7 @@ LL | usize::from(x_u8) > x_usize; | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:29:17 + --> $DIR/numeric-cast-binop.rs:34:17 | LL | x_u16 > x_u8; | ^^^^ @@ -63,7 +63,7 @@ LL | x_u16 > x_u8; | help: you can convert an `u8` to `u16`: `x_u8.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:31:17 + --> $DIR/numeric-cast-binop.rs:36:17 | LL | x_u16 > x_u32; | ^^^^^ expected `u16`, found `u32` @@ -74,7 +74,7 @@ LL | u32::from(x_u16) > x_u32; | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:33:17 + --> $DIR/numeric-cast-binop.rs:38:17 | LL | x_u16 > x_u64; | ^^^^^ expected `u16`, found `u64` @@ -85,7 +85,7 @@ LL | u64::from(x_u16) > x_u64; | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:35:17 + --> $DIR/numeric-cast-binop.rs:40:17 | LL | x_u16 > x_u128; | ^^^^^^ expected `u16`, found `u128` @@ -96,7 +96,7 @@ LL | u128::from(x_u16) > x_u128; | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:37:17 + --> $DIR/numeric-cast-binop.rs:42:17 | LL | x_u16 > x_usize; | ^^^^^^^ expected `u16`, found `usize` @@ -107,7 +107,7 @@ LL | usize::from(x_u16) > x_usize; | ^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:40:17 + --> $DIR/numeric-cast-binop.rs:45:17 | LL | x_u32 > x_u8; | ^^^^ @@ -116,7 +116,7 @@ LL | x_u32 > x_u8; | help: you can convert an `u8` to `u32`: `x_u8.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:42:17 + --> $DIR/numeric-cast-binop.rs:47:17 | LL | x_u32 > x_u16; | ^^^^^ @@ -125,7 +125,7 @@ LL | x_u32 > x_u16; | help: you can convert an `u16` to `u32`: `x_u16.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:44:17 + --> $DIR/numeric-cast-binop.rs:49:17 | LL | x_u32 > x_u64; | ^^^^^ expected `u32`, found `u64` @@ -136,7 +136,7 @@ LL | u64::from(x_u32) > x_u64; | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:46:17 + --> $DIR/numeric-cast-binop.rs:51:17 | LL | x_u32 > x_u128; | ^^^^^^ expected `u32`, found `u128` @@ -147,7 +147,7 @@ LL | u128::from(x_u32) > x_u128; | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:48:17 + --> $DIR/numeric-cast-binop.rs:53:17 | LL | x_u32 > x_usize; | ^^^^^^^ expected `u32`, found `usize` @@ -158,7 +158,7 @@ LL | x_u32 > x_usize.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:51:17 + --> $DIR/numeric-cast-binop.rs:56:17 | LL | x_u64 > x_u8; | ^^^^ @@ -167,7 +167,7 @@ LL | x_u64 > x_u8; | help: you can convert an `u8` to `u64`: `x_u8.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:53:17 + --> $DIR/numeric-cast-binop.rs:58:17 | LL | x_u64 > x_u16; | ^^^^^ @@ -176,7 +176,7 @@ LL | x_u64 > x_u16; | help: you can convert an `u16` to `u64`: `x_u16.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:55:17 + --> $DIR/numeric-cast-binop.rs:60:17 | LL | x_u64 > x_u32; | ^^^^^ @@ -185,7 +185,7 @@ LL | x_u64 > x_u32; | help: you can convert an `u32` to `u64`: `x_u32.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:57:17 + --> $DIR/numeric-cast-binop.rs:62:17 | LL | x_u64 > x_u128; | ^^^^^^ expected `u64`, found `u128` @@ -196,7 +196,7 @@ LL | u128::from(x_u64) > x_u128; | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:59:17 + --> $DIR/numeric-cast-binop.rs:64:17 | LL | x_u64 > x_usize; | ^^^^^^^ expected `u64`, found `usize` @@ -207,7 +207,7 @@ LL | x_u64 > x_usize.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:62:18 + --> $DIR/numeric-cast-binop.rs:67:18 | LL | x_u128 > x_u8; | ^^^^ @@ -216,7 +216,7 @@ LL | x_u128 > x_u8; | help: you can convert an `u8` to `u128`: `x_u8.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:64:18 + --> $DIR/numeric-cast-binop.rs:69:18 | LL | x_u128 > x_u16; | ^^^^^ @@ -225,7 +225,7 @@ LL | x_u128 > x_u16; | help: you can convert an `u16` to `u128`: `x_u16.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:66:18 + --> $DIR/numeric-cast-binop.rs:71:18 | LL | x_u128 > x_u32; | ^^^^^ @@ -234,7 +234,7 @@ LL | x_u128 > x_u32; | help: you can convert an `u32` to `u128`: `x_u32.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:68:18 + --> $DIR/numeric-cast-binop.rs:73:18 | LL | x_u128 > x_u64; | ^^^^^ @@ -243,7 +243,7 @@ LL | x_u128 > x_u64; | help: you can convert an `u64` to `u128`: `x_u64.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:70:18 + --> $DIR/numeric-cast-binop.rs:75:18 | LL | x_u128 > x_usize; | ^^^^^^^ expected `u128`, found `usize` @@ -254,7 +254,7 @@ LL | x_u128 > x_usize.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:73:19 + --> $DIR/numeric-cast-binop.rs:78:19 | LL | x_usize > x_u8; | ^^^^ @@ -263,7 +263,7 @@ LL | x_usize > x_u8; | help: you can convert an `u8` to `usize`: `x_u8.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:75:19 + --> $DIR/numeric-cast-binop.rs:80:19 | LL | x_usize > x_u16; | ^^^^^ @@ -272,7 +272,7 @@ LL | x_usize > x_u16; | help: you can convert an `u16` to `usize`: `x_u16.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:77:19 + --> $DIR/numeric-cast-binop.rs:82:19 | LL | x_usize > x_u32; | ^^^^^ expected `usize`, found `u32` @@ -283,7 +283,7 @@ LL | x_usize > x_u32.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:79:19 + --> $DIR/numeric-cast-binop.rs:84:19 | LL | x_usize > x_u64; | ^^^^^ expected `usize`, found `u64` @@ -294,7 +294,7 @@ LL | x_usize > x_u64.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:81:19 + --> $DIR/numeric-cast-binop.rs:86:19 | LL | x_usize > x_u128; | ^^^^^^ expected `usize`, found `u128` @@ -305,7 +305,7 @@ LL | x_usize > x_u128.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:87:16 + --> $DIR/numeric-cast-binop.rs:92:16 | LL | x_i8 > x_i16; | ^^^^^ expected `i8`, found `i16` @@ -316,7 +316,7 @@ LL | i16::from(x_i8) > x_i16; | ^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:89:16 + --> $DIR/numeric-cast-binop.rs:94:16 | LL | x_i8 > x_i32; | ^^^^^ expected `i8`, found `i32` @@ -327,7 +327,7 @@ LL | i32::from(x_i8) > x_i32; | ^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:91:16 + --> $DIR/numeric-cast-binop.rs:96:16 | LL | x_i8 > x_i64; | ^^^^^ expected `i8`, found `i64` @@ -338,7 +338,7 @@ LL | i64::from(x_i8) > x_i64; | ^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:93:16 + --> $DIR/numeric-cast-binop.rs:98:16 | LL | x_i8 > x_i128; | ^^^^^^ expected `i8`, found `i128` @@ -349,7 +349,7 @@ LL | i128::from(x_i8) > x_i128; | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:95:16 + --> $DIR/numeric-cast-binop.rs:100:16 | LL | x_i8 > x_isize; | ^^^^^^^ expected `i8`, found `isize` @@ -360,7 +360,7 @@ LL | isize::from(x_i8) > x_isize; | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:98:17 + --> $DIR/numeric-cast-binop.rs:103:17 | LL | x_i16 > x_i8; | ^^^^ @@ -369,7 +369,7 @@ LL | x_i16 > x_i8; | help: you can convert an `i8` to `i16`: `x_i8.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:100:17 + --> $DIR/numeric-cast-binop.rs:105:17 | LL | x_i16 > x_i32; | ^^^^^ expected `i16`, found `i32` @@ -380,7 +380,7 @@ LL | i32::from(x_i16) > x_i32; | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:102:17 + --> $DIR/numeric-cast-binop.rs:107:17 | LL | x_i16 > x_i64; | ^^^^^ expected `i16`, found `i64` @@ -391,7 +391,7 @@ LL | i64::from(x_i16) > x_i64; | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:104:17 + --> $DIR/numeric-cast-binop.rs:109:17 | LL | x_i16 > x_i128; | ^^^^^^ expected `i16`, found `i128` @@ -402,7 +402,7 @@ LL | i128::from(x_i16) > x_i128; | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:106:17 + --> $DIR/numeric-cast-binop.rs:111:17 | LL | x_i16 > x_isize; | ^^^^^^^ expected `i16`, found `isize` @@ -413,7 +413,7 @@ LL | isize::from(x_i16) > x_isize; | ^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:109:17 + --> $DIR/numeric-cast-binop.rs:114:17 | LL | x_i32 > x_i8; | ^^^^ @@ -422,7 +422,7 @@ LL | x_i32 > x_i8; | help: you can convert an `i8` to `i32`: `x_i8.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:111:17 + --> $DIR/numeric-cast-binop.rs:116:17 | LL | x_i32 > x_i16; | ^^^^^ @@ -431,7 +431,7 @@ LL | x_i32 > x_i16; | help: you can convert an `i16` to `i32`: `x_i16.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:113:17 + --> $DIR/numeric-cast-binop.rs:118:17 | LL | x_i32 > x_i64; | ^^^^^ expected `i32`, found `i64` @@ -442,7 +442,7 @@ LL | i64::from(x_i32) > x_i64; | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:115:17 + --> $DIR/numeric-cast-binop.rs:120:17 | LL | x_i32 > x_i128; | ^^^^^^ expected `i32`, found `i128` @@ -453,7 +453,7 @@ LL | i128::from(x_i32) > x_i128; | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:117:17 + --> $DIR/numeric-cast-binop.rs:122:17 | LL | x_i32 > x_isize; | ^^^^^^^ expected `i32`, found `isize` @@ -464,7 +464,7 @@ LL | x_i32 > x_isize.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:120:17 + --> $DIR/numeric-cast-binop.rs:125:17 | LL | x_i64 > x_i8; | ^^^^ @@ -473,7 +473,7 @@ LL | x_i64 > x_i8; | help: you can convert an `i8` to `i64`: `x_i8.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:122:17 + --> $DIR/numeric-cast-binop.rs:127:17 | LL | x_i64 > x_i16; | ^^^^^ @@ -482,7 +482,7 @@ LL | x_i64 > x_i16; | help: you can convert an `i16` to `i64`: `x_i16.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:124:17 + --> $DIR/numeric-cast-binop.rs:129:17 | LL | x_i64 > x_i32; | ^^^^^ @@ -491,7 +491,7 @@ LL | x_i64 > x_i32; | help: you can convert an `i32` to `i64`: `x_i32.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:126:17 + --> $DIR/numeric-cast-binop.rs:131:17 | LL | x_i64 > x_i128; | ^^^^^^ expected `i64`, found `i128` @@ -502,7 +502,7 @@ LL | i128::from(x_i64) > x_i128; | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:128:17 + --> $DIR/numeric-cast-binop.rs:133:17 | LL | x_i64 > x_isize; | ^^^^^^^ expected `i64`, found `isize` @@ -513,7 +513,7 @@ LL | x_i64 > x_isize.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:131:18 + --> $DIR/numeric-cast-binop.rs:136:18 | LL | x_i128 > x_i8; | ^^^^ @@ -522,7 +522,7 @@ LL | x_i128 > x_i8; | help: you can convert an `i8` to `i128`: `x_i8.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:133:18 + --> $DIR/numeric-cast-binop.rs:138:18 | LL | x_i128 > x_i16; | ^^^^^ @@ -531,7 +531,7 @@ LL | x_i128 > x_i16; | help: you can convert an `i16` to `i128`: `x_i16.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:135:18 + --> $DIR/numeric-cast-binop.rs:140:18 | LL | x_i128 > x_i32; | ^^^^^ @@ -540,7 +540,7 @@ LL | x_i128 > x_i32; | help: you can convert an `i32` to `i128`: `x_i32.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:137:18 + --> $DIR/numeric-cast-binop.rs:142:18 | LL | x_i128 > x_i64; | ^^^^^ @@ -549,7 +549,7 @@ LL | x_i128 > x_i64; | help: you can convert an `i64` to `i128`: `x_i64.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:139:18 + --> $DIR/numeric-cast-binop.rs:144:18 | LL | x_i128 > x_isize; | ^^^^^^^ expected `i128`, found `isize` @@ -560,7 +560,7 @@ LL | x_i128 > x_isize.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:142:19 + --> $DIR/numeric-cast-binop.rs:147:19 | LL | x_isize > x_i8; | ^^^^ @@ -569,7 +569,7 @@ LL | x_isize > x_i8; | help: you can convert an `i8` to `isize`: `x_i8.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:144:19 + --> $DIR/numeric-cast-binop.rs:149:19 | LL | x_isize > x_i16; | ^^^^^ @@ -578,7 +578,7 @@ LL | x_isize > x_i16; | help: you can convert an `i16` to `isize`: `x_i16.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:146:19 + --> $DIR/numeric-cast-binop.rs:151:19 | LL | x_isize > x_i32; | ^^^^^ expected `isize`, found `i32` @@ -589,7 +589,7 @@ LL | x_isize > x_i32.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:148:19 + --> $DIR/numeric-cast-binop.rs:153:19 | LL | x_isize > x_i64; | ^^^^^ expected `isize`, found `i64` @@ -600,7 +600,7 @@ LL | x_isize > x_i64.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:150:19 + --> $DIR/numeric-cast-binop.rs:155:19 | LL | x_isize > x_i128; | ^^^^^^ expected `isize`, found `i128` @@ -611,7 +611,7 @@ LL | x_isize > x_i128.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:156:16 + --> $DIR/numeric-cast-binop.rs:161:16 | LL | x_u8 > x_i8; | ^^^^ expected `u8`, found `i8` @@ -622,7 +622,7 @@ LL | x_u8 > x_i8.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:158:16 + --> $DIR/numeric-cast-binop.rs:163:16 | LL | x_u8 > x_i16; | ^^^^^ expected `u8`, found `i16` @@ -633,7 +633,7 @@ LL | i16::from(x_u8) > x_i16; | ^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:160:16 + --> $DIR/numeric-cast-binop.rs:165:16 | LL | x_u8 > x_i32; | ^^^^^ expected `u8`, found `i32` @@ -644,7 +644,7 @@ LL | i32::from(x_u8) > x_i32; | ^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:162:16 + --> $DIR/numeric-cast-binop.rs:167:16 | LL | x_u8 > x_i64; | ^^^^^ expected `u8`, found `i64` @@ -655,7 +655,7 @@ LL | i64::from(x_u8) > x_i64; | ^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:164:16 + --> $DIR/numeric-cast-binop.rs:169:16 | LL | x_u8 > x_i128; | ^^^^^^ expected `u8`, found `i128` @@ -666,7 +666,7 @@ LL | i128::from(x_u8) > x_i128; | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:166:16 + --> $DIR/numeric-cast-binop.rs:171:16 | LL | x_u8 > x_isize; | ^^^^^^^ expected `u8`, found `isize` @@ -677,7 +677,7 @@ LL | isize::from(x_u8) > x_isize; | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:169:17 + --> $DIR/numeric-cast-binop.rs:174:17 | LL | x_u16 > x_i8; | ^^^^ expected `u16`, found `i8` @@ -688,7 +688,7 @@ LL | x_u16 > x_i8.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:171:17 + --> $DIR/numeric-cast-binop.rs:176:17 | LL | x_u16 > x_i16; | ^^^^^ expected `u16`, found `i16` @@ -699,7 +699,7 @@ LL | x_u16 > x_i16.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:173:17 + --> $DIR/numeric-cast-binop.rs:178:17 | LL | x_u16 > x_i32; | ^^^^^ expected `u16`, found `i32` @@ -710,7 +710,7 @@ LL | i32::from(x_u16) > x_i32; | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:175:17 + --> $DIR/numeric-cast-binop.rs:180:17 | LL | x_u16 > x_i64; | ^^^^^ expected `u16`, found `i64` @@ -721,7 +721,7 @@ LL | i64::from(x_u16) > x_i64; | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:177:17 + --> $DIR/numeric-cast-binop.rs:182:17 | LL | x_u16 > x_i128; | ^^^^^^ expected `u16`, found `i128` @@ -732,7 +732,7 @@ LL | i128::from(x_u16) > x_i128; | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:179:17 + --> $DIR/numeric-cast-binop.rs:184:17 | LL | x_u16 > x_isize; | ^^^^^^^ expected `u16`, found `isize` @@ -743,7 +743,7 @@ LL | x_u16 > x_isize.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:182:17 + --> $DIR/numeric-cast-binop.rs:187:17 | LL | x_u32 > x_i8; | ^^^^ expected `u32`, found `i8` @@ -754,7 +754,7 @@ LL | x_u32 > x_i8.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:184:17 + --> $DIR/numeric-cast-binop.rs:189:17 | LL | x_u32 > x_i16; | ^^^^^ expected `u32`, found `i16` @@ -765,7 +765,7 @@ LL | x_u32 > x_i16.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:186:17 + --> $DIR/numeric-cast-binop.rs:191:17 | LL | x_u32 > x_i32; | ^^^^^ expected `u32`, found `i32` @@ -776,7 +776,7 @@ LL | x_u32 > x_i32.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:188:17 + --> $DIR/numeric-cast-binop.rs:193:17 | LL | x_u32 > x_i64; | ^^^^^ expected `u32`, found `i64` @@ -787,7 +787,7 @@ LL | i64::from(x_u32) > x_i64; | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:190:17 + --> $DIR/numeric-cast-binop.rs:195:17 | LL | x_u32 > x_i128; | ^^^^^^ expected `u32`, found `i128` @@ -798,7 +798,7 @@ LL | i128::from(x_u32) > x_i128; | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:192:17 + --> $DIR/numeric-cast-binop.rs:197:17 | LL | x_u32 > x_isize; | ^^^^^^^ expected `u32`, found `isize` @@ -809,7 +809,7 @@ LL | x_u32 > x_isize.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:195:17 + --> $DIR/numeric-cast-binop.rs:200:17 | LL | x_u64 > x_i8; | ^^^^ expected `u64`, found `i8` @@ -820,7 +820,7 @@ LL | x_u64 > x_i8.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:197:17 + --> $DIR/numeric-cast-binop.rs:202:17 | LL | x_u64 > x_i16; | ^^^^^ expected `u64`, found `i16` @@ -831,7 +831,7 @@ LL | x_u64 > x_i16.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:199:17 + --> $DIR/numeric-cast-binop.rs:204:17 | LL | x_u64 > x_i32; | ^^^^^ expected `u64`, found `i32` @@ -842,7 +842,7 @@ LL | x_u64 > x_i32.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:201:17 + --> $DIR/numeric-cast-binop.rs:206:17 | LL | x_u64 > x_i64; | ^^^^^ expected `u64`, found `i64` @@ -853,7 +853,7 @@ LL | x_u64 > x_i64.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:203:17 + --> $DIR/numeric-cast-binop.rs:208:17 | LL | x_u64 > x_i128; | ^^^^^^ expected `u64`, found `i128` @@ -864,7 +864,7 @@ LL | i128::from(x_u64) > x_i128; | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:205:17 + --> $DIR/numeric-cast-binop.rs:210:17 | LL | x_u64 > x_isize; | ^^^^^^^ expected `u64`, found `isize` @@ -875,7 +875,7 @@ LL | x_u64 > x_isize.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:208:18 + --> $DIR/numeric-cast-binop.rs:213:18 | LL | x_u128 > x_i8; | ^^^^ expected `u128`, found `i8` @@ -886,7 +886,7 @@ LL | x_u128 > x_i8.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:210:18 + --> $DIR/numeric-cast-binop.rs:215:18 | LL | x_u128 > x_i16; | ^^^^^ expected `u128`, found `i16` @@ -897,7 +897,7 @@ LL | x_u128 > x_i16.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:212:18 + --> $DIR/numeric-cast-binop.rs:217:18 | LL | x_u128 > x_i32; | ^^^^^ expected `u128`, found `i32` @@ -908,7 +908,7 @@ LL | x_u128 > x_i32.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:214:18 + --> $DIR/numeric-cast-binop.rs:219:18 | LL | x_u128 > x_i64; | ^^^^^ expected `u128`, found `i64` @@ -919,7 +919,7 @@ LL | x_u128 > x_i64.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:216:18 + --> $DIR/numeric-cast-binop.rs:221:18 | LL | x_u128 > x_i128; | ^^^^^^ expected `u128`, found `i128` @@ -930,7 +930,7 @@ LL | x_u128 > x_i128.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:218:18 + --> $DIR/numeric-cast-binop.rs:223:18 | LL | x_u128 > x_isize; | ^^^^^^^ expected `u128`, found `isize` @@ -941,7 +941,7 @@ LL | x_u128 > x_isize.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:221:19 + --> $DIR/numeric-cast-binop.rs:226:19 | LL | x_usize > x_i8; | ^^^^ expected `usize`, found `i8` @@ -952,7 +952,7 @@ LL | x_usize > x_i8.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:223:19 + --> $DIR/numeric-cast-binop.rs:228:19 | LL | x_usize > x_i16; | ^^^^^ expected `usize`, found `i16` @@ -963,7 +963,7 @@ LL | x_usize > x_i16.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:225:19 + --> $DIR/numeric-cast-binop.rs:230:19 | LL | x_usize > x_i32; | ^^^^^ expected `usize`, found `i32` @@ -974,7 +974,7 @@ LL | x_usize > x_i32.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:227:19 + --> $DIR/numeric-cast-binop.rs:232:19 | LL | x_usize > x_i64; | ^^^^^ expected `usize`, found `i64` @@ -985,7 +985,7 @@ LL | x_usize > x_i64.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:229:19 + --> $DIR/numeric-cast-binop.rs:234:19 | LL | x_usize > x_i128; | ^^^^^^ expected `usize`, found `i128` @@ -996,7 +996,7 @@ LL | x_usize > x_i128.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:231:19 + --> $DIR/numeric-cast-binop.rs:236:19 | LL | x_usize > x_isize; | ^^^^^^^ expected `usize`, found `isize` @@ -1007,7 +1007,7 @@ LL | x_usize > x_isize.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:237:16 + --> $DIR/numeric-cast-binop.rs:242:16 | LL | x_i8 > x_u8; | ^^^^ expected `i8`, found `u8` @@ -1018,7 +1018,7 @@ LL | x_i8 > x_u8.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:239:16 + --> $DIR/numeric-cast-binop.rs:244:16 | LL | x_i8 > x_u16; | ^^^^^ expected `i8`, found `u16` @@ -1029,7 +1029,7 @@ LL | x_i8 > x_u16.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:241:16 + --> $DIR/numeric-cast-binop.rs:246:16 | LL | x_i8 > x_u32; | ^^^^^ expected `i8`, found `u32` @@ -1040,7 +1040,7 @@ LL | x_i8 > x_u32.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:243:16 + --> $DIR/numeric-cast-binop.rs:248:16 | LL | x_i8 > x_u64; | ^^^^^ expected `i8`, found `u64` @@ -1051,7 +1051,7 @@ LL | x_i8 > x_u64.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:245:16 + --> $DIR/numeric-cast-binop.rs:250:16 | LL | x_i8 > x_u128; | ^^^^^^ expected `i8`, found `u128` @@ -1062,7 +1062,7 @@ LL | x_i8 > x_u128.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:247:16 + --> $DIR/numeric-cast-binop.rs:252:16 | LL | x_i8 > x_usize; | ^^^^^^^ expected `i8`, found `usize` @@ -1073,7 +1073,7 @@ LL | x_i8 > x_usize.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:250:17 + --> $DIR/numeric-cast-binop.rs:255:17 | LL | x_i16 > x_u8; | ^^^^ @@ -1082,7 +1082,7 @@ LL | x_i16 > x_u8; | help: you can convert an `u8` to `i16`: `x_u8.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:252:17 + --> $DIR/numeric-cast-binop.rs:257:17 | LL | x_i16 > x_u16; | ^^^^^ expected `i16`, found `u16` @@ -1093,7 +1093,7 @@ LL | x_i16 > x_u16.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:254:17 + --> $DIR/numeric-cast-binop.rs:259:17 | LL | x_i16 > x_u32; | ^^^^^ expected `i16`, found `u32` @@ -1104,7 +1104,7 @@ LL | x_i16 > x_u32.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:256:17 + --> $DIR/numeric-cast-binop.rs:261:17 | LL | x_i16 > x_u64; | ^^^^^ expected `i16`, found `u64` @@ -1115,7 +1115,7 @@ LL | x_i16 > x_u64.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:258:17 + --> $DIR/numeric-cast-binop.rs:263:17 | LL | x_i16 > x_u128; | ^^^^^^ expected `i16`, found `u128` @@ -1126,7 +1126,7 @@ LL | x_i16 > x_u128.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:260:17 + --> $DIR/numeric-cast-binop.rs:265:17 | LL | x_i16 > x_usize; | ^^^^^^^ expected `i16`, found `usize` @@ -1137,7 +1137,7 @@ LL | x_i16 > x_usize.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:263:17 + --> $DIR/numeric-cast-binop.rs:268:17 | LL | x_i32 > x_u8; | ^^^^ @@ -1146,7 +1146,7 @@ LL | x_i32 > x_u8; | help: you can convert an `u8` to `i32`: `x_u8.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:265:17 + --> $DIR/numeric-cast-binop.rs:270:17 | LL | x_i32 > x_u16; | ^^^^^ @@ -1155,7 +1155,7 @@ LL | x_i32 > x_u16; | help: you can convert an `u16` to `i32`: `x_u16.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:267:17 + --> $DIR/numeric-cast-binop.rs:272:17 | LL | x_i32 > x_u32; | ^^^^^ expected `i32`, found `u32` @@ -1166,7 +1166,7 @@ LL | x_i32 > x_u32.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:269:17 + --> $DIR/numeric-cast-binop.rs:274:17 | LL | x_i32 > x_u64; | ^^^^^ expected `i32`, found `u64` @@ -1177,7 +1177,7 @@ LL | x_i32 > x_u64.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:271:17 + --> $DIR/numeric-cast-binop.rs:276:17 | LL | x_i32 > x_u128; | ^^^^^^ expected `i32`, found `u128` @@ -1188,7 +1188,7 @@ LL | x_i32 > x_u128.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:273:17 + --> $DIR/numeric-cast-binop.rs:278:17 | LL | x_i32 > x_usize; | ^^^^^^^ expected `i32`, found `usize` @@ -1199,7 +1199,7 @@ LL | x_i32 > x_usize.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:276:17 + --> $DIR/numeric-cast-binop.rs:281:17 | LL | x_i64 > x_u8; | ^^^^ @@ -1208,7 +1208,7 @@ LL | x_i64 > x_u8; | help: you can convert an `u8` to `i64`: `x_u8.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:278:17 + --> $DIR/numeric-cast-binop.rs:283:17 | LL | x_i64 > x_u16; | ^^^^^ @@ -1217,7 +1217,7 @@ LL | x_i64 > x_u16; | help: you can convert an `u16` to `i64`: `x_u16.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:280:17 + --> $DIR/numeric-cast-binop.rs:285:17 | LL | x_i64 > x_u32; | ^^^^^ @@ -1226,7 +1226,7 @@ LL | x_i64 > x_u32; | help: you can convert an `u32` to `i64`: `x_u32.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:282:17 + --> $DIR/numeric-cast-binop.rs:287:17 | LL | x_i64 > x_u64; | ^^^^^ expected `i64`, found `u64` @@ -1237,7 +1237,7 @@ LL | x_i64 > x_u64.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:284:17 + --> $DIR/numeric-cast-binop.rs:289:17 | LL | x_i64 > x_u128; | ^^^^^^ expected `i64`, found `u128` @@ -1248,7 +1248,7 @@ LL | x_i64 > x_u128.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:286:17 + --> $DIR/numeric-cast-binop.rs:291:17 | LL | x_i64 > x_usize; | ^^^^^^^ expected `i64`, found `usize` @@ -1259,7 +1259,7 @@ LL | x_i64 > x_usize.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:289:18 + --> $DIR/numeric-cast-binop.rs:294:18 | LL | x_i128 > x_u8; | ^^^^ @@ -1268,7 +1268,7 @@ LL | x_i128 > x_u8; | help: you can convert an `u8` to `i128`: `x_u8.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:291:18 + --> $DIR/numeric-cast-binop.rs:296:18 | LL | x_i128 > x_u16; | ^^^^^ @@ -1277,7 +1277,7 @@ LL | x_i128 > x_u16; | help: you can convert an `u16` to `i128`: `x_u16.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:293:18 + --> $DIR/numeric-cast-binop.rs:298:18 | LL | x_i128 > x_u32; | ^^^^^ @@ -1286,7 +1286,7 @@ LL | x_i128 > x_u32; | help: you can convert an `u32` to `i128`: `x_u32.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:295:18 + --> $DIR/numeric-cast-binop.rs:300:18 | LL | x_i128 > x_u64; | ^^^^^ @@ -1295,7 +1295,7 @@ LL | x_i128 > x_u64; | help: you can convert an `u64` to `i128`: `x_u64.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:297:18 + --> $DIR/numeric-cast-binop.rs:302:18 | LL | x_i128 > x_u128; | ^^^^^^ expected `i128`, found `u128` @@ -1306,7 +1306,7 @@ LL | x_i128 > x_u128.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:299:18 + --> $DIR/numeric-cast-binop.rs:304:18 | LL | x_i128 > x_usize; | ^^^^^^^ expected `i128`, found `usize` @@ -1317,7 +1317,7 @@ LL | x_i128 > x_usize.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:302:19 + --> $DIR/numeric-cast-binop.rs:307:19 | LL | x_isize > x_u8; | ^^^^ @@ -1326,7 +1326,7 @@ LL | x_isize > x_u8; | help: you can convert an `u8` to `isize`: `x_u8.into()` error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:304:19 + --> $DIR/numeric-cast-binop.rs:309:19 | LL | x_isize > x_u16; | ^^^^^ expected `isize`, found `u16` @@ -1337,7 +1337,7 @@ LL | x_isize > x_u16.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:306:19 + --> $DIR/numeric-cast-binop.rs:311:19 | LL | x_isize > x_u32; | ^^^^^ expected `isize`, found `u32` @@ -1348,7 +1348,7 @@ LL | x_isize > x_u32.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:308:19 + --> $DIR/numeric-cast-binop.rs:313:19 | LL | x_isize > x_u64; | ^^^^^ expected `isize`, found `u64` @@ -1359,7 +1359,7 @@ LL | x_isize > x_u64.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:310:19 + --> $DIR/numeric-cast-binop.rs:315:19 | LL | x_isize > x_u128; | ^^^^^^ expected `isize`, found `u128` @@ -1370,7 +1370,7 @@ LL | x_isize > x_u128.try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/numeric-cast-binop.rs:312:19 + --> $DIR/numeric-cast-binop.rs:317:19 | LL | x_isize > x_usize; | ^^^^^^^ expected `isize`, found `usize` From 3a8f6c094374decd1f0792e19ca3227616d02309 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Thu, 11 Jun 2020 19:21:09 +0200 Subject: [PATCH 6/8] Add various Zulip notifications for prioritization --- triagebot.toml | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/triagebot.toml b/triagebot.toml index 833d390f1a2..0eae13b06b9 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -58,7 +58,9 @@ label = "O-ARM" [prioritize] label = "I-prioritize" -prioritize_on = [ + +[autolabel."I-prioritize"] +trigger_labels = [ "regression-from-stable-to-stable", "regression-from-stable-to-beta", "regression-from-stable-to-nightly", @@ -70,4 +72,46 @@ exclude_labels = [ "T-release", "requires-nightly", ] -zulip_stream = 227806 + +[notify-zulip."I-prioritize"] +zulip_stream = 227806 # #t-compiler/wg-prioritization +topic = "I-prioritize #{number} {title}" +message_on_add = "@**WG-prioritization** issue #{number} has been requested for prioritization." +message_on_remove = "Issue #{number}'s prioritization request has been removed." + +[notify-zulip."I-nominated"] +required_labels = ["T-compiler"] +zulip_stream = 227806 # #t-compiler/wg-prioritization +topic = "I-prioritize #{number} {title}" +message_on_add = "@**WG-prioritization** #{number} has been nominated for discussion in `T-compiler` meeting." +message_on_remove = "#{number}'s nomination has been removed." + +[notify-zulip."beta-nominated"] +zulip_stream = 227806 # #t-compiler/wg-prioritization +topic = "Backport #{number} {title}" +message_on_add = "@**WG-prioritization** PR #{number} has been requested for beta backport." +message_on_remove = "PR #{number}'s beta backport request has been removed." + +[notify-zulip."stable-nominated"] +zulip_stream = 227806 # #t-compiler/wg-prioritization +topic = "Backport #{number} {title}" +message_on_add = "@**WG-prioritization** PR #{number} has been requested for stable backport." +message_on_remove = "PR #{number}'s stable backport request has been removed." + +[notify-zulip."S-waiting-on-team"] +required_labels = ["T-compiler"] +zulip_stream = 227806 # #t-compiler/wg-prioritization +topic = "S-waiting-on-team #{number} {title}" +message_on_add = "@**WG-prioritization** PR #{number} is waiting on `T-compiler`." +message_on_remove = "PR #{number}'s is no longer waiting on `T-compiler`." + +[notify-zulip."P-critical"] +zulip_stream = 227806 # #t-compiler/wg-prioritization +topic = "P-critical #{number} {title}" +message_on_add = "@**WG-prioritization** issue #{number} has been assigned `P-critical`." + +[notify-zulip."P-high"] +required_labels = ["regression-from-stable-to-*"] +zulip_stream = 227806 # #t-compiler/wg-prioritization +topic = "P-high regression #{number} {title}" +message_on_add = "@**WG-prioritization** issue #{number} has been assigned `P-high` and is a regression." From 68b4c03dbced1a0eae38138a7dd8ecb3ca30c02f Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Tue, 9 Jun 2020 16:26:21 +0530 Subject: [PATCH 7/8] Add long error explanation for E0724 Minor refactoring Minor refactoring Update src/librustc_error_codes/error_codes/E0724.md Co-authored-by: David Wood Update src/librustc_error_codes/error_codes/E0724.md Co-authored-by: David Wood Update src/librustc_error_codes/error_codes/E0724.md Co-authored-by: David Wood Minor refactoring --- src/librustc_error_codes/error_codes.rs | 2 +- src/librustc_error_codes/error_codes/E0724.md | 24 +++++++++++++++++++ src/test/ui/ffi_returns_twice.stderr | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/librustc_error_codes/error_codes/E0724.md diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs index 760b4d7ba00..04ef1bc876f 100644 --- a/src/librustc_error_codes/error_codes.rs +++ b/src/librustc_error_codes/error_codes.rs @@ -409,6 +409,7 @@ E0718: include_str!("./error_codes/E0718.md"), E0719: include_str!("./error_codes/E0719.md"), E0720: include_str!("./error_codes/E0720.md"), E0723: include_str!("./error_codes/E0723.md"), +E0724: include_str!("./error_codes/E0724.md"), E0725: include_str!("./error_codes/E0725.md"), E0727: include_str!("./error_codes/E0727.md"), E0728: include_str!("./error_codes/E0728.md"), @@ -615,7 +616,6 @@ E0760: include_str!("./error_codes/E0760.md"), E0717, // rustc_promotable without stability attribute // E0721, // `await` keyword E0722, // Malformed `#[optimize]` attribute - E0724, // `#[ffi_returns_twice]` is only allowed in foreign functions E0726, // non-explicit (not `'_`) elided lifetime in unsupported position // E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`. E0755, // `#[ffi_pure]` is only allowed on foreign functions diff --git a/src/librustc_error_codes/error_codes/E0724.md b/src/librustc_error_codes/error_codes/E0724.md new file mode 100644 index 00000000000..7a7ba154854 --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0724.md @@ -0,0 +1,24 @@ +`#[ffi_returns_twice]` was used on non-foreign function. + +Erroneous code example: + +```compile_fail,E0724 +#![feature(ffi_returns_twice)] +#![crate_type = "lib"] + +#[ffi_returns_twice] // error! +pub fn foo() {} +``` + +`#[ffi_returns_twice]` can only be used on foreign function declarations. +For example, we might correct the previous example by declaring +the function inside of an `extern` block. + +``` +#![feature(ffi_returns_twice)] + +extern { + #[ffi_returns_twice] // ok! + pub fn foo(); +} +``` diff --git a/src/test/ui/ffi_returns_twice.stderr b/src/test/ui/ffi_returns_twice.stderr index 862892e27be..2b7f5694f02 100644 --- a/src/test/ui/ffi_returns_twice.stderr +++ b/src/test/ui/ffi_returns_twice.stderr @@ -6,3 +6,4 @@ LL | #[ffi_returns_twice] error: aborting due to previous error +For more information about this error, try `rustc --explain E0724`. From 1d8da94439017344556f7c49750b9e374f7dd579 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 11 Jun 2020 17:16:38 -0400 Subject: [PATCH 8/8] Add comment about LocalDefId -> DefId Now there are instructions on how to convert back and forth on both structs, not just one. --- src/librustc_span/def_id.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustc_span/def_id.rs b/src/librustc_span/def_id.rs index fad9f2f6130..0a70be1f152 100644 --- a/src/librustc_span/def_id.rs +++ b/src/librustc_span/def_id.rs @@ -133,6 +133,8 @@ impl rustc_serialize::UseSpecializedDecodable for DefIndex {} /// A `DefId` identifies a particular *definition*, by combining a crate /// index and a def index. +/// +/// You can create a `DefId` from a `LocalDefId` using `local_def_id.to_def_id()`. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)] pub struct DefId { pub krate: CrateNum,