diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f15a9fcd59124..3e45ac01331ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,12 +121,10 @@ jobs: with: fetch-depth: 2 - # Free up disk space on Linux by removing preinstalled components that - # we do not need. We do this to enable some of the less resource - # intensive jobs to run on free runners, which however also have - # less disk space. + # Free up disk space on Linux or macOS by removing preinstalled components that + # we do not need. - name: free up disk space - run: src/ci/scripts/free-disk-space-linux.sh + run: src/ci/scripts/free-disk-space.sh if: matrix.free_disk # If we don't need to free up disk space then just report how much space we have diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index f2e3f8431c105..c272d2685cfa8 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -485,7 +485,7 @@ impl LayoutCalculator { } // Vectors require at least element alignment, else disable the opt BackendRepr::SimdVector { element, count: _ } - if element.default_align(dl).abi > align => + if element.default_align(dl) > align => { BackendRepr::Memory { sized: true } } @@ -810,7 +810,7 @@ impl LayoutCalculator { // the alignment of the union. (This value is used both for // determining the alignment of the overall enum, and the // determining the alignment of the payload after the tag.) - let mut prefix_align = min_ity.align(dl).abi; + let mut prefix_align = min_ity.align(dl); if repr.c() { for fields in variants { for field in fields { diff --git a/compiler/rustc_abi/src/layout/simple.rs b/compiler/rustc_abi/src/layout/simple.rs index da7260fe6160e..a4636ea1b116f 100644 --- a/compiler/rustc_abi/src/layout/simple.rs +++ b/compiler/rustc_abi/src/layout/simple.rs @@ -83,9 +83,9 @@ impl LayoutData { largest_niche, uninhabited: false, size, - align, + align: AbiAlign::new(align), max_repr_align: None, - unadjusted_abi_align: align.abi, + unadjusted_abi_align: align, repr_c: false, randomization_seed: Hash64::new(randomization_seed), } @@ -93,8 +93,8 @@ impl LayoutData { pub fn scalar_pair(cx: &C, a: Scalar, b: Scalar) -> Self { let dl = cx.data_layout(); - let b_align = b.default_align(dl).abi; - let align = a.default_align(dl).abi.max(b_align).max(dl.aggregate_align); + let b_align = b.default_align(dl); + let align = a.default_align(dl).max(b_align).max(dl.aggregate_align); let b_offset = a.size(dl).align_to(b_align); let size = (b_offset + b.size(dl)).align_to(align); diff --git a/compiler/rustc_abi/src/layout/ty.rs b/compiler/rustc_abi/src/layout/ty.rs index 58d20b9bd3532..821fa54e29fa7 100644 --- a/compiler/rustc_abi/src/layout/ty.rs +++ b/compiler/rustc_abi/src/layout/ty.rs @@ -7,8 +7,8 @@ use rustc_macros::StableHash; use crate::layout::{FieldIdx, VariantIdx}; use crate::{ - AbiAlign, Align, BackendRepr, FieldsShape, Float, HasDataLayout, LayoutData, Niche, Numeric, - PointeeInfo, Primitive, Size, Variants, + Align, BackendRepr, FieldsShape, Float, HasDataLayout, LayoutData, Niche, Numeric, PointeeInfo, + Primitive, Size, Variants, }; // Explicitly import `Float` to avoid ambiguity with `Primitive::Float`. @@ -48,8 +48,8 @@ impl<'a> Layout<'a> { self.0.0.largest_niche } - pub fn align(self) -> AbiAlign { - self.0.0.align + pub fn align(self) -> Align { + self.0.0.align.abi } pub fn size(self) -> Size { diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 0b8203f955766..38c82a4f55a1b 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -781,20 +781,20 @@ impl TargetDataLayout { /// Get the pointer alignment in the default data address space. #[inline] - pub fn pointer_align(&self) -> AbiAlign { - AbiAlign::new(self.default_address_space_pointer_spec.pointer_align) + pub fn pointer_align(&self) -> Align { + self.default_address_space_pointer_spec.pointer_align } /// Get the pointer alignment in a specific address space. #[inline] - pub fn pointer_align_in(&self, c: AddressSpace) -> AbiAlign { - AbiAlign::new(if c == self.default_address_space { + pub fn pointer_align_in(&self, c: AddressSpace) -> Align { + if c == self.default_address_space { self.default_address_space_pointer_spec.pointer_align } else if let Some(e) = self.address_space_info.iter().find(|(a, _)| a == &c) { e.1.pointer_align } else { panic!("Use of unknown address space {c:?}"); - }) + } } } @@ -1312,17 +1312,17 @@ impl Integer { } } - pub fn align(self, cx: &C) -> AbiAlign { + pub fn align(self, cx: &C) -> Align { use Integer::*; let dl = cx.data_layout(); - AbiAlign::new(match self { + match self { I8 => dl.i8_align, I16 => dl.i16_align, I32 => dl.i32_align, I64 => dl.i64_align, I128 => dl.i128_align, - }) + } } /// Returns the largest signed value that can be represented by this Integer. @@ -1383,7 +1383,7 @@ impl Integer { let dl = cx.data_layout(); [I8, I16, I32, I64, I128].into_iter().find(|&candidate| { - wanted == candidate.align(dl).abi && wanted.bytes() == candidate.size().bytes() + wanted == candidate.align(dl) && wanted.bytes() == candidate.size().bytes() }) } @@ -1394,7 +1394,7 @@ impl Integer { // FIXME(eddyb) maybe include I128 in the future, when it works everywhere. for candidate in [I64, I32, I16] { - if wanted >= candidate.align(dl).abi && wanted.bytes() >= candidate.size().bytes() { + if wanted >= candidate.align(dl) && wanted.bytes() >= candidate.size().bytes() { return candidate; } } @@ -1448,17 +1448,17 @@ impl Float { } } - pub fn align(self, cx: &C) -> AbiAlign { + pub fn align(self, cx: &C) -> Align { use Float::*; let dl = cx.data_layout(); - AbiAlign::new(match self { + match self { F16 | F16B => dl.f16_align, F32 => dl.f32_align, F64 => dl.f64_align, F128 => dl.f128_align, PpcF128 => dl.f128_align, - }) + } } pub fn ty_str(self) -> &'static str { @@ -1567,7 +1567,7 @@ impl Primitive { /// /// This is the type alignment for the corresponding built-in. /// In other contexts it might have different alignment. - pub fn default_align(self, cx: &C) -> AbiAlign { + pub fn default_align(self, cx: &C) -> Align { use Primitive::*; let dl = cx.data_layout(); @@ -1644,7 +1644,7 @@ impl Scalar { /// /// This is the type alignment for the corresponding built-in. /// This is *not* necessarily the correct alignment for a type that has this `BackendRepr::Scalar`! - pub fn default_align(self, cx: &impl HasDataLayout) -> AbiAlign { + pub fn default_align(self, cx: &impl HasDataLayout) -> Align { self.primitive().default_align(cx) } @@ -1957,9 +1957,9 @@ impl BackendRepr { /// not calculating something from the `Scalar`s. pub fn scalar_platform_align(&self, cx: &C) -> Option { match *self { - BackendRepr::Scalar(s) => Some(s.default_align(cx).abi), + BackendRepr::Scalar(s) => Some(s.default_align(cx)), BackendRepr::ScalarPair { a: s1, b: s2, b_offset: _ } => { - Some(s1.default_align(cx).max(s2.default_align(cx)).abi) + Some(s1.default_align(cx).max(s2.default_align(cx))) } // The align of a Vector can vary in surprising ways BackendRepr::SimdVector { .. } diff --git a/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs b/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs index 9a6854399dde6..a83592248a512 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs @@ -133,7 +133,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> { ); if mode == IndirectMode::OnStack { // Abi requires aligning struct size to pointer size - let size = self.layout.size.align_to(tcx.data_layout.pointer_align().abi); + let size = self.layout.size.align_to(tcx.data_layout.pointer_align()); let size = u32::try_from(size.bytes()).unwrap(); smallvec![apply_attrs_to_abi_param( AbiParam::special(pointer_ty(tcx), ArgumentPurpose::StructArgument(size),), diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index 6513cc0542ea5..2089f2b2008be 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -758,7 +758,7 @@ impl<'ll> CodegenCx<'ll, '_> { let g = self.define_global(&sym, llty).unwrap_or_else(|| { bug!("symbol `{}` is already defined", sym); }); - set_global_alignment(self, g, self.tcx.data_layout.pointer_align().abi); + set_global_alignment(self, g, self.tcx.data_layout.pointer_align()); llvm::set_initializer(g, llval); llvm::set_linkage(g, llvm::Linkage::PrivateLinkage); llvm::set_section(g, c"__OBJC,__cls_refs,literal_pointers,no_dead_strip"); @@ -778,7 +778,7 @@ impl<'ll> CodegenCx<'ll, '_> { let g = self.define_global(&sym, llty).unwrap_or_else(|| { bug!("symbol `{}` is already defined", sym); }); - set_global_alignment(self, g, self.tcx.data_layout.pointer_align().abi); + set_global_alignment(self, g, self.tcx.data_layout.pointer_align()); llvm::set_initializer(g, llval); llvm::set_linkage(g, llvm::Linkage::InternalLinkage); llvm::set_section(g, c"__DATA,__objc_classrefs,regular,no_dead_strip"); @@ -841,7 +841,7 @@ impl<'ll> CodegenCx<'ll, '_> { let selref_g = self.define_global(&selref_sym, selref_llty).unwrap_or_else(|| { bug!("symbol `{}` is already defined", selref_sym); }); - set_global_alignment(self, selref_g, self.tcx.data_layout.pointer_align().abi); + set_global_alignment(self, selref_g, self.tcx.data_layout.pointer_align()); llvm::set_initializer(selref_g, selref_llval); llvm::set_externally_initialized(selref_g, true); llvm::set_linkage( @@ -897,7 +897,7 @@ impl<'ll> CodegenCx<'ll, '_> { let g = self.define_global(&sym, llty).unwrap_or_else(|| { bug!("symbol `{}` is already defined", sym); }); - set_global_alignment(self, g, self.tcx.data_layout.pointer_align().abi); + set_global_alignment(self, g, self.tcx.data_layout.pointer_align()); llvm::set_initializer(g, llval); llvm::set_linkage(g, llvm::Linkage::PrivateLinkage); llvm::set_section(g, c"__OBJC,__module_info,regular,no_dead_strip"); diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index 87e0612bc102d..8c7e21666aa41 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -180,7 +180,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>( None => { // This is a thin pointer. Create a regular pointer type and give it the correct name. assert_eq!( - (pointer_size, pointer_align.abi), + (pointer_size, pointer_align), cx.size_and_align_of(ptr_type), "ptr_type={ptr_type}, pointee_type={pointee_type}", ); @@ -189,7 +189,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>( cx, pointee_type_di_node, pointer_size, - pointer_align.abi, + pointer_align, &ptr_type_debuginfo_name, ); @@ -326,9 +326,7 @@ fn build_subroutine_type_di_node<'ll, 'tcx>( let name = compute_debuginfo_type_name(cx.tcx, fn_ty, false); let (size, align) = match fn_ty.kind() { ty::FnDef(..) => (Size::ZERO, Align::ONE), - ty::FnPtr(..) => { - (cx.tcx.data_layout.pointer_size(), cx.tcx.data_layout.pointer_align().abi) - } + ty::FnPtr(..) => (cx.tcx.data_layout.pointer_size(), cx.tcx.data_layout.pointer_align()), _ => unreachable!(), }; let di_node = create_pointer_type(cx, fn_di_node, size, align, &name); diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 23aef47bceead..891a48c6701e3 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -596,8 +596,8 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { self.const_bool(true) } else if use_integer_compare { let integer_ty = self.type_ix(layout.size().bits()); - let a_val = self.load(integer_ty, a, layout.align().abi); - let b_val = self.load(integer_ty, b, layout.align().abi); + let a_val = self.load(integer_ty, a, layout.align()); + let b_val = self.load(integer_ty, b, layout.align()); self.icmp(IntPredicate::IntEQ, a_val, b_val) } else { let n = self.const_usize(layout.size().bytes()); @@ -1398,7 +1398,7 @@ fn codegen_msvc_try<'ll, 'tcx>( // // More information can be found in libstd's seh.rs implementation. let ptr_size = bx.tcx().data_layout.pointer_size(); - let ptr_align = bx.tcx().data_layout.pointer_align().abi; + let ptr_align = bx.tcx().data_layout.pointer_align(); let slot = bx.alloca(ptr_size, ptr_align); let try_func_ty = bx.type_func(&[bx.type_ptr()], bx.type_void()); bx.invoke( diff --git a/compiler/rustc_codegen_llvm/src/va_arg.rs b/compiler/rustc_codegen_llvm/src/va_arg.rs index c74ea60ac11f3..1590a33850c16 100644 --- a/compiler/rustc_codegen_llvm/src/va_arg.rs +++ b/compiler/rustc_codegen_llvm/src/va_arg.rs @@ -51,7 +51,7 @@ fn emit_direct_ptr_va_arg<'ll, 'tcx>( let va_list_ty = bx.type_ptr(); let va_list_addr = list.immediate(); - let ptr_align_abi = bx.tcx().data_layout.pointer_align().abi; + let ptr_align_abi = bx.tcx().data_layout.pointer_align(); let ptr = bx.load(va_list_ty, va_list_addr, ptr_align_abi); let (addr, addr_align) = if allow_higher_align && align > slot_size { @@ -171,7 +171,7 @@ fn emit_ptr_va_arg<'ll, 'tcx>( ( bx.cx.layout_of(Ty::new_imm_ptr(bx.cx.tcx, layout.ty)).llvm_type(bx.cx), bx.cx.data_layout().pointer_size(), - bx.cx.data_layout().pointer_align().abi, + bx.cx.data_layout().pointer_align(), ) } else { (layout.llvm_type(bx.cx), layout.size, get_param_type_alignment(bx, layout)) @@ -264,7 +264,7 @@ fn emit_aapcs_va_arg<'ll, 'tcx>( bx.switch_to_block(in_reg); let top_type = bx.type_ptr(); - let top = bx.load(top_type, reg_top, dl.pointer_align().abi); + let top = bx.load(top_type, reg_top, dl.pointer_align()); // reg_value = *(@top + reg_off_v); let mut reg_addr = bx.ptradd(top, reg_off_v); @@ -361,7 +361,7 @@ fn emit_powerpc_va_arg<'ll, 'tcx>( let reg_incr = layout.size.bytes().div_ceil(u64::from(reg_size)) as u8; let use_regs = bx.icmp(IntPredicate::IntULE, num_regs, bx.const_u8(max_regs - reg_incr)); - let ptr_align_abi = bx.tcx().data_layout.pointer_align().abi; + let ptr_align_abi = bx.tcx().data_layout.pointer_align(); let in_reg = bx.append_sibling_block("va_arg.in_reg"); let in_mem = bx.append_sibling_block("va_arg.in_mem"); @@ -469,7 +469,7 @@ fn emit_s390x_va_arg<'ll, 'tcx>( let in_reg = bx.append_sibling_block("va_arg.in_reg"); let in_mem = bx.append_sibling_block("va_arg.in_mem"); let end = bx.append_sibling_block("va_arg.end"); - let ptr_align_abi = dl.pointer_align().abi; + let ptr_align_abi = dl.pointer_align(); // FIXME: vector ABI not yet supported. let target_ty_size = layout.size.bytes(); @@ -675,7 +675,7 @@ fn emit_x86_64_sysv64_va_arg<'ll, 'tcx>( // loads than necessary. Can we clean this up? let reg_save_area_ptr = bx.inbounds_ptradd(va_list_addr, bx.cx.const_usize(2 * unsigned_int_offset + ptr_offset)); - let reg_save_area_v = bx.load(bx.type_ptr(), reg_save_area_ptr, dl.pointer_align().abi); + let reg_save_area_v = bx.load(bx.type_ptr(), reg_save_area_ptr, dl.pointer_align()); let reg_addr = match layout.layout.backend_repr() { BackendRepr::Scalar(scalar) => match scalar.primitive() { @@ -692,8 +692,8 @@ fn emit_x86_64_sysv64_va_arg<'ll, 'tcx>( let ty_lo = bx.cx().scalar_pair_element_backend_type(layout, 0, false); let ty_hi = bx.cx().scalar_pair_element_backend_type(layout, 1, false); - let align_lo = layout.field(bx.cx, 0).layout.align().abi; - let align_hi = layout.field(bx.cx, 1).layout.align().abi; + let align_lo = layout.field(bx.cx, 0).layout.align(); + let align_hi = layout.field(bx.cx, 1).layout.align(); match (scalar1.primitive(), scalar2.primitive()) { (Primitive::Float(_), Primitive::Float(_)) => { @@ -706,7 +706,7 @@ fn emit_x86_64_sysv64_va_arg<'ll, 'tcx>( let reg_lo_addr = bx.inbounds_ptradd(reg_save_area_v, fp_offset_v); let reg_hi_addr = bx.inbounds_ptradd(reg_lo_addr, bx.const_i32(16)); - let align = layout.layout.align().abi; + let align = layout.layout.align(); let tmp = bx.alloca(layout.size, layout.align.abi); let reg_lo = bx.load(ty_lo, reg_lo_addr, align_lo); @@ -814,7 +814,7 @@ fn x86_64_sysv64_va_arg_from_memory<'ll, 'tcx>( layout: TyAndLayout<'tcx>, ) -> &'ll Value { let dl = bx.cx.data_layout(); - let ptr_align_abi = dl.data_layout().pointer_align().abi; + let ptr_align_abi = dl.data_layout().pointer_align(); let overflow_arg_area_ptr = bx.inbounds_ptradd(va_list_addr, bx.const_usize(8)); @@ -864,7 +864,7 @@ fn emit_hexagon_va_arg_musl<'ll, 'tcx>( // All variadic arguments are passed on the stack, but the musl implementation // uses a register save area for compatibility. let va_list_addr = list.immediate(); - let ptr_align_abi = bx.tcx().data_layout.pointer_align().abi; + let ptr_align_abi = bx.tcx().data_layout.pointer_align(); let ptr_size = bx.tcx().data_layout.pointer_size().bytes(); // Check if argument fits in register save area @@ -936,7 +936,7 @@ fn emit_hexagon_va_arg_bare_metal<'ll, 'tcx>( // // va_list is a simple pointer (char *) let va_list_addr = list.immediate(); - let ptr_align_abi = bx.tcx().data_layout.pointer_align().abi; + let ptr_align_abi = bx.tcx().data_layout.pointer_align(); // Load current pointer from va_list let current_ptr = bx.load(bx.type_ptr(), va_list_addr, ptr_align_abi); @@ -989,7 +989,7 @@ fn emit_xtensa_va_arg<'ll, 'tcx>( let from_stack = bx.append_sibling_block("va_arg.from_stack"); let from_regsave = bx.append_sibling_block("va_arg.from_regsave"); let end = bx.append_sibling_block("va_arg.end"); - let ptr_align_abi = bx.tcx().data_layout.pointer_align().abi; + let ptr_align_abi = bx.tcx().data_layout.pointer_align(); // (*va).va_ndx let va_reg_offset = 4; diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index e5d790e15f7a4..ed2c05a20b9d4 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -611,7 +611,7 @@ fn get_argc_argv<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(bx: &mut Bx) -> (Bx::Va let param_handle = bx.get_param(0); let param_system_table = bx.get_param(1); let ptr_size = bx.tcx().data_layout.pointer_size(); - let ptr_align = bx.tcx().data_layout.pointer_align().abi; + let ptr_align = bx.tcx().data_layout.pointer_align(); let arg_argc = bx.const_int(bx.cx().type_isize(), 2); let arg_argv = bx.alloca(2 * ptr_size, ptr_align); bx.store(param_handle, arg_argv, ptr_align); diff --git a/compiler/rustc_codegen_ssa/src/meth.rs b/compiler/rustc_codegen_ssa/src/meth.rs index dd0bf6d0a2287..5b945fc3c2763 100644 --- a/compiler/rustc_codegen_ssa/src/meth.rs +++ b/compiler/rustc_codegen_ssa/src/meth.rs @@ -27,7 +27,7 @@ impl<'a, 'tcx> VirtualIndex { let vtable_byte_offset = self.0 * ptr_size.bytes(); let gep = bx.inbounds_ptradd(llvtable, bx.const_usize(vtable_byte_offset)); - let ptr_align = bx.data_layout().pointer_align().abi; + let ptr_align = bx.data_layout().pointer_align(); let ptr = bx.load(llty, gep, ptr_align); // VTable loads are invariant. diff --git a/compiler/rustc_codegen_ssa/src/mir/retag.rs b/compiler/rustc_codegen_ssa/src/mir/retag.rs index 483df05e4d14f..bce15781e89dd 100644 --- a/compiler/rustc_codegen_ssa/src/mir/retag.rs +++ b/compiler/rustc_codegen_ssa/src/mir/retag.rs @@ -283,7 +283,7 @@ impl<'a, 'tcx, V> RetagPlan { } let intptr_ty = data_layout.ptr_sized_integer(); - let align = intptr_ty.align(data_layout).abi; + let align = intptr_ty.align(data_layout); let alloc = Allocation::from_bytes(&bytes, align, Mutability::Not, ()); let const_alloc = tcx.mk_const_alloc(alloc); diff --git a/compiler/rustc_hir_analysis/src/check/compare_eii.rs b/compiler/rustc_hir_analysis/src/check/compare_eii.rs index 703df0c5d1a6c..663a506eb427b 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_eii.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_eii.rs @@ -520,7 +520,7 @@ fn report_eii_mismatch<'tcx>( infcx.err_ctxt().note_type_err( &mut diag, &cause, - trait_err_span.map(|sp| (sp, Cow::from("type in declaration"), false)), + trait_err_span.map(|sp| (sp.into(), Cow::from("type in declaration"), false)), Some(param_env.and(infer::ValuePairs::PolySigs(ExpectedFound { expected: ty::Binder::dummy(declaration_sig), found: ty::Binder::dummy(external_impl_sig), diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index c757c80280efa..1e08e9b3ddf36 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -18,7 +18,7 @@ use rustc_middle::ty::{ TypeFolder, TypeSuperFoldable, TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode, Unnormalized, Upcast, }; -use rustc_span::{BytePos, DUMMY_SP, Span, bug, span_bug}; +use rustc_span::{BytePos, DUMMY_SP, Span, bug, kw, span_bug}; use rustc_trait_selection::error_reporting::InferCtxtErrorExt; use rustc_trait_selection::infer::InferCtxtExt; use rustc_trait_selection::regions::InferCtxtRegionExt; @@ -625,12 +625,16 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>( "method `{}` has an incompatible return type for trait", trait_m.name() ); + diag.span_context(tcx.def_span(impl_m.container_id(tcx)).shrink_to_lo()); infcx.err_ctxt().note_type_err( &mut diag, &cause, - tcx.hir_get_if_local(impl_m.def_id) - .and_then(|node| node.fn_decl()) - .map(|decl| (decl.output.span(), Cow::from("return type in trait"), false)), + tcx.hir_get_if_local(trait_m.def_id).and_then(|node| node.fn_decl()).map(|decl| { + let mut span: MultiSpan = decl.output.span().into(); + span.push_span_context(tcx.def_span(trait_m.container_id(tcx)).shrink_to_lo()); + span.push_span_context(tcx.def_span(trait_m.def_id).shrink_to_lo()); + (span, Cow::from("return type in trait"), false) + }), Some(param_env.and(infer::ValuePairs::Terms(ExpectedFound { expected: trait_return_ty.into(), found: impl_return_ty.into(), @@ -1014,6 +1018,7 @@ fn report_trait_method_mismatch<'tcx>( "method `{}` has an incompatible type for trait", trait_m.name() ); + diag.span_context(tcx.def_span(impl_m.container_id(tcx)).shrink_to_lo()); match &terr { TypeError::ArgumentMutability(0) | TypeError::ArgumentSorts(_, 0) if trait_m.is_method() => @@ -1079,10 +1084,53 @@ fn report_trait_method_mismatch<'tcx>( } cause.span = impl_err_span; + + let mut labels = vec![]; + let mut context = vec![]; + if let TypeError::ArgumentSorts(_, i) = &terr + && let Some(ty) = + tcx.fn_sig(trait_m.def_id).skip_binder().inputs_and_output().skip_binder().get(*i) + && let ty::Param(param) = ty.kind() + // The expected type corresponds to a type parameter, which migh thave a default type or + // have been explicitly set in the `impl` with a different type. + && let generics = tcx.generics_of(trait_m.def_id) + && let param = generics.type_param(*param, tcx) + && let GenericParamDefKind::Type { has_default: true, .. } = param.kind + { + context.push(tcx.def_span(trait_m.container_id(tcx)).shrink_to_lo()); + + let param_name = param.name; + let msg = if let Some(ty) = trait_sig.inputs_and_output.get(*i) + && infcx.can_eq(param_env, *ty, tcx.type_of(param.def_id).skip_binder()) + { + format!("expected to match the default of type parameter `{param_name}`") + } else if let Some(ty) = trait_sig.inputs_and_output.get(*i) + && let ty::Param(p) = tcx.type_of(param.def_id).skip_binder().kind() + && p.name == kw::SelfUpper + && infcx.can_eq(param_env, *ty, impl_trait_ref.self_ty()) + { + format!("expected to match the `Self` default of type parameter `{param_name}`") + } else { + format!("expected to match type parameter `{param_name}`") + }; + labels.push((tcx.def_span(param.def_id), msg)); + } + infcx.err_ctxt().note_type_err( &mut diag, &cause, - trait_err_span.map(|sp| (sp, Cow::from("type in trait"), false)), + trait_err_span.map(|sp| { + let mut span: MultiSpan = sp.into(); + span.push_span_context(tcx.def_span(trait_m.container_id(tcx)).shrink_to_lo()); + span.push_span_context(tcx.def_span(trait_m.def_id).shrink_to_lo()); + for (sp, label) in labels { + span.push_span_label(sp, label); + } + for sp in context { + span.push_span_context(sp); + } + (span, Cow::from("type in trait"), false) + }), Some(param_env.and(infer::ValuePairs::PolySigs(ExpectedFound { expected: ty::Binder::dummy(trait_sig), found: ty::Binder::dummy(impl_sig), @@ -2190,7 +2238,8 @@ fn compare_const_generic_param_types<'tcx>( infcx.err_ctxt().note_type_err( &mut diag, &cause, - param_trait_ty_span.map(|span| (span, Cow::from("type in trait"), false)), + param_trait_ty_span + .map(|span| (span.into(), Cow::from("type in trait"), false)), Some(param_env.and(infer::ValuePairs::Terms(ExpectedFound { expected: trait_ty.into(), found: impl_ty.into(), @@ -2365,6 +2414,8 @@ fn compare_const_clause_entailment<'tcx>( "implemented const `{}` has an incompatible type for trait", trait_ct.name() ); + diag.span_context(tcx.def_span(impl_ct.container_id(tcx)).shrink_to_lo()); + diag.span_context(tcx.def_span(impl_ct.def_id).shrink_to_lo()); let trait_c_span = trait_ct.def_id.as_local().map(|trait_ct_def_id| { // Add a label to the Span containing just the type of the const @@ -2375,7 +2426,12 @@ fn compare_const_clause_entailment<'tcx>( infcx.err_ctxt().note_type_err( &mut diag, &cause, - trait_c_span.map(|span| (span, Cow::from("type in trait"), false)), + trait_c_span.map(|span| { + let mut span: MultiSpan = span.into(); + span.push_span_context(tcx.def_span(trait_ct.container_id(tcx)).shrink_to_lo()); + span.push_span_context(tcx.def_span(trait_ct.def_id).shrink_to_lo()); + (span, Cow::from("type in trait"), false) + }), Some(param_env.and(infer::ValuePairs::Terms(ExpectedFound { expected: trait_ty.into(), found: impl_ty.into(), diff --git a/compiler/rustc_middle/src/mir/interpret/mod.rs b/compiler/rustc_middle/src/mir/interpret/mod.rs index 10aa9532bea0b..c583383414392 100644 --- a/compiler/rustc_middle/src/mir/interpret/mod.rs +++ b/compiler/rustc_middle/src/mir/interpret/mod.rs @@ -400,7 +400,7 @@ impl<'tcx> GlobalAlloc<'tcx> { GlobalAlloc::Function { .. } => (Size::ZERO, Align::ONE), GlobalAlloc::VTable(..) => { // No data to be accessed here. But vtables are pointer-aligned. - (Size::ZERO, tcx.data_layout.pointer_align().abi) + (Size::ZERO, tcx.data_layout.pointer_align()) } // Fake allocation, there's nothing to access here. GlobalAlloc::TypeId { .. } => (Size::ZERO, Align::ONE), diff --git a/compiler/rustc_middle/src/ty/vtable.rs b/compiler/rustc_middle/src/ty/vtable.rs index fb56bda7d4562..f3c4940e60b82 100644 --- a/compiler/rustc_middle/src/ty/vtable.rs +++ b/compiler/rustc_middle/src/ty/vtable.rs @@ -108,7 +108,7 @@ pub(super) fn vtable_allocation_provider<'tcx>( let align = layout.align.bytes(); let ptr_size = tcx.data_layout.pointer_size(); - let ptr_align = tcx.data_layout.pointer_align().abi; + let ptr_align = tcx.data_layout.pointer_align(); let vtable_size = ptr_size * u64::try_from(vtable_entries.len()).unwrap(); let mut vtable = Allocation::new(vtable_size, ptr_align, AllocInit::Uninit, ()); diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index d0d97592f0e4b..7df6549a07a70 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -297,7 +297,7 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg { }; insert_atomic(sym::integer(i), align); if sess.target.pointer_width as u64 == i { - insert_atomic(sym::ptr, layout.pointer_align().abi); + insert_atomic(sym::ptr, layout.pointer_align()); } } } diff --git a/compiler/rustc_target/src/callconv/sparc64.rs b/compiler/rustc_target/src/callconv/sparc64.rs index bfe7f0cca3cc7..61a0ae982d050 100644 --- a/compiler/rustc_target/src/callconv/sparc64.rs +++ b/compiler/rustc_target/src/callconv/sparc64.rs @@ -39,7 +39,7 @@ fn classify<'a, Ty, C>( match arg_layout.backend_repr { BackendRepr::Scalar(scalar) => match scalar.primitive() { Primitive::Float(float) => { - if offset.is_aligned(Ord::min(*float.align(cx), Align::EIGHT)) { + if offset.is_aligned(Ord::min(float.align(cx), Align::EIGHT)) { let index = offset.bytes_usize() / 8; match float { Float::F128 => { diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs index c0097dc5a60c0..a0e1267ed16e1 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs @@ -54,7 +54,9 @@ use rustc_abi::ExternAbi; use rustc_attr_ir::diagnostic::{CustomDiagnostic, Directive, FormatArgs}; use rustc_attr_ir::find_attr; use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; -use rustc_errors::{Applicability, Diag, DiagStyledString, IntoDiagArg, StringPart, pluralize}; +use rustc_errors::{ + Applicability, Diag, DiagStyledString, IntoDiagArg, MultiSpan, StringPart, pluralize, +}; use rustc_hir as hir; use rustc_hir::def_id::{CRATE_DEF_ID, DefId}; use rustc_hir::intravisit::Visitor; @@ -1464,7 +1466,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { &self, diag: &mut Diag<'_>, cause: &ObligationCause<'tcx>, - secondary_span: Option<(Span, Cow<'static, str>, bool)>, + secondary_span: Option<(MultiSpan, Cow<'static, str>, bool)>, mut values: Option>>, terr: TypeError<'tcx>, prefer_label: bool, @@ -1640,9 +1642,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } }; - let mut label_or_note = |span: Span, msg: Cow<'static, str>| { - if (prefer_label && is_simple_error) || &[span] == diag.span.primary_spans() { - diag.span_label(span, msg); + let mut label_or_note = |span: MultiSpan, msg: Cow<'static, str>| { + if !span.has_span_labels() + && span.span_context().is_empty() + && ((prefer_label && is_simple_error) + || span.primary_spans() == diag.span.primary_spans()) + { + for span in span.primary_spans() { + diag.span_label(*span, msg.clone()); + } } else { diag.span_note(span, msg); } @@ -1658,9 +1666,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { terr.to_string(self.tcx) }; label_or_note(secondary_span, terr); - label_or_note(span, secondary_msg); + label_or_note(span.into(), secondary_msg); } else { - label_or_note(span, terr.to_string(self.tcx)); + label_or_note(span.into(), terr.to_string(self.tcx)); label_or_note(secondary_span, secondary_msg); } } else if let Some(values) = values @@ -1672,12 +1680,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let expected = with_forced_trimmed_paths!(e.sort_string(self.tcx)); let found = with_forced_trimmed_paths!(f.sort_string(self.tcx)); if expected == found { - label_or_note(span, terr.to_string(self.tcx)); + label_or_note(span.into(), terr.to_string(self.tcx)); } else { - label_or_note(span, Cow::from(format!("expected {expected}, found {found}"))); + label_or_note( + span.into(), + Cow::from(format!("expected {expected}, found {found}")), + ); } } else { - label_or_note(span, terr.to_string(self.tcx)); + label_or_note(span.into(), terr.to_string(self.tcx)); } if let Some(param_env) = param_env { diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 4941e1d055719..10e2ba18f3d7c 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -1930,7 +1930,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { .. }), ) => Some(( - ty.span, + ty.span.into(), with_forced_trimmed_paths!(Cow::from(format!( "type mismatch resolving `{}`", self.tcx.short_string( diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index 5d680b26c0221..7e202d8614034 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -1,12 +1,11 @@ use std::range::{RangeFrom, RangeToInclusive}; -use rustc_abi as abi; use rustc_abi::Integer::{I8, I32}; use rustc_abi::Primitive::{self, Float, Int, Pointer}; use rustc_abi::{ - AddressSpace, BackendRepr, FIRST_VARIANT, FieldIdx, FieldsShape, HasDataLayout, Layout, - LayoutCalculatorError, LayoutData, Niche, NicheOptimizations, ReprOptions, Scalar, Size, - StructKind, TagEncoding, VariantIdx, Variants, WrappingRange, + self as abi, AbiAlign, AddressSpace, BackendRepr, FIRST_VARIANT, FieldIdx, FieldsShape, + HasDataLayout, Layout, LayoutCalculatorError, LayoutData, Niche, NicheOptimizations, + ReprOptions, Scalar, Size, StructKind, TagEncoding, VariantIdx, Variants, WrappingRange, }; use rustc_attr_ir::find_attr; use rustc_attr_ir::lang_items::LangItem; @@ -820,14 +819,14 @@ fn layout_of_uncached<'tcx>( if tcx.is_lang_item(def.did(), LangItem::F16B) { let bfloat = scalar_unit(Primitive::Float(abi::Float::F16B)); assert_eq!(layout.size, abi::Float::F16B.size()); - layout.align = abi::Float::F16B.align(cx); + layout.align = AbiAlign::new(abi::Float::F16B.align(cx)); layout.backend_repr = BackendRepr::Scalar(bfloat); } if tcx.is_lang_item(def.did(), LangItem::PpcF128) { let ppcf128 = scalar_unit(Primitive::Float(abi::Float::PpcF128)); assert_eq!(layout.size, abi::Float::PpcF128.size()); - layout.align = abi::Float::PpcF128.align(cx); + layout.align = AbiAlign::new(abi::Float::PpcF128.align(cx)); layout.backend_repr = BackendRepr::Scalar(ppcf128); } diff --git a/compiler/rustc_ty_utils/src/layout/invariant.rs b/compiler/rustc_ty_utils/src/layout/invariant.rs index a244c597eef3d..29e1407e0211f 100644 --- a/compiler/rustc_ty_utils/src/layout/invariant.rs +++ b/compiler/rustc_ty_utils/src/layout/invariant.rs @@ -99,7 +99,7 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou let size = layout.backend_repr.scalar_size(cx); if let Some(align) = align { assert_eq!( - layout.layout.align().abi, + layout.layout.align(), align, "alignment mismatch between ABI and layout in {layout:#?}" ); @@ -225,9 +225,9 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou }; // The fields should be at the right offset, and match the `scalar` layout. let size1 = scalar1.size(cx); - let align1 = scalar1.default_align(cx).abi; + let align1 = scalar1.default_align(cx); let size2 = scalar2.size(cx); - let align2 = scalar2.default_align(cx).abi; + let align2 = scalar2.default_align(cx); assert_eq!( offset1, Size::ZERO, @@ -272,7 +272,7 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou BackendRepr::SimdVector { element, count } => { let align = layout.align.abi; let size = layout.size; - let element_align = element.default_align(cx).abi; + let element_align = element.default_align(cx); let element_size = element.size(cx); // Currently, vectors must always be aligned to at least their elements: assert!(align >= element_align); diff --git a/compiler/rustc_ty_utils/src/needs_drop.rs b/compiler/rustc_ty_utils/src/needs_drop.rs index 05514b2c712f9..522444651778d 100644 --- a/compiler/rustc_ty_utils/src/needs_drop.rs +++ b/compiler/rustc_ty_utils/src/needs_drop.rs @@ -52,7 +52,7 @@ fn needs_async_drop_raw<'tcx>( query.value, query.typing_env, adt_has_async_dtor, - DropTysOptions::default().async_drop(), + DropTysOptions::default().recurse_into_box_for_async_drop(), ) .filter(filter_array_elements_async(tcx, query.typing_env)) .next() @@ -335,9 +335,7 @@ enum DtorType { struct DropTysOptions { only_significant: bool, exhaustive: bool, - /// Compute async drop components: query `adt_async_drop_tys` for nested - /// ADTs and recurse into `Box`. - async_drop: bool, + async_drop_recurses_into_box: bool, } impl DropTysOptions { @@ -351,8 +349,8 @@ impl DropTysOptions { self } - fn async_drop(mut self) -> Self { - self.async_drop = true; + fn recurse_into_box_for_async_drop(mut self) -> Self { + self.async_drop_recurses_into_box = true; self } } @@ -371,17 +369,11 @@ fn drop_tys_helper<'tcx>( fn with_query_cache<'tcx>( tcx: TyCtxt<'tcx>, iter: impl IntoIterator>, - async_drop: bool, ) -> NeedsDropResult>> { iter.into_iter().try_fold(Vec::new(), |mut vec, subty| { match subty.kind() { ty::Adt(adt_id, args) => { - let adt_tys = if async_drop { - tcx.adt_async_drop_tys(adt_id.did())? - } else { - tcx.adt_drop_tys(adt_id.did())? - }; - for subty in adt_tys { + for subty in tcx.adt_drop_tys(adt_id.did())? { vec.push( EarlyBinder::bind(tcx, subty).instantiate(tcx, args).skip_norm_wip(), ); @@ -397,7 +389,7 @@ fn drop_tys_helper<'tcx>( if adt_def.is_manually_drop() { debug!("drop_tys_helper: `{:?}` is manually drop", adt_def); Ok(Vec::new()) - } else if options.async_drop && adt_def.is_box() { + } else if options.async_drop_recurses_into_box && adt_def.is_box() { let box_components = match args.as_slice() { [boxed_ty, allocator_ty] => { let boxed_ty = boxed_ty.expect_ty(); @@ -450,7 +442,7 @@ fn drop_tys_helper<'tcx>( // ADTs are `needs_drop` exactly if they `impl Drop` or if any of their "transitive" // fields do. There can be no cycles here, because ADTs cannot contain themselves as // fields. - with_query_cache(tcx, field_tys, options.async_drop) + with_query_cache(tcx, field_tys) } } .map(|v| v.into_iter()) @@ -514,7 +506,7 @@ fn adt_async_drop_tys<'tcx>( tcx.type_of(def_id).instantiate_identity().skip_norm_wip(), ty::TypingEnv::non_body_analysis(tcx, def_id), adt_has_dtor, - DropTysOptions::default().async_drop(), + DropTysOptions::default().recurse_into_box_for_async_drop(), ) .collect::, _>>() .map(|components| tcx.mk_type_list(&components)) diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 8ee042c415322..68298870cf739 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -17,6 +17,12 @@ runners: - &job-macos-15 os: macos-15 # macOS 15 Arm64 + free_disk: true + <<: *base-job + + - &job-macos-26 + os: macos-26 # macOS 26 Arm64 + free_disk: true # See https://github.com/rust-lang/infra-team/issues/307 <<: *base-job - &job-windows @@ -561,15 +567,41 @@ auto: CODEGEN_BACKENDS: llvm,cranelift <<: *job-macos-15 -# - name: test-aarch64-apple-1 + - name: test-aarch64-apple-1 + env: + # NOTE: keep in sync with `src/ci/docker/scripts/stage_2_test_set1.sh` + SCRIPT: >- + ./x.py --stage 2 test + --host=aarch64-apple-darwin + --target=aarch64-apple-darwin + --skip compiler + --skip src + RUST_CONFIGURE_ARGS: >- + --enable-sanitizers + --enable-profiler + --set build.allocator=jemalloc + DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer + # Aarch64 tooling only needs to support macOS 11.0 and up as nothing else + # supports the hardware, so only need to test it there. + MACOSX_DEPLOYMENT_TARGET: 11.0 + MACOSX_STD_DEPLOYMENT_TARGET: 11.0 + <<: *job-macos-15 + +# - name: test-aarch64-apple-2 # env: -# # NOTE: keep in sync with `src/ci/docker/scripts/stage_2_test_set1.sh` +# # NOTE: keep in sync with `src/ci/docker/scripts/stage_2_test_set2.sh`, +# # union `src/tools/cargo` specifically. # SCRIPT: >- # ./x.py --stage 2 test # --host=aarch64-apple-darwin # --target=aarch64-apple-darwin -# --skip compiler -# --skip src +# --skip tests +# --skip library +# --skip tidyselftest +# && ./x.py --stage 2 test +# --host=aarch64-apple-darwin +# --target=aarch64-apple-darwin +# src/tools/cargo # RUST_CONFIGURE_ARGS: >- # --enable-sanitizers # --enable-profiler @@ -580,8 +612,36 @@ auto: # MACOSX_DEPLOYMENT_TARGET: 11.0 # MACOSX_STD_DEPLOYMENT_TARGET: 11.0 # <<: *job-macos-15 -# -# - name: test-aarch64-apple-2 + + # EXPERIMENT(#157687): we will try to run `aarch64-apple`-equivalent workload + # on `macos-26` runner images in parallel to evaluate the running times, since + # previous attempts have timed out multiple times. Remove/revert this job if + # this hangs or times out, or if it becomes the slowest Merge CI job, and let + # T-infra know. + # See also #165148 + - name: test-aarch64-apple-macos-26-1 + doc_url: https://github.com/rust-lang/rust/issues/157687 + env: + # NOTE: keep in sync with `src/ci/docker/scripts/stage_2_test_set1.sh` + SCRIPT: >- + ./x.py --stage 2 test + --host=aarch64-apple-darwin + --target=aarch64-apple-darwin + --skip compiler + --skip src + RUST_CONFIGURE_ARGS: >- + --enable-sanitizers + --enable-profiler + --set build.allocator=jemalloc + DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer + # Aarch64 tooling only needs to support macOS 11.0 and up as nothing else + # supports the hardware, so only need to test it there. + MACOSX_DEPLOYMENT_TARGET: 11.0 + MACOSX_STD_DEPLOYMENT_TARGET: 11.0 + <<: *job-macos-26 + +# - name: test-aarch64-apple-macos-26-2 +# doc_url: https://github.com/rust-lang/rust/issues/157687 # env: # # NOTE: keep in sync with `src/ci/docker/scripts/stage_2_test_set2.sh`, # # union `src/tools/cargo` specifically. @@ -605,7 +665,7 @@ auto: # # supports the hardware, so only need to test it there. # MACOSX_DEPLOYMENT_TARGET: 11.0 # MACOSX_STD_DEPLOYMENT_TARGET: 11.0 -# <<: *job-macos-15 +# <<: *job-macos-26 ###################### # Windows Builders # diff --git a/src/ci/scripts/free-disk-space-mac.sh b/src/ci/scripts/free-disk-space-mac.sh new file mode 100755 index 0000000000000..b67222ef9210c --- /dev/null +++ b/src/ci/scripts/free-disk-space-mac.sh @@ -0,0 +1,43 @@ +#!/bin/bash +set -euo pipefail +# ignore-tidy-file-linelength + +# Free disk space on macOS GitHub action runners +# Achieved by removing all iOS simulator instance files and runtime images +# See https://developer.apple.com/documentation/xcode/xcode-command-line-tool-reference#Manage-the-Simulator + +echo "Before clean-up:" +df -h + +echo "deleting iOS simulator instance files and runtime images" + +space_before=$(df -k "$GITHUB_WORKSPACE" | awk 'NR == 2 {print $4}') + +xcrun simctl shutdown all +xcrun simctl delete all + +# This subcommand runs asynchronously +xcrun simctl runtime delete all + +# Wait a max of 60 seconds to ensure the clean-up is done before any subsequential build steps +for ((attempt = 0; attempt < 30; attempt++)); do + remaining=$(xcrun simctl runtime list -j | jq -e 'length') + echo "Remaining simulator runtime images: $remaining" + + if [[ "$remaining" == 0 ]]; then + break + fi + sleep 2 +done + +if [[ "$remaining" != 0 ]]; then + echo "::warning::Simulator runtime deletion did not finish within the polling period." +fi + +# Report net increase in available disk space +space_after=$(df -k "$GITHUB_WORKSPACE" | awk 'NR == 2 {print $4}') +extra_space=$(awk -v b="$space_before" -v a="$space_after" 'BEGIN { printf "%.2f", (a - b) / 1048576 }') +echo "Increase in available disk space: $extra_space GiB" + +echo "After clean-up:" +df -h diff --git a/src/ci/scripts/free-disk-space.sh b/src/ci/scripts/free-disk-space.sh new file mode 100755 index 0000000000000..76e0140806e93 --- /dev/null +++ b/src/ci/scripts/free-disk-space.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -euo pipefail + +script_dir=$(cd -- "$(dirname -- "$0")" && pwd) + +# dispatch according to the Github Runner +case "${RUNNER_OS:-}" in + Linux) + exec "${script_dir}/free-disk-space-linux.sh" + ;; + macOS) + exec "${script_dir}/free-disk-space-mac.sh" + ;; + *) + echo "::error:: freeing disk space not supported for: '${RUNNER_OS:-unset}'" + exit 1 + ;; +esac diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 597c648c1106a..9acf150b3b354 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -241,6 +241,10 @@ pub(crate) struct RenderOptions { /// What sorting mode to use for module pages. /// `ModuleSorting::Alphabetical` by default. pub(crate) module_sorting: ModuleSorting, + /// In the sidebar list of all crates, put the current crate(s) under this heading. + /// To put a crate under the unnamed primary heading, which is always listed first, + /// make this the empty string. + pub(crate) crate_list_heading: String, /// List of themes to extend the docs with. Original argument name is included to assist in /// displaying errors if it fails a theme check. pub(crate) themes: Vec, @@ -845,6 +849,7 @@ impl Options { } else { ModuleSorting::Alphabetical }; + let crate_list_heading = matches.opt_str("crate-list-heading").unwrap_or_default(); let resource_suffix = matches.opt_str("resource-suffix").unwrap_or_default(); let markdown_no_toc = matches.opt_present("markdown-no-toc"); let markdown_css = matches.opt_strs("markdown-css"); @@ -954,6 +959,7 @@ impl Options { id_map, playground_url, module_sorting, + crate_list_heading, themes, extension_css, extern_html_root_urls, diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index 258970bbb3b8f..ae040553f5ffa 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -13,6 +13,7 @@ //! --resource-suffix flag and are emitted when --emit-type is empty (default) //! or contains "html-non-static-files". +use std::borrow::Cow; use std::cell::RefCell; use std::ffi::{OsStr, OsString}; use std::fs::File; @@ -80,14 +81,20 @@ pub(crate) fn write_shared( )?; let crate_name = krate.name(cx.tcx()); - let crate_name = crate_name.as_str(); // rand + let crate_name = crate_name.as_str(); // e.g. rand let crate_name_json = OrderedJson::serialize(crate_name).unwrap(); // "rand" + let all_crates_entry_json = OrderedJson::serialize(AllCratesEntry { + heading: Cow::Borrowed(&opt.crate_list_heading), + crate_name: Cow::Borrowed(crate_name), + }) + .unwrap(); // e.g. {"c":"rand","h":"Some User-Specified Heading"} + let external_crates = hack_get_external_crate_names(&cx.dst, &cx.shared.resource_suffix)?; let info = CrateInfo { version: CrateInfoVersion::V2, src_files_js: SourcesPart::get(cx, &crate_name_json)?, search_index, - all_crates: AllCratesPart::get(crate_name_json.clone(), &cx.shared.resource_suffix)?, + all_crates: AllCratesPart::get(all_crates_entry_json, &cx.shared.resource_suffix)?, crates_index: CratesIndexPart::get(crate_name, &external_crates)?, trait_impl: TraitAliasPart::get(cx, &crate_name_json)?, type_impl: TypeAliasPart::get(cx, krate, &crate_name_json)?, @@ -489,6 +496,19 @@ impl AllCratesPart { } } +/// Type of a serialized entry in the [`AllCratesPart`] JSON. +#[derive(Serialize, Deserialize, Clone, Default, Debug)] +struct AllCratesEntry<'a> { + #[serde(rename = "c")] + crate_name: Cow<'a, str>, + + /// If non-absent and non-empty, is the name of a section heading in the crate sidebar. + #[serde(rename = "h")] + #[serde(default)] + #[serde(skip_serializing_if = "str::is_empty")] + heading: Cow<'a, str>, +} + /// Reads `crates.js`, which seems like the best /// place to obtain the list of externally documented crates if the index /// page was disabled when documenting the deps. @@ -509,9 +529,11 @@ fn hack_get_external_crate_names( if let Some(start) = content.find('[') && let Some(end) = content[start..].find(']') { - let content: Vec = + let content: Vec> = try_err!(serde_json::from_str(&content[start..=start + end]), &path); - Ok(content) + let crate_names: Vec = + content.into_iter().map(|entry| entry.crate_name.into_owned()).collect(); + Ok(crate_names) } else { Err(Error::new("could not find crates list in crates.js", path)) } diff --git a/src/librustdoc/html/render/write_shared/tests.rs b/src/librustdoc/html/render/write_shared/tests.rs index 48d592c22f6f0..3ac9e3a2a5a80 100644 --- a/src/librustdoc/html/render/write_shared/tests.rs +++ b/src/librustdoc/html/render/write_shared/tests.rs @@ -9,7 +9,8 @@ fn hack_external_crate_names() { let path = path.path(); let crates = hack_get_external_crate_names(&path, "").unwrap(); assert!(crates.is_empty()); - fs::write(path.join("crates.js"), r#"window.ALL_CRATES = ["a","b","c"];"#).unwrap(); + fs::write(path.join("crates.js"), r#"window.ALL_CRATES = [{"c":"a"},{"c":"b"},{"c":"c"}];"#) + .unwrap(); let crates = hack_get_external_crate_names(&path, "").unwrap(); assert_eq!(crates, ["a".to_string(), "b".to_string(), "c".to_string()]); } diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index e957a13a2b038..11bf38b1e4084 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1123,8 +1123,8 @@ function preLoadCss(cssUrl) { window.register_type_impls(window.pending_type_impls); } + // Draw a convenient sidebar of known crates if we have a listing function addSidebarCrates() { - // @ts-expect-error if (!window.ALL_CRATES) { return; } @@ -1132,27 +1132,59 @@ function preLoadCss(cssUrl) { if (!sidebarElems) { return; } - // Draw a convenient sidebar of known crates if we have a listing - const h3 = document.createElement("h3"); - h3.innerHTML = "Crates"; - const ul = document.createElement("ul"); - ul.className = "block crate"; - // @ts-expect-error - for (const crate of window.ALL_CRATES) { - const link = document.createElement("a"); - link.href = window.rootPath + crate + "/index.html"; - link.textContent = crate; + // h2 puts this on the same level as the current crate name heading at the top + const allCratesHeading = document.createElement("h2"); + allCratesHeading.textContent = "Crates"; + + const allCratesSection = document.createElement("section"); + + // window.ALL_CRATES is in unsorted array-of-structs format; reorganize so crates with the + // same heading are grouped. + const cratesGroupedByHeading = new Map(); + for (const entry of window.ALL_CRATES) { + const heading = entry.h || ""; + const crateName = entry.c; + let group = cratesGroupedByHeading.get(heading); + if (group === undefined) { + group = []; + cratesGroupedByHeading.set(heading, group); + } + group.push(crateName); + } + const headings = Array.from(cratesGroupedByHeading.keys()); + headings.sort(); + + // Generate HTML for grouped crates. + for (const headingText of headings) { + // Empty string denotes a group with no named heading. + if (headingText !== "") { + const crateCategoryHeading = document.createElement("h3"); + crateCategoryHeading.textContent = headingText; + allCratesSection.appendChild(crateCategoryHeading); + } - const li = document.createElement("li"); - if (window.rootPath !== "./" && crate === window.currentCrate) { - li.className = "current"; + const cratesUl = document.createElement("ul"); + cratesUl.className = "block crate"; + + for (const crateName of cratesGroupedByHeading.get(headingText)) { + const link = document.createElement("a"); + link.href = window.rootPath + crateName + "/index.html"; + link.textContent = crateName; + + const li = document.createElement("li"); + if (window.rootPath !== "./" && crateName === window.currentCrate) { + li.className = "current"; + } + li.appendChild(link); + cratesUl.appendChild(li); } - li.appendChild(link); - ul.appendChild(li); + + allCratesSection.appendChild(cratesUl); } - sidebarElems.appendChild(h3); - sidebarElems.appendChild(ul); + + sidebarElems.appendChild(allCratesHeading); + sidebarElems.appendChild(allCratesSection); } function expandAllDocs() { diff --git a/src/librustdoc/html/static/js/rustdoc.d.ts b/src/librustdoc/html/static/js/rustdoc.d.ts index fef93a01a26cb..49580c7870a97 100644 --- a/src/librustdoc/html/static/js/rustdoc.d.ts +++ b/src/librustdoc/html/static/js/rustdoc.d.ts @@ -31,6 +31,8 @@ declare global { /** Notable trait data */ NOTABLE_TRAITS?: { [key: string]: string }; CURRENT_TOOLTIP_ELEMENT?: HTMLElement & { TOOLTIP_BASE: HTMLElement }; + /** List of all documented crates. Generated in `render/write_shared.rs`. */ + ALL_CRATES: rustdoc.AllCratesEntry[]|undefined; /** Used by the popover tooltip code. */ RUSTDOC_TOOLTIP_HOVER_MS: number; /** Used by the popover tooltip code. */ @@ -538,6 +540,18 @@ declare namespace rustdoc { bindings: Map; }; + /** Member of ALL_CRATES. */ + interface AllCratesEntry { + /** + * Heading under which the crate should be listed. + * + * May be empty to specify the first, primary heading. + */ + h?: string, + /** Crate name. */ + c: string, + } + type VlqData = VlqData[] | number; /** diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index f461bace093a1..3674e6e2a9cf2 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -365,6 +365,14 @@ fn opts() -> Vec { "sort modules by where they appear in the program, rather than alphabetically", "", ), + opt( + Unstable, + Opt, + "", + "crate-list-heading", + "heading under which to list this crate in the sidebar crate list", + "TEXT", + ), opt( Stable, Opt, diff --git a/tests/crashes/142155.rs b/tests/crashes/142155.rs new file mode 100644 index 0000000000000..8c0769bf2b586 --- /dev/null +++ b/tests/crashes/142155.rs @@ -0,0 +1,12 @@ +//@ known-bug: #142155 +//@ needs-rustc-debug-assertions +//@ edition: 2021 + +#![warn(tail_expr_drop_order)] +use core::future::Future; + +fn f() -> impl Future> { + async { Some("nope".into()) } +} + +fn main() {} diff --git a/tests/mir-opt/coroutine/coroutine.main-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/coroutine.main-{closure#0}.StateTransform.diff index 70d5034fc50e0..d9d65147e1e83 100644 --- a/tests/mir-opt/coroutine/coroutine.main-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/coroutine.main-{closure#0}.StateTransform.diff @@ -44,7 +44,7 @@ - StorageLive(_5); - StorageLive(_6); - _6 = &_2; -- _5 = ::clone(move _6) -> [return: bb1, unwind: bb29]; +- _5 = ::clone(move _6) -> [return: bb1, unwind: bb31]; + _18 = copy (_1.0: &mut {coroutine@$DIR/coroutine.rs:19:5: 19:18}); + _17 = discriminant((*_18)); + switchInt(move _17) -> [0: bb35, 1: bb33, 2: bb32, 3: bb30, 4: bb31, otherwise: bb34]; @@ -53,7 +53,7 @@ bb1: { StorageDead(_6); StorageLive(_7); -- _7 = Location::<'_>::caller() -> [return: bb2, unwind: bb28]; +- _7 = Location::<'_>::caller() -> [return: bb2, unwind: bb30]; + _7 = Location::<'_>::caller() -> [return: bb2, unwind: bb21]; } @@ -65,7 +65,7 @@ bb3: { StorageDead(_5); -- _3 = yield(move _4) -> [resume: bb4, drop: bb17]; +- _3 = yield(move _4) -> [resume: bb4, drop: bb18]; + _0 = CoroutineState::<(&str, String, &Location<'_>), ()>::Yielded(move _4); + StorageDead(_3); + StorageDead(_4); @@ -79,7 +79,7 @@ bb5: { StorageDead(_4); -- drop(_3) -> [return: bb6, unwind: bb32]; +- drop(_3) -> [return: bb6, unwind: bb34]; + drop(_3) -> [return: bb6, unwind: bb25]; } @@ -94,7 +94,7 @@ StorageLive(_12); StorageLive(_13); - _13 = &_2; -- _12 = ::clone(move _13) -> [return: bb7, unwind: bb26]; +- _12 = ::clone(move _13) -> [return: bb7, unwind: bb28]; + _13 = &(((*_18) as variant#4).0: std::string::String); + _12 = ::clone(move _13) -> [return: bb7, unwind: bb19]; } @@ -103,7 +103,7 @@ StorageDead(_13); StorageLive(_14); StorageLive(_15); -- _15 = Location::<'_>::caller() -> [return: bb8, unwind: bb22]; +- _15 = Location::<'_>::caller() -> [return: bb8, unwind: bb24]; + _15 = Location::<'_>::caller() -> [return: bb8, unwind: bb15]; } @@ -133,7 +133,7 @@ bb11: { StorageDead(_9); -- drop(_8) -> [return: bb12, unwind: bb25]; +- drop(_8) -> [return: bb12, unwind: bb27]; + drop(_8) -> [return: bb12, unwind: bb18]; } @@ -142,13 +142,13 @@ StorageDead(_11); StorageDead(_8); - _0 = const (); -- drop(_2) -> [return: bb13, unwind: bb34]; +- drop(_2) -> [return: bb13, unwind: bb36]; + _16 = const (); + drop((((*_18) as variant#4).0: std::string::String)) -> [return: bb13, unwind: bb27]; } bb13: { -- drop(_1) -> [return: bb14, unwind: bb35]; +- drop(_1) -> [return: bb14, unwind: bb37]; + goto -> bb14; } @@ -167,25 +167,23 @@ - bb16: { - StorageDead(_9); -- StorageDead(_15); -- StorageDead(_11); -- StorageDead(_8); -- goto -> bb19; + bb16 (cleanup): { + StorageDead(_12); + StorageDead(_10); -+ goto -> bb17; + goto -> bb17; } - bb17: { +- StorageDead(_15); +- StorageDead(_11); +- StorageDead(_8); +- goto -> bb21; + bb17 (cleanup): { + StorageDead(_9); - goto -> bb18; ++ goto -> bb18; } - bb18: { -- StorageDead(_4); -- StorageDead(_3); - goto -> bb19; + bb18 (cleanup): { + StorageDead(_15); @@ -193,17 +191,18 @@ } - bb19: { -- drop(_2) -> [return: bb20, unwind: bb36]; +- StorageDead(_4); + bb19 (cleanup): { + StorageDead(_13); + StorageDead(_12); + StorageDead(_10); + StorageDead(_9); -+ goto -> bb20; + goto -> bb20; } - bb20: { -- drop(_1) -> [return: bb21, unwind: bb35]; +- StorageDead(_3); +- goto -> bb21; + bb20 (cleanup): { + StorageDead(_11); + StorageDead(_8); @@ -211,71 +210,71 @@ } - bb21: { -- coroutine_drop; +- drop(_2) -> [return: bb22, unwind: bb38]; + bb21 (cleanup): { + StorageDead(_7); + drop(_5) -> [return: bb23, unwind terminate(cleanup)]; } - bb22 (cleanup): { -- StorageDead(_14); -- drop(_12) -> [return: bb23, unwind terminate(cleanup)]; +- bb22: { +- drop(_1) -> [return: bb23, unwind: bb37]; ++ bb22 (cleanup): { + StorageDead(_6); + goto -> bb23; } - bb23 (cleanup): { -- StorageDead(_12); -- StorageDead(_10); +- bb23: { +- coroutine_drop; ++ bb23 (cleanup): { + StorageDead(_5); - goto -> bb24; ++ goto -> bb24; } bb24 (cleanup): { -- StorageDead(_9); +- StorageDead(_14); +- drop(_12) -> [return: bb25, unwind terminate(cleanup)]; + StorageDead(_4); - goto -> bb25; ++ goto -> bb25; } bb25 (cleanup): { -- StorageDead(_15); -- goto -> bb27; +- StorageDead(_12); +- StorageDead(_10); + StorageDead(_3); -+ goto -> bb26; + goto -> bb26; } bb26 (cleanup): { -- StorageDead(_13); -- StorageDead(_12); -- StorageDead(_10); - StorageDead(_9); - goto -> bb27; + drop((((*_18) as variant#4).0: std::string::String)) -> [return: bb27, unwind terminate(cleanup)]; } bb27 (cleanup): { -- StorageDead(_11); -- StorageDead(_8); -- goto -> bb33; +- StorageDead(_15); +- goto -> bb29; + goto -> bb28; } bb28 (cleanup): { -- StorageDead(_7); -- drop(_5) -> [return: bb30, unwind terminate(cleanup)]; -+ goto -> bb29; +- StorageDead(_13); +- StorageDead(_12); +- StorageDead(_10); +- StorageDead(_9); + goto -> bb29; } bb29 (cleanup): { -- StorageDead(_6); -- goto -> bb30; +- StorageDead(_11); +- StorageDead(_8); +- goto -> bb35; + discriminant((*_18)) = 2; + resume; } - bb30 (cleanup): { -- StorageDead(_5); -- goto -> bb31; +- StorageDead(_7); +- drop(_5) -> [return: bb32, unwind terminate(cleanup)]; + bb30: { + StorageLive(_3); + StorageLive(_4); @@ -284,7 +283,7 @@ } - bb31 (cleanup): { -- StorageDead(_4); +- StorageDead(_6); - goto -> bb32; + bb31: { + StorageLive(_8); @@ -296,30 +295,40 @@ } - bb32 (cleanup): { -- StorageDead(_3); +- StorageDead(_5); - goto -> bb33; + bb32: { + assert(const false, "coroutine resumed after panicking") -> [success: bb32, unwind continue]; } - bb33 (cleanup): { -- drop(_2) -> [return: bb34, unwind terminate(cleanup)]; +- StorageDead(_4); +- goto -> bb34; + bb33: { + assert(const false, "coroutine resumed after completion") -> [success: bb33, unwind continue]; } - bb34 (cleanup): { -- drop(_1) -> [return: bb35, unwind terminate(cleanup)]; +- StorageDead(_3); +- goto -> bb35; + bb34: { + unreachable; } - bb35 (cleanup): { -- resume; +- drop(_2) -> [return: bb36, unwind terminate(cleanup)]; - } - - bb36 (cleanup): { -- drop(_1) -> [return: bb35, unwind terminate(cleanup)]; +- drop(_1) -> [return: bb37, unwind terminate(cleanup)]; +- } +- +- bb37 (cleanup): { +- resume; +- } +- +- bb38 (cleanup): { +- drop(_1) -> [return: bb37, unwind terminate(cleanup)]; + bb35: { + (((*_18) as variant#4).0: std::string::String) = move _2; + StorageLive(_3); diff --git a/tests/mir-opt/coroutine/coroutine.main-{closure#1}.StateTransform.diff b/tests/mir-opt/coroutine/coroutine.main-{closure#1}.StateTransform.diff index 25b60ef5698ff..d25c2f61b722a 100644 --- a/tests/mir-opt/coroutine/coroutine.main-{closure#1}.StateTransform.diff +++ b/tests/mir-opt/coroutine/coroutine.main-{closure#1}.StateTransform.diff @@ -44,7 +44,7 @@ - StorageLive(_5); - StorageLive(_6); - _6 = &_2; -- _5 = ::clone(move _6) -> [return: bb1, unwind: bb29]; +- _5 = ::clone(move _6) -> [return: bb1, unwind: bb31]; + _18 = copy (_1.0: &mut {coroutine@$DIR/coroutine.rs:26:5: 26:18}); + _17 = discriminant((*_18)); + switchInt(move _17) -> [0: bb35, 1: bb33, 2: bb32, 3: bb30, 4: bb31, otherwise: bb34]; @@ -53,7 +53,7 @@ bb1: { StorageDead(_6); StorageLive(_7); -- _7 = Location::<'_>::caller() -> [return: bb2, unwind: bb28]; +- _7 = Location::<'_>::caller() -> [return: bb2, unwind: bb30]; + _7 = Location::<'_>::caller() -> [return: bb2, unwind: bb21]; } @@ -65,7 +65,7 @@ bb3: { StorageDead(_5); -- _3 = yield(move _4) -> [resume: bb4, drop: bb17]; +- _3 = yield(move _4) -> [resume: bb4, drop: bb18]; + _0 = CoroutineState::<(&str, String, &Location<'_>), ()>::Yielded(move _4); + StorageDead(_3); + StorageDead(_4); @@ -79,7 +79,7 @@ bb5: { StorageDead(_4); -- drop(_3) -> [return: bb6, unwind: bb32]; +- drop(_3) -> [return: bb6, unwind: bb34]; + drop(_3) -> [return: bb6, unwind: bb25]; } @@ -94,7 +94,7 @@ StorageLive(_12); StorageLive(_13); - _13 = &_2; -- _12 = ::clone(move _13) -> [return: bb7, unwind: bb26]; +- _12 = ::clone(move _13) -> [return: bb7, unwind: bb28]; + _13 = &(((*_18) as variant#4).0: std::string::String); + _12 = ::clone(move _13) -> [return: bb7, unwind: bb19]; } @@ -103,7 +103,7 @@ StorageDead(_13); StorageLive(_14); StorageLive(_15); -- _15 = Location::<'_>::caller() -> [return: bb8, unwind: bb22]; +- _15 = Location::<'_>::caller() -> [return: bb8, unwind: bb24]; + _15 = Location::<'_>::caller() -> [return: bb8, unwind: bb15]; } @@ -133,7 +133,7 @@ bb11: { StorageDead(_9); -- drop(_8) -> [return: bb12, unwind: bb25]; +- drop(_8) -> [return: bb12, unwind: bb27]; + drop(_8) -> [return: bb12, unwind: bb18]; } @@ -142,13 +142,13 @@ StorageDead(_11); StorageDead(_8); - _0 = const (); -- drop(_2) -> [return: bb13, unwind: bb34]; +- drop(_2) -> [return: bb13, unwind: bb36]; + _16 = const (); + drop((((*_18) as variant#4).0: std::string::String)) -> [return: bb13, unwind: bb27]; } bb13: { -- drop(_1) -> [return: bb14, unwind: bb35]; +- drop(_1) -> [return: bb14, unwind: bb37]; + goto -> bb14; } @@ -167,25 +167,23 @@ - bb16: { - StorageDead(_9); -- StorageDead(_15); -- StorageDead(_11); -- StorageDead(_8); -- goto -> bb19; + bb16 (cleanup): { + StorageDead(_12); + StorageDead(_10); -+ goto -> bb17; + goto -> bb17; } - bb17: { +- StorageDead(_15); +- StorageDead(_11); +- StorageDead(_8); +- goto -> bb21; + bb17 (cleanup): { + StorageDead(_9); - goto -> bb18; ++ goto -> bb18; } - bb18: { -- StorageDead(_4); -- StorageDead(_3); - goto -> bb19; + bb18 (cleanup): { + StorageDead(_15); @@ -193,17 +191,18 @@ } - bb19: { -- drop(_2) -> [return: bb20, unwind: bb36]; +- StorageDead(_4); + bb19 (cleanup): { + StorageDead(_13); + StorageDead(_12); + StorageDead(_10); + StorageDead(_9); -+ goto -> bb20; + goto -> bb20; } - bb20: { -- drop(_1) -> [return: bb21, unwind: bb35]; +- StorageDead(_3); +- goto -> bb21; + bb20 (cleanup): { + StorageDead(_11); + StorageDead(_8); @@ -211,71 +210,71 @@ } - bb21: { -- coroutine_drop; +- drop(_2) -> [return: bb22, unwind: bb38]; + bb21 (cleanup): { + StorageDead(_7); + drop(_5) -> [return: bb23, unwind terminate(cleanup)]; } - bb22 (cleanup): { -- StorageDead(_14); -- drop(_12) -> [return: bb23, unwind terminate(cleanup)]; +- bb22: { +- drop(_1) -> [return: bb23, unwind: bb37]; ++ bb22 (cleanup): { + StorageDead(_6); + goto -> bb23; } - bb23 (cleanup): { -- StorageDead(_12); -- StorageDead(_10); +- bb23: { +- coroutine_drop; ++ bb23 (cleanup): { + StorageDead(_5); - goto -> bb24; ++ goto -> bb24; } bb24 (cleanup): { -- StorageDead(_9); +- StorageDead(_14); +- drop(_12) -> [return: bb25, unwind terminate(cleanup)]; + StorageDead(_4); - goto -> bb25; ++ goto -> bb25; } bb25 (cleanup): { -- StorageDead(_15); -- goto -> bb27; +- StorageDead(_12); +- StorageDead(_10); + StorageDead(_3); -+ goto -> bb26; + goto -> bb26; } bb26 (cleanup): { -- StorageDead(_13); -- StorageDead(_12); -- StorageDead(_10); - StorageDead(_9); - goto -> bb27; + drop((((*_18) as variant#4).0: std::string::String)) -> [return: bb27, unwind terminate(cleanup)]; } bb27 (cleanup): { -- StorageDead(_11); -- StorageDead(_8); -- goto -> bb33; +- StorageDead(_15); +- goto -> bb29; + goto -> bb28; } bb28 (cleanup): { -- StorageDead(_7); -- drop(_5) -> [return: bb30, unwind terminate(cleanup)]; -+ goto -> bb29; +- StorageDead(_13); +- StorageDead(_12); +- StorageDead(_10); +- StorageDead(_9); + goto -> bb29; } bb29 (cleanup): { -- StorageDead(_6); -- goto -> bb30; +- StorageDead(_11); +- StorageDead(_8); +- goto -> bb35; + discriminant((*_18)) = 2; + resume; } - bb30 (cleanup): { -- StorageDead(_5); -- goto -> bb31; +- StorageDead(_7); +- drop(_5) -> [return: bb32, unwind terminate(cleanup)]; + bb30: { + StorageLive(_3); + StorageLive(_4); @@ -284,7 +283,7 @@ } - bb31 (cleanup): { -- StorageDead(_4); +- StorageDead(_6); - goto -> bb32; + bb31: { + StorageLive(_8); @@ -296,30 +295,40 @@ } - bb32 (cleanup): { -- StorageDead(_3); +- StorageDead(_5); - goto -> bb33; + bb32: { + assert(const false, "coroutine resumed after panicking") -> [success: bb32, unwind continue]; } - bb33 (cleanup): { -- drop(_2) -> [return: bb34, unwind terminate(cleanup)]; +- StorageDead(_4); +- goto -> bb34; + bb33: { + assert(const false, "coroutine resumed after completion") -> [success: bb33, unwind continue]; } - bb34 (cleanup): { -- drop(_1) -> [return: bb35, unwind terminate(cleanup)]; +- StorageDead(_3); +- goto -> bb35; + bb34: { + unreachable; } - bb35 (cleanup): { -- resume; +- drop(_2) -> [return: bb36, unwind terminate(cleanup)]; - } - - bb36 (cleanup): { -- drop(_1) -> [return: bb35, unwind terminate(cleanup)]; +- drop(_1) -> [return: bb37, unwind terminate(cleanup)]; +- } +- +- bb37 (cleanup): { +- resume; +- } +- +- bb38 (cleanup): { +- drop(_1) -> [return: bb37, unwind terminate(cleanup)]; + bb35: { + (((*_18) as variant#4).0: std::string::String) = move _2; + StorageLive(_3); diff --git a/tests/mir-opt/coroutine/unwind_in_vec.build-{closure#0}.built.after.mir b/tests/mir-opt/coroutine/unwind_in_vec.build-{closure#0}.built.after.mir index 663d954d9b545..db46970999856 100644 --- a/tests/mir-opt/coroutine/unwind_in_vec.build-{closure#0}.built.after.mir +++ b/tests/mir-opt/coroutine/unwind_in_vec.build-{closure#0}.built.after.mir @@ -37,7 +37,7 @@ yields () FakeRead(ForLet(None), _3); StorageLive(_4); StorageLive(_5); - _5 = Box::<[String; 5]>::new_uninit() -> [return: bb1, unwind: bb44]; + _5 = Box::<[String; 5]>::new_uninit() -> [return: bb1, unwind: bb50]; } bb1: { @@ -46,7 +46,7 @@ yields () StorageLive(_8); _8 = const "0"; _7 = &(*_8); - _6 = ::to_string(move _7) -> [return: bb2, unwind: bb41]; + _6 = ::to_string(move _7) -> [return: bb2, unwind: bb47]; } bb2: { @@ -56,7 +56,7 @@ yields () StorageLive(_11); _11 = const "1"; _10 = &(*_11); - _9 = ::to_string(move _10) -> [return: bb3, unwind: bb37]; + _9 = ::to_string(move _10) -> [return: bb3, unwind: bb43]; } bb3: { @@ -66,7 +66,7 @@ yields () StorageLive(_14); _14 = const "2"; _13 = &(*_14); - _12 = ::to_string(move _13) -> [return: bb4, unwind: bb32]; + _12 = ::to_string(move _13) -> [return: bb4, unwind: bb38]; } bb4: { @@ -76,7 +76,7 @@ yields () StorageLive(_17); _17 = const "3"; _16 = &(*_17); - _15 = ::to_string(move _16) -> [return: bb5, unwind: bb26]; + _15 = ::to_string(move _16) -> [return: bb5, unwind: bb32]; } bb5: { @@ -86,44 +86,44 @@ yields () StorageLive(_20); _20 = const "4"; _19 = &(*_20); - _18 = ::to_string(move _19) -> [return: bb6, unwind: bb18]; + _18 = ::to_string(move _19) -> [return: bb6, unwind: bb24]; } bb6: { StorageDead(_19); (((*_5).1: std::mem::ManuallyDrop<[std::string::String; 5]>).0: [std::string::String; 5]) = [move _6, move _9, move _12, move _15, move _18]; - drop(_18) -> [return: bb7, unwind: bb19]; + drop(_18) -> [return: bb7, unwind: bb25, drop: bb15]; } bb7: { StorageDead(_18); - drop(_15) -> [return: bb8, unwind: bb20]; + drop(_15) -> [return: bb8, unwind: bb26, drop: bb16]; } bb8: { StorageDead(_15); - drop(_12) -> [return: bb9, unwind: bb21]; + drop(_12) -> [return: bb9, unwind: bb27, drop: bb17]; } bb9: { StorageDead(_12); - drop(_9) -> [return: bb10, unwind: bb22]; + drop(_9) -> [return: bb10, unwind: bb28, drop: bb18]; } bb10: { StorageDead(_9); - drop(_6) -> [return: bb11, unwind: bb23]; + drop(_6) -> [return: bb11, unwind: bb29, drop: bb19]; } bb11: { StorageDead(_6); _4 = move _5; - drop(_5) -> [return: bb12, unwind: bb16]; + drop(_5) -> [return: bb12, unwind: bb22]; } bb12: { StorageDead(_5); - _0 = std::boxed::box_assume_init_into_vec_unsafe::(move _4) -> [return: bb13, unwind: bb17]; + _0 = std::boxed::box_assume_init_into_vec_unsafe::(move _4) -> [return: bb13, unwind: bb23]; } bb13: { @@ -134,7 +134,7 @@ yields () StorageDead(_11); StorageDead(_8); StorageDead(_3); - drop(_1) -> [return: bb14, unwind: bb46, drop: bb15]; + drop(_1) -> [return: bb14, unwind: bb52, drop: bb21]; } bb14: { @@ -142,61 +142,66 @@ yields () } bb15: { - coroutine_drop; + StorageDead(_18); + drop(_15) -> [return: bb16, unwind: bb53]; } - bb16 (cleanup): { - StorageDead(_5); - goto -> bb17; + bb16: { + StorageDead(_15); + drop(_12) -> [return: bb17, unwind: bb54]; } - bb17 (cleanup): { - drop(_4) -> [return: bb25, unwind terminate(cleanup)]; + bb17: { + StorageDead(_12); + drop(_9) -> [return: bb18, unwind: bb55]; } - bb18 (cleanup): { - StorageDead(_19); - goto -> bb19; + bb18: { + StorageDead(_9); + drop(_6) -> [return: bb19, unwind: bb56]; } - bb19 (cleanup): { - StorageDead(_18); - drop(_15) -> [return: bb20, unwind terminate(cleanup)]; + bb19: { + StorageDead(_6); + drop(_5) -> [return: bb20, unwind: bb57]; } - bb20 (cleanup): { - StorageDead(_15); - drop(_12) -> [return: bb21, unwind terminate(cleanup)]; + bb20: { + StorageDead(_5); + StorageDead(_4); + StorageDead(_20); + StorageDead(_17); + StorageDead(_14); + StorageDead(_11); + StorageDead(_8); + StorageDead(_3); + drop(_1) -> [return: bb21, unwind: bb52]; } - bb21 (cleanup): { - StorageDead(_12); - drop(_9) -> [return: bb22, unwind terminate(cleanup)]; + bb21: { + coroutine_drop; } bb22 (cleanup): { - StorageDead(_9); - drop(_6) -> [return: bb23, unwind terminate(cleanup)]; + StorageDead(_5); + goto -> bb23; } bb23 (cleanup): { - StorageDead(_6); - drop(_5) -> [return: bb24, unwind terminate(cleanup)]; + drop(_4) -> [return: bb31, unwind terminate(cleanup)]; } bb24 (cleanup): { - StorageDead(_5); + StorageDead(_19); goto -> bb25; } bb25 (cleanup): { - StorageDead(_4); - StorageDead(_20); - goto -> bb31; + StorageDead(_18); + drop(_15) -> [return: bb26, unwind terminate(cleanup)]; } bb26 (cleanup): { - StorageDead(_16); StorageDead(_15); drop(_12) -> [return: bb27, unwind terminate(cleanup)]; } @@ -218,95 +223,159 @@ yields () bb30 (cleanup): { StorageDead(_5); - StorageDead(_4); goto -> bb31; } bb31 (cleanup): { - StorageDead(_17); - goto -> bb36; + StorageDead(_4); + StorageDead(_20); + goto -> bb37; } bb32 (cleanup): { + StorageDead(_16); + StorageDead(_15); + drop(_12) -> [return: bb33, unwind terminate(cleanup)]; + } + + bb33 (cleanup): { + StorageDead(_12); + drop(_9) -> [return: bb34, unwind terminate(cleanup)]; + } + + bb34 (cleanup): { + StorageDead(_9); + drop(_6) -> [return: bb35, unwind terminate(cleanup)]; + } + + bb35 (cleanup): { + StorageDead(_6); + drop(_5) -> [return: bb36, unwind terminate(cleanup)]; + } + + bb36 (cleanup): { + StorageDead(_5); + StorageDead(_4); + goto -> bb37; + } + + bb37 (cleanup): { + StorageDead(_17); + goto -> bb42; + } + + bb38 (cleanup): { StorageDead(_13); StorageDead(_12); - drop(_9) -> [return: bb33, unwind terminate(cleanup)]; + drop(_9) -> [return: bb39, unwind terminate(cleanup)]; } - bb33 (cleanup): { + bb39 (cleanup): { StorageDead(_9); - drop(_6) -> [return: bb34, unwind terminate(cleanup)]; + drop(_6) -> [return: bb40, unwind terminate(cleanup)]; } - bb34 (cleanup): { + bb40 (cleanup): { StorageDead(_6); - drop(_5) -> [return: bb35, unwind terminate(cleanup)]; + drop(_5) -> [return: bb41, unwind terminate(cleanup)]; } - bb35 (cleanup): { + bb41 (cleanup): { StorageDead(_5); StorageDead(_4); - goto -> bb36; + goto -> bb42; } - bb36 (cleanup): { + bb42 (cleanup): { StorageDead(_14); - goto -> bb40; + goto -> bb46; } - bb37 (cleanup): { + bb43 (cleanup): { StorageDead(_10); StorageDead(_9); - drop(_6) -> [return: bb38, unwind terminate(cleanup)]; + drop(_6) -> [return: bb44, unwind terminate(cleanup)]; } - bb38 (cleanup): { + bb44 (cleanup): { StorageDead(_6); - drop(_5) -> [return: bb39, unwind terminate(cleanup)]; + drop(_5) -> [return: bb45, unwind terminate(cleanup)]; } - bb39 (cleanup): { + bb45 (cleanup): { StorageDead(_5); StorageDead(_4); - goto -> bb40; + goto -> bb46; } - bb40 (cleanup): { + bb46 (cleanup): { StorageDead(_11); - goto -> bb43; + goto -> bb49; } - bb41 (cleanup): { + bb47 (cleanup): { StorageDead(_7); StorageDead(_6); - drop(_5) -> [return: bb42, unwind terminate(cleanup)]; + drop(_5) -> [return: bb48, unwind terminate(cleanup)]; } - bb42 (cleanup): { + bb48 (cleanup): { StorageDead(_5); StorageDead(_4); - goto -> bb43; + goto -> bb49; } - bb43 (cleanup): { + bb49 (cleanup): { StorageDead(_8); - goto -> bb45; + goto -> bb51; } - bb44 (cleanup): { + bb50 (cleanup): { StorageDead(_5); StorageDead(_4); - goto -> bb45; + goto -> bb51; } - bb45 (cleanup): { + bb51 (cleanup): { StorageDead(_3); - drop(_1) -> [return: bb46, unwind terminate(cleanup)]; + drop(_1) -> [return: bb52, unwind terminate(cleanup)]; } - bb46 (cleanup): { + bb52 (cleanup): { resume; } + + bb53 (cleanup): { + StorageDead(_15); + drop(_12) -> [return: bb54, unwind terminate(cleanup)]; + } + + bb54 (cleanup): { + StorageDead(_12); + drop(_9) -> [return: bb55, unwind terminate(cleanup)]; + } + + bb55 (cleanup): { + StorageDead(_9); + drop(_6) -> [return: bb56, unwind terminate(cleanup)]; + } + + bb56 (cleanup): { + StorageDead(_6); + drop(_5) -> [return: bb57, unwind terminate(cleanup)]; + } + + bb57 (cleanup): { + StorageDead(_5); + StorageDead(_4); + StorageDead(_20); + StorageDead(_17); + StorageDead(_14); + StorageDead(_11); + StorageDead(_8); + StorageDead(_3); + drop(_1) -> [return: bb52, unwind terminate(cleanup)]; + } } ALLOC0 (size: 1, align: 1) { diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.runtime-optimized.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.runtime-optimized.after.panic-abort.mir index 40384e1ee7472..6696c91a0e67a 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.runtime-optimized.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.runtime-optimized.after.panic-abort.mir @@ -5,41 +5,38 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug f => _2; let mut _0: (); let mut _12: usize; - let mut _32: std::option::Option<(usize, &T)>; - let mut _35: &impl Fn(usize, &T); - let mut _36: (usize, &T); - let _37: (); + let mut _29: std::option::Option<(usize, &T)>; + let mut _32: &impl Fn(usize, &T); + let mut _33: (usize, &T); + let _34: (); scope 1 { debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).0: std::ptr::NonNull) => _8; debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).1: *const T) => _11; debug (((iter: Enumerate>).0: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; debug ((iter: Enumerate>).1: usize) => _12; - let _33: usize; - let _34: &T; + let _30: usize; + let _31: &T; scope 2 { - debug i => _33; - debug x => _34; + debug i => _30; + debug x => _31; } scope 18 (inlined > as Iterator>::next) { - let mut _22: std::option::Option; - let mut _27: std::option::Option<&T>; - let mut _30: (usize, bool); - let mut _31: (usize, &T); + let mut _24: std::option::Option<&T>; + let mut _27: (usize, bool); + let mut _28: (usize, &T); scope 19 { - let _29: usize; + let _26: usize; scope 22 { } } scope 20 { scope 25 (inlined as FromResidual>>::from_residual) { - let mut _21: isize; - let mut _23: bool; } } scope 21 { } scope 23 (inlined as Try>::branch) { - let _28: &T; + let _25: &T; scope 24 { } } @@ -48,8 +45,8 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let _13: std::ptr::NonNull; let _15: std::ptr::NonNull; let mut _18: bool; - let mut _24: usize; - let _26: &T; + let mut _21: usize; + let _23: &T; scope 27 { let _14: *const T; scope 28 { @@ -82,7 +79,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 41 (inlined NonNull::::as_ref::<'_>) { - let _25: *const T; + let _22: *const T; scope 42 (inlined NonNull::::as_ptr) { } scope 43 (inlined std::ptr::mut_ptr::::cast_const) { @@ -175,10 +172,10 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb4: { - StorageLive(_32); - StorageLive(_30); + StorageLive(_29); StorageLive(_27); StorageLive(_24); + StorageLive(_21); StorageLive(_16); StorageLive(_13); _13 = copy _8; @@ -230,17 +227,11 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { StorageDead(_14); StorageDead(_13); StorageDead(_16); + StorageDead(_21); StorageDead(_24); StorageDead(_27); - StorageLive(_21); - StorageLive(_23); - _21 = discriminant(_22); - _23 = Eq(copy _21, const 0_isize); - assume(move _23); - StorageDead(_23); - StorageDead(_21); - StorageDead(_30); - StorageDead(_32); + _0 = const (); + StorageDead(_29); StorageDead(_12); drop(_2) -> [return: bb11, unwind unreachable]; } @@ -250,57 +241,57 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb12: { - _24 = SubUnchecked(copy _20, const 1_usize); - _11 = copy _24 as *const T (Transmute); + _21 = SubUnchecked(copy _20, const 1_usize); + _11 = copy _21 as *const T (Transmute); StorageDead(_20); goto -> bb13; } bb13: { - StorageLive(_26); - StorageLive(_25); - _25 = copy _13 as *const T (Transmute); - _26 = &(*_25); - StorageDead(_25); - _27 = Option::<&T>::Some(copy _26); - StorageDead(_26); + StorageLive(_23); + StorageLive(_22); + _22 = copy _13 as *const T (Transmute); + _23 = &(*_22); + StorageDead(_22); + _24 = Option::<&T>::Some(copy _23); + StorageDead(_23); StorageDead(_14); StorageDead(_13); StorageDead(_16); + StorageDead(_21); + _25 = copy ((_24 as Some).0: &T); StorageDead(_24); - _28 = copy ((_27 as Some).0: &T); - StorageDead(_27); - StorageLive(_29); - _29 = copy _12; - _30 = AddWithOverflow(copy _12, const 1_usize); - assert(!move (_30.1: bool), "attempt to compute `{} + {}`, which would overflow", copy _12, const 1_usize) -> [success: bb14, unwind unreachable]; + StorageLive(_26); + _26 = copy _12; + _27 = AddWithOverflow(copy _12, const 1_usize); + assert(!move (_27.1: bool), "attempt to compute `{} + {}`, which would overflow", copy _12, const 1_usize) -> [success: bb14, unwind unreachable]; } bb14: { - _12 = move (_30.0: usize); + _12 = move (_27.0: usize); + StorageLive(_28); + _28 = (copy _26, copy _25); + _29 = Option::<(usize, &T)>::Some(move _28); + StorageDead(_28); + StorageDead(_26); + StorageDead(_27); + StorageLive(_30); + _30 = copy (((_29 as Some).0: (usize, &T)).0: usize); StorageLive(_31); - _31 = (copy _29, copy _28); - _32 = Option::<(usize, &T)>::Some(move _31); - StorageDead(_31); - StorageDead(_29); - StorageDead(_30); + _31 = copy (((_29 as Some).0: (usize, &T)).1: &T); + StorageLive(_32); + _32 = &_2; StorageLive(_33); - _33 = copy (((_32 as Some).0: (usize, &T)).0: usize); - StorageLive(_34); - _34 = copy (((_32 as Some).0: (usize, &T)).1: &T); - StorageLive(_35); - _35 = &_2; - StorageLive(_36); - _36 = (copy _33, copy _34); - _37 = >::call(move _35, move _36) -> [return: bb15, unwind unreachable]; + _33 = (copy _30, copy _31); + _34 = >::call(move _32, move _33) -> [return: bb15, unwind unreachable]; } bb15: { - StorageDead(_36); - StorageDead(_35); - StorageDead(_34); StorageDead(_33); StorageDead(_32); + StorageDead(_31); + StorageDead(_30); + StorageDead(_29); goto -> bb4; } } diff --git a/tests/run-make/rustdoc/default-output/output-default.stdout b/tests/run-make/rustdoc/default-output/output-default.stdout index 3093a01ec79f7..346140b2d921c 100644 --- a/tests/run-make/rustdoc/default-output/output-default.stdout +++ b/tests/run-make/rustdoc/default-output/output-default.stdout @@ -82,6 +82,9 @@ Options: --sort-modules-by-appearance sort modules by where they appear in the program, rather than alphabetically + --crate-list-heading TEXT + heading under which to list this crate in the sidebar + crate list --default-theme THEME Set the default theme. THEME should be the theme name, generally lowercase. If an unknown default theme is diff --git a/tests/rustdoc-gui/sidebar.goml b/tests/rustdoc-gui/sidebar.goml index 0d371c8c6a46f..7d1067b8a25f3 100644 --- a/tests/rustdoc-gui/sidebar.goml +++ b/tests/rustdoc-gui/sidebar.goml @@ -50,7 +50,9 @@ call-function: ("switch-theme", {"theme": "light"}) assert-text: (".sidebar > .sidebar-crate > h2 > a", "test_docs") // Crate root has no "location" element assert-count: (".sidebar .location", 0) -assert-count: (".sidebar h2", 1) +// Crate root has two h2s, the second of which is the the crate list +assert-count: (".sidebar h2", 2) +assert-text: (".sidebar #rustdoc-modnav h2", "Crates") assert-text: ("#all-types", "All Items") assert-css: ("#all-types", {"color": "#356da4"}) // We check that we have the crates list and that the "current" on is "test_docs". diff --git a/tests/rustdoc-html/crate-list-heading.rs b/tests/rustdoc-html/crate-list-heading.rs new file mode 100644 index 0000000000000..8b7e372c42dce --- /dev/null +++ b/tests/rustdoc-html/crate-list-heading.rs @@ -0,0 +1,5 @@ +//@ compile-flags: -Zunstable-options --crate-list-heading=helloworld +#![crate_name = "foo"] + +//@ hasraw crates.js '"h":"helloworld"' +//@ hasraw crates.js '"c":"foo"' diff --git a/tests/ui/associated-consts/associated-const-generic-obligations.stderr b/tests/ui/associated-consts/associated-const-generic-obligations.stderr index 5ea85ff3b9899..f7431a1e690d7 100644 --- a/tests/ui/associated-consts/associated-const-generic-obligations.stderr +++ b/tests/ui/associated-consts/associated-const-generic-obligations.stderr @@ -1,12 +1,14 @@ error[E0326]: implemented const `FROM` has an incompatible type for trait --> $DIR/associated-const-generic-obligations.rs:14:17 | +LL | impl Bar for T { LL | const FROM: &'static str = "foo"; | ^^^^^^^^^^^^ expected associated type, found `&'static str` | note: type in trait --> $DIR/associated-const-generic-obligations.rs:10:17 | +LL | trait Bar: Foo { LL | const FROM: Self::Out; | ^^^^^^^^^ = note: expected associated type `::Out` diff --git a/tests/ui/associated-consts/associated-const-impl-wrong-type.stderr b/tests/ui/associated-consts/associated-const-impl-wrong-type.stderr index b91b777d5850f..6b517b4a00528 100644 --- a/tests/ui/associated-consts/associated-const-impl-wrong-type.stderr +++ b/tests/ui/associated-consts/associated-const-impl-wrong-type.stderr @@ -1,12 +1,14 @@ error[E0326]: implemented const `BAR` has an incompatible type for trait --> $DIR/associated-const-impl-wrong-type.rs:8:16 | +LL | impl Foo for SignedBar { LL | const BAR: i32 = -1; | ^^^ expected `u32`, found `i32` | note: type in trait --> $DIR/associated-const-impl-wrong-type.rs:2:16 | +LL | trait Foo { LL | const BAR: u32; | ^^^ diff --git a/tests/ui/associated-types/defaults-specialization.stderr b/tests/ui/associated-types/defaults-specialization.stderr index a03296af8a37b..ee0e9878e8e6a 100644 --- a/tests/ui/associated-types/defaults-specialization.stderr +++ b/tests/ui/associated-types/defaults-specialization.stderr @@ -1,12 +1,15 @@ error[E0053]: method `make` has an incompatible type for trait --> $DIR/defaults-specialization.rs:18:18 | +LL | default impl Tr for A { LL | fn make() -> u8 { 0 } | ^^ expected associated type, found `u8` | note: type in trait --> $DIR/defaults-specialization.rs:8:18 | +LL | trait Tr { +... LL | fn make() -> Self::Ty { | ^^^^^^^^ = note: expected signature `fn() -> as Tr>::Ty` @@ -30,6 +33,8 @@ LL | fn make() -> bool { true } note: type in trait --> $DIR/defaults-specialization.rs:8:18 | +LL | trait Tr { +... LL | fn make() -> Self::Ty { | ^^^^^^^^ = note: expected signature `fn() -> as Tr>::Ty` diff --git a/tests/ui/async-await/async-drop/cancelled-future-drops-sync-fields-164901.rs b/tests/ui/async-await/async-drop/cancelled-future-drops-sync-fields-164901.rs deleted file mode 100644 index 280e123eb0b78..0000000000000 --- a/tests/ui/async-await/async-drop/cancelled-future-drops-sync-fields-164901.rs +++ /dev/null @@ -1,56 +0,0 @@ -//@ run-pass -//@ edition: 2024 - -// Regression test for . -// Types with only a sync `Drop` impl nested inside another ADT were treated -// as needing async drop, so a cancelled future leaked them. - -#![feature(async_drop)] -#![allow(incomplete_features)] - -use std::future::Future; -use std::pin::pin; -use std::sync::atomic::{AtomicUsize, Ordering}; -use std::task::{Context, Waker}; - -static DROPS: AtomicUsize = AtomicUsize::new(0); - -struct D; -impl Drop for D { - fn drop(&mut self) { - DROPS.fetch_add(1, Ordering::Relaxed); - } -} - -struct Wrapper(T); - -fn poll_once_then_drop(f: impl Future) { - let mut f = Box::pin(f); - let _ = f.as_mut().poll(&mut Context::from_waker(Waker::noop())); -} - -fn main() { - poll_once_then_drop(async { - let _d = D; - std::future::pending::<()>().await - }); - assert_eq!(DROPS.load(Ordering::Relaxed), 1); - - poll_once_then_drop(async { - let _o = Some(D); - std::future::pending::<()>().await - }); - assert_eq!(DROPS.load(Ordering::Relaxed), 2); - - poll_once_then_drop(async { - let _w = Wrapper(D); - std::future::pending::<()>().await - }); - assert_eq!(DROPS.load(Ordering::Relaxed), 3); - - poll_once_then_drop(async { - let _p = pin!(D); - std::future::pending::<()>().await - }); - assert_eq!(DROPS.load(Ordering::Relaxed), 4); -} diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs index 8d3dbaf6ca1f1..217eadeb26229 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs @@ -4,7 +4,8 @@ use std::future::Future; use std::pin::Pin; trait MyTrait { - fn foo(&self) -> Pin + '_>>; + fn foo(&self) + -> Pin + '_>>; } impl MyTrait for i32 { diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr index c98df134072eb..387626907f1f5 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr @@ -1,14 +1,17 @@ error[E0053]: method `foo` has an incompatible type for trait - --> $DIR/async-example-desugared-boxed-in-trait.rs:11:28 + --> $DIR/async-example-desugared-boxed-in-trait.rs:12:28 | +LL | impl MyTrait for i32 { LL | async fn foo(&self) -> i32 { | ^^^ expected `Pin>>`, found future | note: type in trait - --> $DIR/async-example-desugared-boxed-in-trait.rs:7:22 + --> $DIR/async-example-desugared-boxed-in-trait.rs:8:8 | -LL | fn foo(&self) -> Pin + '_>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait MyTrait { +LL | fn foo(&self) +LL | -> Pin + '_>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `fn(&_) -> Pin>>` found signature `fn(&_) -> impl Future` diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr index d0c11565f4e90..4feaee82fef79 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr @@ -1,12 +1,14 @@ error[E0053]: method `foo` has an incompatible type for trait --> $DIR/dont-project-to-specializable-projection.rs:14:35 | +LL | impl MyTrait for MyStruct { LL | default async fn foo(_: T) -> &'static str { | ^^^^^^^^^^^^ expected associated type, found future | note: type in trait --> $DIR/dont-project-to-specializable-projection.rs:10:27 | +LL | trait MyTrait { LL | async fn foo(_: T) -> &'static str; | ^^^^^^^^^^^^ = note: expected signature `fn(_) -> impl Future` diff --git a/tests/ui/compare-method/bad-self-type.stderr b/tests/ui/compare-method/bad-self-type.stderr index bc1587883a352..fd5e13e5247ce 100644 --- a/tests/ui/compare-method/bad-self-type.stderr +++ b/tests/ui/compare-method/bad-self-type.stderr @@ -1,6 +1,8 @@ error[E0053]: method `poll` has an incompatible type for trait --> $DIR/bad-self-type.rs:10:13 | +LL | impl Future for MyFuture { +LL | type Output = (); LL | fn poll(self, _: &mut Context<'_>) -> Poll<()> { | ^^^^ expected `Pin<&mut MyFuture>`, found `MyFuture` | @@ -14,12 +16,14 @@ LL | fn poll(self: Pin<&mut MyFuture>, _: &mut Context<'_>) -> Poll<()> { error[E0053]: method `foo` has an incompatible type for trait --> $DIR/bad-self-type.rs:22:18 | +LL | impl T for MyFuture { LL | fn foo(self: Box) {} | ^^^^^^^^^ expected `MyFuture`, found `Box` | note: type in trait --> $DIR/bad-self-type.rs:17:12 | +LL | trait T { LL | fn foo(self); | ^^^^ = note: expected signature `fn(MyFuture)` @@ -33,12 +37,16 @@ LL + fn foo(self) {} error[E0053]: method `bar` has an incompatible type for trait --> $DIR/bad-self-type.rs:24:17 | +LL | impl T for MyFuture { +... LL | fn bar(self) {} | ^ expected `Option<()>`, found `()` | note: type in trait --> $DIR/bad-self-type.rs:18:21 | +LL | trait T { +LL | fn foo(self); LL | fn bar(self) -> Option<()>; | ^^^^^^^^^^ = note: expected signature `fn(MyFuture) -> Option<()>` diff --git a/tests/ui/compare-method/default-type-parameter.rs b/tests/ui/compare-method/default-type-parameter.rs new file mode 100644 index 0000000000000..7b72c4eff03d5 --- /dev/null +++ b/tests/ui/compare-method/default-type-parameter.rs @@ -0,0 +1,25 @@ +// Regression test for https://github.com/rust-lang/rust/issues/67991 +// The weird indentation is to exercise the span context that shows the enclosing items in the +// diagnostics being emitted. +trait Trait< + T = (), + K = Self, +> { + fn foo() + -> T; + fn bar() + -> K; +} + +struct S; + +impl Trait for S { + fn foo() -> u32 { 0 } //~ ERROR + fn bar() -> u32 { 0 } //~ ERROR +} +impl Trait for () { + fn foo() -> u32 { 0 } //~ ERROR + fn bar() -> u32 { 0 } //~ ERROR +} + +fn main() {} diff --git a/tests/ui/compare-method/default-type-parameter.stderr b/tests/ui/compare-method/default-type-parameter.stderr new file mode 100644 index 0000000000000..e3109566d7fac --- /dev/null +++ b/tests/ui/compare-method/default-type-parameter.stderr @@ -0,0 +1,107 @@ +error[E0053]: method `foo` has an incompatible type for trait + --> $DIR/default-type-parameter.rs:17:17 + | +LL | impl Trait for S { +LL | fn foo() -> u32 { 0 } + | ^^^ expected `()`, found `u32` + | +note: type in trait + --> $DIR/default-type-parameter.rs:9:8 + | +LL | trait Trait< +LL | T = (), + | ------ expected to match the default of type parameter `T` +... +LL | fn foo() +LL | -> T; + | ^ + = note: expected signature `fn() -> ()` + found signature `fn() -> u32` +help: change the output type to match the trait + | +LL - fn foo() -> u32 { 0 } +LL + fn foo() -> () { 0 } + | + +error[E0053]: method `bar` has an incompatible type for trait + --> $DIR/default-type-parameter.rs:18:17 + | +LL | impl Trait for S { +LL | fn foo() -> u32 { 0 } +LL | fn bar() -> u32 { 0 } + | ^^^ expected `S`, found `u32` + | +note: type in trait + --> $DIR/default-type-parameter.rs:11:8 + | +LL | trait Trait< +LL | T = (), +LL | K = Self, + | -------- expected to match the `Self` default of type parameter `K` +... +LL | fn bar() +LL | -> K; + | ^ + = note: expected signature `fn() -> S` + found signature `fn() -> u32` +help: change the output type to match the trait + | +LL - fn bar() -> u32 { 0 } +LL + fn bar() -> S { 0 } + | + +error[E0053]: method `foo` has an incompatible type for trait + --> $DIR/default-type-parameter.rs:21:17 + | +LL | impl Trait for () { +LL | fn foo() -> u32 { 0 } + | ^^^ expected `i32`, found `u32` + | +note: type in trait + --> $DIR/default-type-parameter.rs:9:8 + | +LL | trait Trait< +LL | T = (), + | ------ expected to match type parameter `T` +... +LL | fn foo() +LL | -> T; + | ^ + = note: expected signature `fn() -> i32` + found signature `fn() -> u32` +help: change the output type to match the trait + | +LL - fn foo() -> u32 { 0 } +LL + fn foo() -> i32 { 0 } + | + +error[E0053]: method `bar` has an incompatible type for trait + --> $DIR/default-type-parameter.rs:22:17 + | +LL | impl Trait for () { +LL | fn foo() -> u32 { 0 } +LL | fn bar() -> u32 { 0 } + | ^^^ expected `()`, found `u32` + | +note: type in trait + --> $DIR/default-type-parameter.rs:11:8 + | +LL | trait Trait< +LL | T = (), +LL | K = Self, + | -------- expected to match the `Self` default of type parameter `K` +... +LL | fn bar() +LL | -> K; + | ^ + = note: expected signature `fn() -> ()` + found signature `fn() -> u32` +help: change the output type to match the trait + | +LL - fn bar() -> u32 { 0 } +LL + fn bar() -> () { 0 } + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/compare-method/issue-90444.stderr b/tests/ui/compare-method/issue-90444.stderr index c69d63b3e30bc..233def019ea42 100644 --- a/tests/ui/compare-method/issue-90444.stderr +++ b/tests/ui/compare-method/issue-90444.stderr @@ -1,6 +1,7 @@ error[E0053]: method `from` has an incompatible type for trait --> $DIR/issue-90444.rs:3:16 | +LL | impl From for A { LL | fn from(_: fn((), (), &mut ())) -> Self { | ^^^^^^^^^^^^^^^^^^^ types differ in mutability | @@ -15,6 +16,7 @@ LL + fn from(_: for<'a> fn((), (), &'a ())) -> Self { error[E0053]: method `from` has an incompatible type for trait --> $DIR/issue-90444.rs:11:16 | +LL | impl From for B { LL | fn from(_: fn((), (), u64)) -> Self { | ^^^^^^^^^^^^^^^ expected `u32`, found `u64` | diff --git a/tests/ui/compare-method/reordered-type-param.stderr b/tests/ui/compare-method/reordered-type-param.stderr index 536364871a368..bea7b43de48d0 100644 --- a/tests/ui/compare-method/reordered-type-param.stderr +++ b/tests/ui/compare-method/reordered-type-param.stderr @@ -1,6 +1,8 @@ error[E0053]: method `b` has an incompatible type for trait --> $DIR/reordered-type-param.rs:16:30 | +LL | impl A for E { +LL | // n.b. The error message is awful -- see #3404 LL | fn b(&self, _x: G) -> G { panic!() } | - - ^ expected type parameter `F`, found type parameter `G` | | | @@ -10,6 +12,7 @@ LL | fn b(&self, _x: G) -> G { panic!() } note: type in trait --> $DIR/reordered-type-param.rs:7:29 | +LL | trait A { LL | fn b(&self, x: C) -> C; | ^ = note: expected signature `fn(&E, F) -> F` diff --git a/tests/ui/const-generics/mgca/type-const-value-type-mismatch.current.stderr b/tests/ui/const-generics/mgca/type-const-value-type-mismatch.current.stderr index dc7f73f2549e8..5d0c6b06dfc8b 100644 --- a/tests/ui/const-generics/mgca/type-const-value-type-mismatch.current.stderr +++ b/tests/ui/const-generics/mgca/type-const-value-type-mismatch.current.stderr @@ -1,12 +1,16 @@ error[E0053]: method `arr` has an incompatible type for trait --> $DIR/type-const-value-type-mismatch.rs:24:5 | +LL | impl Array for A { +... LL | fn arr() -> [u8; const { Self::LEN }] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an array with a size of 0, found one with a size of const { Self::LEN } | note: type in trait --> $DIR/type-const-value-type-mismatch.rs:17:5 | +LL | pub trait Array { +... LL | fn arr() -> [u8; Self::LEN]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `fn() -> [u8; 0]` diff --git a/tests/ui/consts/issue-70942-trait-vs-impl-mismatch.stderr b/tests/ui/consts/issue-70942-trait-vs-impl-mismatch.stderr index 0393316f166ba..0e877df4ea553 100644 --- a/tests/ui/consts/issue-70942-trait-vs-impl-mismatch.stderr +++ b/tests/ui/consts/issue-70942-trait-vs-impl-mismatch.stderr @@ -1,12 +1,14 @@ error[E0326]: implemented const `VALUE` has an incompatible type for trait --> $DIR/issue-70942-trait-vs-impl-mismatch.rs:8:18 | +LL | impl Nat for Zero { LL | const VALUE: i32 = 0; | ^^^ expected `usize`, found `i32` | note: type in trait --> $DIR/issue-70942-trait-vs-impl-mismatch.rs:2:18 | +LL | trait Nat { LL | const VALUE: usize; | ^^^^^ diff --git a/tests/ui/cross-crate/graceful-error-for-mistyped-assoc-const.stderr b/tests/ui/cross-crate/graceful-error-for-mistyped-assoc-const.stderr index 18b06462de7b6..67622e28aca7b 100644 --- a/tests/ui/cross-crate/graceful-error-for-mistyped-assoc-const.stderr +++ b/tests/ui/cross-crate/graceful-error-for-mistyped-assoc-const.stderr @@ -1,6 +1,7 @@ error[E0326]: implemented const `CONST` has an incompatible type for trait --> $DIR/graceful-error-for-mistyped-assoc-const.rs:10:18 | +LL | impl issue_41549::Trait for S { LL | const CONST: () = (); | ^^ expected `u32`, found `()` diff --git a/tests/ui/delegation/target-expr-removal-defs-inside.stderr b/tests/ui/delegation/target-expr-removal-defs-inside.stderr index 6fde7fb8a7bdb..9f52c8c137d2a 100644 --- a/tests/ui/delegation/target-expr-removal-defs-inside.stderr +++ b/tests/ui/delegation/target-expr-removal-defs-inside.stderr @@ -183,6 +183,7 @@ LL | | } note: type in trait --> $DIR/target-expr-removal-defs-inside.rs:4:25 | +LL | pub trait Trait: Sized { LL | fn static_self() -> F { F } | ^ = note: expected signature `fn() -> F` @@ -257,6 +258,7 @@ LL | | } note: type in trait --> $DIR/target-expr-removal-defs-inside.rs:4:25 | +LL | pub trait Trait: Sized { LL | fn static_self() -> F { F } | ^ = note: expected signature `fn() -> F` @@ -335,6 +337,7 @@ LL | | } note: type in trait --> $DIR/target-expr-removal-defs-inside.rs:4:25 | +LL | pub trait Trait: Sized { LL | fn static_self() -> F { F } | ^ = note: expected signature `fn() -> F` diff --git a/tests/ui/delegation/unused-target-expr-in-glob-or-list.stderr b/tests/ui/delegation/unused-target-expr-in-glob-or-list.stderr index 21d9586d2f58e..18291e0f8a9a7 100644 --- a/tests/ui/delegation/unused-target-expr-in-glob-or-list.stderr +++ b/tests/ui/delegation/unused-target-expr-in-glob-or-list.stderr @@ -164,7 +164,8 @@ error[E0053]: method `static_self` has an incompatible type for trait --> $DIR/unused-target-expr-in-glob-or-list.rs:107:37 | LL | macro_rules! delegation { -... +LL | () => { +LL | impl Trait for S { LL | reuse ::static_self { self.0 } | ^^^^^^^^^^^ expected `F`, found `()` ... @@ -174,6 +175,7 @@ LL | delegation!(); note: type in trait --> $DIR/unused-target-expr-in-glob-or-list.rs:4:25 | +LL | pub trait Trait: Sized { LL | fn static_self() -> F { F } | ^ = note: expected signature `fn() -> F` @@ -192,12 +194,14 @@ LL | () => { LL | reuse ::static_self { self.0 } | ^^^^^^^^^^^ expected `F`, found `()` ... +LL | impl Trait for S1 { LL | delegation2!(); | -------------- in this macro invocation | note: type in trait --> $DIR/unused-target-expr-in-glob-or-list.rs:4:25 | +LL | pub trait Trait: Sized { LL | fn static_self() -> F { F } | ^ = note: expected signature `fn() -> F` diff --git a/tests/ui/drop/async-drop-cycle-issue-165263.rs b/tests/ui/drop/async-drop-cycle-issue-165263.rs new file mode 100644 index 0000000000000..3add37ecf990a --- /dev/null +++ b/tests/ui/drop/async-drop-cycle-issue-165263.rs @@ -0,0 +1,22 @@ +//@ build-pass +//@ edition: 2024 +// test that a recursive type in an async block does +// not cause a cycle. + +pub struct A(Box); +pub struct B(A); +pub async fn run(_: A) {} + +pub enum A2 { + X(Box), +} + +pub enum B2 { + Y(A2), +} +pub async fn run2(a: Option) { + async {}.await; + drop(a); +} + +fn main() {} diff --git a/tests/ui/drop/tail_expr_drop_order-on-async-block-with-drop-field.rs b/tests/ui/drop/tail_expr_drop_order-on-async-block-with-drop-field.rs deleted file mode 100644 index 69e9a8e06dc86..0000000000000 --- a/tests/ui/drop/tail_expr_drop_order-on-async-block-with-drop-field.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ edition: 2021 -//@ check-pass - -// Regression test for . -// The tail expr drop order lint used to ICE on this async block. It stopped -// once types with only a sync `Drop` were no longer treated as needing async drop. - -#![warn(tail_expr_drop_order)] -use core::future::Future; - -fn f() -> impl Future> { - async { Some("nope".into()) } -} - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-effective-target-features.default.stderr b/tests/ui/feature-gates/feature-gate-effective-target-features.default.stderr index 1bad811ada64a..7b8ba0e660ece 100644 --- a/tests/ui/feature-gates/feature-gate-effective-target-features.default.stderr +++ b/tests/ui/feature-gates/feature-gate-effective-target-features.default.stderr @@ -20,12 +20,15 @@ LL | fn foo(&self) {} error[E0053]: method `foo` has an incompatible type for trait --> $DIR/feature-gate-effective-target-features.rs:24:5 | +LL | impl Foo for Bar2 { +... LL | fn foo(&self) {} | ^^^^^^^^^^^^^ expected safe fn, found unsafe fn | note: type in trait --> $DIR/feature-gate-effective-target-features.rs:8:5 | +LL | trait Foo { LL | fn foo(&self); | ^^^^^^^^^^^^^^ = note: expected signature `fn(&Bar2)` diff --git a/tests/ui/feature-gates/feature-gate-effective-target-features.feature.stderr b/tests/ui/feature-gates/feature-gate-effective-target-features.feature.stderr index 06090cbbef6fe..d1939e35d4aba 100644 --- a/tests/ui/feature-gates/feature-gate-effective-target-features.feature.stderr +++ b/tests/ui/feature-gates/feature-gate-effective-target-features.feature.stderr @@ -23,12 +23,15 @@ LL | fn foo(&self) {} error[E0053]: method `foo` has an incompatible type for trait --> $DIR/feature-gate-effective-target-features.rs:24:5 | +LL | impl Foo for Bar2 { +... LL | fn foo(&self) {} | ^^^^^^^^^^^^^ expected safe fn, found unsafe fn | note: type in trait --> $DIR/feature-gate-effective-target-features.rs:8:5 | +LL | trait Foo { LL | fn foo(&self); | ^^^^^^^^^^^^^^ = note: expected signature `fn(&Bar2)` diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr index f844bdbc2cb21..3a507e5f218b4 100644 --- a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr @@ -59,6 +59,8 @@ LL | impl Fn<()> for Foo { error[E0053]: method `call` has an incompatible type for trait --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:13:32 | +LL | impl Fn<()> for Foo { +... LL | extern "rust-call" fn call(self, args: ()) -> () {} | ^^^^ expected `&Foo`, found `Foo` | @@ -151,6 +153,8 @@ LL | impl FnOnce() for Foo1 { error[E0053]: method `call_mut` has an incompatible type for trait --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:30:36 | +LL | impl FnMut<()> for Bar { +... LL | extern "rust-call" fn call_mut(&self, args: ()) -> () {} | ^^^^^ types differ in mutability | diff --git a/tests/ui/fn/fn-traits-call-once-signature-15094.stderr b/tests/ui/fn/fn-traits-call-once-signature-15094.stderr index bb1d336e84842..1a892168c2c16 100644 --- a/tests/ui/fn/fn-traits-call-once-signature-15094.stderr +++ b/tests/ui/fn/fn-traits-call-once-signature-15094.stderr @@ -1,6 +1,8 @@ error[E0053]: method `call_once` has an incompatible type for trait --> $DIR/fn-traits-call-once-signature-15094.rs:13:5 | +LL | impl ops::FnOnce<(),> for Debuger { +LL | type Output = (); LL | fn call_once(self, _args: ()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "rust-call" fn, found "Rust" fn | diff --git a/tests/ui/impl-trait/apit/impl-generic-mismatch-ab.stderr b/tests/ui/impl-trait/apit/impl-generic-mismatch-ab.stderr index 9db996cf9ce65..a7f67f04c4905 100644 --- a/tests/ui/impl-trait/apit/impl-generic-mismatch-ab.stderr +++ b/tests/ui/impl-trait/apit/impl-generic-mismatch-ab.stderr @@ -1,6 +1,7 @@ error[E0053]: method `foo` has an incompatible type for trait --> $DIR/impl-generic-mismatch-ab.rs:8:32 | +LL | impl Foo for () { LL | fn foo(&self, a: &impl Debug, b: &B) { } | - ^^^^^^^^^^^ expected type parameter `B`, found type parameter `impl Debug` | | @@ -9,6 +10,7 @@ LL | fn foo(&self, a: &impl Debug, b: &B) { } note: type in trait --> $DIR/impl-generic-mismatch-ab.rs:4:32 | +LL | trait Foo { LL | fn foo(&self, a: &A, b: &impl Debug); | ^^ = note: expected signature `fn(&(), &B, &impl Debug)` diff --git a/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr index 39121c99798bf..5522fea6eb5e2 100644 --- a/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr +++ b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr @@ -16,6 +16,7 @@ LL | type Ty: IntoIterator; error[E0053]: method `method` has an incompatible type for trait --> $DIR/in-assoc-type-unconstrained.rs:22:24 | +LL | impl Trait for () { LL | type Ty = impl Sized; | ---------- the expected opaque type LL | @@ -25,6 +26,8 @@ LL | fn method() -> () {} note: type in trait --> $DIR/in-assoc-type-unconstrained.rs:17:24 | +LL | trait Trait { +LL | type Ty; LL | fn method() -> Self::Ty; | ^^^^^^^^ = note: expected signature `fn() -> <() as compare_method::Trait>::Ty` diff --git a/tests/ui/impl-trait/in-trait/deep-match.stderr b/tests/ui/impl-trait/in-trait/deep-match.stderr index 8ec30239ea8d7..1433664158b9f 100644 --- a/tests/ui/impl-trait/in-trait/deep-match.stderr +++ b/tests/ui/impl-trait/in-trait/deep-match.stderr @@ -1,12 +1,16 @@ error[E0053]: method `bar` has an incompatible return type for trait --> $DIR/deep-match.rs:8:17 | +LL | impl Foo for () { LL | fn bar() -> i32 { - | ^^^ - | | - | expected `Wrapper<_>`, found `i32` - | return type in trait + | ^^^ expected `Wrapper<_>`, found `i32` | +note: return type in trait + --> $DIR/deep-match.rs:4:17 + | +LL | trait Foo { +LL | fn bar() -> Wrapper; + | ^^^^^^^^^^^^^^^^^^^ = note: expected struct `Wrapper<_>` found type `i32` diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr index 97f5b2af862e0..8c3f4300532fe 100644 --- a/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr @@ -1,6 +1,7 @@ error[E0053]: method `early` has an incompatible type for trait --> $DIR/method-signature-matches.rs:55:27 | +LL | impl Lifetimes for () { LL | fn early<'late, T>(_: &'late ()) {} | - ^^^^^^^^^ expected type parameter `T`, found `()` | | @@ -9,6 +10,7 @@ LL | fn early<'late, T>(_: &'late ()) {} note: type in trait --> $DIR/method-signature-matches.rs:50:28 | +LL | trait Lifetimes { LL | fn early<'early, T>(x: &'early T) -> impl Sized; | ^^^^^^^^^ = note: expected signature `fn(&'early T)` diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr index 588b453761003..dd6c906e64255 100644 --- a/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr @@ -1,12 +1,14 @@ error[E0053]: method `owo` has an incompatible type for trait --> $DIR/method-signature-matches.rs:11:15 | +LL | impl Uwu for () { LL | fn owo(_: u8) {} | ^^ expected `()`, found `u8` | note: type in trait --> $DIR/method-signature-matches.rs:6:15 | +LL | trait Uwu { LL | fn owo(x: ()) -> impl Sized; | ^^ = note: expected signature `fn(())` diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr index b0530045bea9a..6a834ceed727e 100644 --- a/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr @@ -1,12 +1,14 @@ error[E0053]: method `owo` has an incompatible type for trait --> $DIR/method-signature-matches.rs:22:21 | +LL | impl AsyncUwu for () { LL | async fn owo(_: u8) {} | ^^ expected `()`, found `u8` | note: type in trait --> $DIR/method-signature-matches.rs:17:21 | +LL | trait AsyncUwu { LL | async fn owo(x: ()) {} | ^^ = note: expected signature `fn(()) -> _` diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.stderr index fbbe1ac40b9ef..ab739dae23d7f 100644 --- a/tests/ui/impl-trait/in-trait/specialization-broken.stderr +++ b/tests/ui/impl-trait/in-trait/specialization-broken.stderr @@ -10,6 +10,7 @@ LL | fn bar(&self) -> U { note: type in trait --> $DIR/specialization-broken.rs:8:22 | +LL | trait Foo { LL | fn bar(&self) -> impl Sized; | ^^^^^^^^^^ = note: expected signature `fn(&_) -> impl Sized` diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr index f921e5a452244..2c99ae95da74f 100644 --- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr +++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr @@ -4,6 +4,8 @@ error[E0053]: method `eq` has an incompatible type for trait LL | type Foo = impl PartialEq<(Foo, i32)>; | -------------------------- the found opaque type ... +LL | impl PartialEq<(Bar, i32)> for Bar { +LL | #[define_opaque(Foo)] LL | fn eq(&self, _other: &(Foo, i32)) -> bool { | ^^^^^^^^^^^ expected `a::Bar`, found opaque type | @@ -21,6 +23,7 @@ error[E0053]: method `eq` has an incompatible type for trait LL | type Foo = impl PartialEq<(Foo, i32)>; | -------------------------- the expected opaque type ... +LL | impl PartialEq<(Foo, i32)> for Bar { LL | fn eq(&self, _other: &(Bar, i32)) -> bool { | ^^^^^^^^^^^ expected opaque type, found `b::Bar` | diff --git a/tests/ui/impl-trait/trait_type.stderr b/tests/ui/impl-trait/trait_type.stderr index 18d914a96a291..ff07297eacff1 100644 --- a/tests/ui/impl-trait/trait_type.stderr +++ b/tests/ui/impl-trait/trait_type.stderr @@ -1,6 +1,7 @@ error[E0053]: method `fmt` has an incompatible type for trait --> $DIR/trait_type.rs:7:21 | +LL | impl std::fmt::Display for MyType { LL | fn fmt(&self, x: &str) -> () { } | ^^^^ types differ in mutability | diff --git a/tests/ui/impl-trait/where-allowed.stderr b/tests/ui/impl-trait/where-allowed.stderr index a0cdc8ee89382..86573088ed971 100644 --- a/tests/ui/impl-trait/where-allowed.stderr +++ b/tests/ui/impl-trait/where-allowed.stderr @@ -348,6 +348,7 @@ LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; error[E0053]: method `in_trait_impl_return` has an incompatible type for trait --> $DIR/where-allowed.rs:129:34 | +LL | impl DummyTrait for () { LL | type Out = impl Debug; | ---------- the expected opaque type ... @@ -357,6 +358,8 @@ LL | fn in_trait_impl_return() -> impl Debug { () } note: type in trait --> $DIR/where-allowed.rs:119:34 | +LL | trait DummyTrait { +... LL | fn in_trait_impl_return() -> Self::Out; | ^^^^^^^^^ = note: expected signature `fn() -> <() as DummyTrait>::Out` diff --git a/tests/ui/mir/inline-wrong-abi.stderr b/tests/ui/mir/inline-wrong-abi.stderr index e44899eb92a5c..cade8c22165f7 100644 --- a/tests/ui/mir/inline-wrong-abi.stderr +++ b/tests/ui/mir/inline-wrong-abi.stderr @@ -1,6 +1,7 @@ error[E0053]: method `call` has an incompatible type for trait --> $DIR/inline-wrong-abi.rs:7:5 | +LL | impl Fn<()> for Foo { LL | extern "C" fn call(&self, _: ()) -> T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "rust-call" fn, found "C" fn | diff --git a/tests/ui/mismatched_types/E0053.stderr b/tests/ui/mismatched_types/E0053.stderr index 32452af5ceda7..6cc5e0b128ee5 100644 --- a/tests/ui/mismatched_types/E0053.stderr +++ b/tests/ui/mismatched_types/E0053.stderr @@ -1,12 +1,14 @@ error[E0053]: method `foo` has an incompatible type for trait --> $DIR/E0053.rs:9:15 | +LL | impl Foo for Bar { LL | fn foo(x: i16) { } | ^^^ expected `u16`, found `i16` | note: type in trait --> $DIR/E0053.rs:2:15 | +LL | trait Foo { LL | fn foo(x: u16); | ^^^ = note: expected signature `fn(u16)` @@ -20,12 +22,16 @@ LL + fn foo(x: u16) { } error[E0053]: method `bar` has an incompatible type for trait --> $DIR/E0053.rs:11:12 | +LL | impl Foo for Bar { +... LL | fn bar(&mut self) { } | ^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/E0053.rs:3:12 | +LL | trait Foo { +LL | fn foo(x: u16); LL | fn bar(&self); | ^^^^^ = note: expected signature `fn(&Bar)` diff --git a/tests/ui/mismatched_types/issue-112036.stderr b/tests/ui/mismatched_types/issue-112036.stderr index fed6b11a7b292..3a4624d206c48 100644 --- a/tests/ui/mismatched_types/issue-112036.stderr +++ b/tests/ui/mismatched_types/issue-112036.stderr @@ -1,6 +1,7 @@ error[E0053]: method `drop` has an incompatible type for trait --> $DIR/issue-112036.rs:4:13 | +LL | impl Drop for Foo { LL | fn drop(self) {} | ^^^^ expected `&mut Foo`, found `Foo` | diff --git a/tests/ui/mismatched_types/issue-13033.stderr b/tests/ui/mismatched_types/issue-13033.stderr index f21d49eac7284..df83d10e29d9c 100644 --- a/tests/ui/mismatched_types/issue-13033.stderr +++ b/tests/ui/mismatched_types/issue-13033.stderr @@ -1,12 +1,14 @@ error[E0053]: method `bar` has an incompatible type for trait --> $DIR/issue-13033.rs:10:30 | +LL | impl Foo for Baz { LL | fn bar(&mut self, other: &dyn Foo) {} | ^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/issue-13033.rs:4:30 | +LL | trait Foo { LL | fn bar(&mut self, other: &mut dyn Foo); | ^^^^^^^^^^^^ = note: expected signature `fn(&mut Baz, &mut dyn Foo)` diff --git a/tests/ui/mismatched_types/trait-impl-fn-incompatibility.stderr b/tests/ui/mismatched_types/trait-impl-fn-incompatibility.stderr index 4aabf2372e478..02df411583fce 100644 --- a/tests/ui/mismatched_types/trait-impl-fn-incompatibility.stderr +++ b/tests/ui/mismatched_types/trait-impl-fn-incompatibility.stderr @@ -1,12 +1,14 @@ error[E0053]: method `foo` has an incompatible type for trait --> $DIR/trait-impl-fn-incompatibility.rs:9:15 | +LL | impl Foo for Bar { LL | fn foo(x: i16) { } | ^^^ expected `u16`, found `i16` | note: type in trait --> $DIR/trait-impl-fn-incompatibility.rs:2:15 | +LL | trait Foo { LL | fn foo(x: u16); | ^^^ = note: expected signature `fn(u16)` @@ -20,12 +22,16 @@ LL + fn foo(x: u16) { } error[E0053]: method `bar` has an incompatible type for trait --> $DIR/trait-impl-fn-incompatibility.rs:10:28 | +LL | impl Foo for Bar { +LL | fn foo(x: i16) { } LL | fn bar(&mut self, bar: &Bar) { } | ^^^^ types differ in mutability | note: type in trait --> $DIR/trait-impl-fn-incompatibility.rs:3:28 | +LL | trait Foo { +LL | fn foo(x: u16); LL | fn bar(&mut self, bar: &mut Bar); | ^^^^^^^^ = note: expected signature `fn(&mut Bar, &mut Bar)` diff --git a/tests/ui/mut/mismatch-trait-mut.e2015.stderr b/tests/ui/mut/mismatch-trait-mut.e2015.stderr index bc9d60e66bc33..0130f2d9833eb 100644 --- a/tests/ui/mut/mismatch-trait-mut.e2015.stderr +++ b/tests/ui/mut/mismatch-trait-mut.e2015.stderr @@ -1,12 +1,14 @@ error[E0053]: method `f` has an incompatible type for trait --> $DIR/mismatch-trait-mut.rs:30:18 | +LL | impl crate::A for X { LL | fn f(_x: &crate::bar::X) {} | ^^^^^^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/mismatch-trait-mut.rs:15:14 | +LL | pub trait A { LL | fn f(_x: &mut bar::X) {} | ^^^^^^^^^^^ = note: expected signature `fn(&mut X)` @@ -19,12 +21,16 @@ LL | fn f(_x: &mut crate::bar::X) {} error[E0053]: method `g` has an incompatible type for trait --> $DIR/mismatch-trait-mut.rs:34:22 | +LL | impl crate::A for X { +... LL | fn g<'a>(_x: &'a crate::bar::X) -> &'a () { &() } | ^^^^^^^^^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/mismatch-trait-mut.rs:17:18 | +LL | pub trait A { +... LL | fn g<'a>(_x: &'a mut bar::X) -> &'a () { &() } | ^^^^^^^^^^^^^^ = note: expected signature `fn(&'a mut X) -> &'a ()` @@ -37,12 +43,16 @@ LL | fn g<'a>(_x: &'a mut crate::bar::X) -> &'a () { &() } error[E0053]: method `f2` has an incompatible type for trait --> $DIR/mismatch-trait-mut.rs:38:19 | +LL | impl crate::A for X { +... LL | fn f2(_x: &mut crate::bar::X) {} | ^^^^^^^^^^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/mismatch-trait-mut.rs:19:15 | +LL | pub trait A { +... LL | fn f2(_x: &bar::X) {} | ^^^^^^^ = note: expected signature `fn(&X)` @@ -56,12 +66,16 @@ LL + fn f2(_x: &crate::bar::X) {} error[E0053]: method `g2` has an incompatible type for trait --> $DIR/mismatch-trait-mut.rs:42:23 | +LL | impl crate::A for X { +... LL | fn g2<'a>(_x: &'a mut crate::bar::X) -> &'a () { &() } | ^^^^^^^^^^^^^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/mismatch-trait-mut.rs:21:19 | +LL | pub trait A { +... LL | fn g2<'a>(_x: &'a bar::X) -> &'a () { &() } | ^^^^^^^^^^ = note: expected signature `fn(&'a X) -> &'a ()` diff --git a/tests/ui/mut/mismatch-trait-mut.e2018.stderr b/tests/ui/mut/mismatch-trait-mut.e2018.stderr index bc9d60e66bc33..0130f2d9833eb 100644 --- a/tests/ui/mut/mismatch-trait-mut.e2018.stderr +++ b/tests/ui/mut/mismatch-trait-mut.e2018.stderr @@ -1,12 +1,14 @@ error[E0053]: method `f` has an incompatible type for trait --> $DIR/mismatch-trait-mut.rs:30:18 | +LL | impl crate::A for X { LL | fn f(_x: &crate::bar::X) {} | ^^^^^^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/mismatch-trait-mut.rs:15:14 | +LL | pub trait A { LL | fn f(_x: &mut bar::X) {} | ^^^^^^^^^^^ = note: expected signature `fn(&mut X)` @@ -19,12 +21,16 @@ LL | fn f(_x: &mut crate::bar::X) {} error[E0053]: method `g` has an incompatible type for trait --> $DIR/mismatch-trait-mut.rs:34:22 | +LL | impl crate::A for X { +... LL | fn g<'a>(_x: &'a crate::bar::X) -> &'a () { &() } | ^^^^^^^^^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/mismatch-trait-mut.rs:17:18 | +LL | pub trait A { +... LL | fn g<'a>(_x: &'a mut bar::X) -> &'a () { &() } | ^^^^^^^^^^^^^^ = note: expected signature `fn(&'a mut X) -> &'a ()` @@ -37,12 +43,16 @@ LL | fn g<'a>(_x: &'a mut crate::bar::X) -> &'a () { &() } error[E0053]: method `f2` has an incompatible type for trait --> $DIR/mismatch-trait-mut.rs:38:19 | +LL | impl crate::A for X { +... LL | fn f2(_x: &mut crate::bar::X) {} | ^^^^^^^^^^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/mismatch-trait-mut.rs:19:15 | +LL | pub trait A { +... LL | fn f2(_x: &bar::X) {} | ^^^^^^^ = note: expected signature `fn(&X)` @@ -56,12 +66,16 @@ LL + fn f2(_x: &crate::bar::X) {} error[E0053]: method `g2` has an incompatible type for trait --> $DIR/mismatch-trait-mut.rs:42:23 | +LL | impl crate::A for X { +... LL | fn g2<'a>(_x: &'a mut crate::bar::X) -> &'a () { &() } | ^^^^^^^^^^^^^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/mismatch-trait-mut.rs:21:19 | +LL | pub trait A { +... LL | fn g2<'a>(_x: &'a bar::X) -> &'a () { &() } | ^^^^^^^^^^ = note: expected signature `fn(&'a X) -> &'a ()` diff --git a/tests/ui/pin-ergonomics/pinned-drop-check.stderr b/tests/ui/pin-ergonomics/pinned-drop-check.stderr index 6087d45dd2900..892413655a229 100644 --- a/tests/ui/pin-ergonomics/pinned-drop-check.stderr +++ b/tests/ui/pin-ergonomics/pinned-drop-check.stderr @@ -113,6 +113,7 @@ LL - #[pin_v2] error[E0053]: method `drop` has an incompatible type for trait --> $DIR/pinned-drop-check.rs:83:17 | +LL | impl Drop for Foo { LL | fn drop(&pin const self) {} | ^^^^^^^^^^^^^^^ expected `&mut drop_pin_const_wrong_type::Foo`, found `Pin<&drop_pin_const_wrong_type::Foo>` | @@ -127,6 +128,7 @@ LL + fn drop(&mut self) {} error[E0053]: method `drop` has an incompatible type for trait --> $DIR/pinned-drop-check.rs:87:17 | +LL | impl Drop for Bar { LL | fn drop(&pin const self) {} | ^^^^^^^^^^^^^^^ expected `&mut drop_pin_const_wrong_type::Bar`, found `Pin<&drop_pin_const_wrong_type::Bar>` | @@ -163,6 +165,7 @@ LL - #[pin_v2] error[E0053]: method `drop` has an incompatible type for trait --> $DIR/pinned-drop-check.rs:99:21 | +LL | impl Drop for Foo { LL | fn drop<'a>(&'a pin mut self) {} | ^^^^^^^^^^^^^^^^ expected `&mut drop_with_lifetime_wrong_type::Foo`, found `Pin<&mut Foo>` | @@ -177,6 +180,7 @@ LL + fn drop<'a>(&mut self) {} error[E0053]: method `drop` has an incompatible type for trait --> $DIR/pinned-drop-check.rs:104:21 | +LL | impl Drop for Bar { LL | fn drop<'a>(&'a pin mut self) {} | ^^^^^^^^^^^^^^^^ expected `&mut drop_with_lifetime_wrong_type::Bar`, found `Pin<&mut Bar>` | @@ -213,6 +217,7 @@ LL - #[pin_v2] error[E0053]: method `drop` has an incompatible type for trait --> $DIR/pinned-drop-check.rs:118:23 | +LL | impl Drop for Foo { LL | fn drop(self: Pin<&mut Self>) {} | ^^^^^^^^^^^^^^ expected `&mut drop_explicit_pin_wrong_type::Foo`, found `Pin<&mut Foo>` | @@ -227,6 +232,7 @@ LL + fn drop(&mut self) {} error[E0053]: method `drop` has an incompatible type for trait --> $DIR/pinned-drop-check.rs:123:23 | +LL | impl Drop for Bar { LL | fn drop(self: Pin<&mut Self>) {} | ^^^^^^^^^^^^^^ expected `&mut drop_explicit_pin_wrong_type::Bar`, found `Pin<&mut Bar>` | @@ -241,6 +247,7 @@ LL + fn drop(&mut self) {} error[E0053]: method `pin_drop` has an incompatible type for trait --> $DIR/pinned-drop-check.rs:135:21 | +LL | impl Drop for Foo { LL | fn pin_drop(&mut self) {} | ^^^^^^^^^ expected `Pin<&mut pin_drop_wrong_type::Foo>`, found `&mut pin_drop_wrong_type::Foo` | @@ -255,6 +262,7 @@ LL + fn pin_drop(self: Pin<&mut pin_drop_wrong_type::Foo>) {} error[E0053]: method `pin_drop` has an incompatible type for trait --> $DIR/pinned-drop-check.rs:139:21 | +LL | impl Drop for Bar { LL | fn pin_drop(&mut self) {} | ^^^^^^^^^ expected `Pin<&mut pin_drop_wrong_type::Bar>`, found `&mut pin_drop_wrong_type::Bar` | diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr index 39b0e5ea18f7d..86634e54aa3e1 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr @@ -10,12 +10,15 @@ LL | fn foo(&self) {} error[E0053]: method `foo` has an incompatible type for trait --> $DIR/trait-impl.rs:13:5 | +LL | impl Foo for Bar { +... LL | fn foo(&self) {} | ^^^^^^^^^^^^^ expected safe fn, found unsafe fn | note: type in trait --> $DIR/trait-impl.rs:4:5 | +LL | trait Foo { LL | fn foo(&self); | ^^^^^^^^^^^^^^ = note: expected signature `fn(&Bar)` diff --git a/tests/ui/splat/splat-invalid-trait-impl.stderr b/tests/ui/splat/splat-invalid-trait-impl.stderr index df414a5e63062..3aafd5e0d5575 100644 --- a/tests/ui/splat/splat-invalid-trait-impl.stderr +++ b/tests/ui/splat/splat-invalid-trait-impl.stderr @@ -1,12 +1,14 @@ error[E0053]: method `method` has an incompatible type for trait --> $DIR/splat-invalid-trait-impl.rs:14:33 | +LL | impl FooTrait for Foo { LL | fn method(#[rustc_splat] _: (u32, f32)) {} | ^^^^^^^^^^ expected `i8`, found `f32` | note: type in trait --> $DIR/splat-invalid-trait-impl.rs:6:33 | +LL | trait FooTrait { LL | fn method(#[rustc_splat] _: (u32, i8)); | ^^^^^^^^^ = note: expected signature `fn(#[rustc_splat] (_, i8))` @@ -20,12 +22,14 @@ LL + fn method(#[rustc_splat] _: (u32, i8)) {} error[E0053]: method `method` has an incompatible type for trait --> $DIR/splat-invalid-trait-impl.rs:19:33 | +LL | impl FooTrait for Foo1 { LL | fn method(#[rustc_splat] _: (f32, i8)) {} | ^^^^^^^^^ expected `u32`, found `f32` | note: type in trait --> $DIR/splat-invalid-trait-impl.rs:6:33 | +LL | trait FooTrait { LL | fn method(#[rustc_splat] _: (u32, i8)); | ^^^^^^^^^ = note: expected signature `fn(#[rustc_splat] (u32, _))` @@ -39,12 +43,14 @@ LL + fn method(#[rustc_splat] _: (u32, i8)) {} error[E0053]: method `method` has an incompatible type for trait --> $DIR/splat-invalid-trait-impl.rs:24:33 | +LL | impl FooTrait for Foo2 { LL | fn method(#[rustc_splat] _: (f32, f64)) {} | ^^^^^^^^^^ expected `u32`, found `f32` | note: type in trait --> $DIR/splat-invalid-trait-impl.rs:6:33 | +LL | trait FooTrait { LL | fn method(#[rustc_splat] _: (u32, i8)); | ^^^^^^^^^ = note: expected signature `fn(#[rustc_splat] (u32, i8))` diff --git a/tests/ui/splat/splat-invalid.stderr b/tests/ui/splat/splat-invalid.stderr index 8681084a3c594..5ef430046ab10 100644 --- a/tests/ui/splat/splat-invalid.stderr +++ b/tests/ui/splat/splat-invalid.stderr @@ -182,12 +182,14 @@ LL | #[rustc_splat] error[E0053]: method `has_splat` has an incompatible type for trait --> $DIR/splat-invalid.rs:59:5 | +LL | impl FooTrait for Foo { LL | fn has_splat(_: ()) {} | ^^^^^^^^^^^^^^^^^^^ expected fn with arg 0 splatted, found fn with no splatted arg | note: type in trait --> $DIR/splat-invalid.rs:51:5 | +LL | trait FooTrait { LL | fn has_splat(#[rustc_splat] _: ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `fn(#[rustc_splat] ())` @@ -196,12 +198,16 @@ LL | fn has_splat(#[rustc_splat] _: ()); error[E0053]: method `no_splat` has an incompatible type for trait --> $DIR/splat-invalid.rs:61:5 | +LL | impl FooTrait for Foo { +... LL | fn no_splat(#[rustc_splat] _: (u32, f64)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected fn with no splatted arg, found fn with arg 0 splatted | note: type in trait --> $DIR/splat-invalid.rs:53:5 | +LL | trait FooTrait { +... LL | fn no_splat(_: (u32, f64)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `fn((_, _))` diff --git a/tests/ui/splat/splat-non-tuple.stderr b/tests/ui/splat/splat-non-tuple.stderr index b92c257b9b021..21129c92ce6ee 100644 --- a/tests/ui/splat/splat-non-tuple.stderr +++ b/tests/ui/splat/splat-non-tuple.stderr @@ -1,12 +1,14 @@ error[E0053]: method `tuple_1` has an incompatible type for trait --> $DIR/splat-non-tuple.rs:39:5 | +LL | impl FooTrait for Foo { LL | fn tuple_1(_: (u32,)) {} | ^^^^^^^^^^^^^^^^^^^^^ expected fn with arg 0 splatted, found fn with no splatted arg | note: type in trait --> $DIR/splat-non-tuple.rs:17:5 | +LL | trait FooTrait { LL | fn tuple_1(#[rustc_splat] _: (u32,)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `fn(#[rustc_splat] (_,))` diff --git a/tests/ui/target-feature/invalid-attribute.stderr b/tests/ui/target-feature/invalid-attribute.stderr index a5c6e21ee73e0..3feef4b2fa42b 100644 --- a/tests/ui/target-feature/invalid-attribute.stderr +++ b/tests/ui/target-feature/invalid-attribute.stderr @@ -219,12 +219,15 @@ LL | fn foo() {} error[E0053]: method `foo` has an incompatible type for trait --> $DIR/invalid-attribute.rs:92:5 | +LL | impl Quux for Foo { +... LL | fn foo() {} | ^^^^^^^^ expected safe fn, found unsafe fn | note: type in trait --> $DIR/invalid-attribute.rs:84:5 | +LL | trait Quux { LL | fn foo(); | ^^^^^^^^^ = note: expected signature `fn()` diff --git a/tests/ui/traits/const-traits/eval-bad-signature.stderr b/tests/ui/traits/const-traits/eval-bad-signature.stderr index db5f434ee0e98..1230515c79f5c 100644 --- a/tests/ui/traits/const-traits/eval-bad-signature.stderr +++ b/tests/ui/traits/const-traits/eval-bad-signature.stderr @@ -1,12 +1,14 @@ error[E0053]: method `value` has an incompatible type for trait --> $DIR/eval-bad-signature.rs:16:19 | +LL | const impl Value for FortyTwo { LL | fn value() -> i64 { | ^^^ expected `u32`, found `i64` | note: type in trait --> $DIR/eval-bad-signature.rs:6:19 | +LL | const trait Value { LL | fn value() -> u32; | ^^^ = note: expected signature `fn() -> u32` diff --git a/tests/ui/traits/error-reporting/incompatible-method-multiline.stderr b/tests/ui/traits/error-reporting/incompatible-method-multiline.stderr index 4f797dedfa846..ee9a29aa84fd6 100644 --- a/tests/ui/traits/error-reporting/incompatible-method-multiline.stderr +++ b/tests/ui/traits/error-reporting/incompatible-method-multiline.stderr @@ -1,6 +1,8 @@ error[E0053]: method `next` has an incompatible type for trait --> $DIR/incompatible-method-multiline.rs:8:27 | +LL | impl Iterator for S { +LL | type Item = i32; LL | fn next(&mut self) -> Result { Ok(7) } | ^^^^^^^^^^^^^^^^ expected `Option`, found `Result` | diff --git a/tests/ui/traits/impl-method-mismatch.stderr b/tests/ui/traits/impl-method-mismatch.stderr index ca8b35e06c78f..9675edd3d84cb 100644 --- a/tests/ui/traits/impl-method-mismatch.stderr +++ b/tests/ui/traits/impl-method-mismatch.stderr @@ -1,12 +1,15 @@ error[E0053]: method `jumbo` has an incompatible type for trait --> $DIR/impl-method-mismatch.rs:9:5 | +LL | impl Mumbo for usize { +LL | // Cannot have a larger effect than the trait: LL | unsafe fn jumbo(&self, x: &usize) { *self + *x; } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected safe fn, found unsafe fn | note: type in trait --> $DIR/impl-method-mismatch.rs:4:5 | +LL | trait Mumbo { LL | fn jumbo(&self, x: &usize) -> usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `fn(&_, &_) -> usize` diff --git a/tests/ui/traits/issue-35869.stderr b/tests/ui/traits/issue-35869.stderr index 98cbd4650007b..17adad92611cc 100644 --- a/tests/ui/traits/issue-35869.stderr +++ b/tests/ui/traits/issue-35869.stderr @@ -1,12 +1,14 @@ error[E0053]: method `foo` has an incompatible type for trait --> $DIR/issue-35869.rs:11:15 | +LL | impl Foo for Bar { LL | fn foo(_: fn(u16) -> ()) {} | ^^^^^^^^^^^^^ expected `u8`, found `u16` | note: type in trait --> $DIR/issue-35869.rs:2:15 | +LL | trait Foo { LL | fn foo(_: fn(u8) -> ()); | ^^^^^^^^^^^^ = note: expected signature `fn(fn(u8))` @@ -20,12 +22,16 @@ LL + fn foo(_: fn(u8)) {} error[E0053]: method `bar` has an incompatible type for trait --> $DIR/issue-35869.rs:13:15 | +LL | impl Foo for Bar { +... LL | fn bar(_: Option) {} | ^^^^^^^^^^^ expected `u8`, found `u16` | note: type in trait --> $DIR/issue-35869.rs:3:15 | +LL | trait Foo { +LL | fn foo(_: fn(u8) -> ()); LL | fn bar(_: Option); | ^^^^^^^^^^ = note: expected signature `fn(Option)` @@ -39,12 +45,16 @@ LL + fn bar(_: std::option::Option) {} error[E0053]: method `baz` has an incompatible type for trait --> $DIR/issue-35869.rs:15:15 | +LL | impl Foo for Bar { +... LL | fn baz(_: (u16, u16)) {} | ^^^^^^^^^^ expected `u8`, found `u16` | note: type in trait --> $DIR/issue-35869.rs:4:15 | +LL | trait Foo { +... LL | fn baz(_: (u8, u16)); | ^^^^^^^^^ = note: expected signature `fn((u8, _))` @@ -58,12 +68,16 @@ LL + fn baz(_: (u8, u16)) {} error[E0053]: method `qux` has an incompatible type for trait --> $DIR/issue-35869.rs:17:17 | +LL | impl Foo for Bar { +... LL | fn qux() -> u16 { 5u16 } | ^^^ expected `u8`, found `u16` | note: type in trait --> $DIR/issue-35869.rs:5:17 | +LL | trait Foo { +... LL | fn qux() -> u8; | ^^ = note: expected signature `fn() -> u8` diff --git a/tests/ui/traits/wrong-mul-method-signature.stderr b/tests/ui/traits/wrong-mul-method-signature.stderr index bdfc4320631b0..ea07a07e09de9 100644 --- a/tests/ui/traits/wrong-mul-method-signature.stderr +++ b/tests/ui/traits/wrong-mul-method-signature.stderr @@ -1,6 +1,8 @@ error[E0053]: method `mul` has an incompatible type for trait --> $DIR/wrong-mul-method-signature.rs:16:21 | +LL | impl Mul for Vec1 { +... LL | fn mul(self, s: &f64) -> Vec1 { | ^^^^ expected `f64`, found `&f64` | @@ -15,6 +17,8 @@ LL + fn mul(self, s: f64) -> Vec1 { error[E0053]: method `mul` has an incompatible type for trait --> $DIR/wrong-mul-method-signature.rs:33:21 | +LL | impl Mul for Vec2 { +... LL | fn mul(self, s: f64) -> Vec2 { | ^^^ expected `Vec2`, found `f64` | @@ -29,6 +33,8 @@ LL + fn mul(self, s: crate::Vec2) -> Vec2 { error[E0053]: method `mul` has an incompatible type for trait --> $DIR/wrong-mul-method-signature.rs:52:29 | +LL | impl Mul for Vec3 { +... LL | fn mul(self, s: f64) -> f64 { | ^^^ expected `i32`, found `f64` | diff --git a/tests/ui/type-alias-impl-trait/unnameable_type.stderr b/tests/ui/type-alias-impl-trait/unnameable_type.stderr index 48fe7ba275fce..ca55fc350fb3d 100644 --- a/tests/ui/type-alias-impl-trait/unnameable_type.stderr +++ b/tests/ui/type-alias-impl-trait/unnameable_type.stderr @@ -3,13 +3,15 @@ error[E0053]: method `dont_define_this` has an incompatible type for trait | LL | type MyPrivate = impl Sized; | ---------- the found opaque type -... +LL | impl Trait for u32 { +LL | #[define_opaque(MyPrivate)] LL | fn dont_define_this(private: MyPrivate) { | ^^^^^^^^^ expected `Private`, found opaque type | note: type in trait --> $DIR/unnameable_type.rs:10:39 | +LL | pub trait Trait { LL | fn dont_define_this(_private: Private) {} | ^^^^^^^ = note: expected signature `fn(Private)` diff --git a/tests/ui/typeck/mismatched-map-under-self.stderr b/tests/ui/typeck/mismatched-map-under-self.stderr index 541de25749e38..8e5bae258f976 100644 --- a/tests/ui/typeck/mismatched-map-under-self.stderr +++ b/tests/ui/typeck/mismatched-map-under-self.stderr @@ -1,12 +1,16 @@ error[E0053]: method `values` has an incompatible type for trait --> $DIR/mismatched-map-under-self.rs:10:15 | +LL | impl Insertable for Option { +... LL | fn values(self) -> Self::Values { | ^^^^ expected `&Option`, found `Option` | note: type in trait --> $DIR/mismatched-map-under-self.rs:4:15 | +LL | pub trait Insertable { +... LL | fn values(&self) -> Self::Values; | ^^^^^ = note: expected signature `fn(&Option<_>)` diff --git a/tests/ui/ufcs/ufcs-explicit-self-bad.stderr b/tests/ui/ufcs/ufcs-explicit-self-bad.stderr index 7b5f7cd9f7033..e0d6d88fca075 100644 --- a/tests/ui/ufcs/ufcs-explicit-self-bad.stderr +++ b/tests/ui/ufcs/ufcs-explicit-self-bad.stderr @@ -1,12 +1,16 @@ error[E0053]: method `dummy2` has an incompatible type for trait --> $DIR/ufcs-explicit-self-bad.rs:37:21 | +LL | impl<'a, T> SomeTrait for &'a Bar { +LL | fn dummy1(self: &&'a Bar) { } LL | fn dummy2(self: &Bar) {} | ^^^^^^^ expected `&'a Bar`, found `Bar` | note: type in trait --> $DIR/ufcs-explicit-self-bad.rs:31:15 | +LL | trait SomeTrait { +LL | fn dummy1(&self); LL | fn dummy2(&self); | ^^^^^ = note: expected signature `fn(&&'a Bar<_>)` diff --git a/tests/ui/unsafe/unsafe-trait-impl.stderr b/tests/ui/unsafe/unsafe-trait-impl.stderr index 8febbb736634d..250d1f1dcbcf7 100644 --- a/tests/ui/unsafe/unsafe-trait-impl.stderr +++ b/tests/ui/unsafe/unsafe-trait-impl.stderr @@ -1,12 +1,14 @@ error[E0053]: method `len` has an incompatible type for trait --> $DIR/unsafe-trait-impl.rs:10:5 | +LL | impl Foo for u32 { LL | fn len(&self) -> u32 { *self } | ^^^^^^^^^^^^^^^^^^^^ expected unsafe fn, found safe fn | note: type in trait --> $DIR/unsafe-trait-impl.rs:6:5 | +LL | trait Foo { LL | unsafe fn len(&self) -> u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `unsafe fn(&_) -> _`