From b380d35849143143ad7c19547a8f2533d880d360 Mon Sep 17 00:00:00 2001 From: csmoe Date: Thu, 24 Oct 2019 01:25:05 +0800 Subject: [PATCH 01/27] add ui test for issue-62097 --- src/test/ui/async-await/issues/issue-62097.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/test/ui/async-await/issues/issue-62097.rs diff --git a/src/test/ui/async-await/issues/issue-62097.rs b/src/test/ui/async-await/issues/issue-62097.rs new file mode 100644 index 0000000000000..ea482d3667e2b --- /dev/null +++ b/src/test/ui/async-await/issues/issue-62097.rs @@ -0,0 +1,19 @@ +// edition:2018 +async fn foo(fun: F) +where + F: FnOnce() + 'static +{ + fun() +} + +struct Struct; + +impl Struct { + pub async fn run_dummy_fn(&self) { //~ ERROR cannot infer + foo(|| self.bar()).await; + } + + pub fn bar(&self) {} +} + +fn main() {} From dcc14c40eee3139e53bfacd3854af8a5a3d379e8 Mon Sep 17 00:00:00 2001 From: csmoe Date: Thu, 24 Oct 2019 01:28:27 +0800 Subject: [PATCH 02/27] suggest to add a constraint except asyn-fn without explicit output --- .../nice_region_error/different_lifetimes.rs | 2 +- .../error_reporting/nice_region_error/mod.rs | 2 +- .../nice_region_error/named_anon_conflict.rs | 2 +- .../nice_region_error/static_impl_trait.rs | 24 +++++++++++-------- src/librustc/ty/context.rs | 8 ++++--- .../nll/region_infer/error_reporting/mod.rs | 4 ++-- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs b/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs index 979815fa7f184..3d98dd8de8b47 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs @@ -43,7 +43,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// /// It will later be extended to trait objects. pub(super) fn try_report_anon_anon_conflict(&self) -> Option { - let (span, sub, sup) = self.get_regions(); + let (span, sub, sup) = self.regions(); // Determine whether the sub and sup consist of both anonymous (elided) regions. let anon_reg_sup = self.tcx().is_suitable_region(sup)?; diff --git a/src/librustc/infer/error_reporting/nice_region_error/mod.rs b/src/librustc/infer/error_reporting/nice_region_error/mod.rs index cd003aa8dab70..09cfbf850a57d 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/mod.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/mod.rs @@ -77,7 +77,7 @@ impl<'cx, 'tcx> NiceRegionError<'cx, 'tcx> { .or_else(|| self.try_report_impl_not_conforming_to_trait()) } - pub fn get_regions(&self) -> (Span, ty::Region<'tcx>, ty::Region<'tcx>) { + pub fn regions(&self) -> (Span, ty::Region<'tcx>, ty::Region<'tcx>) { match (&self.error, self.regions) { (Some(ConcreteFailure(origin, sub, sup)), None) => (origin.span(), sub, sup), (Some(SubSupConflict(_, _, origin, sub, _, sup)), None) => (origin.span(), sub, sup), diff --git a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs index a9a2c15d7d99b..43b0e43a5fd89 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs @@ -9,7 +9,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// When given a `ConcreteFailure` for a function with parameters containing a named region and /// an anonymous region, emit an descriptive diagnostic error. pub(super) fn try_report_named_anon_conflict(&self) -> Option> { - let (span, sub, sup) = self.get_regions(); + let (span, sub, sup) = self.regions(); debug!( "try_report_named_anon_conflict(sub={:?}, sup={:?}, error={:?})", diff --git a/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs b/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs index 9d405d4ea40c9..33bdf31f110c3 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -20,8 +20,9 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { ) = error.clone() { let anon_reg_sup = self.tcx().is_suitable_region(sup_r)?; + let return_ty = self.tcx().return_type_impl_trait(anon_reg_sup.def_id); if sub_r == &RegionKind::ReStatic && - self.tcx().return_type_impl_trait(anon_reg_sup.def_id).is_some() + return_ty.is_some() { let sp = var_origin.span(); let return_sp = sub_origin.span(); @@ -53,16 +54,19 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { _ => "'_".to_owned(), }; if let Ok(snippet) = self.tcx().sess.source_map().span_to_snippet(return_sp) { - err.span_suggestion( - return_sp, - &format!( - "you can add a constraint to the return type to make it last \ + // only apply this suggestion onto non-async fnunctions + if !return_ty.unwrap().1 { + err.span_suggestion( + return_sp, + &format!( + "you can add a constraint to the return type to make it last \ less than `'static` and match {}", - lifetime, - ), - format!("{} + {}", snippet, lifetime_name), - Applicability::Unspecified, - ); + lifetime, + ), + format!("{} + {}", snippet, lifetime_name), + Applicability::Unspecified, + ); + } } err.emit(); return Some(ErrorReported); diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 0906d9ebd8e7f..56bf8b60a7449 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1552,14 +1552,14 @@ impl<'tcx> TyCtxt<'tcx> { return Some(FreeRegionInfo { def_id: suitable_region_binding_scope, boundregion: bound_region, - is_impl_item: is_impl_item, + is_impl_item, }); } pub fn return_type_impl_trait( &self, scope_def_id: DefId, - ) -> Option> { + ) -> Option<(Ty<'tcx>, bool)> { // HACK: `type_of_def_id()` will fail on these (#55796), so return `None`. let hir_id = self.hir().as_local_hir_id(scope_def_id).unwrap(); match self.hir().get(hir_id) { @@ -1579,8 +1579,10 @@ impl<'tcx> TyCtxt<'tcx> { ty::FnDef(_, _) => { let sig = ret_ty.fn_sig(*self); let output = self.erase_late_bound_regions(&sig.output()); + let is_async_fn = + hir::IsAsync::Async == self.asyncness(scope_def_id); if output.is_impl_trait() { - Some(output) + Some((output, is_async_fn)) } else { None } diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs index 7362ae9c638b1..3a202c66a665b 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs @@ -698,10 +698,10 @@ impl<'tcx> RegionInferenceContext<'tcx> { if let (Some(f), Some(ty::RegionKind::ReStatic)) = (self.to_error_region(fr), self.to_error_region(outlived_fr)) { - if let Some(ty::TyS { + if let Some((ty::TyS { kind: ty::Opaque(did, substs), .. - }) = infcx + }, _)) = infcx .tcx .is_suitable_region(f) .map(|r| r.def_id) From 9124f7a096007b5f96300e61e8f5817df10b315a Mon Sep 17 00:00:00 2001 From: csmoe Date: Thu, 24 Oct 2019 01:28:55 +0800 Subject: [PATCH 03/27] update suggestion ui test --- src/librustc/hir/lowering.rs | 14 +++++++-- .../nice_region_error/static_impl_trait.rs | 11 ++++--- src/librustc/ty/context.rs | 7 ++--- .../async-await/issues/issue-62097.nll.stderr | 29 +++++++++++++++++++ .../ui/async-await/issues/issue-62097.stderr | 16 ++++++++++ .../async-await/issues/issue-63388-2.stderr | 4 --- ...types_pin_lifetime_impl_trait-async.stderr | 4 --- 7 files changed, 67 insertions(+), 18 deletions(-) create mode 100644 src/test/ui/async-await/issues/issue-62097.nll.stderr create mode 100644 src/test/ui/async-await/issues/issue-62097.stderr diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index f2d5f043f909d..effc13c8301ef 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -2124,6 +2124,16 @@ impl<'a> LoweringContext<'a> { impl_trait_return_allow: bool, make_ret_async: Option, ) -> P { + debug!("lower_fn_decl(\ + fn_decl: {:?}, \ + in_band_ty_params: {:?}, \ + impl_trait_return_allow: {}, \ + make_ret_async: {:?})", + decl, + in_band_ty_params, + impl_trait_return_allow, + make_ret_async, + ); let lt_mode = if make_ret_async.is_some() { // In `async fn`, argument-position elided lifetimes // must be transformed into fresh generic parameters so that @@ -2416,7 +2426,7 @@ impl<'a> LoweringContext<'a> { hir::FunctionRetTy::Return(P(hir::Ty { kind: opaque_ty_ref, - span, + span: opaque_ty_span, hir_id: self.next_id(), })) } @@ -2526,7 +2536,7 @@ impl<'a> LoweringContext<'a> { hir::Lifetime { hir_id: self.lower_node_id(id), span, - name: name, + name, } } diff --git a/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs b/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs index 33bdf31f110c3..01ba748c4e1f9 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -53,11 +53,14 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { }) => name.to_string(), _ => "'_".to_owned(), }; - if let Ok(snippet) = self.tcx().sess.source_map().span_to_snippet(return_sp) { - // only apply this suggestion onto non-async fnunctions - if !return_ty.unwrap().1 { + let fn_return_span = return_ty.unwrap().1; + if let Ok(snippet) = + self.tcx().sess.source_map().span_to_snippet(fn_return_span) { + // only apply this suggestion onto functions with + // explicit non-desugar'able return. + if fn_return_span.desugaring_kind().is_none() { err.span_suggestion( - return_sp, + fn_return_span, &format!( "you can add a constraint to the return type to make it last \ less than `'static` and match {}", diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 56bf8b60a7449..3985d47abe1dc 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1559,7 +1559,7 @@ impl<'tcx> TyCtxt<'tcx> { pub fn return_type_impl_trait( &self, scope_def_id: DefId, - ) -> Option<(Ty<'tcx>, bool)> { + ) -> Option<(Ty<'tcx>, Span)> { // HACK: `type_of_def_id()` will fail on these (#55796), so return `None`. let hir_id = self.hir().as_local_hir_id(scope_def_id).unwrap(); match self.hir().get(hir_id) { @@ -1579,10 +1579,9 @@ impl<'tcx> TyCtxt<'tcx> { ty::FnDef(_, _) => { let sig = ret_ty.fn_sig(*self); let output = self.erase_late_bound_regions(&sig.output()); - let is_async_fn = - hir::IsAsync::Async == self.asyncness(scope_def_id); if output.is_impl_trait() { - Some((output, is_async_fn)) + let fn_decl = self.hir().fn_decl_by_hir_id(hir_id).unwrap(); + Some((output, fn_decl.output.span())) } else { None } diff --git a/src/test/ui/async-await/issues/issue-62097.nll.stderr b/src/test/ui/async-await/issues/issue-62097.nll.stderr new file mode 100644 index 0000000000000..0c64f90cb9fae --- /dev/null +++ b/src/test/ui/async-await/issues/issue-62097.nll.stderr @@ -0,0 +1,29 @@ +error[E0373]: closure may outlive the current function, but it borrows `self`, which is owned by the current function + --> $DIR/issue-62097.rs:13:13 + | +LL | foo(|| self.bar()).await; + | ^^ ---- `self` is borrowed here + | | + | may outlive borrowed value `self` + | +note: function requires argument type to outlive `'static` + --> $DIR/issue-62097.rs:13:9 + | +LL | foo(|| self.bar()).await; + | ^^^^^^^^^^^^^^^^^^ +help: to force the closure to take ownership of `self` (and any other referenced variables), use the `move` keyword + | +LL | foo(move || self.bar()).await; + | ^^^^^^^ + +error[E0521]: borrowed data escapes outside of function + --> $DIR/issue-62097.rs:13:9 + | +LL | pub async fn run_dummy_fn(&self) { + | ----- `self` is a reference that is only valid in the function body +LL | foo(|| self.bar()).await; + | ^^^^^^^^^^^^^^^^^^ `self` escapes the function body here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0373`. diff --git a/src/test/ui/async-await/issues/issue-62097.stderr b/src/test/ui/async-await/issues/issue-62097.stderr new file mode 100644 index 0000000000000..94afccc06a9e7 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-62097.stderr @@ -0,0 +1,16 @@ +error: cannot infer an appropriate lifetime + --> $DIR/issue-62097.rs:12:31 + | +LL | pub async fn run_dummy_fn(&self) { + | ^^^^^ ...but this borrow... +LL | foo(|| self.bar()).await; + | --- this return type evaluates to the `'static` lifetime... + | +note: ...can't outlive the lifetime `'_` as defined on the method body at 12:31 + --> $DIR/issue-62097.rs:12:31 + | +LL | pub async fn run_dummy_fn(&self) { + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/async-await/issues/issue-63388-2.stderr b/src/test/ui/async-await/issues/issue-63388-2.stderr index efec160588fc4..7e45d588c6c6c 100644 --- a/src/test/ui/async-await/issues/issue-63388-2.stderr +++ b/src/test/ui/async-await/issues/issue-63388-2.stderr @@ -20,10 +20,6 @@ note: ...can't outlive the lifetime `'_` as defined on the method body at 11:14 | LL | foo: &dyn Foo, bar: &'a dyn Foo | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime `'_` as defined on the method body at 11:14 - | -LL | foo + '_ - | error: aborting due to 2 previous errors diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr index bce1900ca602c..91075ffbdb605 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr @@ -11,10 +11,6 @@ note: ...can't outlive the lifetime `'_` as defined on the method body at 8:26 | LL | async fn f(self: Pin<&Self>) -> impl Clone { self } | ^ -help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime `'_` as defined on the method body at 8:26 - | -LL | async fn f(self: Pin<&Self>) -> impl Clone + '_ { self } - | ^^^^^^^^^^^^^^^ error: aborting due to previous error From 405866aaa3e8057218ad482ca60e284ea0c9e350 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 16 Nov 2019 11:44:32 +0100 Subject: [PATCH 04/27] re-add miri intrinsic ABI check --- src/librustc_mir/interpret/terminator.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs index 4f9e404b2c635..0134c77808b82 100644 --- a/src/librustc_mir/interpret/terminator.rs +++ b/src/librustc_mir/interpret/terminator.rs @@ -264,6 +264,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { match instance.def { ty::InstanceDef::Intrinsic(..) => { + if caller_abi != Abi::RustIntrinsic && caller_abi != Abi::PlatformIntrinsic { + throw_ub_format!("Rust intrinsic called with an ABI other than \ + `RustIntrinsic` and `PlatformIntrinsic`."); + } + let old_stack = self.cur_frame(); let old_bb = self.frame().block; M::call_intrinsic(self, span, instance, args, dest, ret, unwind)?; From 44b68116c522ad8870f0a8627550ba1f5c8fc797 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 16 Nov 2019 13:14:41 +0100 Subject: [PATCH 05/27] rename and move read_vector_ty --- src/librustc/ty/sty.rs | 18 ++++++++++++++---- src/librustc_mir/interpret/intrinsics.rs | 21 +++++++++++---------- src/librustc_mir/interpret/operand.rs | 11 ----------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 8f6fc02ab4b37..d1d71a4287244 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -1814,20 +1814,30 @@ impl<'tcx> TyS<'tcx> { pub fn simd_type(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { match self.kind { - Adt(def, substs) => { - def.non_enum_variant().fields[0].ty(tcx, substs) - } + Adt(def, substs) => def.non_enum_variant().fields[0].ty(tcx, substs), _ => bug!("simd_type called on invalid type") } } - pub fn simd_size(&self, _cx: TyCtxt<'_>) -> usize { + pub fn simd_size(&self, _tcx: TyCtxt<'tcx>) -> usize { + // Parameter currently unused, but probably needed in the future to + // allow `#[repr(simd)] struct Simd([T; N]);`. match self.kind { Adt(def, _) => def.non_enum_variant().fields.len(), _ => bug!("simd_size called on invalid type") } } + pub fn simd_size_and_type(&self, tcx: TyCtxt<'tcx>) -> (usize, Ty<'tcx>) { + match self.kind { + Adt(def, substs) => { + let variant = def.non_enum_variant(); + (variant.fields.len(), variant.fields[0].ty(tcx, substs)) + } + _ => bug!("simd_size_and_type called on invalid type") + } + } + #[inline] pub fn is_region_ptr(&self) -> bool { match self.kind { diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs index 6117cf4038a24..e43e6c0e43a80 100644 --- a/src/librustc_mir/interpret/intrinsics.rs +++ b/src/librustc_mir/interpret/intrinsics.rs @@ -302,10 +302,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { self.copy_op_transmute(args[0], dest)?; } "simd_insert" => { - let index = self.read_scalar(args[1])?.to_u32()? as u64; - let scalar = args[2]; + let index = u64::from(self.read_scalar(args[1])?.to_u32()?); + let elem = args[2]; let input = args[0]; - let (len, e_ty) = self.read_vector_ty(input); + let (len, e_ty) = input.layout.ty.simd_size_and_type(self.tcx.tcx); + let len = len as u64; assert!( index < len, "Index `{}` must be in bounds of vector type `{}`: `[0, {})`", @@ -317,15 +318,15 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { dest.layout.ty, input.layout.ty ); assert_eq!( - scalar.layout.ty, e_ty, - "Scalar type `{}` must match vector element type `{}`", - scalar.layout.ty, e_ty + elem.layout.ty, e_ty, + "Scalar element type `{}` must match vector element type `{}`", + elem.layout.ty, e_ty ); for i in 0..len { let place = self.place_field(dest, i)?; let value = if i == index { - scalar + elem } else { self.operand_field(input, i)? }; @@ -333,10 +334,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } } "simd_extract" => { - let index = self.read_scalar(args[1])?.to_u32()? as _; - let (len, e_ty) = self.read_vector_ty(args[0]); + let index = u64::from(self.read_scalar(args[1])?.to_u32()?); + let (len, e_ty) = args[0].layout.ty.simd_size_and_type(self.tcx.tcx); assert!( - index < len, + index < len as u64, "index `{}` is out-of-bounds of vector type `{}` with length `{}`", index, e_ty, len ); diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index 4d2ccdc20da65..970f76a9d6d7c 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -315,17 +315,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } } - /// Read vector length and element type - pub fn read_vector_ty( - &self, op: OpTy<'tcx, M::PointerTag> - ) -> (u64, &rustc::ty::TyS<'tcx>) { - if let layout::Abi::Vector { .. } = op.layout.abi { - (op.layout.ty.simd_size(*self.tcx) as _, op.layout.ty.simd_type(*self.tcx)) - } else { - bug!("Type `{}` is not a SIMD vector type", op.layout.ty) - } - } - /// Read a scalar from a place pub fn read_scalar( &self, From 09180d71fd382c8d0471ff342147d91def3a1595 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 16 Nov 2019 13:31:09 +0100 Subject: [PATCH 06/27] make simd_size return a u64 --- src/librustc/ty/layout.rs | 2 +- src/librustc/ty/sty.rs | 8 ++++---- src/librustc_codegen_llvm/intrinsic.rs | 22 +++++++++++++--------- src/librustc_mir/interpret/intrinsics.rs | 3 +-- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 972452601ddd5..b9fc5f59b7bbc 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -697,7 +697,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { // SIMD vector types. ty::Adt(def, ..) if def.repr.simd() => { let element = self.layout_of(ty.simd_type(tcx))?; - let count = ty.simd_size(tcx) as u64; + let count = ty.simd_size(tcx); assert!(count > 0); let scalar = match element.abi { Abi::Scalar(ref scalar) => scalar.clone(), diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index d1d71a4287244..b7e645d55a5fc 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -1819,20 +1819,20 @@ impl<'tcx> TyS<'tcx> { } } - pub fn simd_size(&self, _tcx: TyCtxt<'tcx>) -> usize { + pub fn simd_size(&self, _tcx: TyCtxt<'tcx>) -> u64 { // Parameter currently unused, but probably needed in the future to // allow `#[repr(simd)] struct Simd([T; N]);`. match self.kind { - Adt(def, _) => def.non_enum_variant().fields.len(), + Adt(def, _) => def.non_enum_variant().fields.len() as u64, _ => bug!("simd_size called on invalid type") } } - pub fn simd_size_and_type(&self, tcx: TyCtxt<'tcx>) -> (usize, Ty<'tcx>) { + pub fn simd_size_and_type(&self, tcx: TyCtxt<'tcx>) -> (u64, Ty<'tcx>) { match self.kind { Adt(def, substs) => { let variant = def.non_enum_variant(); - (variant.fields.len(), variant.fields[0].ty(tcx, substs)) + (variant.fields.len() as u64, variant.fields[0].ty(tcx, substs)) } _ => bug!("simd_size_and_type called on invalid type") } diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index e1ce7f622e2ef..fb5f457bb3a1c 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -28,6 +28,7 @@ use syntax_pos::Span; use std::cmp::Ordering; use std::{iter, i128, u128}; +use std::convert::TryFrom; fn get_simple_intrinsic(cx: &CodegenCx<'ll, '_>, name: &str) -> Option<&'ll Value> { let llvm_name = match name { @@ -1105,8 +1106,8 @@ fn generic_simd_intrinsic( let m_len = match in_ty.kind { // Note that this `.unwrap()` crashes for isize/usize, that's sort // of intentional as there's not currently a use case for that. - ty::Int(i) => i.bit_width().unwrap(), - ty::Uint(i) => i.bit_width().unwrap(), + ty::Int(i) => i.bit_width().unwrap() as u64, + ty::Uint(i) => i.bit_width().unwrap() as u64, _ => return_error!("`{}` is not an integral type", in_ty), }; require_simd!(arg_tys[1], "argument"); @@ -1116,7 +1117,7 @@ fn generic_simd_intrinsic( m_len, v_len ); let i1 = bx.type_i1(); - let i1xn = bx.type_vector(i1, m_len as u64); + let i1xn = bx.type_vector(i1, m_len); let m_i1s = bx.bitcast(args[0].immediate(), i1xn); return Ok(bx.select(m_i1s, args[1].immediate(), args[2].immediate())); } @@ -1166,7 +1167,7 @@ fn generic_simd_intrinsic( require_simd!(ret_ty, "return"); let out_len = ret_ty.simd_size(tcx); - require!(out_len == n, + require!(out_len == n as u64, "expected return type of length {}, found `{}` with length {}", n, ret_ty, out_len); require!(in_elem == ret_ty.simd_type(tcx), @@ -1251,7 +1252,7 @@ fn generic_simd_intrinsic( // trailing bits. let expected_int_bits = in_len.max(8); match ret_ty.kind { - ty::Uint(i) if i.bit_width() == Some(expected_int_bits) => (), + ty::Uint(i) if i.bit_width() == Some(expected_int_bits as usize) => (), _ => return_error!( "bitmask `{}`, expected `u{}`", ret_ty, expected_int_bits @@ -1276,7 +1277,8 @@ fn generic_simd_intrinsic( // Shift the MSB to the right by "in_elem_bitwidth - 1" into the first bit position. let shift_indices = vec![ - bx.cx.const_int(bx.type_ix(in_elem_bitwidth as _), (in_elem_bitwidth - 1) as _); in_len + bx.cx.const_int(bx.type_ix(in_elem_bitwidth as _), (in_elem_bitwidth - 1) as _); + in_len as _ ]; let i_xn_msb = bx.lshr(i_xn, bx.const_vector(shift_indices.as_slice())); // Truncate vector to an @@ -1291,7 +1293,7 @@ fn generic_simd_intrinsic( name: &str, in_elem: &::rustc::ty::TyS<'_>, in_ty: &::rustc::ty::TyS<'_>, - in_len: usize, + in_len: u64, bx: &mut Builder<'a, 'll, 'tcx>, span: Span, args: &[OperandRef<'tcx, &'ll Value>], @@ -1506,11 +1508,12 @@ fn generic_simd_intrinsic( // Truncate the mask vector to a vector of i1s: let (mask, mask_ty) = { let i1 = bx.type_i1(); - let i1xn = bx.type_vector(i1, in_len as u64); + let i1xn = bx.type_vector(i1, in_len); (bx.trunc(args[2].immediate(), i1xn), i1xn) }; // Type of the vector of pointers: + let in_len = usize::try_from(in_len).unwrap(); let llvm_pointer_vec_ty = llvm_vector_ty(bx, underlying_ty, in_len, pointer_count); let llvm_pointer_vec_str = llvm_vector_str(underlying_ty, in_len, pointer_count); @@ -1606,13 +1609,14 @@ fn generic_simd_intrinsic( // Truncate the mask vector to a vector of i1s: let (mask, mask_ty) = { let i1 = bx.type_i1(); - let i1xn = bx.type_vector(i1, in_len as u64); + let i1xn = bx.type_vector(i1, in_len); (bx.trunc(args[2].immediate(), i1xn), i1xn) }; let ret_t = bx.type_void(); // Type of the vector of pointers: + let in_len = usize::try_from(in_len).unwrap(); let llvm_pointer_vec_ty = llvm_vector_ty(bx, underlying_ty, in_len, pointer_count); let llvm_pointer_vec_str = llvm_vector_str(underlying_ty, in_len, pointer_count); diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs index e43e6c0e43a80..23f7b1acb54d4 100644 --- a/src/librustc_mir/interpret/intrinsics.rs +++ b/src/librustc_mir/interpret/intrinsics.rs @@ -306,7 +306,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let elem = args[2]; let input = args[0]; let (len, e_ty) = input.layout.ty.simd_size_and_type(self.tcx.tcx); - let len = len as u64; assert!( index < len, "Index `{}` must be in bounds of vector type `{}`: `[0, {})`", @@ -337,7 +336,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let index = u64::from(self.read_scalar(args[1])?.to_u32()?); let (len, e_ty) = args[0].layout.ty.simd_size_and_type(self.tcx.tcx); assert!( - index < len as u64, + index < len, "index `{}` is out-of-bounds of vector type `{}` with length `{}`", index, e_ty, len ); From 8952c8aa42209919c2980e99f11694e36f2b6845 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 16 Nov 2019 14:10:07 +0100 Subject: [PATCH 07/27] ICE on invalid MIR --- src/librustc_mir/interpret/terminator.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs index 0134c77808b82..50c4a249c63c2 100644 --- a/src/librustc_mir/interpret/terminator.rs +++ b/src/librustc_mir/interpret/terminator.rs @@ -264,10 +264,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { match instance.def { ty::InstanceDef::Intrinsic(..) => { - if caller_abi != Abi::RustIntrinsic && caller_abi != Abi::PlatformIntrinsic { - throw_ub_format!("Rust intrinsic called with an ABI other than \ - `RustIntrinsic` and `PlatformIntrinsic`."); - } + assert!(caller_abi == Abi::RustIntrinsic || caller_abi == Abi::PlatformIntrinsic); let old_stack = self.cur_frame(); let old_bb = self.frame().block; From 5e115a25ca3799a9232f2c3712ed36626025c752 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 16 Nov 2019 16:09:45 +0100 Subject: [PATCH 08/27] avoid some casts --- src/librustc_codegen_llvm/intrinsic.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index fb5f457bb3a1c..4277ce1d1f754 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -28,7 +28,6 @@ use syntax_pos::Span; use std::cmp::Ordering; use std::{iter, i128, u128}; -use std::convert::TryFrom; fn get_simple_intrinsic(cx: &CodegenCx<'ll, '_>, name: &str) -> Option<&'ll Value> { let llvm_name = match name { @@ -1161,13 +1160,13 @@ fn generic_simd_intrinsic( } if name.starts_with("simd_shuffle") { - let n: usize = name["simd_shuffle".len()..].parse().unwrap_or_else(|_| + let n: u64 = name["simd_shuffle".len()..].parse().unwrap_or_else(|_| span_bug!(span, "bad `simd_shuffle` instruction only caught in codegen?")); require_simd!(ret_ty, "return"); let out_len = ret_ty.simd_size(tcx); - require!(out_len == n as u64, + require!(out_len == n, "expected return type of length {}, found `{}` with length {}", n, ret_ty, out_len); require!(in_elem == ret_ty.simd_type(tcx), @@ -1176,7 +1175,7 @@ fn generic_simd_intrinsic( in_elem, in_ty, ret_ty, ret_ty.simd_type(tcx)); - let total_len = in_len as u128 * 2; + let total_len = u128::from(in_len) * 2; let vector = args[2].immediate(); @@ -1402,7 +1401,7 @@ fn generic_simd_intrinsic( // FIXME: use: // https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/Function.h#L182 // https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/Intrinsics.h#L81 - fn llvm_vector_str(elem_ty: Ty<'_>, vec_len: usize, no_pointers: usize) -> String { + fn llvm_vector_str(elem_ty: Ty<'_>, vec_len: u64, no_pointers: usize) -> String { let p0s: String = "p0".repeat(no_pointers); match elem_ty.kind { ty::Int(v) => format!("v{}{}i{}", vec_len, p0s, v.bit_width().unwrap()), @@ -1412,7 +1411,7 @@ fn generic_simd_intrinsic( } } - fn llvm_vector_ty(cx: &CodegenCx<'ll, '_>, elem_ty: Ty<'_>, vec_len: usize, + fn llvm_vector_ty(cx: &CodegenCx<'ll, '_>, elem_ty: Ty<'_>, vec_len: u64, mut no_pointers: usize) -> &'ll Type { // FIXME: use cx.layout_of(ty).llvm_type() ? let mut elem_ty = match elem_ty.kind { @@ -1425,7 +1424,7 @@ fn generic_simd_intrinsic( elem_ty = cx.type_ptr_to(elem_ty); no_pointers -= 1; } - cx.type_vector(elem_ty, vec_len as u64) + cx.type_vector(elem_ty, vec_len) } @@ -1513,7 +1512,6 @@ fn generic_simd_intrinsic( }; // Type of the vector of pointers: - let in_len = usize::try_from(in_len).unwrap(); let llvm_pointer_vec_ty = llvm_vector_ty(bx, underlying_ty, in_len, pointer_count); let llvm_pointer_vec_str = llvm_vector_str(underlying_ty, in_len, pointer_count); @@ -1616,7 +1614,6 @@ fn generic_simd_intrinsic( let ret_t = bx.type_void(); // Type of the vector of pointers: - let in_len = usize::try_from(in_len).unwrap(); let llvm_pointer_vec_ty = llvm_vector_ty(bx, underlying_ty, in_len, pointer_count); let llvm_pointer_vec_str = llvm_vector_str(underlying_ty, in_len, pointer_count); From 5b0e702f6c610a46e71fbd881d282a497353cf20 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 9 Nov 2019 20:34:55 +0100 Subject: [PATCH 09/27] Create a generic HashStable derive. --- src/librustc_macros/src/hash_stable.rs | 38 ++++++++++++++++++++++++++ src/librustc_macros/src/lib.rs | 5 ++++ 2 files changed, 43 insertions(+) diff --git a/src/librustc_macros/src/hash_stable.rs b/src/librustc_macros/src/hash_stable.rs index 735cfb11b365c..3fb252cbf8d9c 100644 --- a/src/librustc_macros/src/hash_stable.rs +++ b/src/librustc_macros/src/hash_stable.rs @@ -47,6 +47,44 @@ fn parse_attributes(field: &syn::Field) -> Attributes { attrs } +pub fn hash_stable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream { + let generic: syn::GenericParam = parse_quote!(__CTX); + s.add_bounds(synstructure::AddBounds::Generics); + s.add_impl_generic(generic); + let body = s.each(|bi| { + let attrs = parse_attributes(bi.ast()); + if attrs.ignore { + quote!{} + } else if let Some(project) = attrs.project { + quote!{ + &#bi.#project.hash_stable(__hcx, __hasher); + } + } else { + quote!{ + #bi.hash_stable(__hcx, __hasher); + } + } + }); + + let discriminant = match s.ast().data { + syn::Data::Enum(_) => quote! { + ::std::mem::discriminant(self).hash_stable(__hcx, __hasher); + }, + syn::Data::Struct(_) => quote! {}, + syn::Data::Union(_) => panic!("cannot derive on union"), + }; + + s.bound_impl(quote!(::rustc_data_structures::stable_hasher::HashStable<__CTX>), quote!{ + fn hash_stable( + &self, + __hcx: &mut __CTX, + __hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher) { + #discriminant + match *self { #body } + } + }) +} + pub fn hash_stable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream { let generic: syn::GenericParam = parse_quote!('__ctx); s.add_bounds(synstructure::AddBounds::Generics); diff --git a/src/librustc_macros/src/lib.rs b/src/librustc_macros/src/lib.rs index 351d60b9368b5..af022115ed064 100644 --- a/src/librustc_macros/src/lib.rs +++ b/src/librustc_macros/src/lib.rs @@ -24,4 +24,9 @@ pub fn symbols(input: TokenStream) -> TokenStream { } decl_derive!([HashStable, attributes(stable_hasher)] => hash_stable::hash_stable_derive); +decl_derive!( + [HashStable_Generic, attributes(stable_hasher)] => + hash_stable::hash_stable_generic_derive +); + decl_derive!([TypeFoldable, attributes(type_foldable)] => type_foldable::type_foldable_derive); From c2e1658c6758ccbc1e12e37193e9780398368698 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 9 Nov 2019 20:56:19 +0100 Subject: [PATCH 10/27] Use proc_macro for HashStable derive in libsyntax. --- Cargo.lock | 1 + src/librustc/ich/impls_syntax.rs | 33 -------------------------------- src/libsyntax/Cargo.toml | 1 + src/libsyntax/ast.rs | 33 +++++++++++++++++--------------- src/libsyntax/attr/builtin.rs | 2 +- src/libsyntax/lib.rs | 2 ++ 6 files changed, 23 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7eb5d4b464c06..34bcba8926197 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4411,6 +4411,7 @@ dependencies = [ "rustc_errors", "rustc_index", "rustc_lexer", + "rustc_macros", "scoped-tls", "serialize", "smallvec 1.0.0", diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index b3d82e5522cf2..bfd4b31af2e56 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -55,11 +55,6 @@ impl<'a> ToStableHashKey> for ast::Name { } } -impl_stable_hash_for!(enum ::syntax::ast::AsmDialect { - Att, - Intel -}); - impl_stable_hash_for!(enum ::syntax_pos::hygiene::MacroKind { Bang, Attr, @@ -124,22 +119,6 @@ for ::syntax::attr::StabilityLevel { impl_stable_hash_for!(struct ::syntax::attr::RustcDeprecation { since, reason, suggestion }); -impl_stable_hash_for!(enum ::syntax::attr::IntType { - SignedInt(int_ty), - UnsignedInt(uint_ty) -}); - -impl_stable_hash_for!(enum ::syntax::ast::LitIntType { - Signed(int_ty), - Unsigned(int_ty), - Unsuffixed -}); - -impl_stable_hash_for!(enum ::syntax::ast::LitFloatType { - Suffixed(float_ty), - Unsuffixed -}); - impl_stable_hash_for!(struct ::syntax::ast::Lit { kind, token, @@ -159,19 +138,7 @@ impl_stable_hash_for!(enum ::syntax::ast::LitKind { impl_stable_hash_for_spanned!(::syntax::ast::LitKind); -impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 }); -impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 }); -impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 }); -impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal }); -impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst }); -impl_stable_hash_for!(enum ::syntax::ast::Defaultness { Default, Final }); impl_stable_hash_for!(struct ::syntax::ast::Lifetime { id, ident }); -impl_stable_hash_for!(enum ::syntax::ast::StrStyle { Cooked, Raw(pounds) }); -impl_stable_hash_for!(enum ::syntax::ast::AttrStyle { Outer, Inner }); -impl_stable_hash_for!(enum ::syntax::ast::Movability { Static, Movable }); -impl_stable_hash_for!(enum ::syntax::ast::CaptureBy { Value, Ref }); -impl_stable_hash_for!(enum ::syntax::ast::IsAuto { Yes, No }); -impl_stable_hash_for!(enum ::syntax::ast::ImplPolarity { Positive, Negative }); impl<'a> HashStable> for [ast::Attribute] { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { diff --git a/src/libsyntax/Cargo.toml b/src/libsyntax/Cargo.toml index d96b5b7a3dde4..dff23076c82e6 100644 --- a/src/libsyntax/Cargo.toml +++ b/src/libsyntax/Cargo.toml @@ -20,5 +20,6 @@ errors = { path = "../librustc_errors", package = "rustc_errors" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_index = { path = "../librustc_index" } rustc_lexer = { path = "../librustc_lexer" } +rustc_macros = { path = "../librustc_macros" } smallvec = { version = "1.0", features = ["union", "may_dangle"] } rustc_error_codes = { path = "../librustc_error_codes" } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index bbf00825acb33..fb9c7e9bd56a8 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1328,7 +1328,7 @@ pub struct QSelf { } /// A capture clause used in closures and `async` blocks. -#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)] +#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)] pub enum CaptureBy { /// `move |x| y + x`. Value, @@ -1339,7 +1339,7 @@ pub enum CaptureBy { /// The movability of a generator / closure literal: /// whether a generator contains self-references, causing it to be `!Unpin`. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, - RustcEncodable, RustcDecodable, Debug, Copy)] + RustcEncodable, RustcDecodable, Debug, Copy, HashStable_Generic)] pub enum Movability { /// May contain self-references, `!Unpin`. Static, @@ -1400,7 +1400,7 @@ impl MacroDef { } // Clippy uses Hash and PartialEq -#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy, Hash, PartialEq)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy, Hash, PartialEq, HashStable_Generic)] pub enum StrStyle { /// A regular string, like `"foo"`. Cooked, @@ -1451,7 +1451,7 @@ impl StrLit { // Clippy uses Hash and PartialEq /// Type of the integer literal based on provided suffix. -#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq)] +#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq, HashStable_Generic)] pub enum LitIntType { /// e.g. `42_i32`. Signed(IntTy), @@ -1462,7 +1462,7 @@ pub enum LitIntType { } /// Type of the float literal based on provided suffix. -#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq)] +#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq, HashStable_Generic)] pub enum LitFloatType { /// A float literal with a suffix (`1f32` or `1E10f32`). Suffixed(FloatTy), @@ -1609,7 +1609,8 @@ pub enum ImplItemKind { Macro(Mac), } -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable_Generic, + RustcEncodable, RustcDecodable, Debug)] pub enum FloatTy { F32, F64, @@ -1638,7 +1639,8 @@ impl FloatTy { } } -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable_Generic, + RustcEncodable, RustcDecodable, Debug)] pub enum IntTy { Isize, I8, @@ -1690,7 +1692,8 @@ impl IntTy { } } -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Copy, Debug)] +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable_Generic, + RustcEncodable, RustcDecodable, Copy, Debug)] pub enum UintTy { Usize, U8, @@ -1863,7 +1866,7 @@ pub enum TraitObjectSyntax { /// Inline assembly dialect. /// /// E.g., `"intel"` as in `asm!("mov eax, 2" : "={eax}"(result) : : : "intel")`. -#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)] +#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy, HashStable_Generic)] pub enum AsmDialect { Att, Intel, @@ -2021,14 +2024,14 @@ impl FnDecl { } /// Is the trait definition an auto trait? -#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)] +#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)] pub enum IsAuto { Yes, No, } #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, - RustcEncodable, RustcDecodable, Debug)] + RustcEncodable, RustcDecodable, Debug, HashStable_Generic)] pub enum Unsafety { Unsafe, Normal, @@ -2085,7 +2088,7 @@ impl IsAsync { } } -#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)] +#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)] pub enum Constness { Const, NotConst, @@ -2093,13 +2096,13 @@ pub enum Constness { /// Item defaultness. /// For details see the [RFC #2532](https://github.com/rust-lang/rfcs/pull/2532). -#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)] +#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)] pub enum Defaultness { Default, Final, } -#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] +#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable_Generic)] pub enum ImplPolarity { /// `impl Trait for Type` Positive, @@ -2233,7 +2236,7 @@ impl UseTree { /// Distinguishes between `Attribute`s that decorate items and Attributes that /// are contained as statements within items. These two cases need to be /// distinguished for pretty-printing. -#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)] +#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy, HashStable_Generic)] pub enum AttrStyle { Outer, Inner, diff --git a/src/libsyntax/attr/builtin.rs b/src/libsyntax/attr/builtin.rs index 767fcabc017ed..d7f4c9469f65f 100644 --- a/src/libsyntax/attr/builtin.rs +++ b/src/libsyntax/attr/builtin.rs @@ -763,7 +763,7 @@ pub enum ReprAttr { ReprAlign(u32), } -#[derive(Eq, PartialEq, Debug, RustcEncodable, RustcDecodable, Copy, Clone)] +#[derive(Eq, PartialEq, Debug, RustcEncodable, RustcDecodable, Copy, Clone, HashStable_Generic)] pub enum IntType { SignedInt(ast::IntTy), UnsignedInt(ast::UintTy) diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index e3eca75dfe7e7..23db4cf985cdc 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -19,6 +19,8 @@ #![recursion_limit="256"] +#[macro_use] extern crate rustc_macros; + pub use errors; use rustc_data_structures::sync::Lock; use rustc_index::bit_set::GrowableBitSet; From 05f5f76b3b2b225420d81b5ad632e4aadd882595 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 9 Nov 2019 21:07:58 +0100 Subject: [PATCH 11/27] Move impl HashStable for SymbolStr in libsyntax_pos. --- src/librustc/ich/impls_syntax.rs | 19 ------------------- src/libsyntax_pos/symbol.rs | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index bfd4b31af2e56..4a331cbf40d97 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -18,25 +18,6 @@ use crate::hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX}; use smallvec::SmallVec; use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher}; -impl<'a> HashStable> for SymbolStr { - #[inline] - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - let str = self as &str; - str.hash_stable(hcx, hasher) - } -} - -impl<'a> ToStableHashKey> for SymbolStr { - type KeyType = SymbolStr; - - #[inline] - fn to_stable_hash_key(&self, - _: &StableHashingContext<'a>) - -> SymbolStr { - self.clone() - } -} - impl<'a> HashStable> for ast::Name { #[inline] fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 86eaeeab5a426..633688316144f 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -8,6 +8,7 @@ use rustc_index::vec::Idx; use rustc_macros::symbols; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use rustc_serialize::{UseSpecializedDecodable, UseSpecializedEncodable}; +use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher}; use std::cmp::{PartialEq, PartialOrd, Ord}; use std::fmt; @@ -1136,3 +1137,20 @@ impl fmt::Display for SymbolStr { fmt::Display::fmt(self.string, f) } } + +impl HashStable for SymbolStr { + #[inline] + fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + let str = self as &str; + str.hash_stable(hcx, hasher) + } +} + +impl ToStableHashKey for SymbolStr { + type KeyType = SymbolStr; + + #[inline] + fn to_stable_hash_key(&self, _: &CTX) -> SymbolStr { + self.clone() + } +} From 1dd5133dce33fed1cffea9bc6fb6ee4f37dc7053 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 9 Nov 2019 21:17:21 +0100 Subject: [PATCH 12/27] Move impl HashStable for Symbol in libsyntax_pos. --- src/librustc/ich/impls_syntax.rs | 21 +-------------------- src/libsyntax_pos/symbol.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index 4a331cbf40d97..005d03f4d0ae1 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -10,31 +10,12 @@ use syntax::ast; use syntax::feature_gate; use syntax::token; use syntax::tokenstream; -use syntax_pos::symbol::SymbolStr; use syntax_pos::SourceFile; use crate::hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX}; use smallvec::SmallVec; -use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher}; - -impl<'a> HashStable> for ast::Name { - #[inline] - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - self.as_str().hash_stable(hcx, hasher); - } -} - -impl<'a> ToStableHashKey> for ast::Name { - type KeyType = SymbolStr; - - #[inline] - fn to_stable_hash_key(&self, - _: &StableHashingContext<'a>) - -> SymbolStr { - self.as_str() - } -} +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; impl_stable_hash_for!(enum ::syntax_pos::hygiene::MacroKind { Bang, diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 633688316144f..f63776338577e 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -940,6 +940,22 @@ impl Decodable for Symbol { } } +impl HashStable for Symbol { + #[inline] + fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + self.as_str().hash_stable(hcx, hasher); + } +} + +impl ToStableHashKey for Symbol { + type KeyType = SymbolStr; + + #[inline] + fn to_stable_hash_key(&self, _: &CTX) -> SymbolStr { + self.as_str() + } +} + // The `&'static str`s in this type actually point into the arena. #[derive(Default)] pub struct Interner { From efcb695f4c38f653d8f0adb70f94aa29328be679 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 9 Nov 2019 21:34:12 +0100 Subject: [PATCH 13/27] Further HashStable_Generic derives. --- src/librustc/ich/impls_syntax.rs | 47 -------------------------------- src/libsyntax/ast.rs | 2 +- src/libsyntax/attr/builtin.rs | 11 +++++--- src/libsyntax_pos/hygiene.rs | 4 ++- 4 files changed, 11 insertions(+), 53 deletions(-) diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index 005d03f4d0ae1..bf716dbf0619a 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -17,13 +17,6 @@ use crate::hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX}; use smallvec::SmallVec; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; -impl_stable_hash_for!(enum ::syntax_pos::hygiene::MacroKind { - Bang, - Attr, - Derive, -}); - - impl_stable_hash_for!(enum ::rustc_target::spec::abi::Abi { Cdecl, Stdcall, @@ -47,57 +40,17 @@ impl_stable_hash_for!(enum ::rustc_target::spec::abi::Abi { Unadjusted }); -impl_stable_hash_for!(struct ::syntax::attr::Deprecation { since, note }); -impl_stable_hash_for!(struct ::syntax::attr::Stability { - level, - feature, - rustc_depr, - promotable, - allow_const_fn_ptr, - const_stability -}); - impl_stable_hash_for!(enum ::syntax::edition::Edition { Edition2015, Edition2018, }); -impl<'a> HashStable> -for ::syntax::attr::StabilityLevel { - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - mem::discriminant(self).hash_stable(hcx, hasher); - match *self { - ::syntax::attr::StabilityLevel::Unstable { ref reason, ref issue, ref is_soft } => { - reason.hash_stable(hcx, hasher); - issue.hash_stable(hcx, hasher); - is_soft.hash_stable(hcx, hasher); - } - ::syntax::attr::StabilityLevel::Stable { ref since } => { - since.hash_stable(hcx, hasher); - } - } - } -} - -impl_stable_hash_for!(struct ::syntax::attr::RustcDeprecation { since, reason, suggestion }); - impl_stable_hash_for!(struct ::syntax::ast::Lit { kind, token, span }); -impl_stable_hash_for!(enum ::syntax::ast::LitKind { - Str(value, style), - ByteStr(value), - Byte(value), - Char(value), - Int(value, lit_int_type), - Float(value, lit_float_type), - Bool(value), - Err(value) -}); - impl_stable_hash_for_spanned!(::syntax::ast::LitKind); impl_stable_hash_for!(struct ::syntax::ast::Lifetime { id, ident }); diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index fb9c7e9bd56a8..19a8398ae78af 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1474,7 +1474,7 @@ pub enum LitFloatType { /// /// E.g., `"foo"`, `42`, `12.34`, or `bool`. // Clippy uses Hash and PartialEq -#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq, HashStable_Generic)] pub enum LitKind { /// A string literal (`"foo"`). Str(Symbol, StrStyle), diff --git a/src/libsyntax/attr/builtin.rs b/src/libsyntax/attr/builtin.rs index d7f4c9469f65f..6032e8a5b216a 100644 --- a/src/libsyntax/attr/builtin.rs +++ b/src/libsyntax/attr/builtin.rs @@ -141,7 +141,8 @@ pub fn find_unwind_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> Op } /// Represents the #[stable], #[unstable], #[rustc_{deprecated,const_unstable}] attributes. -#[derive(RustcEncodable, RustcDecodable, Copy, Clone, Debug, PartialEq, Eq, Hash)] +#[derive(RustcEncodable, RustcDecodable, Copy, Clone, Debug, + PartialEq, Eq, Hash, HashStable_Generic)] pub struct Stability { pub level: StabilityLevel, pub feature: Symbol, @@ -157,7 +158,8 @@ pub struct Stability { } /// The available stability levels. -#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Copy, Clone, Debug, Eq, Hash)] +#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, + Copy, Clone, Debug, Eq, Hash, HashStable_Generic)] pub enum StabilityLevel { // Reason for the current stability level and the relevant rust-lang issue Unstable { reason: Option, issue: Option, is_soft: bool }, @@ -181,7 +183,8 @@ impl StabilityLevel { } } -#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Copy, Clone, Debug, Eq, Hash)] +#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, + Copy, Clone, Debug, Eq, Hash, HashStable_Generic)] pub struct RustcDeprecation { pub since: Symbol, pub reason: Symbol, @@ -636,7 +639,7 @@ pub fn eval_condition(cfg: &ast::MetaItem, sess: &ParseSess, eval: &mut F) } } -#[derive(RustcEncodable, RustcDecodable, Clone)] +#[derive(RustcEncodable, RustcDecodable, Clone, HashStable_Generic)] pub struct Deprecation { pub since: Option, pub note: Option, diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index 2a48f8e44aa12..daabd0569dc0b 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -30,6 +30,7 @@ use crate::{Span, DUMMY_SP}; use crate::edition::Edition; use crate::symbol::{kw, sym, Symbol}; +use rustc_macros::HashStable_Generic; use rustc_serialize::{Encodable, Decodable, Encoder, Decoder}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lrc; @@ -707,7 +708,8 @@ impl ExpnKind { } /// The kind of macro invocation or definition. -#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, + Hash, Debug, HashStable_Generic)] pub enum MacroKind { /// A bang macro `foo!()`. Bang, From 2a67986eb6970f5ec1d4df8e409f04397568935b Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 9 Nov 2019 22:02:24 +0100 Subject: [PATCH 14/27] HashStable literals in libsyntax. --- src/librustc/ich/impls_syntax.rs | 19 ------------------- src/libsyntax/token.rs | 4 ++-- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index bf716dbf0619a..d86fd0f1dc362 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -137,25 +137,6 @@ for tokenstream::TokenStream { } } -impl_stable_hash_for!(enum token::LitKind { - Bool, - Byte, - Char, - Integer, - Float, - Str, - ByteStr, - StrRaw(n), - ByteStrRaw(n), - Err -}); - -impl_stable_hash_for!(struct token::Lit { - kind, - symbol, - suffix -}); - impl<'a> HashStable> for token::TokenKind { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { mem::discriminant(self).hash_stable(hcx, hasher); diff --git a/src/libsyntax/token.rs b/src/libsyntax/token.rs index ab798e93d67fc..8099b55780cb4 100644 --- a/src/libsyntax/token.rs +++ b/src/libsyntax/token.rs @@ -53,7 +53,7 @@ impl DelimToken { } } -#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)] +#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)] pub enum LitKind { Bool, // AST only, must never appear in a `Token` Byte, @@ -68,7 +68,7 @@ pub enum LitKind { } /// A literal token. -#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)] +#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)] pub struct Lit { pub kind: LitKind, pub symbol: Symbol, From a265bc22f161c7399c5a35835305d2dacf24753a Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 9 Nov 2019 22:25:30 +0100 Subject: [PATCH 15/27] HashStable_Generic for libsyntax_pos. --- src/librustc/ich/impls_syntax.rs | 48 -------------------------------- src/libsyntax_pos/edition.rs | 5 +++- src/libsyntax_pos/hygiene.rs | 9 +++--- src/libsyntax_pos/lib.rs | 4 ++- 4 files changed, 12 insertions(+), 54 deletions(-) diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index d86fd0f1dc362..42d6576ba6de4 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -40,11 +40,6 @@ impl_stable_hash_for!(enum ::rustc_target::spec::abi::Abi { Unadjusted }); -impl_stable_hash_for!(enum ::syntax::edition::Edition { - Edition2015, - Edition2018, -}); - impl_stable_hash_for!(struct ::syntax::ast::Lit { kind, token, @@ -222,12 +217,6 @@ impl_stable_hash_for!(enum ::syntax::ast::MetaItemKind { NameValue(lit) }); -impl_stable_hash_for!(enum ::syntax_pos::hygiene::Transparency { - Transparent, - SemiTransparent, - Opaque, -}); - impl_stable_hash_for!(struct ::syntax_pos::hygiene::ExpnData { kind, parent -> _, @@ -239,43 +228,6 @@ impl_stable_hash_for!(struct ::syntax_pos::hygiene::ExpnData { edition }); -impl_stable_hash_for!(enum ::syntax_pos::hygiene::ExpnKind { - Root, - Macro(kind, descr), - AstPass(kind), - Desugaring(kind) -}); - -impl_stable_hash_for!(enum ::syntax_pos::hygiene::AstPass { - StdImports, - TestHarness, - ProcMacroHarness, - PluginMacroDefs, -}); - -impl_stable_hash_for!(enum ::syntax_pos::hygiene::DesugaringKind { - CondTemporary, - Async, - Await, - QuestionMark, - OpaqueTy, - ForLoop, - TryBlock -}); - -impl_stable_hash_for!(enum ::syntax_pos::FileName { - Real(pb), - Macros(s), - QuoteExpansion(s), - Anon(s), - MacroExpansion(s), - ProcMacroSourceCode(s), - CliCrateAttr(s), - CfgSpec(s), - Custom(s), - DocTest(pb, line), -}); - impl<'a> HashStable> for SourceFile { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { let SourceFile { diff --git a/src/libsyntax_pos/edition.rs b/src/libsyntax_pos/edition.rs index 00cd00f283784..727aad546f5f1 100644 --- a/src/libsyntax_pos/edition.rs +++ b/src/libsyntax_pos/edition.rs @@ -2,8 +2,11 @@ use crate::symbol::{Symbol, sym}; use std::fmt; use std::str::FromStr; +use rustc_macros::HashStable_Generic; + /// The edition of the compiler (RFC 2052) -#[derive(Clone, Copy, Hash, PartialEq, PartialOrd, Debug, RustcEncodable, RustcDecodable, Eq)] +#[derive(Clone, Copy, Hash, PartialEq, PartialOrd, Debug, + RustcEncodable, RustcDecodable, Eq, HashStable_Generic)] pub enum Edition { // editions must be kept in order, oldest to newest diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index daabd0569dc0b..eb420454f03d3 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -59,7 +59,8 @@ pub struct ExpnId(u32); /// A property of a macro expansion that determines how identifiers /// produced by that expansion are resolved. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Hash, Debug, RustcEncodable, RustcDecodable)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Hash, Debug, + RustcEncodable, RustcDecodable, HashStable_Generic)] pub enum Transparency { /// Identifier produced by a transparent expansion is always resolved at call-site. /// Call-site spans in procedural macros, hygiene opt-out in `macro` should use this. @@ -684,7 +685,7 @@ impl ExpnData { } /// Expansion kind. -#[derive(Clone, Debug, RustcEncodable, RustcDecodable)] +#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable_Generic)] pub enum ExpnKind { /// No expansion, aka root expansion. Only `ExpnId::root()` has this kind. Root, @@ -744,7 +745,7 @@ impl MacroKind { } /// The kind of AST transform. -#[derive(Clone, Copy, PartialEq, Debug, RustcEncodable, RustcDecodable)] +#[derive(Clone, Copy, PartialEq, Debug, RustcEncodable, RustcDecodable, HashStable_Generic)] pub enum AstPass { StdImports, TestHarness, @@ -764,7 +765,7 @@ impl AstPass { } /// The kind of compiler desugaring. -#[derive(Clone, Copy, PartialEq, Debug, RustcEncodable, RustcDecodable)] +#[derive(Clone, Copy, PartialEq, Debug, RustcEncodable, RustcDecodable, HashStable_Generic)] pub enum DesugaringKind { /// We desugar `if c { i } else { e }` to `match $ExprKind::Use(c) { true => i, _ => e }`. /// However, we do not want to blame `c` for unreachability but rather say that `i` diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index b88d6dbc3f379..720ace90324b9 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -15,6 +15,7 @@ #![feature(step_trait)] use rustc_serialize::{Encodable, Decodable, Encoder, Decoder}; +use rustc_macros::HashStable_Generic; pub mod source_map; @@ -66,7 +67,8 @@ impl Globals { scoped_tls::scoped_thread_local!(pub static GLOBALS: Globals); /// Differentiates between real files and common virtual files. -#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, RustcDecodable, RustcEncodable)] +#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, + RustcDecodable, RustcEncodable, HashStable_Generic)] pub enum FileName { Real(PathBuf), /// A macro. This includes the full name of the macro, so that there are no clashes. From 2ba84c6bea8ce018d81b3eb2ef923aeb996f02f0 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 9 Nov 2019 22:27:52 +0100 Subject: [PATCH 16/27] HashStable_Generic for librustc_target. --- Cargo.lock | 1 + src/librustc/ich/impls_syntax.rs | 23 ----------------------- src/librustc_target/Cargo.toml | 1 + src/librustc_target/spec/abi.rs | 5 ++++- 4 files changed, 6 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 34bcba8926197..4c1dfd59e42a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3844,6 +3844,7 @@ dependencies = [ "log", "rustc_data_structures", "rustc_index", + "rustc_macros", "serialize", "syntax_pos", ] diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index 42d6576ba6de4..f8bf8f4ab8a2f 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -17,29 +17,6 @@ use crate::hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX}; use smallvec::SmallVec; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; -impl_stable_hash_for!(enum ::rustc_target::spec::abi::Abi { - Cdecl, - Stdcall, - Fastcall, - Vectorcall, - Thiscall, - Aapcs, - Win64, - SysV64, - PtxKernel, - Msp430Interrupt, - X86Interrupt, - AmdGpuKernel, - EfiApi, - Rust, - C, - System, - RustIntrinsic, - RustCall, - PlatformIntrinsic, - Unadjusted -}); - impl_stable_hash_for!(struct ::syntax::ast::Lit { kind, token, diff --git a/src/librustc_target/Cargo.toml b/src/librustc_target/Cargo.toml index c73d0adea38da..0e0732490fbbd 100644 --- a/src/librustc_target/Cargo.toml +++ b/src/librustc_target/Cargo.toml @@ -12,6 +12,7 @@ path = "lib.rs" bitflags = "1.2.1" log = "0.4" rustc_data_structures = { path = "../librustc_data_structures" } +rustc_macros = { path = "../librustc_macros" } rustc_serialize = { path = "../libserialize", package = "serialize" } syntax_pos = { path = "../libsyntax_pos" } rustc_index = { path = "../librustc_index" } diff --git a/src/librustc_target/spec/abi.rs b/src/librustc_target/spec/abi.rs index 3a24d30966f63..736358a995b64 100644 --- a/src/librustc_target/spec/abi.rs +++ b/src/librustc_target/spec/abi.rs @@ -1,9 +1,12 @@ use std::fmt; +use rustc_macros::HashStable_Generic; + #[cfg(test)] mod tests; -#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Clone, Copy, Debug)] +#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, + Clone, Copy, Debug, HashStable_Generic)] pub enum Abi { // N.B., this ordering MUST match the AbiDatas array below. // (This is ensured by the test indices_are_correct().) From 333c11433b537f7763f6a262655aadc61e58e600 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 9 Nov 2019 22:57:25 +0100 Subject: [PATCH 17/27] Derive HashStable in librustc_target. --- src/librustc/ty/layout.rs | 152 --------------------------------- src/librustc_target/abi/mod.rs | 67 +++++++++++++-- 2 files changed, 59 insertions(+), 160 deletions(-) diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 972452601ddd5..1400d5fb899ab 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -2327,158 +2327,6 @@ where } } -impl<'a> HashStable> for Variants { - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use crate::ty::layout::Variants::*; - mem::discriminant(self).hash_stable(hcx, hasher); - - match *self { - Single { index } => { - index.hash_stable(hcx, hasher); - } - Multiple { - ref discr, - ref discr_kind, - discr_index, - ref variants, - } => { - discr.hash_stable(hcx, hasher); - discr_kind.hash_stable(hcx, hasher); - discr_index.hash_stable(hcx, hasher); - variants.hash_stable(hcx, hasher); - } - } - } -} - -impl<'a> HashStable> for DiscriminantKind { - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use crate::ty::layout::DiscriminantKind::*; - mem::discriminant(self).hash_stable(hcx, hasher); - - match *self { - Tag => {} - Niche { - dataful_variant, - ref niche_variants, - niche_start, - } => { - dataful_variant.hash_stable(hcx, hasher); - niche_variants.start().hash_stable(hcx, hasher); - niche_variants.end().hash_stable(hcx, hasher); - niche_start.hash_stable(hcx, hasher); - } - } - } -} - -impl<'a> HashStable> for FieldPlacement { - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use crate::ty::layout::FieldPlacement::*; - mem::discriminant(self).hash_stable(hcx, hasher); - - match *self { - Union(count) => { - count.hash_stable(hcx, hasher); - } - Array { count, stride } => { - count.hash_stable(hcx, hasher); - stride.hash_stable(hcx, hasher); - } - Arbitrary { ref offsets, ref memory_index } => { - offsets.hash_stable(hcx, hasher); - memory_index.hash_stable(hcx, hasher); - } - } - } -} - -impl<'a> HashStable> for VariantIdx { - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - self.as_u32().hash_stable(hcx, hasher) - } -} - -impl<'a> HashStable> for Abi { - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use crate::ty::layout::Abi::*; - mem::discriminant(self).hash_stable(hcx, hasher); - - match *self { - Uninhabited => {} - Scalar(ref value) => { - value.hash_stable(hcx, hasher); - } - ScalarPair(ref a, ref b) => { - a.hash_stable(hcx, hasher); - b.hash_stable(hcx, hasher); - } - Vector { ref element, count } => { - element.hash_stable(hcx, hasher); - count.hash_stable(hcx, hasher); - } - Aggregate { sized } => { - sized.hash_stable(hcx, hasher); - } - } - } -} - -impl<'a> HashStable> for Scalar { - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - let Scalar { value, ref valid_range } = *self; - value.hash_stable(hcx, hasher); - valid_range.start().hash_stable(hcx, hasher); - valid_range.end().hash_stable(hcx, hasher); - } -} - -impl_stable_hash_for!(struct crate::ty::layout::Niche { - offset, - scalar -}); - -impl_stable_hash_for!(struct crate::ty::layout::LayoutDetails { - variants, - fields, - abi, - largest_niche, - size, - align -}); - -impl_stable_hash_for!(enum crate::ty::layout::Integer { - I8, - I16, - I32, - I64, - I128 -}); - -impl_stable_hash_for!(enum crate::ty::layout::Primitive { - Int(integer, signed), - F32, - F64, - Pointer -}); - -impl_stable_hash_for!(struct crate::ty::layout::AbiAndPrefAlign { - abi, - pref -}); - -impl<'tcx> HashStable> for Align { - fn hash_stable(&self, hcx: &mut StableHashingContext<'tcx>, hasher: &mut StableHasher) { - self.bytes().hash_stable(hcx, hasher); - } -} - -impl<'tcx> HashStable> for Size { - fn hash_stable(&self, hcx: &mut StableHashingContext<'tcx>, hasher: &mut StableHasher) { - self.bytes().hash_stable(hcx, hasher); - } -} - impl<'a, 'tcx> HashStable> for LayoutError<'tcx> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { use crate::ty::layout::LayoutError::*; diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index 2d7e05037ba0d..ff13218831c0c 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -6,6 +6,8 @@ use crate::spec::Target; use std::ops::{Add, Deref, Sub, Mul, AddAssign, Range, RangeInclusive}; use rustc_index::vec::{Idx, IndexVec}; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_macros::HashStable_Generic; use syntax_pos::Span; pub mod call; @@ -246,6 +248,12 @@ pub struct Size { raw: u64 } +impl HashStable for Size { + fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + self.bytes().hash_stable(hcx, hasher); + } +} + impl Size { pub const ZERO: Size = Self::from_bytes(0); @@ -369,6 +377,12 @@ pub struct Align { pow2: u8, } +impl HashStable for Align { + fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + self.bytes().hash_stable(hcx, hasher); + } +} + impl Align { pub fn from_bits(bits: u64) -> Result { Align::from_bytes(Size::from_bits(bits).bytes()) @@ -422,7 +436,8 @@ impl Align { } /// A pair of aligments, ABI-mandated and preferred. -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, + RustcEncodable, RustcDecodable, HashStable_Generic)] pub struct AbiAndPrefAlign { pub abi: Align, pub pref: Align, @@ -452,7 +467,7 @@ impl AbiAndPrefAlign { } /// Integers, also used for enum discriminants. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, HashStable_Generic)] pub enum Integer { I8, I16, @@ -533,7 +548,7 @@ impl Integer { } /// Fundamental unit of memory access and layout. -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)] pub enum Primitive { /// The `bool` is the signedness of the `Integer` type. /// @@ -608,6 +623,15 @@ pub struct Scalar { pub valid_range: RangeInclusive, } +impl HashStable for Scalar { + fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + let Scalar { value, ref valid_range } = *self; + value.hash_stable(hcx, hasher); + valid_range.start().hash_stable(hcx, hasher); + valid_range.end().hash_stable(hcx, hasher); + } +} + impl Scalar { pub fn is_bool(&self) -> bool { if let Int(I8, _) = self.value { @@ -636,7 +660,7 @@ impl Scalar { } /// Describes how the fields of a type are located in memory. -#[derive(PartialEq, Eq, Hash, Debug)] +#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)] pub enum FieldPlacement { /// All fields start at no offset. The `usize` is the field count. /// @@ -752,7 +776,7 @@ impl FieldPlacement { /// Describes how values of the type are passed by target ABIs, /// in terms of categories of C types there are ABI rules for. -#[derive(Clone, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)] pub enum Abi { Uninhabited, Scalar(Scalar), @@ -803,7 +827,13 @@ rustc_index::newtype_index! { pub struct VariantIdx { .. } } -#[derive(PartialEq, Eq, Hash, Debug)] +impl HashStable for VariantIdx { + fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + self.as_u32().hash_stable(hcx, hasher) + } +} + +#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)] pub enum Variants { /// Single enum variants, structs/tuples, unions, and all non-ADTs. Single { @@ -842,7 +872,28 @@ pub enum DiscriminantKind { }, } -#[derive(Clone, PartialEq, Eq, Hash, Debug)] +impl HashStable for DiscriminantKind { + fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { + use DiscriminantKind::*; + std::mem::discriminant(self).hash_stable(hcx, hasher); + + match *self { + Tag => {} + Niche { + dataful_variant, + ref niche_variants, + niche_start, + } => { + dataful_variant.hash_stable(hcx, hasher); + niche_variants.start().hash_stable(hcx, hasher); + niche_variants.end().hash_stable(hcx, hasher); + niche_start.hash_stable(hcx, hasher); + } + } + } +} + +#[derive(Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)] pub struct Niche { pub offset: Size, pub scalar: Scalar, @@ -906,7 +957,7 @@ impl Niche { } } -#[derive(PartialEq, Eq, Hash, Debug)] +#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)] pub struct LayoutDetails { pub variants: Variants, pub fields: FieldPlacement, From 375a7613036f92881f8cbc6e9cde186ee7a326c7 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 9 Nov 2019 23:18:36 +0100 Subject: [PATCH 18/27] HashStable in libsyntax. --- src/librustc/ich/impls_hir.rs | 5 ----- src/librustc/ich/impls_ty.rs | 5 ----- src/libsyntax/ast.rs | 7 +++---- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index c0255e5b8a481..bec1a14d61278 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -220,11 +220,6 @@ impl<'a> HashStable> for hir::ImplItem { } } -impl_stable_hash_for!(enum ast::CrateSugar { - JustCrate, - PubCrate, -}); - impl<'a> HashStable> for hir::VisibilityKind { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { mem::discriminant(self).hash_stable(hcx, hasher); diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index c643baf11254c..7f50d859cde3a 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -159,11 +159,6 @@ where } } -impl_stable_hash_for!(enum ::syntax::ast::Mutability { - Immutable, - Mutable -}); - impl<'a> ToStableHashKey> for region::Scope { type KeyType = region::Scope; diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 19a8398ae78af..aa658986d87b7 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -722,9 +722,8 @@ pub enum PatKind { Mac(Mac), } -#[derive( - Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug, Copy, -)] +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, + RustcEncodable, RustcDecodable, Debug, Copy, HashStable_Generic)] pub enum Mutability { Mutable, Immutable, @@ -2334,7 +2333,7 @@ impl PolyTraitRef { } } -#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug)] +#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)] pub enum CrateSugar { /// Source is `pub(crate)`. PubCrate, From 79bde05b4584db1183d25a78a3dd4eb377dcb01a Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 9 Nov 2019 23:32:17 +0100 Subject: [PATCH 19/27] Derive HashStable for PanicStrategy. --- src/librustc/ich/impls_misc.rs | 7 ------- src/librustc/ich/mod.rs | 1 - src/librustc_target/spec/mod.rs | 4 +++- 3 files changed, 3 insertions(+), 9 deletions(-) delete mode 100644 src/librustc/ich/impls_misc.rs diff --git a/src/librustc/ich/impls_misc.rs b/src/librustc/ich/impls_misc.rs deleted file mode 100644 index 417305139e472..0000000000000 --- a/src/librustc/ich/impls_misc.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! This module contains `HashStable` implementations for various data types -//! that don't fit into any of the other impls_xxx modules. - -impl_stable_hash_for!(enum ::rustc_target::spec::PanicStrategy { - Abort, - Unwind -}); diff --git a/src/librustc/ich/mod.rs b/src/librustc/ich/mod.rs index f3fc7ec8fda15..9e985ffb14ca7 100644 --- a/src/librustc/ich/mod.rs +++ b/src/librustc/ich/mod.rs @@ -10,7 +10,6 @@ mod caching_source_map_view; mod hcx; mod impls_hir; -mod impls_misc; mod impls_ty; mod impls_syntax; diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 4cd2f13d09cbd..716aef056a35b 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -42,6 +42,8 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use crate::spec::abi::{Abi, lookup as lookup_abi}; +use rustc_macros::HashStable_Generic; + pub mod abi; mod android_base; mod apple_base; @@ -153,7 +155,7 @@ flavor_mappings! { ((LinkerFlavor::Lld(LldFlavor::Link)), "lld-link"), } -#[derive(Clone, Copy, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)] +#[derive(Clone, Copy, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable, HashStable_Generic)] pub enum PanicStrategy { Unwind, Abort, From e8e7ad6fb86dc07cb4466a170a38b97d38746902 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 16 Nov 2019 11:45:57 +0100 Subject: [PATCH 20/27] Implement HashStable for RangeInclusive. --- src/librustc_data_structures/stable_hasher.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/librustc_data_structures/stable_hasher.rs b/src/librustc_data_structures/stable_hasher.rs index 092208cfe1db7..ce62021ac1711 100644 --- a/src/librustc_data_structures/stable_hasher.rs +++ b/src/librustc_data_structures/stable_hasher.rs @@ -429,6 +429,16 @@ impl HashStable for ::std::mem::Discriminant { } } +impl HashStable for ::std::ops::RangeInclusive + where T: HashStable +{ + #[inline] + fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) { + self.start().hash_stable(ctx, hasher); + self.end().hash_stable(ctx, hasher); + } +} + impl HashStable for vec::IndexVec where T: HashStable, { From 5b4dad7ad2666237a45e0467374fd744dd01bb6e Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 16 Nov 2019 11:52:00 +0100 Subject: [PATCH 21/27] Derive HashStable_Generic for ABI types. --- src/librustc_target/abi/mod.rs | 60 +++++----------------------------- 1 file changed, 8 insertions(+), 52 deletions(-) diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index ff13218831c0c..ac781819cc35e 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -6,7 +6,6 @@ use crate::spec::Target; use std::ops::{Add, Deref, Sub, Mul, AddAssign, Range, RangeInclusive}; use rustc_index::vec::{Idx, IndexVec}; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_macros::HashStable_Generic; use syntax_pos::Span; @@ -244,16 +243,11 @@ pub enum Endian { /// Size of a type in bytes. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)] +#[derive(HashStable_Generic)] pub struct Size { raw: u64 } -impl HashStable for Size { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - self.bytes().hash_stable(hcx, hasher); - } -} - impl Size { pub const ZERO: Size = Self::from_bytes(0); @@ -373,16 +367,11 @@ impl AddAssign for Size { /// Alignment of a type in bytes (always a power of two). #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)] +#[derive(HashStable_Generic)] pub struct Align { pow2: u8, } -impl HashStable for Align { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - self.bytes().hash_stable(hcx, hasher); - } -} - impl Align { pub fn from_bits(bits: u64) -> Result { Align::from_bytes(Size::from_bits(bits).bytes()) @@ -436,8 +425,8 @@ impl Align { } /// A pair of aligments, ABI-mandated and preferred. -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, - RustcEncodable, RustcDecodable, HashStable_Generic)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)] +#[derive(HashStable_Generic)] pub struct AbiAndPrefAlign { pub abi: Align, pub pref: Align, @@ -603,6 +592,7 @@ impl Primitive { /// Information about one scalar component of a Rust type. #[derive(Clone, PartialEq, Eq, Hash, Debug)] +#[derive(HashStable_Generic)] pub struct Scalar { pub value: Primitive, @@ -623,15 +613,6 @@ pub struct Scalar { pub valid_range: RangeInclusive, } -impl HashStable for Scalar { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - let Scalar { value, ref valid_range } = *self; - value.hash_stable(hcx, hasher); - valid_range.start().hash_stable(hcx, hasher); - valid_range.end().hash_stable(hcx, hasher); - } -} - impl Scalar { pub fn is_bool(&self) -> bool { if let Int(I8, _) = self.value { @@ -824,12 +805,8 @@ impl Abi { } rustc_index::newtype_index! { - pub struct VariantIdx { .. } -} - -impl HashStable for VariantIdx { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - self.as_u32().hash_stable(hcx, hasher) + pub struct VariantIdx { + derive [HashStable_Generic] } } @@ -851,7 +828,7 @@ pub enum Variants { }, } -#[derive(PartialEq, Eq, Hash, Debug)] +#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)] pub enum DiscriminantKind { /// Integer tag holding the discriminant value itself. Tag, @@ -872,27 +849,6 @@ pub enum DiscriminantKind { }, } -impl HashStable for DiscriminantKind { - fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - use DiscriminantKind::*; - std::mem::discriminant(self).hash_stable(hcx, hasher); - - match *self { - Tag => {} - Niche { - dataful_variant, - ref niche_variants, - niche_start, - } => { - dataful_variant.hash_stable(hcx, hasher); - niche_variants.start().hash_stable(hcx, hasher); - niche_variants.end().hash_stable(hcx, hasher); - niche_start.hash_stable(hcx, hasher); - } - } - } -} - #[derive(Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)] pub struct Niche { pub offset: Size, From 3d97a91e7f896e8fbb94fef43dd57f2e6fb061c8 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 16 Nov 2019 11:53:44 +0100 Subject: [PATCH 22/27] Remove extern crate. --- src/libsyntax/ast.rs | 1 + src/libsyntax/attr/builtin.rs | 1 + src/libsyntax/lib.rs | 2 -- src/libsyntax/token.rs | 1 + 4 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index aa658986d87b7..a9f03e4af5b65 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -37,6 +37,7 @@ use rustc_data_structures::sync::Lrc; use rustc_data_structures::thin_vec::ThinVec; use rustc_index::vec::Idx; use rustc_serialize::{self, Decoder, Encoder}; +use rustc_macros::HashStable_Generic; use std::fmt; diff --git a/src/libsyntax/attr/builtin.rs b/src/libsyntax/attr/builtin.rs index 6032e8a5b216a..c10541c8c7e75 100644 --- a/src/libsyntax/attr/builtin.rs +++ b/src/libsyntax/attr/builtin.rs @@ -9,6 +9,7 @@ use errors::{Applicability, Handler}; use std::num::NonZeroU32; use syntax_pos::hygiene::Transparency; use syntax_pos::{symbol::Symbol, symbol::sym, Span}; +use rustc_macros::HashStable_Generic; use super::{mark_used, MetaItemKind}; diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 23db4cf985cdc..e3eca75dfe7e7 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -19,8 +19,6 @@ #![recursion_limit="256"] -#[macro_use] extern crate rustc_macros; - pub use errors; use rustc_data_structures::sync::Lock; use rustc_index::bit_set::GrowableBitSet; diff --git a/src/libsyntax/token.rs b/src/libsyntax/token.rs index 8099b55780cb4..fd1623384a443 100644 --- a/src/libsyntax/token.rs +++ b/src/libsyntax/token.rs @@ -15,6 +15,7 @@ use syntax_pos::{self, Span, DUMMY_SP}; use std::fmt; use std::mem; use rustc_data_structures::sync::Lrc; +use rustc_macros::HashStable_Generic; #[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] pub enum BinOpToken { From 44a595f52ca0dec2cf7a08ba182ce9f1eb637795 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 16 Nov 2019 11:59:46 +0100 Subject: [PATCH 23/27] Simplify impl for SymbolStr. --- src/libsyntax_pos/symbol.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index f63776338577e..d885133db65cf 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -1157,8 +1157,7 @@ impl fmt::Display for SymbolStr { impl HashStable for SymbolStr { #[inline] fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { - let str = self as &str; - str.hash_stable(hcx, hasher) + self.string.hash_stable(hcx, hasher) } } From eda67ba05cccba4a3360fd27ffc033765a9b41d9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 18 Nov 2019 07:41:10 -0800 Subject: [PATCH 24/27] Disable gdb pretty printer global section on wasm targets The wasm targets don't support gdb anyway so there's no need for this section there. --- src/librustc_target/spec/wasm32_base.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustc_target/spec/wasm32_base.rs b/src/librustc_target/spec/wasm32_base.rs index 6f00245b00941..e18a9e66468c7 100644 --- a/src/librustc_target/spec/wasm32_base.rs +++ b/src/librustc_target/spec/wasm32_base.rs @@ -140,6 +140,9 @@ pub fn options() -> TargetOptions { has_elf_tls: true, tls_model: "local-exec".to_string(), + // gdb scripts don't work on wasm blobs + emit_debug_gdb_scripts: false, + .. Default::default() } } From c90ad207ee31d8d240eca6de3cd53e1121d9d8b4 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 11 Nov 2019 14:31:32 +0100 Subject: [PATCH 25/27] ci: add support for GitHub Actions in the CI scripts --- src/bootstrap/util.rs | 4 ++ src/ci/azure-pipelines/steps/run.yml | 31 ------------ src/ci/docker/run.sh | 2 + src/ci/run.sh | 4 +- src/ci/scripts/install-mingw.sh | 2 +- src/ci/scripts/install-msys2.sh | 6 +-- src/ci/shared.sh | 71 ++++++++++++++++++++++++---- 7 files changed, 73 insertions(+), 47 deletions(-) diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index 98ae7b692bb3c..6f8a630874570 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -262,6 +262,8 @@ pub enum CiEnv { None, /// The Azure Pipelines environment, for Linux (including Docker), Windows, and macOS builds. AzurePipelines, + /// The GitHub Actions environment, for Linux (including Docker), Windows and macOS builds. + GitHubActions, } impl CiEnv { @@ -269,6 +271,8 @@ impl CiEnv { pub fn current() -> CiEnv { if env::var("TF_BUILD").ok().map_or(false, |e| &*e == "True") { CiEnv::AzurePipelines + } else if env::var("GITHUB_ACTIONS").ok().map_or(false, |e| &*e == "true") { + CiEnv::GitHubActions } else { CiEnv::None } diff --git a/src/ci/azure-pipelines/steps/run.yml b/src/ci/azure-pipelines/steps/run.yml index 214c11fd69024..698aa5f2cf1ad 100644 --- a/src/ci/azure-pipelines/steps/run.yml +++ b/src/ci/azure-pipelines/steps/run.yml @@ -38,38 +38,26 @@ steps: displayName: Show the current environment - bash: src/ci/scripts/install-sccache.sh - env: - AGENT_OS: $(Agent.OS) displayName: Install sccache condition: and(succeeded(), not(variables.SKIP_JOB)) - bash: src/ci/scripts/install-clang.sh - env: - AGENT_OS: $(Agent.OS) displayName: Install clang condition: and(succeeded(), not(variables.SKIP_JOB)) - bash: src/ci/scripts/switch-xcode.sh - env: - AGENT_OS: $(Agent.OS) displayName: Switch to Xcode 9.3 condition: and(succeeded(), not(variables.SKIP_JOB)) - bash: src/ci/scripts/install-wix.sh - env: - AGENT_OS: $(Agent.OS) displayName: Install wix condition: and(succeeded(), not(variables.SKIP_JOB)) - bash: src/ci/scripts/install-innosetup.sh - env: - AGENT_OS: $(Agent.OS) displayName: Install InnoSetup condition: and(succeeded(), not(variables.SKIP_JOB)) - bash: src/ci/scripts/windows-symlink-build-dir.sh - env: - AGENT_OS: $(Agent.OS) displayName: Ensure the build happens on C:\ instead of D:\ condition: and(succeeded(), not(variables.SKIP_JOB)) @@ -78,35 +66,22 @@ steps: condition: and(succeeded(), not(variables.SKIP_JOB)) - bash: src/ci/scripts/install-msys2.sh - env: - AGENT_OS: $(Agent.OS) - SYSTEM_WORKFOLDER: $(System.Workfolder) displayName: Install msys2 condition: and(succeeded(), not(variables.SKIP_JOB)) - bash: src/ci/scripts/install-msys2-packages.sh - env: - AGENT_OS: $(Agent.OS) - SYSTEM_WORKFOLDER: $(System.Workfolder) displayName: Install msys2 packages condition: and(succeeded(), not(variables.SKIP_JOB)) - bash: src/ci/scripts/install-mingw.sh - env: - AGENT_OS: $(Agent.OS) - SYSTEM_WORKFOLDER: $(System.Workfolder) displayName: Install MinGW condition: and(succeeded(), not(variables.SKIP_JOB)) - bash: src/ci/scripts/install-ninja.sh - env: - AGENT_OS: $(Agent.OS) displayName: Install ninja condition: and(succeeded(), not(variables.SKIP_JOB)) - bash: src/ci/scripts/enable-docker-ipv6.sh - env: - AGENT_OS: $(Agent.OS) displayName: Enable IPv6 on Docker condition: and(succeeded(), not(variables.SKIP_JOB)) @@ -120,22 +95,16 @@ steps: condition: and(succeeded(), not(variables.SKIP_JOB)) - bash: src/ci/scripts/checkout-submodules.sh - env: - AGENT_OS: $(Agent.OS) displayName: Checkout submodules condition: and(succeeded(), not(variables.SKIP_JOB)) - bash: src/ci/scripts/verify-line-endings.sh - env: - AGENT_OS: $(Agent.OS) displayName: Verify line endings condition: and(succeeded(), not(variables.SKIP_JOB)) # Ensure the `aws` CLI is installed so we can deploy later on, cache docker # images, etc. - bash: src/ci/scripts/install-awscli.sh - env: - AGENT_OS: $(Agent.OS) condition: and(succeeded(), not(variables.SKIP_JOB)) displayName: Install awscli diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index cdafcbadc9ec7..f29f9f3bf1c45 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -172,6 +172,8 @@ docker \ --env CI \ --env TF_BUILD \ --env BUILD_SOURCEBRANCHNAME \ + --env GITHUB_ACTIONS \ + --env GITHUB_REF \ --env TOOLSTATE_REPO_ACCESS_TOKEN \ --env TOOLSTATE_REPO \ --env TOOLSTATE_PUBLISH \ diff --git a/src/ci/run.sh b/src/ci/run.sh index bce35670c8d46..ae5b22493ab07 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -23,9 +23,7 @@ fi ci_dir=`cd $(dirname $0) && pwd` source "$ci_dir/shared.sh" -branch_name=$(getCIBranch) - -if [ ! isCI ] || [ "$branch_name" = "auto" ] || [ "$branch_name" = "try" ]; then +if [ ! isCI ] || isCiBranch auto || isCiBranch beta; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set build.print-step-timings --enable-verbose-tests" fi diff --git a/src/ci/scripts/install-mingw.sh b/src/ci/scripts/install-mingw.sh index 8b579587b9e1f..98373df7fce50 100755 --- a/src/ci/scripts/install-mingw.sh +++ b/src/ci/scripts/install-mingw.sh @@ -52,7 +52,7 @@ if isWindows; then if [[ "${CUSTOM_MINGW-0}" -ne 1 ]]; then pacman -S --noconfirm --needed mingw-w64-$arch-toolchain mingw-w64-$arch-cmake \ mingw-w64-$arch-gcc mingw-w64-$arch-python2 - ciCommandAddPath "${SYSTEM_WORKFOLDER}/msys2/mingw${bits}/bin" + ciCommandAddPath "$(ciCheckoutPath)/msys2/mingw${bits}/bin" else mingw_dir="mingw${bits}" diff --git a/src/ci/scripts/install-msys2.sh b/src/ci/scripts/install-msys2.sh index ce37c3b146977..c9fafc7fe6b41 100755 --- a/src/ci/scripts/install-msys2.sh +++ b/src/ci/scripts/install-msys2.sh @@ -12,8 +12,8 @@ IFS=$'\n\t' source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" if isWindows; then - choco install msys2 --params="/InstallDir:${SYSTEM_WORKFOLDER}/msys2 /NoPath" -y --no-progress - mkdir -p "${SYSTEM_WORKFOLDER}/msys2/home/${USERNAME}" + choco install msys2 --params="/InstallDir:$(ciCheckoutPath)/msys2 /NoPath" -y --no-progress + mkdir -p "$(ciCheckoutPath)/msys2/home/${USERNAME}" - ciCommandAddPath "${SYSTEM_WORKFOLDER}/msys2/usr/bin" + ciCommandAddPath "$(ciCheckoutPath)/msys2/usr/bin" fi diff --git a/src/ci/shared.sh b/src/ci/shared.sh index 862ded0d5dbf0..394a57158873c 100644 --- a/src/ci/shared.sh +++ b/src/ci/shared.sh @@ -27,27 +27,66 @@ function retry { } function isCI { - [ "$CI" = "true" ] || [ "$TF_BUILD" = "True" ] + [[ "${CI-false}" = "true" ]] || isAzurePipelines || isGitHubActions +} + +function isAzurePipelines { + [[ "${TF_BUILD-False}" = "True" ]] +} + +function isGitHubActions { + [[ "${GITHUB_ACTIONS-false}" = "true" ]] } function isMacOS { - [ "$AGENT_OS" = "Darwin" ] + [[ "${OSTYPE}" = "darwin"* ]] } function isWindows { - [ "$AGENT_OS" = "Windows_NT" ] + [[ "${OSTYPE}" = "cygwin" ]] || [[ "${OSTYPE}" = "msys" ]] } function isLinux { - [ "$AGENT_OS" = "Linux" ] + [[ "${OSTYPE}" = "linux-gnu" ]] } -function getCIBranch { - echo "$BUILD_SOURCEBRANCHNAME" +function isCiBranch { + if [[ $# -ne 1 ]]; then + echo "usage: $0 " + exit 1 + fi + name="$1" + + if isAzurePipelines; then + [[ "${BUILD_SOURCEBRANCHNAME}" = "${name}" ]] + elif isGitHubActions; then + [[ "${GITHUB_REF}" = "refs/heads/${name}" ]] + else + echo "isCiBranch only works inside CI!" + exit 1 + fi } function ciCommit { - echo "${BUILD_SOURCEVERSION}" + if isAzurePipelines; then + echo "${BUILD_SOURCEVERSION}" + elif isGitHubActions; then + echo "${GITHUB_SHA}" + else + echo "ciCommit only works inside CI!" + exit 1 + fi +} + +function ciCheckoutPath { + if isAzurePipelines; then + echo "${BUILD_WORKFOLDER}" + elif isGitHubActions; then + echo "${GITHUB_WORKSPACE}" + else + echo "ciCheckoutPath only works inside CI!" + exit 1 + fi } function ciCommandAddPath { @@ -57,7 +96,14 @@ function ciCommandAddPath { fi path="$1" - echo "##vso[task.prependpath]${path}" + if isAzurePipelines; then + echo "##vso[task.prependpath]${path}" + elif isGitHubActions; then + echo "::add-path::${value}" + else + echo "ciCommandAddPath only works inside CI!" + exit 1 + fi } function ciCommandSetEnv { @@ -68,5 +114,12 @@ function ciCommandSetEnv { name="$1" value="$2" - echo "##vso[task.setvariable variable=${name}]${value}" + if isAzurePipelines; then + echo "##vso[task.setvariable variable=${name}]${value}" + elif isGitHubActions; then + echo "::set-env name=${name}::${value}" + else + echo "ciCommandSetEnv only works inside CI!" + exit 1 + fi } From bca64ce869311a79107f341bba777dd8dc32863b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 18 Nov 2019 21:00:24 -0800 Subject: [PATCH 26/27] Point at type in `let` assignment on type errors --- src/librustc_typeck/check/demand.rs | 28 +++- .../failed-doctest-missing-codes.stdout | 4 +- src/test/ui/array-not-vector.stderr | 8 +- .../associated-types-eq-3.stderr | 4 +- .../associated-types-path-2.stderr | 4 +- src/test/ui/c-variadic/variadic-ffi-1.stderr | 8 +- src/test/ui/closures/closure-no-fn-1.stderr | 4 +- src/test/ui/closures/closure-no-fn-2.stderr | 4 +- src/test/ui/coercion/coerce-to-bang.stderr | 4 +- src/test/ui/coercion/coercion-slice.stderr | 9 +- .../fn-const-param-infer.stderr | 8 +- .../const-generics/raw-ptr-const-param.stderr | 4 +- .../slice-const-param-mismatch.stderr | 12 +- .../types-mismatch-const-args.stderr | 8 +- src/test/ui/conversion-methods.stderr | 36 ++--- src/test/ui/cross/cross-borrow-trait.stderr | 9 +- ...xpected-float-found-integer-literal.stderr | 35 +++-- .../did_you_mean/recursion_limit_deref.stderr | 4 +- src/test/ui/dst/dst-bad-coerce1.stderr | 8 +- src/test/ui/dst/dst-bad-coerce2.stderr | 16 ++- src/test/ui/dst/dst-bad-coerce4.stderr | 8 +- src/test/ui/dst/dst-bad-coercions.stderr | 38 ++++-- ...loat-literal-inference-restrictions.stderr | 13 +- src/test/ui/fn/fn-trait-formatting.stderr | 12 +- .../generic-type-params-name-repr.stderr | 24 +++- src/test/ui/hrtb/hrtb-exists-forall-fn.stderr | 4 +- src/test/ui/impl-trait/equality2.stderr | 8 +- .../ui/include-macros/mismatched-types.stderr | 8 +- src/test/ui/issues/issue-1362.stderr | 4 +- src/test/ui/issues/issue-22684.stderr | 4 +- src/test/ui/issues/issue-24322.stderr | 4 +- src/test/ui/issues/issue-27042.stderr | 4 + src/test/ui/issues/issue-3477.stderr | 4 +- src/test/ui/issues/issue-37665.stderr | 4 +- src/test/ui/issues/issue-38940.stderr | 4 +- src/test/ui/issues/issue-5100.stderr | 4 +- src/test/ui/issues/issue-53692.stderr | 18 +-- src/test/ui/issues/issue-56943.stderr | 4 +- .../ui/json-bom-plus-crlf-multifile.stderr | 8 +- src/test/ui/json-bom-plus-crlf.stderr | 8 +- .../meta-expected-error-correct-rev.a.stderr | 4 +- ...od-ambig-one-trait-unknown-int-type.stderr | 4 +- ...e-trait-object-with-separate-params.stderr | 20 ++- src/test/ui/mir-unpretty.stderr | 4 +- src/test/ui/mismatched_types/main.stderr | 4 +- .../never_type/never-assign-wrong-type.stderr | 4 +- src/test/ui/noexporttypeexe.stderr | 4 +- src/test/ui/numeric/const-scope.stderr | 16 ++- src/test/ui/numeric/numeric-cast-2.stderr | 12 +- .../issue-64879-trailing-before-guard.stderr | 4 +- .../or-patterns-syntactic-fail.stderr | 9 +- .../ui/parser/lex-bad-char-literals-6.stderr | 4 +- src/test/ui/parser/numeric-lifetime.stderr | 4 +- .../ui/parser/recover-from-homoglyph.stderr | 4 +- .../ui/parser/recover-missing-semi.stderr | 8 +- src/test/ui/parser/recover-tuple.stderr | 4 +- .../parser/unclosed-delimiter-in-dep.stderr | 4 +- .../attribute-spans-preserved.stderr | 8 +- .../ui/proc-macro/attribute-with-error.stderr | 16 ++- .../ui/proc-macro/nested-item-spans.stderr | 8 +- .../ui/proc-macro/span-preservation.stderr | 4 +- src/test/ui/ptr-coercion.stderr | 12 +- ...lifetime-bounds-on-fns-where-clause.stderr | 4 +- ...lifetime-bounds-on-fns-where-clause.stderr | 4 +- .../regions-lifetime-bounds-on-fns.stderr | 4 +- src/test/ui/reify-intrinsic.stderr | 9 +- src/test/ui/resolve/privacy-enum-ctor.stderr | 27 ++-- src/test/ui/shift-various-bad-types.stderr | 4 +- src/test/ui/slice-mut.stderr | 4 +- src/test/ui/span/coerce-suggestions.stderr | 13 +- src/test/ui/span/move-closure.stderr | 4 +- src/test/ui/str/str-array-assignment.stderr | 9 +- src/test/ui/str/str-lit-type-mismatch.stderr | 27 ++-- .../ui/struct-literal-variant-in-if.stderr | 4 +- src/test/ui/substs-ppaux.normal.stderr | 36 ++--- src/test/ui/substs-ppaux.verbose.stderr | 36 ++--- src/test/ui/suggestions/as-ref.stderr | 17 ++- .../fn-or-tuple-struct-without-args.stderr | 126 ++++++++++-------- src/test/ui/suggestions/format-borrow.stderr | 18 +-- src/test/ui/suggestions/issue-59819.stderr | 27 ++-- .../mismatched-types-numeric-from.stderr | 4 +- ...ecover-from-semicolon-trailing-item.stderr | 8 +- src/test/ui/suggestions/suggest-box.stderr | 4 +- .../tag-that-dare-not-speak-its-name.stderr | 4 +- .../non-whitespace-trimming-2.stderr | 6 +- .../non-whitespace-trimming-unicode.stderr | 6 +- .../non-whitespace-trimming.stderr | 6 +- .../terminal-width/whitespace-trimming.stderr | 4 +- ...priority-higher-than-other-inherent.stderr | 4 +- ...eric_type_does_not_live_long_enough.stderr | 4 +- .../never_reveal_concrete_type.stderr | 4 +- ...o_revealing_outside_defining_module.stderr | 4 +- .../assignment-expected-bool.stderr | 4 +- .../ui/type/type-mismatch-multiple.stderr | 8 +- src/test/ui/type/type-shadow.stderr | 4 +- .../typeck_type_placeholder_mismatch.stderr | 8 +- src/test/ui/wrong-mul-method-signature.stderr | 4 +- 97 files changed, 672 insertions(+), 350 deletions(-) diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 5d9b3a8fba4d7..6a7cf4dd32878 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -102,12 +102,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // N.B., this code relies on `self.diverges` to be accurate. In // particular, assignments to `!` will be permitted if the // diverges flag is currently "always". - pub fn demand_coerce_diag(&self, - expr: &hir::Expr, - checked_ty: Ty<'tcx>, - expected: Ty<'tcx>, - allow_two_phase: AllowTwoPhase) - -> (Ty<'tcx>, Option>) { + pub fn demand_coerce_diag( + &self, + expr: &hir::Expr, + checked_ty: Ty<'tcx>, + expected: Ty<'tcx>, + allow_two_phase: AllowTwoPhase, + ) -> (Ty<'tcx>, Option>) { let expected = self.resolve_vars_with_obligations(expected); let e = match self.try_coerce(expr, checked_ty, expected, allow_two_phase) { @@ -126,6 +127,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return (expected, None) } + self.annotate_expected_due_to_let_ty(&mut err, expr); self.suggest_compatible_variants(&mut err, expr, expected, expr_ty); self.suggest_ref_or_into(&mut err, expr, expected, expr_ty); self.suggest_boxing_when_appropriate(&mut err, expr, expected, expr_ty); @@ -134,6 +136,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { (expected, Some(err)) } + fn annotate_expected_due_to_let_ty(&self, err: &mut DiagnosticBuilder<'_>, expr: &hir::Expr) { + let parent = self.tcx.hir().get_parent_node(expr.hir_id); + if let Some(hir::Node::Local(hir::Local { + ty: Some(ty), + init: Some(init), + .. + })) = self.tcx.hir().find(parent) { + if init.hir_id == expr.hir_id { + // Point at `let` assignment type. + err.span_label(ty.span, "expected due to this"); + } + } + } + /// Returns whether the expected type is `bool` and the expression is `x = y`. pub fn is_assign_to_bool(&self, expr: &hir::Expr, expected: Ty<'tcx>) -> bool { if let hir::ExprKind::Assign(..) = expr.kind { diff --git a/src/test/rustdoc-ui/failed-doctest-missing-codes.stdout b/src/test/rustdoc-ui/failed-doctest-missing-codes.stdout index a8753d14de22f..f4ee2970950d4 100644 --- a/src/test/rustdoc-ui/failed-doctest-missing-codes.stdout +++ b/src/test/rustdoc-ui/failed-doctest-missing-codes.stdout @@ -9,7 +9,9 @@ error[E0308]: mismatched types --> $DIR/failed-doctest-missing-codes.rs:9:13 | LL | let x: () = 5i32; - | ^^^^ expected (), found i32 + | -- ^^^^ expected (), found i32 + | | + | expected due to this | = note: expected type `()` found type `i32` diff --git a/src/test/ui/array-not-vector.stderr b/src/test/ui/array-not-vector.stderr index b5a5389db093a..cd87a9f67c2d6 100644 --- a/src/test/ui/array-not-vector.stderr +++ b/src/test/ui/array-not-vector.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/array-not-vector.rs:2:19 | LL | let _x: i32 = [1, 2, 3]; - | ^^^^^^^^^ expected i32, found array of 3 elements + | --- ^^^^^^^^^ expected i32, found array of 3 elements + | | + | expected due to this | = note: expected type `i32` found type `[{integer}; 3]` @@ -11,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/array-not-vector.rs:9:20 | LL | let _y: &i32 = x; - | ^ expected i32, found slice + | ---- ^ expected i32, found slice + | | + | expected due to this | = note: expected type `&i32` found type `&[i32]` diff --git a/src/test/ui/associated-types/associated-types-eq-3.stderr b/src/test/ui/associated-types/associated-types-eq-3.stderr index 0f2bc84aa1c59..882556f0199de 100644 --- a/src/test/ui/associated-types/associated-types-eq-3.stderr +++ b/src/test/ui/associated-types/associated-types-eq-3.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/associated-types-eq-3.rs:23:18 | LL | let _: Bar = x.boo(); - | ^^^^^^^ expected struct `Bar`, found associated type + | --- ^^^^^^^ expected struct `Bar`, found associated type + | | + | expected due to this | = note: expected type `Bar` found type `::A` diff --git a/src/test/ui/associated-types/associated-types-path-2.stderr b/src/test/ui/associated-types/associated-types-path-2.stderr index 246c745cd3385..c2026c5291147 100644 --- a/src/test/ui/associated-types/associated-types-path-2.stderr +++ b/src/test/ui/associated-types/associated-types-path-2.stderr @@ -43,7 +43,9 @@ error[E0308]: mismatched types --> $DIR/associated-types-path-2.rs:41:18 | LL | let _: i32 = f2(2i32); - | ^^^^^^^^ expected i32, found u32 + | --- ^^^^^^^^ expected i32, found u32 + | | + | expected due to this | help: you can convert an `u32` to `i32` and panic if the converted value wouldn't fit | diff --git a/src/test/ui/c-variadic/variadic-ffi-1.stderr b/src/test/ui/c-variadic/variadic-ffi-1.stderr index 73f72a177bcaa..d3b24b4a2694a 100644 --- a/src/test/ui/c-variadic/variadic-ffi-1.stderr +++ b/src/test/ui/c-variadic/variadic-ffi-1.stderr @@ -26,7 +26,9 @@ error[E0308]: mismatched types --> $DIR/variadic-ffi-1.rs:19:56 | LL | let x: unsafe extern "C" fn(f: isize, x: u8) = foo; - | ^^^ expected non-variadic fn, found variadic function + | ------------------------------------- ^^^ expected non-variadic fn, found variadic function + | | + | expected due to this | = note: expected type `unsafe extern "C" fn(isize, u8)` found type `unsafe extern "C" fn(isize, u8, ...) {foo}` @@ -35,7 +37,9 @@ error[E0308]: mismatched types --> $DIR/variadic-ffi-1.rs:20:54 | LL | let y: extern "C" fn(f: isize, x: u8, ...) = bar; - | ^^^ expected variadic fn, found non-variadic function + | ----------------------------------- ^^^ expected variadic fn, found non-variadic function + | | + | expected due to this | = note: expected type `extern "C" fn(isize, u8, ...)` found type `extern "C" fn(isize, u8) {bar}` diff --git a/src/test/ui/closures/closure-no-fn-1.stderr b/src/test/ui/closures/closure-no-fn-1.stderr index 6d07c6b035ee4..8405846513d09 100644 --- a/src/test/ui/closures/closure-no-fn-1.stderr +++ b/src/test/ui/closures/closure-no-fn-1.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/closure-no-fn-1.rs:6:29 | LL | let foo: fn(u8) -> u8 = |v: u8| { a += v; a }; - | ^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found closure + | ------------ ^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found closure + | | + | expected due to this | = note: expected type `fn(u8) -> u8` found type `[closure@$DIR/closure-no-fn-1.rs:6:29: 6:50 a:_]` diff --git a/src/test/ui/closures/closure-no-fn-2.stderr b/src/test/ui/closures/closure-no-fn-2.stderr index 5adcdf6058b71..5126a8db0551e 100644 --- a/src/test/ui/closures/closure-no-fn-2.stderr +++ b/src/test/ui/closures/closure-no-fn-2.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/closure-no-fn-2.rs:6:27 | LL | let bar: fn() -> u8 = || { b }; - | ^^^^^^^^ expected fn pointer, found closure + | ---------- ^^^^^^^^ expected fn pointer, found closure + | | + | expected due to this | = note: expected type `fn() -> u8` found type `[closure@$DIR/closure-no-fn-2.rs:6:27: 6:35 b:_]` diff --git a/src/test/ui/coercion/coerce-to-bang.stderr b/src/test/ui/coercion/coerce-to-bang.stderr index a46e97da8159b..0aa4bc3fe25ed 100644 --- a/src/test/ui/coercion/coerce-to-bang.stderr +++ b/src/test/ui/coercion/coerce-to-bang.stderr @@ -47,7 +47,9 @@ error[E0308]: mismatched types --> $DIR/coerce-to-bang.rs:50:21 | LL | let x: [!; 2] = [return, 22]; - | ^^^^^^^^^^^^ expected !, found integer + | ------ ^^^^^^^^^^^^ expected !, found integer + | | + | expected due to this | = note: expected type `[!; 2]` found type `[{integer}; 2]` diff --git a/src/test/ui/coercion/coercion-slice.stderr b/src/test/ui/coercion/coercion-slice.stderr index ccd776e987938..f274f3dc9ef60 100644 --- a/src/test/ui/coercion/coercion-slice.stderr +++ b/src/test/ui/coercion/coercion-slice.stderr @@ -2,10 +2,11 @@ error[E0308]: mismatched types --> $DIR/coercion-slice.rs:4:21 | LL | let _: &[i32] = [0]; - | ^^^ - | | - | expected &[i32], found array of 1 element - | help: consider borrowing here: `&[0]` + | ------ ^^^ + | | | + | | expected &[i32], found array of 1 element + | | help: consider borrowing here: `&[0]` + | expected due to this | = note: expected type `&[i32]` found type `[{integer}; 1]` diff --git a/src/test/ui/const-generics/fn-const-param-infer.stderr b/src/test/ui/const-generics/fn-const-param-infer.stderr index e36bb824151f7..d39c367f182b2 100644 --- a/src/test/ui/const-generics/fn-const-param-infer.stderr +++ b/src/test/ui/const-generics/fn-const-param-infer.stderr @@ -10,7 +10,9 @@ error[E0308]: mismatched types --> $DIR/fn-const-param-infer.rs:16:31 | LL | let _: Checked = Checked::; - | ^^^^^^^^^^^^^^^^^^ expected `not_one`, found `not_two` + | ---------------- ^^^^^^^^^^^^^^^^^^ expected `not_one`, found `not_two` + | | + | expected due to this | = note: expected type `Checked` found type `Checked` @@ -34,7 +36,9 @@ error[E0308]: mismatched types --> $DIR/fn-const-param-infer.rs:25:40 | LL | let _: Checked<{generic::}> = Checked::<{generic::}>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `generic::`, found `generic::` + | ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `generic::`, found `generic::` + | | + | expected due to this | = note: expected type `Checked>` found type `Checked>` diff --git a/src/test/ui/const-generics/raw-ptr-const-param.stderr b/src/test/ui/const-generics/raw-ptr-const-param.stderr index 75b4c0a0a3de3..6763295a4274c 100644 --- a/src/test/ui/const-generics/raw-ptr-const-param.stderr +++ b/src/test/ui/const-generics/raw-ptr-const-param.stderr @@ -10,7 +10,9 @@ error[E0308]: mismatched types --> $DIR/raw-ptr-const-param.rs:7:38 | LL | let _: Const<{15 as *const _}> = Const::<{10 as *const _}>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{pointer}`, found `{pointer}` + | ----------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{pointer}`, found `{pointer}` + | | + | expected due to this | = note: expected type `Const<{pointer}>` found type `Const<{pointer}>` diff --git a/src/test/ui/const-generics/slice-const-param-mismatch.stderr b/src/test/ui/const-generics/slice-const-param-mismatch.stderr index 380a70d664e05..35a5eec3225ee 100644 --- a/src/test/ui/const-generics/slice-const-param-mismatch.stderr +++ b/src/test/ui/const-generics/slice-const-param-mismatch.stderr @@ -10,7 +10,9 @@ error[E0308]: mismatched types --> $DIR/slice-const-param-mismatch.rs:9:35 | LL | let _: ConstString<"Hello"> = ConstString::<"World">; - | ^^^^^^^^^^^^^^^^^^^^^^ expected `"Hello"`, found `"World"` + | -------------------- ^^^^^^^^^^^^^^^^^^^^^^ expected `"Hello"`, found `"World"` + | | + | expected due to this | = note: expected type `ConstString<"Hello">` found type `ConstString<"World">` @@ -19,7 +21,9 @@ error[E0308]: mismatched types --> $DIR/slice-const-param-mismatch.rs:11:33 | LL | let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↥">; - | ^^^^^^^^^^^^^^^^^^^^^ expected `"ℇ㇈↦"`, found `"ℇ㇈↥"` + | ------------------- ^^^^^^^^^^^^^^^^^^^^^ expected `"ℇ㇈↦"`, found `"ℇ㇈↥"` + | | + | expected due to this | = note: expected type `ConstString<"ℇ㇈↦">` found type `ConstString<"ℇ㇈↥">` @@ -28,7 +32,9 @@ error[E0308]: mismatched types --> $DIR/slice-const-param-mismatch.rs:13:33 | LL | let _: ConstBytes = ConstBytes::; - | ^^^^^^^^^^^^^^^^^^^^ expected `b"AAA"`, found `b"BBB"` + | ------------------ ^^^^^^^^^^^^^^^^^^^^ expected `b"AAA"`, found `b"BBB"` + | | + | expected due to this | = note: expected type `ConstBytes` found type `ConstBytes` diff --git a/src/test/ui/const-generics/types-mismatch-const-args.stderr b/src/test/ui/const-generics/types-mismatch-const-args.stderr index 805a3067d3b6b..276c73a7393ea 100644 --- a/src/test/ui/const-generics/types-mismatch-const-args.stderr +++ b/src/test/ui/const-generics/types-mismatch-const-args.stderr @@ -10,7 +10,9 @@ error[E0308]: mismatched types --> $DIR/types-mismatch-const-args.rs:13:41 | LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data: PhantomData }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2u32`, found `4u32` + | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2u32`, found `4u32` + | | + | expected due to this | = note: expected type `A<'_, _, 2u32, _>` found type `A<'_, _, 4u32, _>` @@ -19,7 +21,9 @@ error[E0308]: mismatched types --> $DIR/types-mismatch-const-args.rs:15:41 | LL | let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u16, found u32 + | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u16, found u32 + | | + | expected due to this | = note: expected type `A<'a, u16, _, _>` found type `A<'b, u32, _, _>` diff --git a/src/test/ui/conversion-methods.stderr b/src/test/ui/conversion-methods.stderr index 5c666afb89a33..bf0741766a8ba 100644 --- a/src/test/ui/conversion-methods.stderr +++ b/src/test/ui/conversion-methods.stderr @@ -2,10 +2,11 @@ error[E0308]: mismatched types --> $DIR/conversion-methods.rs:5:41 | LL | let _tis_an_instants_play: String = "'Tis a fond Ambush—"; - | ^^^^^^^^^^^^^^^^^^^^^ - | | - | expected struct `std::string::String`, found reference - | help: try using a conversion method: `"'Tis a fond Ambush—".to_string()` + | ------ ^^^^^^^^^^^^^^^^^^^^^ + | | | + | | expected struct `std::string::String`, found reference + | | help: try using a conversion method: `"'Tis a fond Ambush—".to_string()` + | expected due to this | = note: expected type `std::string::String` found type `&'static str` @@ -14,10 +15,11 @@ error[E0308]: mismatched types --> $DIR/conversion-methods.rs:6:40 | LL | let _just_to_make_bliss: PathBuf = Path::new("/ern/her/own/surprise"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected struct `std::path::PathBuf`, found reference - | help: try using a conversion method: `Path::new("/ern/her/own/surprise").to_path_buf()` + | ------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | expected struct `std::path::PathBuf`, found reference + | | help: try using a conversion method: `Path::new("/ern/her/own/surprise").to_path_buf()` + | expected due to this | = note: expected type `std::path::PathBuf` found type `&std::path::Path` @@ -26,10 +28,11 @@ error[E0308]: mismatched types --> $DIR/conversion-methods.rs:9:40 | LL | let _but_should_the_play: String = 2; // Perhaps surprisingly, we suggest .to_string() here - | ^ - | | - | expected struct `std::string::String`, found integer - | help: try using a conversion method: `2.to_string()` + | ------ ^ + | | | + | | expected struct `std::string::String`, found integer + | | help: try using a conversion method: `2.to_string()` + | expected due to this | = note: expected type `std::string::String` found type `{integer}` @@ -38,10 +41,11 @@ error[E0308]: mismatched types --> $DIR/conversion-methods.rs:12:47 | LL | let _prove_piercing_earnest: Vec = &[1, 2, 3]; - | ^^^^^^^^^^ - | | - | expected struct `std::vec::Vec`, found reference - | help: try using a conversion method: `(&[1, 2, 3]).to_vec()` + | ---------- ^^^^^^^^^^ + | | | + | | expected struct `std::vec::Vec`, found reference + | | help: try using a conversion method: `(&[1, 2, 3]).to_vec()` + | expected due to this | = note: expected type `std::vec::Vec` found type `&[{integer}; 3]` diff --git a/src/test/ui/cross/cross-borrow-trait.stderr b/src/test/ui/cross/cross-borrow-trait.stderr index ada1c0204eb01..445daffc9d8d1 100644 --- a/src/test/ui/cross/cross-borrow-trait.stderr +++ b/src/test/ui/cross/cross-borrow-trait.stderr @@ -2,10 +2,11 @@ error[E0308]: mismatched types --> $DIR/cross-borrow-trait.rs:10:26 | LL | let _y: &dyn Trait = x; - | ^ - | | - | expected &dyn Trait, found struct `std::boxed::Box` - | help: consider borrowing here: `&x` + | ---------- ^ + | | | + | | expected &dyn Trait, found struct `std::boxed::Box` + | | help: consider borrowing here: `&x` + | expected due to this | = note: expected type `&dyn Trait` found type `std::boxed::Box` diff --git a/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.stderr b/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.stderr index 301704ec0c7ef..97a1333bdc288 100644 --- a/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.stderr +++ b/src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.stderr @@ -2,10 +2,11 @@ error[E0308]: mismatched types --> $DIR/issue-53280-expected-float-found-integer-literal.rs:2:24 | LL | let sixteen: f32 = 16; - | ^^ - | | - | expected f32, found integer - | help: use a float literal: `16.0` + | --- ^^ + | | | + | | expected f32, found integer + | | help: use a float literal: `16.0` + | expected due to this | = note: expected type `f32` found type `{integer}` @@ -14,10 +15,11 @@ error[E0308]: mismatched types --> $DIR/issue-53280-expected-float-found-integer-literal.rs:5:38 | LL | let a_million_and_seventy: f64 = 1_000_070; - | ^^^^^^^^^ - | | - | expected f64, found integer - | help: use a float literal: `1_000_070.0` + | --- ^^^^^^^^^ + | | | + | | expected f64, found integer + | | help: use a float literal: `1_000_070.0` + | expected due to this | = note: expected type `f64` found type `{integer}` @@ -26,10 +28,11 @@ error[E0308]: mismatched types --> $DIR/issue-53280-expected-float-found-integer-literal.rs:8:30 | LL | let negative_nine: f32 = -9; - | ^^ - | | - | expected f32, found integer - | help: use a float literal: `-9.0` + | --- ^^ + | | | + | | expected f32, found integer + | | help: use a float literal: `-9.0` + | expected due to this | = note: expected type `f32` found type `{integer}` @@ -38,7 +41,9 @@ error[E0308]: mismatched types --> $DIR/issue-53280-expected-float-found-integer-literal.rs:15:30 | LL | let sixteen_again: f64 = 0x10; - | ^^^^ expected f64, found integer + | --- ^^^^ expected f64, found integer + | | + | expected due to this | = note: expected type `f64` found type `{integer}` @@ -47,7 +52,9 @@ error[E0308]: mismatched types --> $DIR/issue-53280-expected-float-found-integer-literal.rs:17:30 | LL | let and_once_more: f32 = 0o20; - | ^^^^ expected f32, found integer + | --- ^^^^ expected f32, found integer + | | + | expected due to this | = note: expected type `f32` found type `{integer}` diff --git a/src/test/ui/did_you_mean/recursion_limit_deref.stderr b/src/test/ui/did_you_mean/recursion_limit_deref.stderr index c76efb1d00920..dcb37e00b4124 100644 --- a/src/test/ui/did_you_mean/recursion_limit_deref.stderr +++ b/src/test/ui/did_you_mean/recursion_limit_deref.stderr @@ -10,7 +10,9 @@ error[E0308]: mismatched types --> $DIR/recursion_limit_deref.rs:50:22 | LL | let x: &Bottom = &t; - | ^^ expected struct `Bottom`, found struct `Top` + | ------- ^^ expected struct `Bottom`, found struct `Top` + | | + | expected due to this | = note: expected type `&Bottom` found type `&Top` diff --git a/src/test/ui/dst/dst-bad-coerce1.stderr b/src/test/ui/dst/dst-bad-coerce1.stderr index a48f37b20be97..d4af035409e54 100644 --- a/src/test/ui/dst/dst-bad-coerce1.stderr +++ b/src/test/ui/dst/dst-bad-coerce1.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/dst-bad-coerce1.rs:16:29 | LL | let f3: &Fat<[usize]> = f2; - | ^^ expected slice, found array of 3 elements + | ------------- ^^ expected slice, found array of 3 elements + | | + | expected due to this | = note: expected type `&Fat<[usize]>` found type `&Fat<[isize; 3]>` @@ -19,7 +21,9 @@ error[E0308]: mismatched types --> $DIR/dst-bad-coerce1.rs:28:27 | LL | let f3: &([usize],) = f2; - | ^^ expected slice, found array of 3 elements + | ----------- ^^ expected slice, found array of 3 elements + | | + | expected due to this | = note: expected type `&([usize],)` found type `&([isize; 3],)` diff --git a/src/test/ui/dst/dst-bad-coerce2.stderr b/src/test/ui/dst/dst-bad-coerce2.stderr index d1da9b6ca0749..1c0bbdd08d74e 100644 --- a/src/test/ui/dst/dst-bad-coerce2.stderr +++ b/src/test/ui/dst/dst-bad-coerce2.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/dst-bad-coerce2.rs:15:33 | LL | let f3: &mut Fat<[isize]> = f2; - | ^^ types differ in mutability + | ----------------- ^^ types differ in mutability + | | + | expected due to this | = note: expected type `&mut Fat<[isize]>` found type `&Fat<[isize; 3]>` @@ -11,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/dst-bad-coerce2.rs:20:33 | LL | let f3: &mut Fat = f2; - | ^^ types differ in mutability + | ----------------- ^^ types differ in mutability + | | + | expected due to this | = note: expected type `&mut Fat` found type `&Fat` @@ -20,7 +24,9 @@ error[E0308]: mismatched types --> $DIR/dst-bad-coerce2.rs:25:31 | LL | let f3: &mut ([isize],) = f2; - | ^^ types differ in mutability + | --------------- ^^ types differ in mutability + | | + | expected due to this | = note: expected type `&mut ([isize],)` found type `&([isize; 3],)` @@ -29,7 +35,9 @@ error[E0308]: mismatched types --> $DIR/dst-bad-coerce2.rs:30:31 | LL | let f3: &mut (dyn Bar,) = f2; - | ^^ types differ in mutability + | --------------- ^^ types differ in mutability + | | + | expected due to this | = note: expected type `&mut (dyn Bar,)` found type `&(Foo,)` diff --git a/src/test/ui/dst/dst-bad-coerce4.stderr b/src/test/ui/dst/dst-bad-coerce4.stderr index fbf59ae5c6600..9c752176943ee 100644 --- a/src/test/ui/dst/dst-bad-coerce4.stderr +++ b/src/test/ui/dst/dst-bad-coerce4.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/dst-bad-coerce4.rs:12:32 | LL | let f2: &Fat<[isize; 3]> = f1; - | ^^ expected array of 3 elements, found slice + | ---------------- ^^ expected array of 3 elements, found slice + | | + | expected due to this | = note: expected type `&Fat<[isize; 3]>` found type `&Fat<[isize]>` @@ -11,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/dst-bad-coerce4.rs:20:30 | LL | let f2: &([isize; 3],) = f1; - | ^^ expected array of 3 elements, found slice + | -------------- ^^ expected array of 3 elements, found slice + | | + | expected due to this | = note: expected type `&([isize; 3],)` found type `&([isize],)` diff --git a/src/test/ui/dst/dst-bad-coercions.stderr b/src/test/ui/dst/dst-bad-coercions.stderr index e4bc6ee0010a2..b8a7d5fb3ec0b 100644 --- a/src/test/ui/dst/dst-bad-coercions.stderr +++ b/src/test/ui/dst/dst-bad-coercions.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/dst-bad-coercions.rs:14:17 | LL | let y: &S = x; - | ^ expected &S, found *-ptr + | -- ^ expected &S, found *-ptr + | | + | expected due to this | = note: expected type `&S` found type `*const S` @@ -11,10 +13,11 @@ error[E0308]: mismatched types --> $DIR/dst-bad-coercions.rs:15:21 | LL | let y: &dyn T = x; - | ^ - | | - | expected &dyn T, found *-ptr - | help: consider borrowing here: `&x` + | ------ ^ + | | | + | | expected &dyn T, found *-ptr + | | help: consider borrowing here: `&x` + | expected due to this | = note: expected type `&dyn T` found type `*const S` @@ -23,7 +26,9 @@ error[E0308]: mismatched types --> $DIR/dst-bad-coercions.rs:19:17 | LL | let y: &S = x; - | ^ expected &S, found *-ptr + | -- ^ expected &S, found *-ptr + | | + | expected due to this | = note: expected type `&S` found type `*mut S` @@ -32,10 +37,11 @@ error[E0308]: mismatched types --> $DIR/dst-bad-coercions.rs:20:21 | LL | let y: &dyn T = x; - | ^ - | | - | expected &dyn T, found *-ptr - | help: consider borrowing here: `&x` + | ------ ^ + | | | + | | expected &dyn T, found *-ptr + | | help: consider borrowing here: `&x` + | expected due to this | = note: expected type `&dyn T` found type `*mut S` @@ -44,7 +50,9 @@ error[E0308]: mismatched types --> $DIR/dst-bad-coercions.rs:23:25 | LL | let x: &mut dyn T = &S; - | ^^ types differ in mutability + | ---------- ^^ types differ in mutability + | | + | expected due to this | = note: expected type `&mut dyn T` found type `&S` @@ -53,7 +61,9 @@ error[E0308]: mismatched types --> $DIR/dst-bad-coercions.rs:24:25 | LL | let x: *mut dyn T = &S; - | ^^ types differ in mutability + | ---------- ^^ types differ in mutability + | | + | expected due to this | = note: expected type `*mut dyn T` found type `&S` @@ -62,7 +72,9 @@ error[E0308]: mismatched types --> $DIR/dst-bad-coercions.rs:25:21 | LL | let x: *mut S = &S; - | ^^ types differ in mutability + | ------ ^^ types differ in mutability + | | + | expected due to this | = note: expected type `*mut S` found type `&S` diff --git a/src/test/ui/float-literal-inference-restrictions.stderr b/src/test/ui/float-literal-inference-restrictions.stderr index 08513507ecf96..80fe031dbd8fc 100644 --- a/src/test/ui/float-literal-inference-restrictions.stderr +++ b/src/test/ui/float-literal-inference-restrictions.stderr @@ -2,10 +2,11 @@ error[E0308]: mismatched types --> $DIR/float-literal-inference-restrictions.rs:2:18 | LL | let x: f32 = 1; - | ^ - | | - | expected f32, found integer - | help: use a float literal: `1.0` + | --- ^ + | | | + | | expected f32, found integer + | | help: use a float literal: `1.0` + | expected due to this | = note: expected type `f32` found type `{integer}` @@ -14,7 +15,9 @@ error[E0308]: mismatched types --> $DIR/float-literal-inference-restrictions.rs:3:18 | LL | let y: f32 = 1f64; - | ^^^^ expected f32, found f64 + | --- ^^^^ expected f32, found f64 + | | + | expected due to this | help: change the type of the numeric literal from `f64` to `f32` | diff --git a/src/test/ui/fn/fn-trait-formatting.stderr b/src/test/ui/fn/fn-trait-formatting.stderr index f891b9c6439be..84cf8b02b8918 100644 --- a/src/test/ui/fn/fn-trait-formatting.stderr +++ b/src/test/ui/fn/fn-trait-formatting.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/fn-trait-formatting.rs:6:17 | LL | let _: () = (box |_: isize| {}) as Box; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` + | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` + | | + | expected due to this | = note: expected type `()` found type `std::boxed::Box` @@ -11,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/fn-trait-formatting.rs:10:17 | LL | let _: () = (box |_: isize, isize| {}) as Box; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` + | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` + | | + | expected due to this | = note: expected type `()` found type `std::boxed::Box` @@ -20,7 +24,9 @@ error[E0308]: mismatched types --> $DIR/fn-trait-formatting.rs:14:17 | LL | let _: () = (box || -> isize { unimplemented!() }) as Box isize>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` + | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` + | | + | expected due to this | = note: expected type `()` found type `std::boxed::Box isize>` diff --git a/src/test/ui/generic/generic-type-params-name-repr.stderr b/src/test/ui/generic/generic-type-params-name-repr.stderr index 2aa9cafb8bf0e..ab19743bcdb8c 100644 --- a/src/test/ui/generic/generic-type-params-name-repr.stderr +++ b/src/test/ui/generic/generic-type-params-name-repr.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/generic-type-params-name-repr.rs:13:25 | LL | let _: Foo = (); - | ^^ expected struct `Foo`, found () + | ---------- ^^ expected struct `Foo`, found () + | | + | expected due to this | = note: expected type `Foo` found type `()` @@ -11,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/generic-type-params-name-repr.rs:20:31 | LL | let _: Foo = (); - | ^^ expected struct `Foo`, found () + | ---------------- ^^ expected struct `Foo`, found () + | | + | expected due to this | = note: expected type `Foo` found type `()` @@ -20,7 +24,9 @@ error[E0308]: mismatched types --> $DIR/generic-type-params-name-repr.rs:27:37 | LL | let _: HashMap = (); - | ^^ expected struct `HashMap`, found () + | ---------------------- ^^ expected struct `HashMap`, found () + | | + | expected due to this | = note: expected type `HashMap` found type `()` @@ -29,7 +35,9 @@ error[E0308]: mismatched types --> $DIR/generic-type-params-name-repr.rs:32:51 | LL | let _: HashMap> = (); - | ^^ expected struct `HashMap`, found () + | ------------------------------------ ^^ expected struct `HashMap`, found () + | | + | expected due to this | = note: expected type `HashMap` found type `()` @@ -38,7 +46,9 @@ error[E0308]: mismatched types --> $DIR/generic-type-params-name-repr.rs:39:31 | LL | let _: Foo = (); - | ^^ expected struct `Foo`, found () + | ---------------- ^^ expected struct `Foo`, found () + | | + | expected due to this | = note: expected type `Foo` found type `()` @@ -47,7 +57,9 @@ error[E0308]: mismatched types --> $DIR/generic-type-params-name-repr.rs:46:27 | LL | let _: Foo = (); - | ^^ expected struct `Foo`, found () + | ------------ ^^ expected struct `Foo`, found () + | | + | expected due to this | = note: expected type `Foo` found type `()` diff --git a/src/test/ui/hrtb/hrtb-exists-forall-fn.stderr b/src/test/ui/hrtb/hrtb-exists-forall-fn.stderr index d893cd606f1e4..be07694a4476c 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-fn.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-fn.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/hrtb-exists-forall-fn.rs:17:34 | LL | let _: for<'b> fn(&'b u32) = foo(); - | ^^^^^ expected concrete lifetime, found bound lifetime parameter 'b + | ------------------- ^^^^^ expected concrete lifetime, found bound lifetime parameter 'b + | | + | expected due to this | = note: expected type `for<'b> fn(&'b u32)` found type `fn(&u32)` diff --git a/src/test/ui/impl-trait/equality2.stderr b/src/test/ui/impl-trait/equality2.stderr index e30e2626e9f34..e05568c7b349a 100644 --- a/src/test/ui/impl-trait/equality2.stderr +++ b/src/test/ui/impl-trait/equality2.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/equality2.rs:25:18 | LL | let _: u32 = hide(0_u32); - | ^^^^^^^^^^^ expected u32, found opaque type + | --- ^^^^^^^^^^^ expected u32, found opaque type + | | + | expected due to this | = note: expected type `u32` found type `impl Foo` @@ -11,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/equality2.rs:31:18 | LL | let _: i32 = Leak::leak(hide(0_i32)); - | ^^^^^^^^^^^^^^^^^^^^^^^ expected i32, found associated type + | --- ^^^^^^^^^^^^^^^^^^^^^^^ expected i32, found associated type + | | + | expected due to this | = note: expected type `i32` found type `::T` diff --git a/src/test/ui/include-macros/mismatched-types.stderr b/src/test/ui/include-macros/mismatched-types.stderr index 33204f1cfce9b..3b4660a9348ae 100644 --- a/src/test/ui/include-macros/mismatched-types.stderr +++ b/src/test/ui/include-macros/mismatched-types.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/mismatched-types.rs:2:20 | LL | let b: &[u8] = include_str!("file.txt"); - | ^^^^^^^^^^^^^^^^^^^^^^^^ expected slice, found str + | ----- ^^^^^^^^^^^^^^^^^^^^^^^^ expected slice, found str + | | + | expected due to this | = note: expected type `&[u8]` found type `&'static str` @@ -11,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/mismatched-types.rs:3:19 | LL | let s: &str = include_bytes!("file.txt"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected str, found array of 0 elements + | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected str, found array of 0 elements + | | + | expected due to this | = note: expected type `&str` found type `&'static [u8; 0]` diff --git a/src/test/ui/issues/issue-1362.stderr b/src/test/ui/issues/issue-1362.stderr index 7ffbbbce7a83b..b4c6ccbbc6c19 100644 --- a/src/test/ui/issues/issue-1362.stderr +++ b/src/test/ui/issues/issue-1362.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/issue-1362.rs:4:16 | LL | let x: u32 = 20i32; - | ^^^^^ expected u32, found i32 + | --- ^^^^^ expected u32, found i32 + | | + | expected due to this | help: change the type of the numeric literal from `i32` to `u32` | diff --git a/src/test/ui/issues/issue-22684.stderr b/src/test/ui/issues/issue-22684.stderr index 738123ec4d41b..4179ddc4ae561 100644 --- a/src/test/ui/issues/issue-22684.stderr +++ b/src/test/ui/issues/issue-22684.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/issue-22684.rs:17:17 | LL | let _: () = foo::Foo.bar(); - | ^^^^^^^^^^^^^^ expected (), found bool + | -- ^^^^^^^^^^^^^^ expected (), found bool + | | + | expected due to this | = note: expected type `()` found type `bool` diff --git a/src/test/ui/issues/issue-24322.stderr b/src/test/ui/issues/issue-24322.stderr index def373cf2c0a8..490297b2e5454 100644 --- a/src/test/ui/issues/issue-24322.stderr +++ b/src/test/ui/issues/issue-24322.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/issue-24322.rs:8:29 | LL | let x: &fn(&B) -> u32 = &B::func; - | ^^^^^^^^ expected fn pointer, found fn item + | -------------- ^^^^^^^^ expected fn pointer, found fn item + | | + | expected due to this | = note: expected type `&for<'r> fn(&'r B) -> u32` found type `&for<'r> fn(&'r B) -> u32 {B::func}` diff --git a/src/test/ui/issues/issue-27042.stderr b/src/test/ui/issues/issue-27042.stderr index 7678984a518ba..0a506d6853345 100644 --- a/src/test/ui/issues/issue-27042.stderr +++ b/src/test/ui/issues/issue-27042.stderr @@ -23,6 +23,8 @@ LL | loop { break }; error[E0308]: mismatched types --> $DIR/issue-27042.rs:8:9 | +LL | let _: i32 = + | --- expected due to this LL | / 'b: LL | | LL | | while true { break }; // but here we cite the whole loop @@ -44,6 +46,8 @@ LL | | for _ in None { break }; // but here we cite the whole loop error[E0308]: mismatched types --> $DIR/issue-27042.rs:15:9 | +LL | let _: i32 = + | --- expected due to this LL | / 'd: LL | | while let Some(_) = None { break }; | |__________________________________________^ expected i32, found () diff --git a/src/test/ui/issues/issue-3477.stderr b/src/test/ui/issues/issue-3477.stderr index 1b7f597d50e2a..7ac1db4b822a3 100644 --- a/src/test/ui/issues/issue-3477.stderr +++ b/src/test/ui/issues/issue-3477.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/issue-3477.rs:2:20 | LL | let _p: char = 100; - | ^^^ expected char, found u8 + | ---- ^^^ expected char, found u8 + | | + | expected due to this error: aborting due to previous error diff --git a/src/test/ui/issues/issue-37665.stderr b/src/test/ui/issues/issue-37665.stderr index c27494699515b..73b2c8ec623ed 100644 --- a/src/test/ui/issues/issue-37665.stderr +++ b/src/test/ui/issues/issue-37665.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/issue-37665.rs:10:17 | LL | let x: () = 0; - | ^ expected (), found integer + | -- ^ expected (), found integer + | | + | expected due to this | = note: expected type `()` found type `{integer}` diff --git a/src/test/ui/issues/issue-38940.stderr b/src/test/ui/issues/issue-38940.stderr index 4851c01a347b6..19969043d15e1 100644 --- a/src/test/ui/issues/issue-38940.stderr +++ b/src/test/ui/issues/issue-38940.stderr @@ -10,7 +10,9 @@ error[E0308]: mismatched types --> $DIR/issue-38940.rs:43:22 | LL | let x: &Bottom = &t; - | ^^ expected struct `Bottom`, found struct `Top` + | ------- ^^ expected struct `Bottom`, found struct `Top` + | | + | expected due to this | = note: expected type `&Bottom` found type `&Top` diff --git a/src/test/ui/issues/issue-5100.stderr b/src/test/ui/issues/issue-5100.stderr index b50d24671a850..bc3954506fecd 100644 --- a/src/test/ui/issues/issue-5100.stderr +++ b/src/test/ui/issues/issue-5100.stderr @@ -57,7 +57,9 @@ error[E0308]: mismatched types --> $DIR/issue-5100.rs:55:19 | LL | let x: char = true; - | ^^^^ expected char, found bool + | ---- ^^^^ expected char, found bool + | | + | expected due to this error: aborting due to 7 previous errors diff --git a/src/test/ui/issues/issue-53692.stderr b/src/test/ui/issues/issue-53692.stderr index 2928d4461c5ec..d02ffdef7e329 100644 --- a/src/test/ui/issues/issue-53692.stderr +++ b/src/test/ui/issues/issue-53692.stderr @@ -2,10 +2,11 @@ error[E0308]: mismatched types --> $DIR/issue-53692.rs:4:37 | LL | let items_clone: Vec = ref_items.clone(); - | ^^^^^^^^^^^^^^^^^ - | | - | expected struct `std::vec::Vec`, found &[i32] - | help: try using a conversion method: `ref_items.to_vec()` + | -------- ^^^^^^^^^^^^^^^^^ + | | | + | | expected struct `std::vec::Vec`, found &[i32] + | | help: try using a conversion method: `ref_items.to_vec()` + | expected due to this | = note: expected type `std::vec::Vec` found type `&[i32]` @@ -14,10 +15,11 @@ error[E0308]: mismatched types --> $DIR/issue-53692.rs:11:30 | LL | let string: String = s.clone(); - | ^^^^^^^^^ - | | - | expected struct `std::string::String`, found &str - | help: try using a conversion method: `s.to_string()` + | ------ ^^^^^^^^^ + | | | + | | expected struct `std::string::String`, found &str + | | help: try using a conversion method: `s.to_string()` + | expected due to this | = note: expected type `std::string::String` found type `&str` diff --git a/src/test/ui/issues/issue-56943.stderr b/src/test/ui/issues/issue-56943.stderr index 27202051524c9..bb12f43dac188 100644 --- a/src/test/ui/issues/issue-56943.stderr +++ b/src/test/ui/issues/issue-56943.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/issue-56943.rs:6:29 | LL | let _: issue_56943::S = issue_56943::S2; - | ^^^^^^^^^^^^^^^ expected struct `issue_56943::S`, found struct `issue_56943::S2` + | -------------- ^^^^^^^^^^^^^^^ expected struct `issue_56943::S`, found struct `issue_56943::S2` + | | + | expected due to this | = note: expected type `issue_56943::S` found type `issue_56943::S2` diff --git a/src/test/ui/json-bom-plus-crlf-multifile.stderr b/src/test/ui/json-bom-plus-crlf-multifile.stderr index 39f6b69bbecaa..17c0bbc72ffde 100644 --- a/src/test/ui/json-bom-plus-crlf-multifile.stderr +++ b/src/test/ui/json-bom-plus-crlf-multifile.stderr @@ -15,7 +15,7 @@ let x: i32 = \"I am not a number!\"; // | // type `i32` assigned to variable `x` ``` -"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::string::String` +"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":612,"byte_end":618,"line_start":17,"line_end":17,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::string::String` found type `{integer}`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:17:22: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"This error occurs when the compiler was unable to infer the concrete type of a @@ -35,7 +35,7 @@ let x: i32 = \"I am not a number!\"; // | // type `i32` assigned to variable `x` ``` -"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::string::String` +"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":672,"byte_end":678,"line_start":19,"line_end":19,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = 1","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::string::String` found type `{integer}`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:19:22: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"This error occurs when the compiler was unable to infer the concrete type of a @@ -55,7 +55,7 @@ let x: i32 = \"I am not a number!\"; // | // type `i32` assigned to variable `x` ``` -"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::string::String` +"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":735,"byte_end":741,"line_start":22,"line_end":22,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String =","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::string::String` found type `{integer}`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:23:1: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"This error occurs when the compiler was unable to infer the concrete type of a @@ -75,7 +75,7 @@ let x: i32 = \"I am not a number!\"; // | // type `i32` assigned to variable `x` ``` -"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":801,"byte_end":809,"line_start":25,"line_end":26,"column_start":22,"column_end":6,"is_primary":true,"text":[{"text":" let s : String = (","highlight_start":22,"highlight_end":23},{"text":" ); // Error spanning the newline.","highlight_start":1,"highlight_end":6}],"label":"expected struct `std::string::String`, found ()","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::string::String` +"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":801,"byte_end":809,"line_start":25,"line_end":26,"column_start":22,"column_end":6,"is_primary":true,"text":[{"text":" let s : String = (","highlight_start":22,"highlight_end":23},{"text":" ); // Error spanning the newline.","highlight_start":1,"highlight_end":6}],"label":"expected struct `std::string::String`, found ()","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":792,"byte_end":798,"line_start":25,"line_end":25,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = (","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::string::String` found type `()`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:25:22: error[E0308]: mismatched types "} {"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors diff --git a/src/test/ui/json-bom-plus-crlf.stderr b/src/test/ui/json-bom-plus-crlf.stderr index d62140e4de765..051bc87b2267a 100644 --- a/src/test/ui/json-bom-plus-crlf.stderr +++ b/src/test/ui/json-bom-plus-crlf.stderr @@ -15,7 +15,7 @@ let x: i32 = \"I am not a number!\"; // | // type `i32` assigned to variable `x` ``` -"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::string::String` +"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":612,"byte_end":618,"line_start":17,"line_end":17,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::string::String` found type `{integer}`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":621,"byte_end":622,"line_start":17,"line_end":17,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1; // Error in the middle of line.","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:17:22: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"This error occurs when the compiler was unable to infer the concrete type of a @@ -35,7 +35,7 @@ let x: i32 = \"I am not a number!\"; // | // type `i32` assigned to variable `x` ``` -"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::string::String` +"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":672,"byte_end":678,"line_start":19,"line_end":19,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = 1","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::string::String` found type `{integer}`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":681,"byte_end":682,"line_start":19,"line_end":19,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":" let s : String = 1","highlight_start":22,"highlight_end":23}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:19:22: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"This error occurs when the compiler was unable to infer the concrete type of a @@ -55,7 +55,7 @@ let x: i32 = \"I am not a number!\"; // | // type `i32` assigned to variable `x` ``` -"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::string::String` +"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":"expected struct `std::string::String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":735,"byte_end":741,"line_start":22,"line_end":22,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String =","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::string::String` found type `{integer}`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":745,"byte_end":746,"line_start":23,"line_end":23,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":"1.to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:23:1: error[E0308]: mismatched types "} {"message":"mismatched types","code":{"code":"E0308","explanation":"This error occurs when the compiler was unable to infer the concrete type of a @@ -75,7 +75,7 @@ let x: i32 = \"I am not a number!\"; // | // type `i32` assigned to variable `x` ``` -"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":801,"byte_end":809,"line_start":25,"line_end":26,"column_start":22,"column_end":6,"is_primary":true,"text":[{"text":" let s : String = (","highlight_start":22,"highlight_end":23},{"text":" ); // Error spanning the newline.","highlight_start":1,"highlight_end":6}],"label":"expected struct `std::string::String`, found ()","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::string::String` +"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":801,"byte_end":809,"line_start":25,"line_end":26,"column_start":22,"column_end":6,"is_primary":true,"text":[{"text":" let s : String = (","highlight_start":22,"highlight_end":23},{"text":" ); // Error spanning the newline.","highlight_start":1,"highlight_end":6}],"label":"expected struct `std::string::String`, found ()","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":792,"byte_end":798,"line_start":25,"line_end":25,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":" let s : String = (","highlight_start":13,"highlight_end":19}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::string::String` found type `()`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:25:22: error[E0308]: mismatched types "} {"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors diff --git a/src/test/ui/meta-expected-error-correct-rev.a.stderr b/src/test/ui/meta-expected-error-correct-rev.a.stderr index 968b87288c015..e9b9a03394928 100644 --- a/src/test/ui/meta-expected-error-correct-rev.a.stderr +++ b/src/test/ui/meta-expected-error-correct-rev.a.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/meta-expected-error-correct-rev.rs:7:18 | LL | let x: u32 = 22_usize; - | ^^^^^^^^ expected u32, found usize + | --- ^^^^^^^^ expected u32, found usize + | | + | expected due to this | help: change the type of the numeric literal from `usize` to `u32` | diff --git a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr index 8dfbde92f646b..20b435548ec39 100644 --- a/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr +++ b/src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr @@ -10,7 +10,9 @@ error[E0308]: mismatched types --> $DIR/method-ambig-one-trait-unknown-int-type.rs:33:20 | LL | let y: usize = x.foo(); - | ^^^^^^^ expected usize, found isize + | ----- ^^^^^^^ expected usize, found isize + | | + | expected due to this | help: you can convert an `isize` to `usize` and panic if the converted value wouldn't fit | diff --git a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr index 283ef8fcba7a4..c143c457fc2a4 100644 --- a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr +++ b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:85:24 | LL | let _seetype: () = z; - | ^ expected (), found u32 + | -- ^ expected (), found u32 + | | + | expected due to this | = note: expected type `()` found type `u32` @@ -11,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:102:24 | LL | let _seetype: () = z; - | ^ expected (), found u64 + | -- ^ expected (), found u64 + | | + | expected due to this | = note: expected type `()` found type `u64` @@ -45,7 +49,9 @@ error[E0308]: mismatched types --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:137:24 | LL | let _seetype: () = z; - | ^ expected (), found u8 + | -- ^ expected (), found u8 + | | + | expected due to this | = note: expected type `()` found type `u8` @@ -54,7 +60,9 @@ error[E0308]: mismatched types --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:155:24 | LL | let _seetype: () = z; - | ^ expected (), found u32 + | -- ^ expected (), found u32 + | | + | expected due to this | = note: expected type `()` found type `u32` @@ -63,7 +71,9 @@ error[E0308]: mismatched types --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:172:24 | LL | let _seetype: () = z; - | ^ expected (), found u32 + | -- ^ expected (), found u32 + | | + | expected due to this | = note: expected type `()` found type `u32` diff --git a/src/test/ui/mir-unpretty.stderr b/src/test/ui/mir-unpretty.stderr index 6e5dac226692a..e84cbcb553589 100644 --- a/src/test/ui/mir-unpretty.stderr +++ b/src/test/ui/mir-unpretty.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/mir-unpretty.rs:4:17 | LL | let x: () = 0; - | ^ expected (), found integer + | -- ^ expected (), found integer + | | + | expected due to this | = note: expected type `()` found type `{integer}` diff --git a/src/test/ui/mismatched_types/main.stderr b/src/test/ui/mismatched_types/main.stderr index 1d53cfdd2527c..0f4a273548da1 100644 --- a/src/test/ui/mismatched_types/main.stderr +++ b/src/test/ui/mismatched_types/main.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/main.rs:2:18 | LL | let x: u32 = ( - | __________________^ + | ____________---___^ + | | | + | | expected due to this LL | | ); | |_____^ expected u32, found () | diff --git a/src/test/ui/never_type/never-assign-wrong-type.stderr b/src/test/ui/never_type/never-assign-wrong-type.stderr index da2e77d023d19..e95670efed6d5 100644 --- a/src/test/ui/never_type/never-assign-wrong-type.stderr +++ b/src/test/ui/never_type/never-assign-wrong-type.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/never-assign-wrong-type.rs:7:16 | LL | let x: ! = "hello"; - | ^^^^^^^ expected !, found reference + | - ^^^^^^^ expected !, found reference + | | + | expected due to this | = note: expected type `!` found type `&'static str` diff --git a/src/test/ui/noexporttypeexe.stderr b/src/test/ui/noexporttypeexe.stderr index 329787fe74444..15a03c0e58255 100644 --- a/src/test/ui/noexporttypeexe.stderr +++ b/src/test/ui/noexporttypeexe.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/noexporttypeexe.rs:10:18 | LL | let x: isize = noexporttypelib::foo(); - | ^^^^^^^^^^^^^^^^^^^^^^ expected isize, found enum `std::option::Option` + | ----- ^^^^^^^^^^^^^^^^^^^^^^ expected isize, found enum `std::option::Option` + | | + | expected due to this | = note: expected type `isize` found type `std::option::Option` diff --git a/src/test/ui/numeric/const-scope.stderr b/src/test/ui/numeric/const-scope.stderr index c88495059224b..e4dde0b03b415 100644 --- a/src/test/ui/numeric/const-scope.stderr +++ b/src/test/ui/numeric/const-scope.stderr @@ -14,19 +14,25 @@ error[E0308]: mismatched types --> $DIR/const-scope.rs:5:18 | LL | let c: i32 = 1i8; - | ^^^ expected i32, found i8 + | --- ^^^ expected i32, found i8 + | | + | expected due to this error[E0308]: mismatched types --> $DIR/const-scope.rs:6:17 | LL | let d: i8 = c; - | ^ expected i8, found i32 + | -- ^ expected i8, found i32 + | | + | expected due to this error[E0308]: mismatched types --> $DIR/const-scope.rs:10:18 | LL | let c: i32 = 1i8; - | ^^^ expected i32, found i8 + | --- ^^^ expected i32, found i8 + | | + | expected due to this | help: change the type of the numeric literal from `i8` to `i32` | @@ -37,7 +43,9 @@ error[E0308]: mismatched types --> $DIR/const-scope.rs:11:17 | LL | let d: i8 = c; - | ^ expected i8, found i32 + | -- ^ expected i8, found i32 + | | + | expected due to this | help: you can convert an `i32` to `i8` and panic if the converted value wouldn't fit | diff --git a/src/test/ui/numeric/numeric-cast-2.stderr b/src/test/ui/numeric/numeric-cast-2.stderr index 9f08985bdb3c6..f1d5cb87b9556 100644 --- a/src/test/ui/numeric/numeric-cast-2.stderr +++ b/src/test/ui/numeric/numeric-cast-2.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/numeric-cast-2.rs:5:18 | LL | let x: u16 = foo(); - | ^^^^^ expected u16, found i32 + | --- ^^^^^ expected u16, found i32 + | | + | expected due to this | help: you can convert an `i32` to `u16` and panic if the converted value wouldn't fit | @@ -13,7 +15,9 @@ error[E0308]: mismatched types --> $DIR/numeric-cast-2.rs:7:18 | LL | let y: i64 = x + x; - | ^^^^^ expected i64, found u16 + | --- ^^^^^ expected i64, found u16 + | | + | expected due to this | help: you can convert an `u16` to `i64` and panic if the converted value wouldn't fit | @@ -24,7 +28,9 @@ error[E0308]: mismatched types --> $DIR/numeric-cast-2.rs:9:18 | LL | let z: i32 = x + x; - | ^^^^^ expected i32, found u16 + | --- ^^^^^ expected i32, found u16 + | | + | expected due to this | help: you can convert an `u16` to `i32` and panic if the converted value wouldn't fit | diff --git a/src/test/ui/or-patterns/issue-64879-trailing-before-guard.stderr b/src/test/ui/or-patterns/issue-64879-trailing-before-guard.stderr index db6670fc5b1e0..5ddbd98a95f95 100644 --- a/src/test/ui/or-patterns/issue-64879-trailing-before-guard.stderr +++ b/src/test/ui/or-patterns/issue-64879-trailing-before-guard.stderr @@ -10,7 +10,9 @@ error[E0308]: mismatched types --> $DIR/issue-64879-trailing-before-guard.rs:12:42 | LL | let recovery_witness: bool = 0; - | ^ expected bool, found integer + | ---- ^ expected bool, found integer + | | + | expected due to this | = note: expected type `bool` found type `{integer}` diff --git a/src/test/ui/or-patterns/or-patterns-syntactic-fail.stderr b/src/test/ui/or-patterns/or-patterns-syntactic-fail.stderr index 6d08b47c058ed..4bf6f8ecabbbf 100644 --- a/src/test/ui/or-patterns/or-patterns-syntactic-fail.stderr +++ b/src/test/ui/or-patterns/or-patterns-syntactic-fail.stderr @@ -118,10 +118,11 @@ error[E0308]: mismatched types --> $DIR/or-patterns-syntactic-fail.rs:52:36 | LL | let recovery_witness: String = 0; - | ^ - | | - | expected struct `std::string::String`, found integer - | help: try using a conversion method: `0.to_string()` + | ------ ^ + | | | + | | expected struct `std::string::String`, found integer + | | help: try using a conversion method: `0.to_string()` + | expected due to this | = note: expected type `std::string::String` found type `{integer}` diff --git a/src/test/ui/parser/lex-bad-char-literals-6.stderr b/src/test/ui/parser/lex-bad-char-literals-6.stderr index 662cf2657e7b5..a9899faf59a02 100644 --- a/src/test/ui/parser/lex-bad-char-literals-6.stderr +++ b/src/test/ui/parser/lex-bad-char-literals-6.stderr @@ -43,7 +43,9 @@ error[E0308]: mismatched types --> $DIR/lex-bad-char-literals-6.rs:15:20 | LL | let a: usize = ""; - | ^^ expected usize, found reference + | ----- ^^ expected usize, found reference + | | + | expected due to this | = note: expected type `usize` found type `&'static str` diff --git a/src/test/ui/parser/numeric-lifetime.stderr b/src/test/ui/parser/numeric-lifetime.stderr index 4018b24aac175..a9e953b048832 100644 --- a/src/test/ui/parser/numeric-lifetime.stderr +++ b/src/test/ui/parser/numeric-lifetime.stderr @@ -14,7 +14,9 @@ error[E0308]: mismatched types --> $DIR/numeric-lifetime.rs:6:20 | LL | let x: usize = ""; - | ^^ expected usize, found reference + | ----- ^^ expected usize, found reference + | | + | expected due to this | = note: expected type `usize` found type `&'static str` diff --git a/src/test/ui/parser/recover-from-homoglyph.stderr b/src/test/ui/parser/recover-from-homoglyph.stderr index ec7d041647a9f..60ed71385f42b 100644 --- a/src/test/ui/parser/recover-from-homoglyph.stderr +++ b/src/test/ui/parser/recover-from-homoglyph.stderr @@ -13,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/recover-from-homoglyph.rs:3:20 | LL | let x: usize = (); - | ^^ expected usize, found () + | ----- ^^ expected usize, found () + | | + | expected due to this | = note: expected type `usize` found type `()` diff --git a/src/test/ui/parser/recover-missing-semi.stderr b/src/test/ui/parser/recover-missing-semi.stderr index c40918ee2bd5f..6fc11eab5bcdb 100644 --- a/src/test/ui/parser/recover-missing-semi.stderr +++ b/src/test/ui/parser/recover-missing-semi.stderr @@ -20,7 +20,9 @@ error[E0308]: mismatched types --> $DIR/recover-missing-semi.rs:2:20 | LL | let _: usize = () - | ^^ expected usize, found () + | ----- ^^ expected usize, found () + | | + | expected due to this | = note: expected type `usize` found type `()` @@ -29,7 +31,9 @@ error[E0308]: mismatched types --> $DIR/recover-missing-semi.rs:9:20 | LL | let _: usize = () - | ^^ expected usize, found () + | ----- ^^ expected usize, found () + | | + | expected due to this | = note: expected type `usize` found type `()` diff --git a/src/test/ui/parser/recover-tuple.stderr b/src/test/ui/parser/recover-tuple.stderr index 4252fc1fd1e1b..0c93ab55373a8 100644 --- a/src/test/ui/parser/recover-tuple.stderr +++ b/src/test/ui/parser/recover-tuple.stderr @@ -8,7 +8,9 @@ error[E0308]: mismatched types --> $DIR/recover-tuple.rs:6:20 | LL | let y: usize = ""; - | ^^ expected usize, found reference + | ----- ^^ expected usize, found reference + | | + | expected due to this | = note: expected type `usize` found type `&'static str` diff --git a/src/test/ui/parser/unclosed-delimiter-in-dep.stderr b/src/test/ui/parser/unclosed-delimiter-in-dep.stderr index 818f61b4d2229..986f30575dc66 100644 --- a/src/test/ui/parser/unclosed-delimiter-in-dep.stderr +++ b/src/test/ui/parser/unclosed-delimiter-in-dep.stderr @@ -13,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/unclosed-delimiter-in-dep.rs:4:20 | LL | let _: usize = unclosed_delim_mod::new(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected usize, found enum `std::result::Result` + | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^ expected usize, found enum `std::result::Result` + | | + | expected due to this | = note: expected type `usize` found type `std::result::Result` diff --git a/src/test/ui/proc-macro/attribute-spans-preserved.stderr b/src/test/ui/proc-macro/attribute-spans-preserved.stderr index 6c571dbdb4769..94ede4c60d335 100644 --- a/src/test/ui/proc-macro/attribute-spans-preserved.stderr +++ b/src/test/ui/proc-macro/attribute-spans-preserved.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/attribute-spans-preserved.rs:7:23 | LL | #[ foo ( let y: u32 = "z"; ) ] - | ^^^ expected u32, found reference + | --- ^^^ expected u32, found reference + | | + | expected due to this | = note: expected type `u32` found type `&'static str` @@ -11,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/attribute-spans-preserved.rs:8:23 | LL | #[ bar { let x: u32 = "y"; } ] - | ^^^ expected u32, found reference + | --- ^^^ expected u32, found reference + | | + | expected due to this | = note: expected type `u32` found type `&'static str` diff --git a/src/test/ui/proc-macro/attribute-with-error.stderr b/src/test/ui/proc-macro/attribute-with-error.stderr index 937d47ff08979..5dbf708000afa 100644 --- a/src/test/ui/proc-macro/attribute-with-error.stderr +++ b/src/test/ui/proc-macro/attribute-with-error.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/attribute-with-error.rs:10:18 | LL | let a: i32 = "foo"; - | ^^^^^ expected i32, found reference + | --- ^^^^^ expected i32, found reference + | | + | expected due to this | = note: expected type `i32` found type `&'static str` @@ -11,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/attribute-with-error.rs:12:18 | LL | let b: i32 = "f'oo"; - | ^^^^^^ expected i32, found reference + | --- ^^^^^^ expected i32, found reference + | | + | expected due to this | = note: expected type `i32` found type `&'static str` @@ -20,7 +24,9 @@ error[E0308]: mismatched types --> $DIR/attribute-with-error.rs:25:22 | LL | let a: i32 = "foo"; - | ^^^^^ expected i32, found reference + | --- ^^^^^ expected i32, found reference + | | + | expected due to this | = note: expected type `i32` found type `&'static str` @@ -29,7 +35,9 @@ error[E0308]: mismatched types --> $DIR/attribute-with-error.rs:35:22 | LL | let a: i32 = "foo"; - | ^^^^^ expected i32, found reference + | --- ^^^^^ expected i32, found reference + | | + | expected due to this | = note: expected type `i32` found type `&'static str` diff --git a/src/test/ui/proc-macro/nested-item-spans.stderr b/src/test/ui/proc-macro/nested-item-spans.stderr index bef80311f38e5..f1a062fc06447 100644 --- a/src/test/ui/proc-macro/nested-item-spans.stderr +++ b/src/test/ui/proc-macro/nested-item-spans.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/nested-item-spans.rs:9:22 | LL | let x: u32 = "x"; - | ^^^ expected u32, found reference + | --- ^^^ expected u32, found reference + | | + | expected due to this | = note: expected type `u32` found type `&'static str` @@ -11,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/nested-item-spans.rs:18:22 | LL | let x: u32 = "x"; - | ^^^ expected u32, found reference + | --- ^^^ expected u32, found reference + | | + | expected due to this | = note: expected type `u32` found type `&'static str` diff --git a/src/test/ui/proc-macro/span-preservation.stderr b/src/test/ui/proc-macro/span-preservation.stderr index 545c2fa5f40e4..e4751573916d6 100644 --- a/src/test/ui/proc-macro/span-preservation.stderr +++ b/src/test/ui/proc-macro/span-preservation.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/span-preservation.rs:11:20 | LL | let x: usize = "hello"; - | ^^^^^^^ expected usize, found reference + | ----- ^^^^^^^ expected usize, found reference + | | + | expected due to this | = note: expected type `usize` found type `&'static str` diff --git a/src/test/ui/ptr-coercion.stderr b/src/test/ui/ptr-coercion.stderr index 019241d6874aa..ea812f5c4b626 100644 --- a/src/test/ui/ptr-coercion.stderr +++ b/src/test/ui/ptr-coercion.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/ptr-coercion.rs:7:25 | LL | let x: *mut isize = x; - | ^ types differ in mutability + | ---------- ^ types differ in mutability + | | + | expected due to this | = note: expected type `*mut isize` found type `*const isize` @@ -11,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/ptr-coercion.rs:13:25 | LL | let x: *mut isize = &42; - | ^^^ types differ in mutability + | ---------- ^^^ types differ in mutability + | | + | expected due to this | = note: expected type `*mut isize` found type `&isize` @@ -20,7 +24,9 @@ error[E0308]: mismatched types --> $DIR/ptr-coercion.rs:19:25 | LL | let x: *mut isize = x; - | ^ types differ in mutability + | ---------- ^ types differ in mutability + | | + | expected due to this | = note: expected type `*mut isize` found type `*const isize` diff --git a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr index 36c66451cfaf6..272c2dceb642f 100644 --- a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr +++ b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr @@ -20,7 +20,9 @@ error[E0308]: mismatched types --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:43 | LL | let _: fn(&mut &isize, &mut &isize) = a; - | ^ expected concrete lifetime, found bound lifetime parameter + | ---------------------------- ^ expected concrete lifetime, found bound lifetime parameter + | | + | expected due to this | = note: expected type `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` found type `for<'r, 's> fn(&'r mut &isize, &'s mut &isize) {a::<'_, '_>}` diff --git a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr index a366bd2e5c2d7..d1cfcab73f3ed 100644 --- a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr +++ b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr @@ -31,7 +31,9 @@ error[E0308]: mismatched types --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:56 | LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; - | ^ expected concrete lifetime, found bound lifetime parameter + | ----------------------------------------- ^ expected concrete lifetime, found bound lifetime parameter + | | + | expected due to this | = note: expected type `for<'r, 's, 't0, 't1, 't2, 't3> fn(&'r mut &'s isize, &'t0 mut &'t1 isize, &'t2 mut &'t3 isize)` found type `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize) {a::<'_, '_, '_>}` diff --git a/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr b/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr index e260fccf8488c..cf980de99290b 100644 --- a/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr +++ b/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr @@ -20,7 +20,9 @@ error[E0308]: mismatched types --> $DIR/regions-lifetime-bounds-on-fns.rs:20:43 | LL | let _: fn(&mut &isize, &mut &isize) = a; - | ^ expected concrete lifetime, found bound lifetime parameter + | ---------------------------- ^ expected concrete lifetime, found bound lifetime parameter + | | + | expected due to this | = note: expected type `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` found type `for<'r, 's> fn(&'r mut &isize, &'s mut &isize) {a::<'_, '_>}` diff --git a/src/test/ui/reify-intrinsic.stderr b/src/test/ui/reify-intrinsic.stderr index 4a1bd77cf7ee9..b629a27f7a48a 100644 --- a/src/test/ui/reify-intrinsic.stderr +++ b/src/test/ui/reify-intrinsic.stderr @@ -2,10 +2,11 @@ error[E0308]: cannot coerce intrinsics to function pointers --> $DIR/reify-intrinsic.rs:6:64 | LL | let _: unsafe extern "rust-intrinsic" fn(isize) -> usize = std::mem::transmute; - | ^^^^^^^^^^^^^^^^^^^ - | | - | cannot coerce intrinsics to function pointers - | help: use parentheses to call this function: `std::mem::transmute(...)` + | ------------------------------------------------- ^^^^^^^^^^^^^^^^^^^ + | | | + | | cannot coerce intrinsics to function pointers + | | help: use parentheses to call this function: `std::mem::transmute(...)` + | expected due to this | = note: expected type `unsafe extern "rust-intrinsic" fn(isize) -> usize` found type `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}` diff --git a/src/test/ui/resolve/privacy-enum-ctor.stderr b/src/test/ui/resolve/privacy-enum-ctor.stderr index 8a450ab85e926..b243e09d93594 100644 --- a/src/test/ui/resolve/privacy-enum-ctor.stderr +++ b/src/test/ui/resolve/privacy-enum-ctor.stderr @@ -280,10 +280,11 @@ LL | Fn(u8), | ------ fn(u8) -> m::n::Z {m::n::Z::Fn} defined here ... LL | let _: Z = Z::Fn; - | ^^^^^ - | | - | expected enum `m::n::Z`, found fn item - | help: use parentheses to instantiate this tuple variant: `Z::Fn(_)` + | - ^^^^^ + | | | + | | expected enum `m::n::Z`, found fn item + | | help: use parentheses to instantiate this tuple variant: `Z::Fn(_)` + | expected due to this | = note: expected type `m::n::Z` found type `fn(u8) -> m::n::Z {m::n::Z::Fn}` @@ -311,10 +312,11 @@ LL | Fn(u8), | ------ fn(u8) -> m::E {m::E::Fn} defined here ... LL | let _: E = m::E::Fn; - | ^^^^^^^^ - | | - | expected enum `m::E`, found fn item - | help: use parentheses to instantiate this tuple variant: `m::E::Fn(_)` + | - ^^^^^^^^ + | | | + | | expected enum `m::E`, found fn item + | | help: use parentheses to instantiate this tuple variant: `m::E::Fn(_)` + | expected due to this | = note: expected type `m::E` found type `fn(u8) -> m::E {m::E::Fn}` @@ -342,10 +344,11 @@ LL | Fn(u8), | ------ fn(u8) -> m::E {m::E::Fn} defined here ... LL | let _: E = E::Fn; - | ^^^^^ - | | - | expected enum `m::E`, found fn item - | help: use parentheses to instantiate this tuple variant: `E::Fn(_)` + | - ^^^^^ + | | | + | | expected enum `m::E`, found fn item + | | help: use parentheses to instantiate this tuple variant: `E::Fn(_)` + | expected due to this | = note: expected type `m::E` found type `fn(u8) -> m::E {m::E::Fn}` diff --git a/src/test/ui/shift-various-bad-types.stderr b/src/test/ui/shift-various-bad-types.stderr index c7a9588322651..170229bdd8c2e 100644 --- a/src/test/ui/shift-various-bad-types.stderr +++ b/src/test/ui/shift-various-bad-types.stderr @@ -26,7 +26,9 @@ error[E0308]: mismatched types --> $DIR/shift-various-bad-types.rs:25:18 | LL | let _: i32 = 22_i64 >> 1_i32; - | ^^^^^^^^^^^^^^^ expected i32, found i64 + | --- ^^^^^^^^^^^^^^^ expected i32, found i64 + | | + | expected due to this | help: you can convert an `i64` to `i32` and panic if the converted value wouldn't fit | diff --git a/src/test/ui/slice-mut.stderr b/src/test/ui/slice-mut.stderr index e99d83d0fed38..072f0178c14f1 100644 --- a/src/test/ui/slice-mut.stderr +++ b/src/test/ui/slice-mut.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/slice-mut.rs:7:22 | LL | let y: &mut[_] = &x[2..4]; - | ^^^^^^^^ types differ in mutability + | ------- ^^^^^^^^ types differ in mutability + | | + | expected due to this | = note: expected type `&mut [_]` found type `&[isize]` diff --git a/src/test/ui/span/coerce-suggestions.stderr b/src/test/ui/span/coerce-suggestions.stderr index 0d15a2a753ed0..2b19787b2c50c 100644 --- a/src/test/ui/span/coerce-suggestions.stderr +++ b/src/test/ui/span/coerce-suggestions.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/coerce-suggestions.rs:7:20 | LL | let x: usize = String::new(); - | ^^^^^^^^^^^^^ expected usize, found struct `std::string::String` + | ----- ^^^^^^^^^^^^^ expected usize, found struct `std::string::String` + | | + | expected due to this | = note: expected type `usize` found type `std::string::String` @@ -11,10 +13,11 @@ error[E0308]: mismatched types --> $DIR/coerce-suggestions.rs:9:19 | LL | let x: &str = String::new(); - | ^^^^^^^^^^^^^ - | | - | expected &str, found struct `std::string::String` - | help: consider borrowing here: `&String::new()` + | ---- ^^^^^^^^^^^^^ + | | | + | | expected &str, found struct `std::string::String` + | | help: consider borrowing here: `&String::new()` + | expected due to this | = note: expected type `&str` found type `std::string::String` diff --git a/src/test/ui/span/move-closure.stderr b/src/test/ui/span/move-closure.stderr index e2226b197aeb8..e86469a99c4ac 100644 --- a/src/test/ui/span/move-closure.stderr +++ b/src/test/ui/span/move-closure.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/move-closure.rs:5:17 | LL | let x: () = move || (); - | ^^^^^^^^^^ expected (), found closure + | -- ^^^^^^^^^^ expected (), found closure + | | + | expected due to this | = note: expected type `()` found type `[closure@$DIR/move-closure.rs:5:17: 5:27]` diff --git a/src/test/ui/str/str-array-assignment.stderr b/src/test/ui/str/str-array-assignment.stderr index ecd5fb4412967..16390c56d4e36 100644 --- a/src/test/ui/str/str-array-assignment.stderr +++ b/src/test/ui/str/str-array-assignment.stderr @@ -38,10 +38,11 @@ error[E0308]: mismatched types --> $DIR/str-array-assignment.rs:9:17 | LL | let w: &str = s[..2]; - | ^^^^^^ - | | - | expected &str, found str - | help: consider borrowing here: `&s[..2]` + | ---- ^^^^^^ + | | | + | | expected &str, found str + | | help: consider borrowing here: `&s[..2]` + | expected due to this | = note: expected type `&str` found type `str` diff --git a/src/test/ui/str/str-lit-type-mismatch.stderr b/src/test/ui/str/str-lit-type-mismatch.stderr index ef40faa8e26eb..e502dc12a3822 100644 --- a/src/test/ui/str/str-lit-type-mismatch.stderr +++ b/src/test/ui/str/str-lit-type-mismatch.stderr @@ -2,10 +2,11 @@ error[E0308]: mismatched types --> $DIR/str-lit-type-mismatch.rs:2:20 | LL | let x: &[u8] = "foo"; - | ^^^^^ - | | - | expected slice, found str - | help: consider adding a leading `b`: `b"foo"` + | ----- ^^^^^ + | | | + | | expected slice, found str + | | help: consider adding a leading `b`: `b"foo"` + | expected due to this | = note: expected type `&[u8]` found type `&'static str` @@ -14,10 +15,11 @@ error[E0308]: mismatched types --> $DIR/str-lit-type-mismatch.rs:3:23 | LL | let y: &[u8; 4] = "baaa"; - | ^^^^^^ - | | - | expected array of 4 elements, found str - | help: consider adding a leading `b`: `b"baaa"` + | -------- ^^^^^^ + | | | + | | expected array of 4 elements, found str + | | help: consider adding a leading `b`: `b"baaa"` + | expected due to this | = note: expected type `&[u8; 4]` found type `&'static str` @@ -26,10 +28,11 @@ error[E0308]: mismatched types --> $DIR/str-lit-type-mismatch.rs:4:19 | LL | let z: &str = b"foo"; - | ^^^^^^ - | | - | expected str, found array of 3 elements - | help: consider removing the leading `b`: `"foo"` + | ---- ^^^^^^ + | | | + | | expected str, found array of 3 elements + | | help: consider removing the leading `b`: `"foo"` + | expected due to this | = note: expected type `&str` found type `&'static [u8; 3]` diff --git a/src/test/ui/struct-literal-variant-in-if.stderr b/src/test/ui/struct-literal-variant-in-if.stderr index bfc8b24e8ac49..cc2bf7d558143 100644 --- a/src/test/ui/struct-literal-variant-in-if.stderr +++ b/src/test/ui/struct-literal-variant-in-if.stderr @@ -66,7 +66,9 @@ error[E0308]: mismatched types --> $DIR/struct-literal-variant-in-if.rs:21:20 | LL | let y: usize = (); - | ^^ expected usize, found () + | ----- ^^ expected usize, found () + | | + | expected due to this | = note: expected type `usize` found type `()` diff --git a/src/test/ui/substs-ppaux.normal.stderr b/src/test/ui/substs-ppaux.normal.stderr index cb55203c88e31..33d56a3a09dfe 100644 --- a/src/test/ui/substs-ppaux.normal.stderr +++ b/src/test/ui/substs-ppaux.normal.stderr @@ -5,10 +5,11 @@ LL | fn bar<'a, T>() where T: 'a {} | --------------------------- fn() {>::bar::<'static, char>} defined here ... LL | let x: () = >::bar::<'static, char>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected (), found fn item - | help: use parentheses to call this function: `>::bar::<'static, char>()` + | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | expected (), found fn item + | | help: use parentheses to call this function: `>::bar::<'static, char>()` + | expected due to this | = note: expected type `()` found type `fn() {>::bar::<'static, char>}` @@ -20,10 +21,11 @@ LL | fn bar<'a, T>() where T: 'a {} | --------------------------- fn() {>::bar::<'static, char>} defined here ... LL | let x: () = >::bar::<'static, char>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected (), found fn item - | help: use parentheses to call this function: `>::bar::<'static, char>()` + | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | expected (), found fn item + | | help: use parentheses to call this function: `>::bar::<'static, char>()` + | expected due to this | = note: expected type `()` found type `fn() {>::bar::<'static, char>}` @@ -35,10 +37,11 @@ LL | fn baz() {} | -------- fn() {>::baz} defined here ... LL | let x: () = >::baz; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected (), found fn item - | help: use parentheses to call this function: `>::baz()` + | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | expected (), found fn item + | | help: use parentheses to call this function: `>::baz()` + | expected due to this | = note: expected type `()` found type `fn() {>::baz}` @@ -50,10 +53,11 @@ LL | fn foo<'z>() where &'z (): Sized { | -------------------------------- fn() {foo::<'static>} defined here ... LL | let x: () = foo::<'static>; - | ^^^^^^^^^^^^^^ - | | - | expected (), found fn item - | help: use parentheses to call this function: `foo::<'static>()` + | -- ^^^^^^^^^^^^^^ + | | | + | | expected (), found fn item + | | help: use parentheses to call this function: `foo::<'static>()` + | expected due to this | = note: expected type `()` found type `fn() {foo::<'static>}` diff --git a/src/test/ui/substs-ppaux.verbose.stderr b/src/test/ui/substs-ppaux.verbose.stderr index cafcba97b92c8..8c958406d8e43 100644 --- a/src/test/ui/substs-ppaux.verbose.stderr +++ b/src/test/ui/substs-ppaux.verbose.stderr @@ -5,10 +5,11 @@ LL | fn bar<'a, T>() where T: 'a {} | --------------------------- fn() {>::bar::} defined here ... LL | let x: () = >::bar::<'static, char>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected (), found fn item - | help: use parentheses to call this function: `>::bar::<'static, char>()` + | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | expected (), found fn item + | | help: use parentheses to call this function: `>::bar::<'static, char>()` + | expected due to this | = note: expected type `()` found type `fn() {>::bar::}` @@ -20,10 +21,11 @@ LL | fn bar<'a, T>() where T: 'a {} | --------------------------- fn() {>::bar::} defined here ... LL | let x: () = >::bar::<'static, char>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected (), found fn item - | help: use parentheses to call this function: `>::bar::<'static, char>()` + | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | expected (), found fn item + | | help: use parentheses to call this function: `>::bar::<'static, char>()` + | expected due to this | = note: expected type `()` found type `fn() {>::bar::}` @@ -35,10 +37,11 @@ LL | fn baz() {} | -------- fn() {>::baz} defined here ... LL | let x: () = >::baz; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected (), found fn item - | help: use parentheses to call this function: `>::baz()` + | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | expected (), found fn item + | | help: use parentheses to call this function: `>::baz()` + | expected due to this | = note: expected type `()` found type `fn() {>::baz}` @@ -50,10 +53,11 @@ LL | fn foo<'z>() where &'z (): Sized { | -------------------------------- fn() {foo::} defined here ... LL | let x: () = foo::<'static>; - | ^^^^^^^^^^^^^^ - | | - | expected (), found fn item - | help: use parentheses to call this function: `foo::<'static>()` + | -- ^^^^^^^^^^^^^^ + | | | + | | expected (), found fn item + | | help: use parentheses to call this function: `foo::<'static>()` + | expected due to this | = note: expected type `()` found type `fn() {foo::}` diff --git a/src/test/ui/suggestions/as-ref.stderr b/src/test/ui/suggestions/as-ref.stderr index 8143acc957b4c..3ea21af3f9f57 100644 --- a/src/test/ui/suggestions/as-ref.stderr +++ b/src/test/ui/suggestions/as-ref.stderr @@ -46,10 +46,11 @@ error[E0308]: mismatched types --> $DIR/as-ref.rs:16:27 | LL | let y: Option<&usize> = x; - | ^ - | | - | expected enum `std::option::Option`, found reference - | help: you can convert from `&Option` to `Option<&T>` using `.as_ref()`: `x.as_ref()` + | -------------- ^ + | | | + | | expected enum `std::option::Option`, found reference + | | help: you can convert from `&Option` to `Option<&T>` using `.as_ref()`: `x.as_ref()` + | expected due to this | = note: expected type `std::option::Option<&usize>` found type `&std::option::Option` @@ -58,7 +59,9 @@ error[E0308]: mismatched types --> $DIR/as-ref.rs:19:35 | LL | let y: Result<&usize, &usize> = x; - | ^ expected enum `std::result::Result`, found reference + | ---------------------- ^ expected enum `std::result::Result`, found reference + | | + | expected due to this | = note: expected type `std::result::Result<&usize, &usize>` found type `&std::result::Result` @@ -71,7 +74,9 @@ error[E0308]: mismatched types --> $DIR/as-ref.rs:23:34 | LL | let y: Result<&usize, usize> = x; - | ^ expected enum `std::result::Result`, found reference + | --------------------- ^ expected enum `std::result::Result`, found reference + | | + | expected due to this | = note: expected type `std::result::Result<&usize, usize>` found type `&std::result::Result` diff --git a/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr b/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr index 56810a4915869..1343a018165ac 100644 --- a/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr +++ b/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr @@ -19,10 +19,11 @@ LL | fn foo(a: usize, b: usize) -> usize { a } | ----------------------------------- fn(usize, usize) -> usize {foo} defined here ... LL | let _: usize = foo; - | ^^^ - | | - | expected usize, found fn item - | help: use parentheses to call this function: `foo(a, b)` + | ----- ^^^ + | | | + | | expected usize, found fn item + | | help: use parentheses to call this function: `foo(a, b)` + | expected due to this | = note: expected type `usize` found type `fn(usize, usize) -> usize {foo}` @@ -34,10 +35,11 @@ LL | struct S(usize, usize); | ----------------------- fn(usize, usize) -> S {S} defined here ... LL | let _: S = S; - | ^ - | | - | expected struct `S`, found fn item - | help: use parentheses to instantiate this tuple struct: `S(_, _)` + | - ^ + | | | + | | expected struct `S`, found fn item + | | help: use parentheses to instantiate this tuple struct: `S(_, _)` + | expected due to this | = note: expected type `S` found type `fn(usize, usize) -> S {S}` @@ -49,10 +51,11 @@ LL | fn bar() -> usize { 42 } | ----------------- fn() -> usize {bar} defined here ... LL | let _: usize = bar; - | ^^^ - | | - | expected usize, found fn item - | help: use parentheses to call this function: `bar()` + | ----- ^^^ + | | | + | | expected usize, found fn item + | | help: use parentheses to call this function: `bar()` + | expected due to this | = note: expected type `usize` found type `fn() -> usize {bar}` @@ -64,10 +67,11 @@ LL | struct V(); | ----------- fn() -> V {V} defined here ... LL | let _: V = V; - | ^ - | | - | expected struct `V`, found fn item - | help: use parentheses to instantiate this tuple struct: `V()` + | - ^ + | | | + | | expected struct `V`, found fn item + | | help: use parentheses to instantiate this tuple struct: `V()` + | expected due to this | = note: expected type `V` found type `fn() -> V {V}` @@ -79,10 +83,11 @@ LL | fn baz(x: usize, y: usize) -> usize { x } | ----------------------------------- fn(usize, usize) -> usize {<_ as T>::baz} defined here ... LL | let _: usize = T::baz; - | ^^^^^^ - | | - | expected usize, found fn item - | help: use parentheses to call this function: `T::baz(x, y)` + | ----- ^^^^^^ + | | | + | | expected usize, found fn item + | | help: use parentheses to call this function: `T::baz(x, y)` + | expected due to this | = note: expected type `usize` found type `fn(usize, usize) -> usize {<_ as T>::baz}` @@ -94,10 +99,11 @@ LL | fn bat(x: usize) -> usize { 42 } | ------------------------- fn(usize) -> usize {<_ as T>::bat} defined here ... LL | let _: usize = T::bat; - | ^^^^^^ - | | - | expected usize, found fn item - | help: use parentheses to call this function: `T::bat(x)` + | ----- ^^^^^^ + | | | + | | expected usize, found fn item + | | help: use parentheses to call this function: `T::bat(x)` + | expected due to this | = note: expected type `usize` found type `fn(usize) -> usize {<_ as T>::bat}` @@ -109,10 +115,11 @@ LL | A(usize), | -------- fn(usize) -> E {E::A} defined here ... LL | let _: E = E::A; - | ^^^^ - | | - | expected enum `E`, found fn item - | help: use parentheses to instantiate this tuple variant: `E::A(_)` + | - ^^^^ + | | | + | | expected enum `E`, found fn item + | | help: use parentheses to instantiate this tuple variant: `E::A(_)` + | expected due to this | = note: expected type `E` found type `fn(usize) -> E {E::A}` @@ -124,10 +131,11 @@ LL | fn baz(x: usize, y: usize) -> usize { x } | ----------------------------------- fn(usize, usize) -> usize {::baz} defined here ... LL | let _: usize = X::baz; - | ^^^^^^ - | | - | expected usize, found fn item - | help: use parentheses to call this function: `X::baz(x, y)` + | ----- ^^^^^^ + | | | + | | expected usize, found fn item + | | help: use parentheses to call this function: `X::baz(x, y)` + | expected due to this | = note: expected type `usize` found type `fn(usize, usize) -> usize {::baz}` @@ -139,10 +147,11 @@ LL | fn bat(x: usize) -> usize { 42 } | ------------------------- fn(usize) -> usize {::bat} defined here ... LL | let _: usize = X::bat; - | ^^^^^^ - | | - | expected usize, found fn item - | help: use parentheses to call this function: `X::bat(x)` + | ----- ^^^^^^ + | | | + | | expected usize, found fn item + | | help: use parentheses to call this function: `X::bat(x)` + | expected due to this | = note: expected type `usize` found type `fn(usize) -> usize {::bat}` @@ -154,10 +163,11 @@ LL | fn bax(x: usize) -> usize { 42 } | ------------------------- fn(usize) -> usize {::bax} defined here ... LL | let _: usize = X::bax; - | ^^^^^^ - | | - | expected usize, found fn item - | help: use parentheses to call this function: `X::bax(x)` + | ----- ^^^^^^ + | | | + | | expected usize, found fn item + | | help: use parentheses to call this function: `X::bax(x)` + | expected due to this | = note: expected type `usize` found type `fn(usize) -> usize {::bax}` @@ -169,10 +179,11 @@ LL | fn bach(x: usize) -> usize; | --------------------------- fn(usize) -> usize {::bach} defined here ... LL | let _: usize = X::bach; - | ^^^^^^^ - | | - | expected usize, found fn item - | help: use parentheses to call this function: `X::bach(x)` + | ----- ^^^^^^^ + | | | + | | expected usize, found fn item + | | help: use parentheses to call this function: `X::bach(x)` + | expected due to this | = note: expected type `usize` found type `fn(usize) -> usize {::bach}` @@ -184,10 +195,11 @@ LL | fn ban(&self) -> usize { 42 } | ---------------------- for<'r> fn(&'r X) -> usize {::ban} defined here ... LL | let _: usize = X::ban; - | ^^^^^^ - | | - | expected usize, found fn item - | help: use parentheses to call this function: `X::ban(_)` + | ----- ^^^^^^ + | | | + | | expected usize, found fn item + | | help: use parentheses to call this function: `X::ban(_)` + | expected due to this | = note: expected type `usize` found type `for<'r> fn(&'r X) -> usize {::ban}` @@ -199,10 +211,11 @@ LL | fn bal(&self) -> usize; | ----------------------- for<'r> fn(&'r X) -> usize {::bal} defined here ... LL | let _: usize = X::bal; - | ^^^^^^ - | | - | expected usize, found fn item - | help: use parentheses to call this function: `X::bal(_)` + | ----- ^^^^^^ + | | | + | | expected usize, found fn item + | | help: use parentheses to call this function: `X::bal(_)` + | expected due to this | = note: expected type `usize` found type `for<'r> fn(&'r X) -> usize {::bal}` @@ -225,10 +238,11 @@ error[E0308]: mismatched types LL | let closure = || 42; | -- closure defined here LL | let _: usize = closure; - | ^^^^^^^ - | | - | expected usize, found closure - | help: use parentheses to call this closure: `closure()` + | ----- ^^^^^^^ + | | | + | | expected usize, found closure + | | help: use parentheses to call this closure: `closure()` + | expected due to this | = note: expected type `usize` found type `[closure@$DIR/fn-or-tuple-struct-without-args.rs:45:19: 45:24]` diff --git a/src/test/ui/suggestions/format-borrow.stderr b/src/test/ui/suggestions/format-borrow.stderr index 44bb11faa7f38..7ed6abb3c5c15 100644 --- a/src/test/ui/suggestions/format-borrow.stderr +++ b/src/test/ui/suggestions/format-borrow.stderr @@ -2,10 +2,11 @@ error[E0308]: mismatched types --> $DIR/format-borrow.rs:2:21 | LL | let a: String = &String::from("a"); - | ^^^^^^^^^^^^^^^^^^ - | | - | expected struct `std::string::String`, found reference - | help: consider removing the borrow: `String::from("a")` + | ------ ^^^^^^^^^^^^^^^^^^ + | | | + | | expected struct `std::string::String`, found reference + | | help: consider removing the borrow: `String::from("a")` + | expected due to this | = note: expected type `std::string::String` found type `&std::string::String` @@ -14,10 +15,11 @@ error[E0308]: mismatched types --> $DIR/format-borrow.rs:4:21 | LL | let b: String = &format!("b"); - | ^^^^^^^^^^^^^ - | | - | expected struct `std::string::String`, found reference - | help: consider removing the borrow: `format!("b")` + | ------ ^^^^^^^^^^^^^ + | | | + | | expected struct `std::string::String`, found reference + | | help: consider removing the borrow: `format!("b")` + | expected due to this | = note: expected type `std::string::String` found type `&std::string::String` diff --git a/src/test/ui/suggestions/issue-59819.stderr b/src/test/ui/suggestions/issue-59819.stderr index 66898115cbd6d..c19e8273b02c4 100644 --- a/src/test/ui/suggestions/issue-59819.stderr +++ b/src/test/ui/suggestions/issue-59819.stderr @@ -2,10 +2,11 @@ error[E0308]: mismatched types --> $DIR/issue-59819.rs:28:18 | LL | let y: i32 = x; - | ^ - | | - | expected i32, found struct `Foo` - | help: consider dereferencing the type: `*x` + | --- ^ + | | | + | | expected i32, found struct `Foo` + | | help: consider dereferencing the type: `*x` + | expected due to this | = note: expected type `i32` found type `Foo` @@ -14,10 +15,11 @@ error[E0308]: mismatched types --> $DIR/issue-59819.rs:30:18 | LL | let b: i32 = a; - | ^ - | | - | expected i32, found &{integer} - | help: consider dereferencing the borrow: `*a` + | --- ^ + | | | + | | expected i32, found &{integer} + | | help: consider dereferencing the borrow: `*a` + | expected due to this | = note: expected type `i32` found type `&{integer}` @@ -26,10 +28,11 @@ error[E0308]: mismatched types --> $DIR/issue-59819.rs:34:21 | LL | let g: String = f; - | ^ - | | - | expected struct `std::string::String`, found struct `Bar` - | help: try using a conversion method: `f.to_string()` + | ------ ^ + | | | + | | expected struct `std::string::String`, found struct `Bar` + | | help: try using a conversion method: `f.to_string()` + | expected due to this | = note: expected type `std::string::String` found type `Bar` diff --git a/src/test/ui/suggestions/mismatched-types-numeric-from.stderr b/src/test/ui/suggestions/mismatched-types-numeric-from.stderr index 223b6747322c1..788e460028dc5 100644 --- a/src/test/ui/suggestions/mismatched-types-numeric-from.stderr +++ b/src/test/ui/suggestions/mismatched-types-numeric-from.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/mismatched-types-numeric-from.rs:2:18 | LL | let _: u32 = i32::from(0_u8); - | ^^^^^^^^^^^^^^^ expected u32, found i32 + | --- ^^^^^^^^^^^^^^^ expected u32, found i32 + | | + | expected due to this error: aborting due to previous error diff --git a/src/test/ui/suggestions/recover-from-semicolon-trailing-item.stderr b/src/test/ui/suggestions/recover-from-semicolon-trailing-item.stderr index 9a47a1efb752a..42ddac65d2975 100644 --- a/src/test/ui/suggestions/recover-from-semicolon-trailing-item.stderr +++ b/src/test/ui/suggestions/recover-from-semicolon-trailing-item.stderr @@ -22,7 +22,9 @@ error[E0308]: mismatched types --> $DIR/recover-from-semicolon-trailing-item.rs:10:20 | LL | let _: usize = S {}; - | ^^^^ expected usize, found struct `S` + | ----- ^^^^ expected usize, found struct `S` + | | + | expected due to this | = note: expected type `usize` found type `S` @@ -31,7 +33,9 @@ error[E0308]: mismatched types --> $DIR/recover-from-semicolon-trailing-item.rs:12:20 | LL | let _: usize = X {}; - | ^^^^ expected usize, found struct `main::X` + | ----- ^^^^ expected usize, found struct `main::X` + | | + | expected due to this | = note: expected type `usize` found type `main::X` diff --git a/src/test/ui/suggestions/suggest-box.stderr b/src/test/ui/suggestions/suggest-box.stderr index 50c106d63a02b..8d87375618dba 100644 --- a/src/test/ui/suggestions/suggest-box.stderr +++ b/src/test/ui/suggestions/suggest-box.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/suggest-box.rs:4:47 | LL | let _x: Box Result<(), ()>> = || { - | _______________________________________________^ + | _____________-------------------------------___^ + | | | + | | expected due to this LL | | Err(())?; LL | | Ok(()) LL | | }; diff --git a/src/test/ui/tag-that-dare-not-speak-its-name.stderr b/src/test/ui/tag-that-dare-not-speak-its-name.stderr index 23e3d66526215..eeecced36b57d 100644 --- a/src/test/ui/tag-that-dare-not-speak-its-name.stderr +++ b/src/test/ui/tag-that-dare-not-speak-its-name.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/tag-that-dare-not-speak-its-name.rs:11:20 | LL | let x : char = last(y); - | ^^^^^^^ expected char, found enum `std::option::Option` + | ---- ^^^^^^^ expected char, found enum `std::option::Option` + | | + | expected due to this | = note: expected type `char` found type `std::option::Option<_>` diff --git a/src/test/ui/terminal-width/non-whitespace-trimming-2.stderr b/src/test/ui/terminal-width/non-whitespace-trimming-2.stderr index bf1699f5cabbb..59c3dc1698634 100644 --- a/src/test/ui/terminal-width/non-whitespace-trimming-2.stderr +++ b/src/test/ui/terminal-width/non-whitespace-trimming-2.stderr @@ -1,8 +1,10 @@ error[E0308]: mismatched types --> $DIR/non-whitespace-trimming-2.rs:4:311 | -LL | ...; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let _:... - | ^^ expected (), found integer +LL | ... 13; let _: usize = 14; let _: usize = 15; let _: () = 42; let _: usize = 0; let _: usize = 1; let _: usize = 2; let _: usize = 3; let... + | -- ^^ expected (), found integer + | | + | expected due to this | = note: expected type `()` found type `{integer}` diff --git a/src/test/ui/terminal-width/non-whitespace-trimming-unicode.stderr b/src/test/ui/terminal-width/non-whitespace-trimming-unicode.stderr index b56b1948d9e07..9530ffde41ed3 100644 --- a/src/test/ui/terminal-width/non-whitespace-trimming-unicode.stderr +++ b/src/test/ui/terminal-width/non-whitespace-trimming-unicode.stderr @@ -1,8 +1,10 @@ error[E0308]: mismatched types --> $DIR/non-whitespace-trimming-unicode.rs:4:415 | -LL | ...♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42; let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃♄♅♆... - | ^^ expected (), found integer +LL | ...♬♭♮♯♰♱♲♳♴♵♶♷♸♹♺♻♼♽♾♿⚀⚁⚂⚃⚄⚅⚆⚈⚉4"; let _: () = 42; let _: &str = "🦀☀☁☂☃☄★☆☇☈☉☊☋☌☍☎☏☐☑☒☓ ☖☗☘☙☚☛☜☝☞☟☠☡☢☣☤☥☦☧☨☩☪☫☬☭☮☯☰☱☲☳☴☵☶☷☸☹☺☻☼☽☾☿♀♁♂♃... + | -- ^^ expected (), found integer + | | + | expected due to this | = note: expected type `()` found type `{integer}` diff --git a/src/test/ui/terminal-width/non-whitespace-trimming.stderr b/src/test/ui/terminal-width/non-whitespace-trimming.stderr index 622713eb5f6fc..fb2d92c7b3c03 100644 --- a/src/test/ui/terminal-width/non-whitespace-trimming.stderr +++ b/src/test/ui/terminal-width/non-whitespace-trimming.stderr @@ -1,8 +1,10 @@ error[E0308]: mismatched types --> $DIR/non-whitespace-trimming.rs:4:241 | -LL | ...) = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () = ()... - | ^^ expected (), found integer +LL | ...: () = (); let _: () = (); let _: () = (); let _: () = 42; let _: () = (); let _: () = (); let _: () = (); let _: () = (); let _: () =... + | -- ^^ expected (), found integer + | | + | expected due to this | = note: expected type `()` found type `{integer}` diff --git a/src/test/ui/terminal-width/whitespace-trimming.stderr b/src/test/ui/terminal-width/whitespace-trimming.stderr index 45a804b9f6a46..2e73f93150925 100644 --- a/src/test/ui/terminal-width/whitespace-trimming.stderr +++ b/src/test/ui/terminal-width/whitespace-trimming.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/whitespace-trimming.rs:4:193 | LL | ... let _: () = 42; - | ^^ expected (), found integer + | -- ^^ expected (), found integer + | | + | expected due to this | = note: expected type `()` found type `{integer}` diff --git a/src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr b/src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr index 0394ddab46cda..eb34ed8c2a5c5 100644 --- a/src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr +++ b/src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr @@ -11,7 +11,9 @@ error[E0308]: mismatched types --> $DIR/enum-variant-priority-higher-than-other-inherent.rs:22:17 | LL | let _: u8 = ::V; - | ^^^^^^^ expected u8, found enum `E2` + | -- ^^^^^^^ expected u8, found enum `E2` + | | + | expected due to this | = note: expected type `u8` found type `E2` diff --git a/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr index d9600f1d1d6bc..ab74a32efe3aa 100644 --- a/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr @@ -8,7 +8,9 @@ error[E0308]: mismatched types --> $DIR/generic_type_does_not_live_long_enough.rs:6:18 | LL | let z: i32 = x; - | ^ expected i32, found opaque type + | --- ^ expected i32, found opaque type + | | + | expected due to this | = note: expected type `i32` found type `WrongGeneric::<&{integer}>` diff --git a/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.stderr b/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.stderr index 7c195f1fad006..0ab3dd079036e 100644 --- a/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.stderr +++ b/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/never_reveal_concrete_type.rs:13:27 | LL | let _: &'static str = x; - | ^ expected reference, found opaque type + | ------------ ^ expected reference, found opaque type + | | + | expected due to this | = note: expected type `&'static str` found type `NoReveal` diff --git a/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr b/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr index 5e5826978fc7e..0112d953aa206 100644 --- a/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr +++ b/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/no_revealing_outside_defining_module.rs:15:19 | LL | let _: &str = bomp(); - | ^^^^^^ expected &str, found opaque type + | ---- ^^^^^^ expected &str, found opaque type + | | + | expected due to this | = note: expected type `&str` found type `Boo` diff --git a/src/test/ui/type/type-check/assignment-expected-bool.stderr b/src/test/ui/type/type-check/assignment-expected-bool.stderr index b636a71f3afe2..a2e03dac813ce 100644 --- a/src/test/ui/type/type-check/assignment-expected-bool.stderr +++ b/src/test/ui/type/type-check/assignment-expected-bool.stderr @@ -140,7 +140,9 @@ error[E0308]: mismatched types --> $DIR/assignment-expected-bool.rs:31:20 | LL | let _: usize = 0 = 0; - | ^^^^^ expected usize, found () + | ----- ^^^^^ expected usize, found () + | | + | expected due to this | = note: expected type `usize` found type `()` diff --git a/src/test/ui/type/type-mismatch-multiple.stderr b/src/test/ui/type/type-mismatch-multiple.stderr index 8f6b23ea091a2..469a3449aa53f 100644 --- a/src/test/ui/type/type-mismatch-multiple.stderr +++ b/src/test/ui/type/type-mismatch-multiple.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/type-mismatch-multiple.rs:3:27 | LL | fn main() { let a: bool = 1; let b: i32 = true; } - | ^ expected bool, found integer + | ---- ^ expected bool, found integer + | | + | expected due to this | = note: expected type `bool` found type `{integer}` @@ -11,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/type-mismatch-multiple.rs:3:43 | LL | fn main() { let a: bool = 1; let b: i32 = true; } - | ^^^^ expected i32, found bool + | --- ^^^^ expected i32, found bool + | | + | expected due to this error: aborting due to 2 previous errors diff --git a/src/test/ui/type/type-shadow.stderr b/src/test/ui/type/type-shadow.stderr index f15bdc16d5144..88498bb9f6322 100644 --- a/src/test/ui/type/type-shadow.stderr +++ b/src/test/ui/type/type-shadow.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/type-shadow.rs:6:20 | LL | let y: Y = "hello"; - | ^^^^^^^ expected isize, found reference + | - ^^^^^^^ expected isize, found reference + | | + | expected due to this | = note: expected type `isize` found type `&'static str` diff --git a/src/test/ui/typeck/typeck_type_placeholder_mismatch.stderr b/src/test/ui/typeck/typeck_type_placeholder_mismatch.stderr index 89114874824d6..5b78a594acfa9 100644 --- a/src/test/ui/typeck/typeck_type_placeholder_mismatch.stderr +++ b/src/test/ui/typeck/typeck_type_placeholder_mismatch.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/typeck_type_placeholder_mismatch.rs:13:21 | LL | let x: Foo<_> = Bar::(PhantomData); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Foo`, found struct `Bar` + | ------ ^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Foo`, found struct `Bar` + | | + | expected due to this | = note: expected type `Foo<_>` found type `Bar` @@ -11,7 +13,9 @@ error[E0308]: mismatched types --> $DIR/typeck_type_placeholder_mismatch.rs:22:21 | LL | let x: Foo<_> = Bar::(PhantomData); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Foo`, found struct `Bar` + | ------ ^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Foo`, found struct `Bar` + | | + | expected due to this | = note: expected type `Foo<_>` found type `Bar` diff --git a/src/test/ui/wrong-mul-method-signature.stderr b/src/test/ui/wrong-mul-method-signature.stderr index 2317bf8e8293c..f50f8ea7d1276 100644 --- a/src/test/ui/wrong-mul-method-signature.stderr +++ b/src/test/ui/wrong-mul-method-signature.stderr @@ -38,7 +38,9 @@ error[E0308]: mismatched types --> $DIR/wrong-mul-method-signature.rs:63:19 | LL | let x: Vec2 = Vec2 { x: 1.0, y: 2.0 } * 2.0; // trait had reversed order - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Vec2`, found f64 + | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Vec2`, found f64 + | | + | expected due to this | = note: expected type `Vec2` found type `f64` From b1a5bb0cee7e15646081dff5e78481d00b3a2b2d Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 18 Nov 2019 15:34:07 +0100 Subject: [PATCH 27/27] ci: guess some environment variables based on builder name and os Some environment variables (like DEPLOY or DEPLOY_ALT for dist builders, or IMAGE on Linux builders) are set on a lot of builders, and whether they should be present or not can be detected automatically based on the builder name and the platform. This commit simplifies the CI configuration by automatically setting those environment variables. --- src/ci/azure-pipelines/auto.yml | 168 ++++++--------------------- src/ci/azure-pipelines/pr.yml | 7 +- src/ci/azure-pipelines/steps/run.yml | 3 + src/ci/azure-pipelines/try.yml | 6 +- src/ci/scripts/setup-environment.sh | 31 +++++ 5 files changed, 72 insertions(+), 143 deletions(-) create mode 100755 src/ci/scripts/setup-environment.sh diff --git a/src/ci/azure-pipelines/auto.yml b/src/ci/azure-pipelines/auto.yml index 946eb483c2946..bfe5174bf1e57 100644 --- a/src/ci/azure-pipelines/auto.yml +++ b/src/ci/azure-pipelines/auto.yml @@ -19,136 +19,46 @@ jobs: strategy: matrix: x86_64-gnu-llvm-6.0: - IMAGE: x86_64-gnu-llvm-6.0 RUST_BACKTRACE: 1 - - dist-x86_64-linux: - IMAGE: dist-x86_64-linux - DEPLOY: 1 - - # "alternate" deployments, these are "nightlies" but have LLVM assertions - # turned on, they're deployed to a different location primarily for - # additional testing. + dist-x86_64-linux: {} dist-x86_64-linux-alt: IMAGE: dist-x86_64-linux - DEPLOY_ALT: 1 - - # Linux builders, remaining docker images - arm-android: - IMAGE: arm-android - - armhf-gnu: - IMAGE: armhf-gnu - - dist-various-1: - IMAGE: dist-various-1 - DEPLOY: 1 - - dist-various-2: - IMAGE: dist-various-2 - DEPLOY: 1 - - dist-aarch64-linux: - IMAGE: dist-aarch64-linux - DEPLOY: 1 - - dist-android: - IMAGE: dist-android - DEPLOY: 1 - - dist-arm-linux: - IMAGE: dist-arm-linux - DEPLOY: 1 - - dist-armhf-linux: - IMAGE: dist-armhf-linux - DEPLOY: 1 - - dist-armv7-linux: - IMAGE: dist-armv7-linux - DEPLOY: 1 - - dist-i586-gnu-i586-i686-musl: - IMAGE: dist-i586-gnu-i586-i686-musl - DEPLOY: 1 - - dist-i686-freebsd: - IMAGE: dist-i686-freebsd - DEPLOY: 1 - - dist-i686-linux: - IMAGE: dist-i686-linux - DEPLOY: 1 - - dist-mips-linux: - IMAGE: dist-mips-linux - DEPLOY: 1 - - dist-mips64-linux: - IMAGE: dist-mips64-linux - DEPLOY: 1 - - dist-mips64el-linux: - IMAGE: dist-mips64el-linux - DEPLOY: 1 - - dist-mipsel-linux: - IMAGE: dist-mipsel-linux - DEPLOY: 1 - - dist-powerpc-linux: - IMAGE: dist-powerpc-linux - DEPLOY: 1 - - dist-powerpc64-linux: - IMAGE: dist-powerpc64-linux - DEPLOY: 1 - - dist-powerpc64le-linux: - IMAGE: dist-powerpc64le-linux - DEPLOY: 1 - - dist-s390x-linux: - IMAGE: dist-s390x-linux - DEPLOY: 1 - - dist-x86_64-freebsd: - IMAGE: dist-x86_64-freebsd - DEPLOY: 1 - - dist-x86_64-musl: - IMAGE: dist-x86_64-musl - DEPLOY: 1 - - dist-x86_64-netbsd: - IMAGE: dist-x86_64-netbsd - DEPLOY: 1 - - i686-gnu: - IMAGE: i686-gnu - i686-gnu-nopt: - IMAGE: i686-gnu-nopt - test-various: - IMAGE: test-various - wasm32: - IMAGE: wasm32 - x86_64-gnu: - IMAGE: x86_64-gnu - x86_64-gnu-full-bootstrap: - IMAGE: x86_64-gnu-full-bootstrap - x86_64-gnu-aux: - IMAGE: x86_64-gnu-aux + arm-android: {} + armhf-gnu: {} + dist-various-1: {} + dist-various-2: {} + dist-aarch64-linux: {} + dist-android: {} + dist-arm-linux: {} + dist-armhf-linux: {} + dist-armv7-linux: {} + dist-i586-gnu-i586-i686-musl: {} + dist-i686-freebsd: {} + dist-i686-linux: {} + dist-mips-linux: {} + dist-mips64-linux: {} + dist-mips64el-linux: {} + dist-mipsel-linux: {} + dist-powerpc-linux: {} + dist-powerpc64-linux: {} + dist-powerpc64le-linux: {} + dist-s390x-linux: {} + dist-x86_64-freebsd: {} + dist-x86_64-musl: {} + dist-x86_64-netbsd: {} + i686-gnu: {} + i686-gnu-nopt: {} + test-various: {} + wasm32: {} + x86_64-gnu: {} + x86_64-gnu-full-bootstrap: {} + x86_64-gnu-aux: {} x86_64-gnu-tools: - IMAGE: x86_64-gnu-tools DEPLOY_TOOLSTATES_JSON: toolstates-linux.json - x86_64-gnu-debug: - IMAGE: x86_64-gnu-debug - x86_64-gnu-nopt: - IMAGE: x86_64-gnu-nopt - x86_64-gnu-distcheck: - IMAGE: x86_64-gnu-distcheck - mingw-check: - IMAGE: mingw-check + x86_64-gnu-debug: {} + x86_64-gnu-nopt: {} + x86_64-gnu-distcheck: {} + mingw-check: {} - job: macOS timeoutInMinutes: 600 @@ -176,7 +86,6 @@ jobs: dist-x86_64-apple: SCRIPT: ./x.py dist RUST_CONFIGURE_ARGS: --target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc - DEPLOY: 1 RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 MACOSX_DEPLOYMENT_TARGET: 10.7 NO_LLVM_ASSERTIONS: 1 @@ -186,7 +95,6 @@ jobs: dist-x86_64-apple-alt: SCRIPT: ./x.py dist RUST_CONFIGURE_ARGS: --enable-extended --enable-profiler --set rust.jemalloc - DEPLOY_ALT: 1 RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 MACOSX_DEPLOYMENT_TARGET: 10.7 NO_LLVM_ASSERTIONS: 1 @@ -204,7 +112,6 @@ jobs: dist-i686-apple: SCRIPT: ./x.py dist RUST_CONFIGURE_ARGS: --build=i686-apple-darwin --enable-full-tools --enable-profiler --set rust.jemalloc - DEPLOY: 1 RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 MACOSX_DEPLOYMENT_TARGET: 10.7 NO_LLVM_ASSERTIONS: 1 @@ -304,7 +211,6 @@ jobs: --enable-profiler SCRIPT: python x.py dist DIST_REQUIRE_ALL_TOOLS: 1 - DEPLOY: 1 dist-i686-msvc: RUST_CONFIGURE_ARGS: >- --build=i686-pc-windows-msvc @@ -313,22 +219,18 @@ jobs: --enable-profiler SCRIPT: python x.py dist DIST_REQUIRE_ALL_TOOLS: 1 - DEPLOY: 1 dist-i686-mingw: RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu --enable-full-tools --enable-profiler SCRIPT: python x.py dist CUSTOM_MINGW: 1 DIST_REQUIRE_ALL_TOOLS: 1 - DEPLOY: 1 dist-x86_64-mingw: SCRIPT: python x.py dist RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-gnu --enable-full-tools --enable-profiler CUSTOM_MINGW: 1 DIST_REQUIRE_ALL_TOOLS: 1 - DEPLOY: 1 # "alternate" deployment, see .travis.yml for more info dist-x86_64-msvc-alt: RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-extended --enable-profiler SCRIPT: python x.py dist - DEPLOY_ALT: 1 diff --git a/src/ci/azure-pipelines/pr.yml b/src/ci/azure-pipelines/pr.yml index 566e654fdb3f0..aee4d8d5136aa 100644 --- a/src/ci/azure-pipelines/pr.yml +++ b/src/ci/azure-pipelines/pr.yml @@ -18,10 +18,7 @@ jobs: - template: steps/run.yml strategy: matrix: - x86_64-gnu-llvm-6.0: - IMAGE: x86_64-gnu-llvm-6.0 - mingw-check: - IMAGE: mingw-check + x86_64-gnu-llvm-6.0: {} + mingw-check: {} x86_64-gnu-tools: - IMAGE: x86_64-gnu-tools CI_ONLY_WHEN_SUBMODULES_CHANGED: 1 diff --git a/src/ci/azure-pipelines/steps/run.yml b/src/ci/azure-pipelines/steps/run.yml index 698aa5f2cf1ad..f536388b25b96 100644 --- a/src/ci/azure-pipelines/steps/run.yml +++ b/src/ci/azure-pipelines/steps/run.yml @@ -28,6 +28,9 @@ steps: - checkout: self fetchDepth: 2 +- bash: src/ci/scripts/setup-environment.sh + displayName: Setup environment + - bash: src/ci/scripts/should-skip-this.sh displayName: Decide whether to run this job diff --git a/src/ci/azure-pipelines/try.yml b/src/ci/azure-pipelines/try.yml index fe39ce3e24116..b6177b2cc9b25 100644 --- a/src/ci/azure-pipelines/try.yml +++ b/src/ci/azure-pipelines/try.yml @@ -14,13 +14,9 @@ jobs: - template: steps/run.yml strategy: matrix: - dist-x86_64-linux: - IMAGE: dist-x86_64-linux - DEPLOY: 1 - + dist-x86_64-linux: {} dist-x86_64-linux-alt: IMAGE: dist-x86_64-linux - DEPLOY_ALT: 1 # The macOS and Windows builds here are currently disabled due to them not being # overly necessary on `try` builds. We also don't actually have anything that diff --git a/src/ci/scripts/setup-environment.sh b/src/ci/scripts/setup-environment.sh new file mode 100755 index 0000000000000..e126a06edab73 --- /dev/null +++ b/src/ci/scripts/setup-environment.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# This script guesses some environment variables based on the builder name and +# the current platform, to reduce the amount of variables defined in the CI +# configuration. + +set -euo pipefail +IFS=$'\n\t' + +source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" + +# Builders starting with `dist-` are dist builders, but if they also end with +# `-alt` they are alternate dist builders. +if [[ "${CI_JOB_NAME}" = dist-* ]]; then + if [[ "${CI_JOB_NAME}" = *-alt ]]; then + echo "alternate dist builder detected, setting DEPLOY_ALT=1" + ciCommandSetEnv DEPLOY_ALT 1 + else + echo "normal dist builder detected, setting DEPLOY=1" + ciCommandSetEnv DEPLOY 1 + fi +fi + +# All the Linux builds happen inside Docker. +if isLinux; then + if [[ -z "${IMAGE+x}" ]]; then + echo "linux builder detected, using docker to run the build" + ciCommandSetEnv IMAGE "${CI_JOB_NAME}" + else + echo "a custom docker image is already set" + fi +fi