diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index 93d888d17dc51..414f8dd58d439 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -662,7 +662,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> { /// --> $DIR/lifetime-bound-will-change-warning.rs:44:5 /// | /// LL | fn test2<'a>(x: &'a Box) { - /// | - `x` is a reference that is only valid in the function body + /// | - `x` is only valid in the function body /// LL | // but ref_obj will not, so warn. /// LL | ref_obj(x) /// | ^^^^^^^^^^ `x` escapes the function body here @@ -714,9 +714,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> { if let Some((Some(fr_name), fr_span)) = fr_name_and_span { diag.span_label( fr_span, - format!( - "`{fr_name}` is a reference that is only valid in the {escapes_from} body", - ), + format!("`{fr_name}` is only valid in the {escapes_from} body"), ); diag.span_label(*span, format!("`{fr_name}` escapes the {escapes_from} body here")); diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index c71e83d8f99bd..c2fca69c78821 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -351,7 +351,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { } } - emit_va_arg(self, args[0], result_layout.ty) + emit_va_arg(self, args[0], result_layout) } sym::volatile_load | sym::unaligned_volatile_load => { diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 5324ec240b0ab..718a500a9abec 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -432,6 +432,8 @@ fn update_target_reliable_float_cfg(target: &Target, cfg: &mut TargetConfig) { // - with +vsx // - without +vsx (Arch::PowerPC, _) => false, + // AIX does not support f128. + (Arch::PowerPC64, Os::Aix) => false, // ABI bugs on BE without +vsx . (Arch::PowerPC64, _) => cfg.internal_target_features.contains(&sym::vsx), // ABI unsupported (fixed in llvm22) diff --git a/compiler/rustc_codegen_llvm/src/va_arg.rs b/compiler/rustc_codegen_llvm/src/va_arg.rs index ca57bee3e6271..b21ce3f2be8e4 100644 --- a/compiler/rustc_codegen_llvm/src/va_arg.rs +++ b/compiler/rustc_codegen_llvm/src/va_arg.rs @@ -150,7 +150,7 @@ enum ForceRightAdjust { fn emit_ptr_va_arg<'ll, 'tcx>( bx: &mut Builder<'_, 'll, 'tcx>, list: OperandRef<'tcx, &'ll Value>, - target_ty: Ty<'tcx>, + layout: TyAndLayout<'tcx>, pass_mode: PassMode, slot_size: SlotSize, allow_higher_align: AllowHigherAlign, @@ -161,10 +161,9 @@ fn emit_ptr_va_arg<'ll, 'tcx>( let force_right_adjust = matches!(force_right_adjust, ForceRightAdjust::Yes); let slot_size = Align::from_bytes(slot_size as u64).unwrap(); - let layout = bx.cx.layout_of(target_ty); let (llty, size, align) = if indirect { ( - bx.cx.layout_of(Ty::new_imm_ptr(bx.cx.tcx, target_ty)).llvm_type(bx.cx), + 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, ) @@ -191,7 +190,7 @@ fn emit_ptr_va_arg<'ll, 'tcx>( fn emit_aapcs_va_arg<'ll, 'tcx>( bx: &mut Builder<'_, 'll, 'tcx>, list: OperandRef<'tcx, &'ll Value>, - target_ty: Ty<'tcx>, + layout: TyAndLayout<'tcx>, ) -> &'ll Value { let dl = bx.cx.data_layout(); @@ -218,8 +217,6 @@ fn emit_aapcs_va_arg<'ll, 'tcx>( let gr_offs = bx.inbounds_ptradd(va_list_addr, bx.cx.const_usize(3 * ptr_offset)); let vr_offs = bx.inbounds_ptradd(va_list_addr, bx.cx.const_usize(3 * ptr_offset + i32_offset)); - let layout = bx.cx.layout_of(target_ty); - let maybe_reg = bx.append_sibling_block("va_arg.maybe_reg"); let in_reg = bx.append_sibling_block("va_arg.in_reg"); let on_stack = bx.append_sibling_block("va_arg.on_stack"); @@ -227,7 +224,7 @@ fn emit_aapcs_va_arg<'ll, 'tcx>( let zero = bx.const_i32(0); let offset_align = Align::from_bytes(4).unwrap(); - let gr_type = target_ty.is_any_ptr() || target_ty.is_integral(); + let gr_type = layout.ty.is_any_ptr() || layout.ty.is_integral(); let (reg_off, reg_top, slot_size) = if gr_type { let nreg = layout.size.bytes().div_ceil(8); (gr_offs, gr_top, nreg * 8) @@ -279,7 +276,7 @@ fn emit_aapcs_va_arg<'ll, 'tcx>( let stack_value = emit_ptr_va_arg( bx, list, - target_ty, + layout, PassMode::Direct, SlotSize::Bytes8, AllowHigherAlign::Yes, @@ -297,7 +294,7 @@ fn emit_aapcs_va_arg<'ll, 'tcx>( fn emit_powerpc_va_arg<'ll, 'tcx>( bx: &mut Builder<'_, 'll, 'tcx>, list: OperandRef<'tcx, &'ll Value>, - target_ty: Ty<'tcx>, + layout: TyAndLayout<'tcx>, ) -> &'ll Value { let dl = bx.cx.data_layout(); @@ -311,15 +308,7 @@ fn emit_powerpc_va_arg<'ll, 'tcx>( let va_list_addr = list.immediate(); // Peel off any newtype wrappers. - let layout = { - let mut layout = bx.cx.layout_of(target_ty); - - while let Some((_, inner)) = layout.non_1zst_field(bx.cx) { - layout = inner; - } - - layout - }; + let layout = layout.peel_transparent_wrappers(bx.cx); // Rust does not currently support any powerpc softfloat targets. let target = &bx.cx.tcx.sess.target; @@ -435,7 +424,7 @@ fn emit_powerpc_va_arg<'ll, 'tcx>( fn emit_s390x_va_arg<'ll, 'tcx>( bx: &mut Builder<'_, 'll, 'tcx>, list: OperandRef<'tcx, &'ll Value>, - target_ty: Ty<'tcx>, + layout: TyAndLayout<'tcx>, ) -> &'ll Value { let dl = bx.cx.data_layout(); @@ -460,15 +449,13 @@ fn emit_s390x_va_arg<'ll, 'tcx>( let reg_save_area = bx.inbounds_ptradd(va_list_addr, bx.cx.const_usize(2 * i64_offset + ptr_offset)); - let layout = bx.cx.layout_of(target_ty); - 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; // FIXME: vector ABI not yet supported. - let target_ty_size = bx.cx.size_of(target_ty).bytes(); + let target_ty_size = layout.size.bytes(); let indirect: bool = target_ty_size > 8 || !target_ty_size.is_power_of_two(); let unpadded_size = if indirect { 8 } else { target_ty_size }; let padded_size = 8; @@ -535,7 +522,7 @@ fn emit_s390x_va_arg<'ll, 'tcx>( fn emit_x86_64_sysv64_va_arg<'ll, 'tcx>( bx: &mut Builder<'_, 'll, 'tcx>, list: OperandRef<'tcx, &'ll Value>, - target_ty: Ty<'tcx>, + layout: TyAndLayout<'tcx>, ) -> &'ll Value { let dl = bx.cx.data_layout(); @@ -570,15 +557,7 @@ fn emit_x86_64_sysv64_va_arg<'ll, 'tcx>( // #[repr(C)] // struct Foo([Empty; 8], i32); // ``` - let layout = { - let mut layout = bx.cx.layout_of(target_ty); - - while let Some((_, inner)) = layout.non_1zst_field(bx.cx) { - layout = inner; - } - - layout - }; + let layout = layout.peel_transparent_wrappers(bx.cx); // AMD64-ABI 3.5.7p5: Step 1. Determine whether type may be passed // in the registers. If not go to step 7. @@ -847,7 +826,7 @@ fn x86_64_sysv64_va_arg_from_memory<'ll, 'tcx>( fn emit_hexagon_va_arg_musl<'ll, 'tcx>( bx: &mut Builder<'_, 'll, 'tcx>, list: OperandRef<'tcx, &'ll Value>, - target_ty: Ty<'tcx>, + layout: TyAndLayout<'tcx>, ) -> &'ll Value { // Implementation of va_arg for Hexagon musl target. // Based on LLVM's HexagonBuiltinVaList implementation. @@ -861,7 +840,6 @@ 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 layout = bx.cx.layout_of(target_ty); let ptr_align_abi = bx.tcx().data_layout.pointer_align().abi; let ptr_size = bx.tcx().data_layout.pointer_size().bytes(); @@ -881,7 +859,7 @@ fn emit_hexagon_va_arg_musl<'ll, 'tcx>( // Align current pointer based on argument type size (following LLVM's implementation) // Arguments <= 32 bits (4 bytes) use 4-byte alignment, > 32 bits use 8-byte alignment - let type_size_bits = bx.cx.size_of(target_ty).bits(); + let type_size_bits = layout.size.bits(); let arg_align = if type_size_bits > 32 { Align::from_bytes(8).unwrap() } else { @@ -931,14 +909,13 @@ fn emit_hexagon_va_arg_musl<'ll, 'tcx>( fn emit_hexagon_va_arg_bare_metal<'ll, 'tcx>( bx: &mut Builder<'_, 'll, 'tcx>, list: OperandRef<'tcx, &'ll Value>, - target_ty: Ty<'tcx>, + layout: TyAndLayout<'tcx>, ) -> &'ll Value { // Implementation of va_arg for Hexagon bare-metal (non-musl) targets. // Based on LLVM's EmitVAArgForHexagon implementation. // // va_list is a simple pointer (char *) let va_list_addr = list.immediate(); - let layout = bx.cx.layout_of(target_ty); let ptr_align_abi = bx.tcx().data_layout.pointer_align().abi; // Load current pointer from va_list @@ -969,7 +946,7 @@ fn emit_hexagon_va_arg_bare_metal<'ll, 'tcx>( fn emit_xtensa_va_arg<'ll, 'tcx>( bx: &mut Builder<'_, 'll, 'tcx>, list: OperandRef<'tcx, &'ll Value>, - target_ty: Ty<'tcx>, + layout: TyAndLayout<'tcx>, ) -> &'ll Value { // Implementation of va_arg for Xtensa. There doesn't seem to be an authoritative source for // this, other than "what GCC does". @@ -989,7 +966,6 @@ fn emit_xtensa_va_arg<'ll, 'tcx>( // primitive value and va_ndx = 20, we instead bump the offset and read everything from va_stk. let va_list_addr = list.immediate(); // FIXME: handle multi-field structs that split across regsave/stack? - let layout = bx.cx.layout_of(target_ty); 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"); @@ -1071,14 +1047,11 @@ fn emit_xtensa_va_arg<'ll, 'tcx>( pub(super) fn emit_va_arg<'ll, 'tcx>( bx: &mut Builder<'_, 'll, 'tcx>, addr: OperandRef<'tcx, &'ll Value>, - target_ty: Ty<'tcx>, + layout: TyAndLayout<'tcx>, ) -> &'ll Value { - let layout = bx.cx.layout_of(target_ty); - let target_ty_size = layout.layout.size().bytes(); - // Some ABIs have special behavior for zero-sized types. currently `VaArgSafe` is not // implemented for any zero-sized types, so this assert should always hold. - assert!(!bx.layout_of(target_ty).is_zst()); + assert!(!layout.is_zst()); let target = &bx.cx.tcx.sess.target; let stability = target.supports_c_variadic_definitions(); @@ -1087,7 +1060,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( Arch::X86 => emit_ptr_va_arg( bx, addr, - target_ty, + layout, PassMode::Direct, SlotSize::Bytes4, if target.is_like_windows { AllowHigherAlign::No } else { AllowHigherAlign::Yes }, @@ -1096,10 +1069,10 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( Arch::Arm64EC => emit_ptr_va_arg( bx, addr, - target_ty, + layout, // MS x64 ABI requirement: "Any argument that doesn't fit in 8 bytes, or is // not 1, 2, 4, or 8 bytes, must be passed by reference." - if target_ty_size > 8 || !target_ty_size.is_power_of_two() { + if layout.size.bytes() > 8 || !layout.size.bytes().is_power_of_two() { PassMode::Indirect } else { PassMode::Direct @@ -1111,35 +1084,35 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( Arch::AArch64 if target.is_like_windows || target.is_like_darwin => emit_ptr_va_arg( bx, addr, - target_ty, + layout, PassMode::Direct, SlotSize::Bytes8, AllowHigherAlign::Yes, ForceRightAdjust::No, ), - Arch::AArch64 => emit_aapcs_va_arg(bx, addr, target_ty), + Arch::AArch64 => emit_aapcs_va_arg(bx, addr, layout), Arch::Arm => { // Types wider than 16 bytes are not currently supported. Clang has special logic for // such types, but `VaArgSafe` is not implemented for any type that is this large on // arm (i.e. 32-bit) targets. - assert!(bx.cx.size_of(target_ty).bytes() <= 16); + assert!(layout.size.bytes() <= 16); emit_ptr_va_arg( bx, addr, - target_ty, + layout, PassMode::Direct, SlotSize::Bytes4, AllowHigherAlign::Yes, ForceRightAdjust::No, ) } - Arch::S390x => emit_s390x_va_arg(bx, addr, target_ty), - Arch::PowerPC => emit_powerpc_va_arg(bx, addr, target_ty), + Arch::S390x => emit_s390x_va_arg(bx, addr, layout), + Arch::PowerPC => emit_powerpc_va_arg(bx, addr, layout), Arch::PowerPC64 => emit_ptr_va_arg( bx, addr, - target_ty, + layout, PassMode::Direct, SlotSize::Bytes8, AllowHigherAlign::Yes, @@ -1159,8 +1132,8 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( Arch::RiscV32 | Arch::LoongArch32 => emit_ptr_va_arg( bx, addr, - target_ty, - if target_ty_size > 2 * 4 { PassMode::Indirect } else { PassMode::Direct }, + layout, + if layout.size.bytes() > 2 * 4 { PassMode::Indirect } else { PassMode::Direct }, SlotSize::Bytes4, AllowHigherAlign::Yes, ForceRightAdjust::No, @@ -1168,8 +1141,8 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( Arch::RiscV64 | Arch::LoongArch64 => emit_ptr_va_arg( bx, addr, - target_ty, - if target_ty_size > 2 * 8 { PassMode::Indirect } else { PassMode::Direct }, + layout, + if layout.size.bytes() > 2 * 8 { PassMode::Indirect } else { PassMode::Direct }, SlotSize::Bytes8, AllowHigherAlign::Yes, ForceRightAdjust::No, @@ -1177,7 +1150,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( Arch::AmdGpu => emit_ptr_va_arg( bx, addr, - target_ty, + layout, PassMode::Direct, SlotSize::Bytes4, AllowHigherAlign::No, @@ -1186,7 +1159,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( Arch::Nvptx64 => emit_ptr_va_arg( bx, addr, - target_ty, + layout, PassMode::Direct, SlotSize::Bytes1, AllowHigherAlign::Yes, @@ -1195,7 +1168,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( Arch::Wasm32 | Arch::Wasm64 => emit_ptr_va_arg( bx, addr, - target_ty, + layout, if layout.is_aggregate() || layout.is_zst() || layout.is_1zst() { PassMode::Indirect } else { @@ -1208,7 +1181,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( Arch::CSky => emit_ptr_va_arg( bx, addr, - target_ty, + layout, PassMode::Direct, SlotSize::Bytes4, AllowHigherAlign::Yes, @@ -1218,8 +1191,8 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( Arch::X86_64 if target.is_like_windows => emit_ptr_va_arg( bx, addr, - target_ty, - if target_ty_size > 8 || !target_ty_size.is_power_of_two() { + layout, + if layout.size.bytes() > 8 || !layout.size.bytes().is_power_of_two() { PassMode::Indirect } else { PassMode::Direct @@ -1229,17 +1202,17 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( ForceRightAdjust::No, ), // This includes `target.is_like_darwin`, which on x86_64 targets is like sysv64. - Arch::X86_64 => emit_x86_64_sysv64_va_arg(bx, addr, target_ty), - Arch::Xtensa => emit_xtensa_va_arg(bx, addr, target_ty), + Arch::X86_64 => emit_x86_64_sysv64_va_arg(bx, addr, layout), + Arch::Xtensa => emit_xtensa_va_arg(bx, addr, layout), Arch::Hexagon => match target.env { - Env::Musl => emit_hexagon_va_arg_musl(bx, addr, target_ty), - _ => emit_hexagon_va_arg_bare_metal(bx, addr, target_ty), + Env::Musl => emit_hexagon_va_arg_musl(bx, addr, layout), + _ => emit_hexagon_va_arg_bare_metal(bx, addr, layout), }, Arch::Sparc64 => emit_ptr_va_arg( bx, addr, - target_ty, - if target_ty_size > 2 * 8 { PassMode::Indirect } else { PassMode::Direct }, + layout, + if layout.size.bytes() > 2 * 8 { PassMode::Indirect } else { PassMode::Direct }, SlotSize::Bytes8, AllowHigherAlign::Yes, // sparc64 is a big-endian target and stores variable arguments right-adjusted. @@ -1260,7 +1233,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( emit_ptr_va_arg( bx, addr, - target_ty, + layout, pass_mode, SlotSize::Bytes4, AllowHigherAlign::No, @@ -1270,7 +1243,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( Arch::Mips | Arch::Mips32r6 | Arch::Mips64 | Arch::Mips64r6 => emit_ptr_va_arg( bx, addr, - target_ty, + layout, PassMode::Direct, match &target.llvm_abiname { LlvmAbi::N32 | LlvmAbi::N64 => SlotSize::Bytes8, @@ -1294,7 +1267,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>( std::assert_matches!(stability, CVariadicStatus::Unstable { .. }); // Clang uses the LLVM implementation for these architectures. - bx.va_arg(addr.immediate(), bx.cx.layout_of(target_ty).llvm_type(bx.cx)) + bx.va_arg(addr.immediate(), layout.llvm_type(bx.cx)) } Arch::Other(ref arch) => { diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs index 4a35bcb5ef28f..715e7065799b8 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs @@ -97,12 +97,24 @@ fn generic_arg_mismatch_err( GenericArg::Type(hir::Ty { kind: hir::TyKind::Array(_, len), .. }), GenericParamDefKind::Const { .. }, ) if tcx.type_of(param.def_id).skip_binder() == tcx.types.usize => { + err.span_label(arg.span(), "array type provided where a `usize` was expected"); let snippet = sess.source_map().span_to_snippet(tcx.hir_span(len.hir_id)); if let Ok(snippet) = snippet { - err.span_suggestion( + let sugg = if let hir::ConstArgKind::Anon(hir::AnonConst { body, .. }) = len.kind + && let hir::ExprKind::Lit(..) = tcx.hir_body(*body).value.kind + { + // We don't need to surround literals in braces when used as consts + snippet + } else if let hir::ConstArgKind::Literal { .. } = len.kind { + // We don't need to surround literals in braces when used as consts + snippet + } else { + format!("{{ {snippet} }}") + }; + err.span_suggestion_verbose( arg.span(), - "array type provided where a `usize` was expected, try", - format!("{{ {snippet} }}"), + format!("you might have meant to use the array's length's value"), + sugg, Applicability::MaybeIncorrect, ); } diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index a017b0dfcb507..85d03108f207f 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -1230,7 +1230,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); if let Some(span) = and_pat_span { - err.span_suggestion( + err.span_suggestion_short( span, "replace this `&` with `&mut`", "&mut ", diff --git a/compiler/rustc_lint/src/diagnostics.rs b/compiler/rustc_lint/src/diagnostics.rs index d96cadaca87eb..fcfb05480d6df 100644 --- a/compiler/rustc_lint/src/diagnostics.rs +++ b/compiler/rustc_lint/src/diagnostics.rs @@ -1912,7 +1912,7 @@ impl<'a> Diagnostic<'a, ()> for NonLocalDefinitionsDiag { if let Some(const_anon) = const_anon { diag.note(msg!("items in an anonymous const item (`const _: () = {\"{\"} ... {\"}\"}`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint")); if let Some(const_anon) = const_anon { - diag.span_suggestion( + diag.span_suggestion_verbose( const_anon, msg!("use a const-anon item to suppress this lint"), "_", diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 4a6846d09a8c4..5befb5918627e 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -1511,7 +1511,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { .. })) = source { - err.span_suggestion( + err.span_suggestion_verbose( span, "use the similarly named label", label_ident.name, @@ -1527,9 +1527,9 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { self.suggest_ident_hidden_by_hygiene(err, path, span); // cannot find type in this scope if let Some(correct) = Self::likely_rust_type(path) { - err.span_suggestion( + err.span_suggestion_verbose( span, - "perhaps you intended to use this type", + format!("you might have intended to use the `{correct}` primitive type"), correct, Applicability::MaybeIncorrect, ); diff --git a/compiler/rustc_span/src/macros.rs b/compiler/rustc_span/src/macros.rs index db8b7ebbfa11f..58db6ef66f43b 100644 --- a/compiler/rustc_span/src/macros.rs +++ b/compiler/rustc_span/src/macros.rs @@ -25,7 +25,9 @@ pub macro bug { bug!("impossible case reached") ), ($($arg:tt)+) => ( - bug_impl(None, std::format_args!($($arg)+), Location::caller()) + // Use the full path of `bug_impl` to make sure rust-analyzer can resolve it, + // to avoid bogus type errors about `()` versus `!`. + $crate::macros::bug_impl(None, std::format_args!($($arg)+), Location::caller()) ), } @@ -39,7 +41,9 @@ pub macro bug { /// /// [`DiagCtxtHandle::span_delayed_bug`]: ../../rustc_errors/struct.DiagCtxtHandle.html#method.span_delayed_bug pub macro span_bug($span:expr, $($arg:tt)+){ - bug_impl(Some($span), std::format_args!($($arg)+), Location::caller()) + // Use the full path of `bug_impl` to make sure rust-analyzer can resolve it, + // to avoid bogus type errors about `()` versus `!`. + $crate::macros::bug_impl(Some($span), std::format_args!($($arg)+), Location::caller()) } #[cold] diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index fffe80be255ce..25281ac7b8f1c 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -4449,11 +4449,27 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { format!("required because it appears within the type `{ty_str}`") }; match *ty.kind() { - ty::Adt(def, _) => { + ty::Adt(def, args) => { let msg = msg(); match tcx.opt_item_ident(def.did()) { Some(ident) => { - err.span_note(ident.span, msg); + let mut spans = MultiSpan::from(ident.span); + if def.did().is_local() + && let Some(pred) = predicate.as_trait_clause() + { + let field_ty = self.deeply_resolve_ignoring_regions( + pred.skip_binder().self_ty(), + ); + for field in def.all_fields() { + if field.ty(tcx, args).skip_norm_wip() == field_ty { + spans.push_span_label( + tcx.def_span(field.did), + "required by this field", + ); + } + } + } + err.span_note(spans, msg); } None => { err.note(msg); diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index a57f3d58e3998..214c12686c204 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -886,7 +886,8 @@ const impl AsMut for str { /// } /// ``` /// -/// Note: since CURRENT_RUSTC_VERSION this is an alias to `!`. If targeting that or future versions, -/// prefer using the never type directly. +/// Note: Since [`!`] (the "never" type) was stabilized in Rust CURRENT_RUSTC_VERSION, it is +/// preferred to use `!` directly unless targeting older Rust versions. `Infallible` may be +/// deprecated in a future Rust version. #[stable(feature = "convert_infallible", since = "1.34.0")] pub type Infallible = !; diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index ab2bbb8ab4449..ecc8b66ec5785 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -154,8 +154,20 @@ pub const unsafe fn atomic_cxchgweak< /// Loads the current value of the pointer. /// `T` must be an integer or pointer type. /// +/// # Safety +/// +/// * If `VOLATILE` is `true`, this is equivalent to [Atomic::load_volatile]. +/// Refer to the documentation of that method for safety requirements. +/// +/// * If `VOLATILE` is `false`, this is equivalent to [Atomic::from_ptr] followed +/// by [Atomic::load]. Refer to the documentation of [Atomic::from_ptr] for safety requirements. +/// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `load` method. For example, [`AtomicBool::load`]. +/// +/// [Atomic::load_volatile]: AtomicI32::load_volatile +/// [Atomic::from_ptr]: AtomicI32::from_ptr +/// [Atomic::load]: AtomicI32::load #[rustc_intrinsic] #[rustc_nounwind] pub const unsafe fn atomic_load( @@ -165,8 +177,20 @@ pub const unsafe fn atomic_load( diff --git a/library/std/src/os/unix/net/addr.rs b/library/std/src/os/unix/net/addr.rs index 3daddc2d34323..dd6e4a690e326 100644 --- a/library/std/src/os/unix/net/addr.rs +++ b/library/std/src/os/unix/net/addr.rs @@ -123,6 +123,8 @@ impl SocketAddr { .map_or(len, |new_len| (new_len + SUN_PATH_OFFSET) as libc::socklen_t); } + len = len.min(size_of::() as libc::socklen_t); + if len == 0 { // When there is a datagram from unnamed unix socket // linux returns zero bytes of address diff --git a/library/std/src/os/unix/net/tests.rs b/library/std/src/os/unix/net/tests.rs index 9c3119e787b33..4014767461389 100644 --- a/library/std/src/os/unix/net/tests.rs +++ b/library/std/src/os/unix/net/tests.rs @@ -52,6 +52,25 @@ fn sock_addr_without_trailing_nul() { assert_eq!(address.as_pathname(), Some(Path::new("/path/to/socket"))); } +#[test] +#[cfg(any(target_os = "android", target_os = "linux"))] +fn sock_addr_pathname_fills_sun_path() { + use crate::ffi::OsStr; + use crate::os::unix::ffi::OsStrExt; + + let mut addr: libc::sockaddr_un = unsafe { crate::mem::zeroed() }; + addr.sun_family = libc::AF_UNIX as libc::sa_family_t; + let mut path = vec![b'a'; addr.sun_path.len()]; + path[0] = b'/'; + for (dst, &src) in addr.sun_path.iter_mut().zip(&path) { + *dst = src as _; + } + let offset = crate::mem::offset_of!(libc::sockaddr_un, sun_path); + + let address = or_panic!(SocketAddr::from_parts(addr, (offset + path.len() + 1) as _)); + assert_eq!(address.as_pathname(), Some(Path::new(OsStr::from_bytes(&path)))); +} + #[test] #[cfg_attr(target_os = "android", ignore)] // Android SELinux rules prevent creating Unix sockets #[cfg_attr(target_os = "vxworks", ignore = "Unix sockets are not implemented in VxWorks")] diff --git a/src/tools/clippy/tests/ui/crashes/ice-6256.stderr b/src/tools/clippy/tests/ui/crashes/ice-6256.stderr index 922772a6147bc..4cb83e24e7a05 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-6256.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-6256.stderr @@ -7,7 +7,7 @@ LL | let f = |x: &dyn TT| x.func(); | | | `x` escapes the closure body here | | | argument requires that `'1` must outlive `'static` | | let's call the lifetime of this reference `'1` - | `x` is a reference that is only valid in the closure body + | `x` is only valid in the closure body error: aborting due to 1 previous error diff --git a/tests/assembly-llvm/c-variadic/aarch64.rs b/tests/assembly-llvm/c-variadic/aarch64.rs index 436318bee91e4..b0b06a2536862 100644 --- a/tests/assembly-llvm/c-variadic/aarch64.rs +++ b/tests/assembly-llvm/c-variadic/aarch64.rs @@ -25,33 +25,9 @@ // desugar va_arg early, hence we don't actually match Clang there. extern crate minicore; +use minicore::ffi::VaList; use minicore::*; -#[lang = "va_arg_safe"] -pub unsafe trait VaArgSafe {} - -unsafe impl VaArgSafe for i32 {} -unsafe impl VaArgSafe for i64 {} -unsafe impl VaArgSafe for i128 {} -unsafe impl VaArgSafe for f64 {} -unsafe impl VaArgSafe for *const T {} - -#[repr(transparent)] -struct VaListInner { - ptr: *const c_void, -} - -#[repr(transparent)] -#[lang = "va_list"] -pub struct VaList<'a> { - inner: VaListInner, - _marker: PhantomData<&'a mut ()>, -} - -#[rustc_intrinsic] -#[rustc_nounwind] -pub const unsafe fn va_arg(ap: &mut VaList<'_>) -> T; - #[unsafe(no_mangle)] unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // AARCH64_LINUX-LABEL: read_f64: @@ -109,7 +85,7 @@ unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // AARCH64_MSVC-NEXT: ldr d0, [x8], #8 // AARCH64_MSVC-NEXT: str x8, [x0] // AARCH64_MSVC-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -172,7 +148,7 @@ unsafe extern "C" fn read_i32(ap: &mut VaList<'_>) -> i32 { // AARCH64_MSVC-NEXT: ldr w0, [x9], #8 // AARCH64_MSVC-NEXT: str x9, [x8] // AARCH64_MSVC-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -236,7 +212,7 @@ unsafe extern "C" fn read_i64(ap: &mut VaList<'_>) -> i64 { // AARCH64_MSVC-NEXT: ldr x0, [x9], #8 // AARCH64_MSVC-NEXT: str x9, [x8] // AARCH64_MSVC-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -319,7 +295,7 @@ unsafe extern "C" fn read_i128(ap: &mut VaList<'_>) -> i128 { // AARCH64_MSVC-NEXT: ldr x0, [x10], #16 // AARCH64_MSVC-NEXT: str x10, [x8] // AARCH64_MSVC-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -329,5 +305,5 @@ unsafe extern "C" fn read_ptr(ap: &mut VaList<'_>) -> *const u8 { // AARCH64_MSVC: read_ptr = read_i64 // ARM64EC_MSVC: "#read_ptr" = "#read_i64" // AARCH64_DARWIN-CHECK: _read_ptr = _read_i64 - va_arg(ap) + ap.next_arg() } diff --git a/tests/assembly-llvm/c-variadic/avr.rs b/tests/assembly-llvm/c-variadic/avr.rs index a795e57cb8287..b2f1668917fc7 100644 --- a/tests/assembly-llvm/c-variadic/avr.rs +++ b/tests/assembly-llvm/c-variadic/avr.rs @@ -11,34 +11,9 @@ // Check that rustc and clang output match, see https://godbolt.org/z/1MvxoceeT. extern crate minicore; +use minicore::ffi::VaList; use minicore::*; -#[lang = "va_arg_safe"] -pub unsafe trait VaArgSafe {} - -unsafe impl VaArgSafe for i16 {} -unsafe impl VaArgSafe for i32 {} -unsafe impl VaArgSafe for i64 {} -unsafe impl VaArgSafe for f32 {} -unsafe impl VaArgSafe for f64 {} -unsafe impl VaArgSafe for *const T {} - -#[repr(transparent)] -struct VaListInner { - ptr: *const c_void, -} - -#[repr(transparent)] -#[lang = "va_list"] -pub struct VaList<'a> { - inner: VaListInner, - _marker: PhantomData<&'a mut ()>, -} - -#[rustc_intrinsic] -#[rustc_nounwind] -pub const unsafe fn va_arg(ap: &mut VaList<'_>) -> T; - #[unsafe(no_mangle)] unsafe extern "C" fn read_f32(ap: &mut VaList<'_>) -> f32 { // CHECK-LABEL: read_f32 @@ -63,7 +38,7 @@ unsafe extern "C" fn read_f32(ap: &mut VaList<'_>) -> f32 { // AVR-NEXT: ldd r24, Z+2 // AVR-NEXT: ldd r25, Z+3 // AVR-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -114,7 +89,7 @@ unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // AVR-NEXT: pop r15 // AVR-NEXT: pop r14 // AVR-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -132,7 +107,7 @@ unsafe extern "C" fn read_i16(ap: &mut VaList<'_>) -> i16 { // AVR-NEXT: ld r24, Z // AVR-NEXT: ldd r25, Z+1 // AVR-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -159,7 +134,7 @@ unsafe extern "C" fn read_i32(ap: &mut VaList<'_>) -> i32 { // AVR-NEXT: ldd r24, Z+2 // AVR-NEXT: ldd r25, Z+3 // AVR-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -210,11 +185,11 @@ unsafe extern "C" fn read_i64(ap: &mut VaList<'_>) -> i64 { // AVR-NEXT: pop r15 // AVR-NEXT: pop r14 // AVR-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] unsafe extern "C" fn read_ptr(ap: &mut VaList<'_>) -> *const u8 { // AVR: read_ptr = pm(read_i16) - va_arg(ap) + ap.next_arg() } diff --git a/tests/assembly-llvm/c-variadic/gpu.rs b/tests/assembly-llvm/c-variadic/gpu.rs index 0bc9c0f428705..137228d5877bc 100644 --- a/tests/assembly-llvm/c-variadic/gpu.rs +++ b/tests/assembly-llvm/c-variadic/gpu.rs @@ -12,33 +12,9 @@ #![crate_type = "lib"] extern crate minicore; +use minicore::ffi::VaList; use minicore::*; -#[lang = "va_arg_safe"] -pub unsafe trait VaArgSafe {} - -unsafe impl VaArgSafe for i32 {} -unsafe impl VaArgSafe for i64 {} -unsafe impl VaArgSafe for i128 {} -unsafe impl VaArgSafe for f64 {} -unsafe impl VaArgSafe for *const T {} - -#[repr(transparent)] -struct VaListInner { - ptr: *const c_void, -} - -#[repr(transparent)] -#[lang = "va_list"] -pub struct VaList<'a> { - inner: VaListInner, - _marker: PhantomData<&'a mut ()>, -} - -#[rustc_intrinsic] -#[rustc_nounwind] -pub const unsafe fn va_arg(ap: &mut VaList<'_>) -> T; - #[unsafe(no_mangle)] unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // CHECK-LABEL: read_f64 @@ -64,7 +40,7 @@ unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // NVPTX-NEXT: ld.b64 %rd6, [%rd4]; // NVPTX-NEXT: st.param.b64 [func_retval0], %rd6; // NVPTX-NEXT: ret; - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -91,7 +67,7 @@ unsafe extern "C" fn read_i32(ap: &mut VaList<'_>) -> i32 { // NVPTX-NEXT: ld.b32 %r1, [%rd4]; // NVPTX-NEXT: st.param.b32 [func_retval0], %r1; // NVPTX-NEXT: ret; - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -119,7 +95,7 @@ unsafe extern "C" fn read_i64(ap: &mut VaList<'_>) -> i64 { // NVPTX-NEXT: ld.b64 %rd6, [%rd4]; // NVPTX-NEXT: st.param.b64 [func_retval0], %rd6; // NVPTX-NEXT: ret; - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -147,7 +123,7 @@ unsafe extern "C" fn read_i128(ap: &mut VaList<'_>) -> i128 { // NVPTX-NEXT: ld.v2.b64 {%rd6, %rd7}, [%rd4]; // NVPTX-NEXT: st.param.v2.b64 [func_retval0], {%rd6, %rd7}; // NVPTX-NEXT: ret; - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -175,5 +151,5 @@ unsafe extern "C" fn read_ptr(ap: &mut VaList<'_>) -> *const u8 { // NVPTX-NEXT: ld.b64 %rd6, [%rd4]; // NVPTX-NEXT: st.param.b64 [func_retval0], %rd6; // NVPTX-NEXT: ret; - va_arg(ap) + ap.next_arg() } diff --git a/tests/assembly-llvm/c-variadic/mips.rs b/tests/assembly-llvm/c-variadic/mips.rs index da9c08481fc33..0873f968ba563 100644 --- a/tests/assembly-llvm/c-variadic/mips.rs +++ b/tests/assembly-llvm/c-variadic/mips.rs @@ -13,32 +13,9 @@ // Check that the assembly that rustc generates matches what clang emits. extern crate minicore; +use minicore::ffi::VaList; use minicore::*; -#[lang = "va_arg_safe"] -pub unsafe trait VaArgSafe {} - -unsafe impl VaArgSafe for i32 {} -unsafe impl VaArgSafe for i64 {} -unsafe impl VaArgSafe for f64 {} -unsafe impl VaArgSafe for *const T {} - -#[repr(transparent)] -struct VaListInner { - ptr: *const c_void, -} - -#[repr(transparent)] -#[lang = "va_list"] -pub struct VaList<'a> { - inner: VaListInner, - _marker: PhantomData<&'a mut ()>, -} - -#[rustc_intrinsic] -#[rustc_nounwind] -pub const unsafe fn va_arg(ap: &mut VaList<'_>) -> T; - #[unsafe(no_mangle)] unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // CHECK-LABEL: read_f64 @@ -65,7 +42,7 @@ unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // MIPS64EL-NEXT: ldc1 $f0, 0($1) // MIPS64EL-NEXT: jr $ra // MIPS64EL-NEXT: nop - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -91,7 +68,7 @@ unsafe extern "C" fn read_i32(ap: &mut VaList<'_>) -> i32 { // MIPS64EL-NEXT: lw $2, 0($1) // MIPS64EL-NEXT: jr $ra // MIPS64EL-NEXT: nop - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -123,7 +100,7 @@ unsafe extern "C" fn read_i64(ap: &mut VaList<'_>) -> i64 { // MIPS64EL-NEXT: ld $2, 0($1) // MIPS64EL-NEXT: jr $ra // MIPS64EL-NEXT: nop - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -131,5 +108,5 @@ unsafe extern "C" fn read_ptr(ap: &mut VaList<'_>) -> *const u8 { // MIPS: read_ptr = read_i32 // MIPS64: read_ptr = read_i64 // MIPS64EL: read_ptr = read_i64 - va_arg(ap) + ap.next_arg() } diff --git a/tests/assembly-llvm/c-variadic/powerpc.rs b/tests/assembly-llvm/c-variadic/powerpc.rs index 896817f628662..b5875ebf81b89 100644 --- a/tests/assembly-llvm/c-variadic/powerpc.rs +++ b/tests/assembly-llvm/c-variadic/powerpc.rs @@ -17,34 +17,9 @@ // Check that the assembly that rustc generates matches what clang emits. extern crate minicore; +use minicore::ffi::VaList; use minicore::*; -#[lang = "va_arg_safe"] -pub unsafe trait VaArgSafe {} - -unsafe impl VaArgSafe for i32 {} -unsafe impl VaArgSafe for i64 {} -#[cfg(target_pointer_width = "64")] -unsafe impl VaArgSafe for i128 {} -unsafe impl VaArgSafe for f64 {} -unsafe impl VaArgSafe for *const T {} - -#[repr(transparent)] -struct VaListInner { - ptr: *const c_void, -} - -#[repr(transparent)] -#[lang = "va_list"] -pub struct VaList<'a> { - inner: VaListInner, - _marker: PhantomData<&'a mut ()>, -} - -#[rustc_intrinsic] -#[rustc_nounwind] -pub const unsafe fn va_arg(ap: &mut VaList<'_>) -> T; - #[unsafe(no_mangle)] unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // CHECK-LABEL: read_f64 @@ -78,7 +53,7 @@ unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // AIX-NEXT: addi 5, 4, 8 // AIX-NEXT: std 5, 0(3) // AIX-NEXT: blr - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -115,7 +90,7 @@ unsafe extern "C" fn read_i32(ap: &mut VaList<'_>) -> i32 { // AIX-NEXT: std 5, 0(3) // AIX-NEXT: lwa 3, 4(4) // AIX-NEXT: blr - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -156,7 +131,7 @@ unsafe extern "C" fn read_i64(ap: &mut VaList<'_>) -> i64 { // AIX-NEXT: std 5, 0(3) // AIX-NEXT: ld 3, 0(4) // AIX-NEXT: blr - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -186,7 +161,7 @@ unsafe extern "C" fn read_i128(ap: &mut VaList<'_>) -> i128 { // AIX-NEXT: ld 3, 0(4) // AIX-NEXT: ld 4, 8(4) // AIX-NEXT: blr - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -194,5 +169,5 @@ unsafe extern "C" fn read_ptr(ap: &mut VaList<'_>) -> *const u8 { // POWERPC: read_ptr = read_i32 // POWERPC64: read_ptr = read_i64 // POWERPC64LE: read_ptr = read_i64 - va_arg(ap) + ap.next_arg() } diff --git a/tests/assembly-llvm/c-variadic/riscv.rs b/tests/assembly-llvm/c-variadic/riscv.rs index 989c47a04a58d..3a785269e40ce 100644 --- a/tests/assembly-llvm/c-variadic/riscv.rs +++ b/tests/assembly-llvm/c-variadic/riscv.rs @@ -11,34 +11,9 @@ #![crate_type = "lib"] extern crate minicore; +use minicore::ffi::VaList; use minicore::*; -#[lang = "va_arg_safe"] -pub unsafe trait VaArgSafe {} - -unsafe impl VaArgSafe for i32 {} -unsafe impl VaArgSafe for i64 {} -#[cfg(target_pointer_width = "64")] -unsafe impl VaArgSafe for i128 {} -unsafe impl VaArgSafe for f64 {} -unsafe impl VaArgSafe for *const T {} - -#[repr(transparent)] -struct VaListInner { - ptr: *const c_void, -} - -#[repr(transparent)] -#[lang = "va_list"] -pub struct VaList<'a> { - inner: VaListInner, - _marker: PhantomData<&'a mut ()>, -} - -#[rustc_intrinsic] -#[rustc_nounwind] -pub const unsafe fn va_arg(ap: &mut VaList<'_>) -> T; - #[unsafe(no_mangle)] unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // CHECK-LABEL: read_f64 @@ -56,7 +31,7 @@ unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // RISCV64-NEXT: addi a1, a1, 8 // RISCV64-NEXT: sd a1, 0(a0) // RISCV64-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -74,7 +49,7 @@ unsafe extern "C" fn read_i32(ap: &mut VaList<'_>) -> i32 { // RISCV64-NEXT: addi a2, a2, 8 // RISCV64-NEXT: sd a2, 0([[PTR:a[0-1]]]) // RISCV64: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -95,7 +70,7 @@ unsafe extern "C" fn read_i64(ap: &mut VaList<'_>) -> i64 { // RISCV64-NEXT: addi a2, a2, 8 // RISCV64-NEXT: sd a2, 0([[PTR:a[0-1]]]) // RISCV64: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -111,12 +86,12 @@ unsafe extern "C" fn read_i128(ap: &mut VaList<'_>) -> i128 { // RISCV64-NEXT: addi a3, a3, 16 // RISCV64-NEXT: sd a3, 0([[LIST:a[02]]]) // RISCV64: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] unsafe extern "C" fn read_ptr(ap: &mut VaList<'_>) -> *const u8 { // RISCV32: read_ptr = read_i32 // RISCV64: read_ptr = read_i64 - va_arg(ap) + ap.next_arg() } diff --git a/tests/assembly-llvm/c-variadic/s390x.rs b/tests/assembly-llvm/c-variadic/s390x.rs index cfa193726f862..7dfcda83fda3b 100644 --- a/tests/assembly-llvm/c-variadic/s390x.rs +++ b/tests/assembly-llvm/c-variadic/s390x.rs @@ -10,33 +10,9 @@ // Check that the assembly that rustc generates matches what clang emits. extern crate minicore; +use minicore::ffi::VaList; use minicore::*; -#[lang = "va_arg_safe"] -pub unsafe trait VaArgSafe {} - -unsafe impl VaArgSafe for i32 {} -unsafe impl VaArgSafe for i64 {} -unsafe impl VaArgSafe for i128 {} -unsafe impl VaArgSafe for f64 {} -unsafe impl VaArgSafe for *const T {} - -#[repr(transparent)] -struct VaListInner { - ptr: *const c_void, -} - -#[repr(transparent)] -#[lang = "va_list"] -pub struct VaList<'a> { - inner: VaListInner, - _marker: PhantomData<&'a mut ()>, -} - -#[rustc_intrinsic] -#[rustc_nounwind] -pub const unsafe fn va_arg(ap: &mut VaList<'_>) -> T; - #[unsafe(no_mangle)] unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // CHECK-LABEL: read_f64: @@ -55,7 +31,7 @@ unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // CHECK-NEXT: stg %r0, 16(%r2) // CHECK-NEXT: ld %f0, 0(%r1) // CHECK-NEXT: br %r14 - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -77,7 +53,7 @@ unsafe extern "C" fn read_i32(ap: &mut VaList<'_>) -> i32 { // CHECK-NEXT: stg %r0, 16(%r2) // CHECK-NEXT: lgf %r2, 0(%r1) // CHECK-NEXT: br %r14 - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -98,7 +74,7 @@ unsafe extern "C" fn read_i64(ap: &mut VaList<'_>) -> i64 { // CHECK-NEXT: stg %r0, 16(%r2) // CHECK-NEXT: lg %r2, 0(%r1) // CHECK-NEXT: br %r14 - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -123,11 +99,11 @@ unsafe extern "C" fn read_i128(ap: &mut VaList<'_>) -> i128 { // CHECK-NEXT: mvc 8(8,%r2), 8(%r1) // CHECK-NEXT: mvc 0(8,%r2), 0(%r1) // CHECK-NEXT: br %r14 - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] unsafe extern "C" fn read_ptr(ap: &mut VaList<'_>) -> *const u8 { // CHECK: read_ptr = read_i64 - va_arg(ap) + ap.next_arg() } diff --git a/tests/assembly-llvm/c-variadic/sparc.rs b/tests/assembly-llvm/c-variadic/sparc.rs index 78ce38ac3480e..44e5ce92bfa96 100644 --- a/tests/assembly-llvm/c-variadic/sparc.rs +++ b/tests/assembly-llvm/c-variadic/sparc.rs @@ -14,34 +14,9 @@ // Check that the assembly that rustc generates matches what clang emits. extern crate minicore; +use minicore::ffi::VaList; use minicore::*; -#[lang = "va_arg_safe"] -pub unsafe trait VaArgSafe {} - -unsafe impl VaArgSafe for i32 {} -unsafe impl VaArgSafe for i64 {} -#[cfg(target_pointer_width = "64")] -unsafe impl VaArgSafe for i128 {} -unsafe impl VaArgSafe for f64 {} -unsafe impl VaArgSafe for *const T {} - -#[repr(transparent)] -struct VaListInner { - ptr: *const c_void, -} - -#[repr(transparent)] -#[lang = "va_list"] -pub struct VaList<'a> { - inner: VaListInner, - _marker: PhantomData<&'a mut ()>, -} - -#[rustc_intrinsic] -#[rustc_nounwind] -pub const unsafe fn va_arg(ap: &mut VaList<'_>) -> T; - #[unsafe(no_mangle)] unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // CHECK-LABEL: read_f64 @@ -64,7 +39,7 @@ unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // SPARC64-NEXT: stx %o2, [%o0] // SPARC64-NEXT: retl // SPARC64-NEXT: ldd [%o1], %f0 - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -82,7 +57,7 @@ unsafe extern "C" fn read_i32(ap: &mut VaList<'_>) -> i32 { // SPARC64-NEXT: stx %o2, [%o0] // SPARC64-NEXT: retl // SPARC64-NEXT: ldsw [%o1+4], %o0 - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -107,7 +82,7 @@ unsafe extern "C" fn read_i64(ap: &mut VaList<'_>) -> i64 { // SPARC64-NEXT: stx %o2, [%o0] // SPARC64-NEXT: retl // SPARC64-NEXT: ldx [%o1], %o0 - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -123,12 +98,12 @@ unsafe extern "C" fn read_i128(ap: &mut VaList<'_>) -> i128 { // SPARC64-NEXT: or %o1, 8, %o1 // SPARC64-NEXT: retl // SPARC64-NEXT: ldx [%o1], %o1 - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] unsafe extern "C" fn read_ptr(ap: &mut VaList<'_>) -> *const u8 { // SPARC: read_ptr = read_i32 // SPARC64: read_ptr = read_i64 - va_arg(ap) + ap.next_arg() } diff --git a/tests/assembly-llvm/c-variadic/wasm.rs b/tests/assembly-llvm/c-variadic/wasm.rs index 69fd8fa9d18b5..3168e79ea9d7f 100644 --- a/tests/assembly-llvm/c-variadic/wasm.rs +++ b/tests/assembly-llvm/c-variadic/wasm.rs @@ -13,33 +13,9 @@ // Check that the assembly that rustc generates matches what clang emits. extern crate minicore; +use minicore::ffi::VaList; use minicore::*; -#[lang = "va_arg_safe"] -pub unsafe trait VaArgSafe {} - -unsafe impl VaArgSafe for i32 {} -unsafe impl VaArgSafe for i64 {} -unsafe impl VaArgSafe for i128 {} -unsafe impl VaArgSafe for f64 {} -unsafe impl VaArgSafe for *const T {} - -#[repr(transparent)] -struct VaListInner { - ptr: *const c_void, -} - -#[repr(transparent)] -#[lang = "va_list"] -pub struct VaList<'a> { - inner: VaListInner, - _marker: PhantomData<&'a mut ()>, -} - -#[rustc_intrinsic] -#[rustc_nounwind] -pub const unsafe fn va_arg(ap: &mut VaList<'_>) -> T; - #[unsafe(no_mangle)] unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // WASM32-LABEL: read_f64: @@ -73,7 +49,7 @@ unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // WASM64-NEXT: local.get 1 // WASM64-NEXT: f64.load 0 // WASM64-NEXT: end_function - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -101,7 +77,7 @@ unsafe extern "C" fn read_i32(ap: &mut VaList<'_>) -> i32 { // WASM64-NEXT: local.get 1 // WASM64-NEXT: i32.load 0 // WASM64-NEXT: end_function - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -133,7 +109,7 @@ unsafe extern "C" fn read_ptr(ap: &mut VaList<'_>) -> *const u8 { // WASM64-NEXT: local.get 1 // WASM64-NEXT: i64.load 0 // WASM64-NEXT: end_function - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -169,7 +145,7 @@ unsafe extern "C" fn read_i64(ap: &mut VaList<'_>) -> i64 { // WASM64-NEXT: local.get 1 // WASM64-NEXT: i64.load 0 // WASM64-NEXT: end_function - va_arg(ap) + ap.next_arg() } // Clang and Rustc use a different ABI for i128 on wasm32, and LLVM optimizes differently if we use @@ -220,5 +196,6 @@ unsafe extern "C" fn read_i128(out: *mut i128, ap: *mut VaList<'_>) { // WASM64-NEXT: i64.load 8 // WASM64-NEXT: i64.store 8 // WASM64-NEXT: end_function - *out = va_arg(mem::transmute(ap)); + let ap = &mut *ap; + *out = ap.next_arg(); } diff --git a/tests/assembly-llvm/c-variadic/x86-linux.rs b/tests/assembly-llvm/c-variadic/x86-linux.rs index 59ea4d629281a..d2f5c1144a991 100644 --- a/tests/assembly-llvm/c-variadic/x86-linux.rs +++ b/tests/assembly-llvm/c-variadic/x86-linux.rs @@ -16,34 +16,9 @@ // Check that the assembly that rustc generates matches what clang emits. extern crate minicore; +use minicore::ffi::VaList; use minicore::*; -#[lang = "va_arg_safe"] -pub unsafe trait VaArgSafe {} - -unsafe impl VaArgSafe for i32 {} -unsafe impl VaArgSafe for i64 {} -#[cfg(target_pointer_width = "64")] -unsafe impl VaArgSafe for i128 {} -unsafe impl VaArgSafe for f64 {} -unsafe impl VaArgSafe for *const T {} - -#[repr(transparent)] -struct VaListInner { - ptr: *const c_void, -} - -#[repr(transparent)] -#[lang = "va_list"] -pub struct VaList<'a> { - inner: VaListInner, - _marker: PhantomData<&'a mut ()>, -} - -#[rustc_intrinsic] -#[rustc_nounwind] -pub const unsafe fn va_arg(ap: &mut VaList<'_>) -> T; - #[unsafe(no_mangle)] unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // CHECK-LABEL: read_f64 @@ -86,7 +61,7 @@ unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // I686-NEXT: mov dword ptr [eax], edx // I686-NEXT: fld qword ptr [ecx] // I686-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -131,7 +106,7 @@ unsafe extern "C" fn read_i32(ap: &mut VaList<'_>) -> i32 { // I686-NEXT: mov dword ptr [eax], edx // I686-NEXT: mov eax, dword ptr [ecx] // I686-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -177,7 +152,7 @@ unsafe extern "C" fn read_i64(ap: &mut VaList<'_>) -> i64 { // I686-NEXT: mov eax, dword ptr [ecx] // I686-NEXT: mov edx, dword ptr [ecx + 4] // I686-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -223,7 +198,7 @@ unsafe extern "C" fn read_i128(ap: &mut VaList<'_>) -> i128 { // X86_64-NEXT_GNUX32-NEXT: mov rdx, qword ptr [ecx + 8] // X86_64-NEXT_GNUX32-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -231,5 +206,5 @@ unsafe extern "C" fn read_ptr(ap: &mut VaList<'_>) -> *const u8 { // X86_64: read_ptr = read_i64 // X86_64_GNUX32: read_ptr = read_i32 // I686: read_ptr = read_i32 - va_arg(ap) + ap.next_arg() } diff --git a/tests/assembly-llvm/c-variadic/x86-windows.rs b/tests/assembly-llvm/c-variadic/x86-windows.rs index 18a1fd9cb5127..7de244290958d 100644 --- a/tests/assembly-llvm/c-variadic/x86-windows.rs +++ b/tests/assembly-llvm/c-variadic/x86-windows.rs @@ -28,34 +28,9 @@ // ``` extern crate minicore; +use minicore::ffi::VaList; use minicore::*; -#[lang = "va_arg_safe"] -pub unsafe trait VaArgSafe {} - -unsafe impl VaArgSafe for i32 {} -unsafe impl VaArgSafe for i64 {} -#[cfg(target_pointer_width = "64")] -unsafe impl VaArgSafe for i128 {} -unsafe impl VaArgSafe for f64 {} -unsafe impl VaArgSafe for *const T {} - -#[repr(transparent)] -struct VaListInner { - ptr: *const c_void, -} - -#[repr(transparent)] -#[lang = "va_list"] -pub struct VaList<'a> { - inner: VaListInner, - _marker: PhantomData<&'a mut ()>, -} - -#[rustc_intrinsic] -#[rustc_nounwind] -pub const unsafe fn va_arg(ap: &mut VaList<'_>) -> T; - #[unsafe(no_mangle)] unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // CHECK-LABEL: read_f64: @@ -73,7 +48,7 @@ unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // I686-NEXT: fld qword ptr [ecx] // I686-NEXT: pop ebp // I686-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -93,7 +68,7 @@ unsafe extern "C" fn read_i32(ap: &mut VaList<'_>) -> i32 { // I686-NEXT: mov eax, dword ptr [ecx] // I686-NEXT: pop ebp // I686-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -114,7 +89,7 @@ unsafe extern "C" fn read_i64(ap: &mut VaList<'_>) -> i64 { // I686-NEXT: mov edx, dword ptr [ecx + 4] // I686-NEXT: pop ebp // I686-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -128,12 +103,12 @@ unsafe extern "C" fn read_i128(ap: &mut VaList<'_>) -> i128 { // X86_64-NEXT: mov rax, qword ptr [rax] // X86_64-NEXT: movups xmm0, xmmword ptr [rax] // X86_64-NEXT: ret - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] unsafe extern "C" fn read_ptr(ap: &mut VaList<'_>) -> *const u8 { // X86_64: read_ptr = read_i64 // X86: _read_ptr = _read_i32 - va_arg(ap) + ap.next_arg() } diff --git a/tests/assembly-llvm/c-variadic/xtensa.rs b/tests/assembly-llvm/c-variadic/xtensa.rs index 0038c4af4eee6..a070980cff3d6 100644 --- a/tests/assembly-llvm/c-variadic/xtensa.rs +++ b/tests/assembly-llvm/c-variadic/xtensa.rs @@ -12,33 +12,9 @@ // Check that the assembly that rustc generates matches what GCC emits. extern crate minicore; +use minicore::ffi::VaList; use minicore::*; -pub unsafe trait VaArgSafe {} - -unsafe impl VaArgSafe for i32 {} -unsafe impl VaArgSafe for i64 {} -unsafe impl VaArgSafe for f64 {} -unsafe impl VaArgSafe for *const T {} - -#[repr(C)] -struct VaListInner { - va_stk: *const c_void, - va_reg: *const c_void, - va_ndx: i32, -} - -#[repr(transparent)] -#[lang = "va_list"] -pub struct VaList<'a> { - inner: VaListInner, - _marker: PhantomData<&'a mut ()>, -} - -#[rustc_intrinsic] -#[rustc_nounwind] -pub const unsafe fn va_arg(ap: &mut VaList<'_>) -> T; - #[unsafe(no_mangle)] unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // CHECK-LABEL: read_f64 @@ -68,7 +44,7 @@ unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { // XTENSA-NEXT: l32i a2, a8, 0 // XTENSA-NEXT: l32i a3, a8, 4 // XTENSA-NEXT: retw.n - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -98,7 +74,7 @@ unsafe extern "C" fn read_i32(ap: &mut VaList<'_>) -> i32 { // XTENSA-NEXT: add a8, a9, a8 // XTENSA-NEXT: l32i a2, a8, 0 // XTENSA-NEXT: retw.n - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] @@ -130,11 +106,11 @@ unsafe extern "C" fn read_i64(ap: &mut VaList<'_>) -> i64 { // XTENSA-NEXT: l32i a2, a8, 0 // XTENSA-NEXT: l32i a3, a8, 4 // XTENSA-NEXT: retw.n - va_arg(ap) + ap.next_arg() } #[unsafe(no_mangle)] unsafe extern "C" fn read_ptr(ap: &mut VaList<'_>) -> *const u8 { // XTENSA: read_ptr = read_i32 - va_arg(ap) + ap.next_arg() } diff --git a/tests/auxiliary/minicore.rs b/tests/auxiliary/minicore.rs index 2b7eb0b9afbcf..bcbba883b2178 100644 --- a/tests/auxiliary/minicore.rs +++ b/tests/auxiliary/minicore.rs @@ -498,3 +498,104 @@ pub mod simd { pub type u8x16 = Simd; pub type u64x2 = Simd; } + +pub mod ffi { + use super::*; + + #[repr(transparent)] + #[lang = "va_list"] + pub struct VaList<'a> { + inner: VaListInner, + _marker: PhantomCovariantLifetime<'a>, + } + + #[rustc_intrinsic] + const unsafe fn va_arg(ap: &mut VaList<'_>) -> T; + + impl VaList<'_> { + pub unsafe fn next_arg(&mut self) -> T { + va_arg(self) + } + } + + #[repr(transparent)] + struct PhantomCovariantLifetime<'a>(PhantomCovariant<&'a ()>); + + #[repr(transparent)] + struct PhantomCovariant(PhantomData T>); + + cfg_select! { + all( + target_arch = "aarch64", + not(target_vendor = "apple"), + not(target_os = "uefi"), + not(windows) + ) => { + #[repr(C)] + struct VaListInner { + stack: *const c_void, + gr_top: *const c_void, + vr_top: *const c_void, + gr_offs: i32, + vr_offs: i32, + } + } + all(target_arch = "powerpc", not(target_os = "uefi"), not(windows)) => { + #[repr(C)] + #[rustc_pass_indirectly_in_non_rustic_abis] + struct VaListInner { + gpr: u8, + fpr: u8, + reserved: u16, + overflow_arg_area: *const c_void, + reg_save_area: *const c_void, + } + } + target_arch = "s390x" => { + #[repr(C)] + #[rustc_pass_indirectly_in_non_rustic_abis] + struct VaListInner { + gpr: i64, + fpr: i64, + overflow_arg_area: *const c_void, + reg_save_area: *const c_void, + } + } + all(target_arch = "x86_64", not(target_os = "uefi"), not(windows)) => { + #[repr(C)] + #[rustc_pass_indirectly_in_non_rustic_abis] + struct VaListInner { + gp_offset: i32, + fp_offset: i32, + overflow_arg_area: *const c_void, + reg_save_area: *const c_void, + } + } + target_arch = "xtensa" => { + #[repr(C)] + #[rustc_pass_indirectly_in_non_rustic_abis] + struct VaListInner { + stk: *const i32, + reg: *const i32, + ndx: i32, + } + } + + all(target_arch = "hexagon", target_env = "musl") => { + #[repr(C)] + #[rustc_pass_indirectly_in_non_rustic_abis] + struct VaListInner { + __current_saved_reg_area_pointer: *const c_void, + __saved_reg_area_end_pointer: *const c_void, + __overflow_area_pointer: *const c_void, + } + } + + _ => { + #[repr(transparent)] + struct VaListInner { + ptr: *const c_void, + } + } + } +} diff --git a/tests/ui/any/any_static.next.stderr b/tests/ui/any/any_static.next.stderr index e57d544140980..2f4a0e10427d8 100644 --- a/tests/ui/any/any_static.next.stderr +++ b/tests/ui/any/any_static.next.stderr @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of function LL | fn extend(a: &Payload) -> &'static Payload { | - - let's call the lifetime of this reference `'1` | | - | `a` is a reference that is only valid in the function body + | `a` is only valid in the function body LL | let b: &(dyn Any + 'static) = try_as_dyn::<&Payload, dyn Any + 'static>(&a).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | diff --git a/tests/ui/any/any_static.old.stderr b/tests/ui/any/any_static.old.stderr index e57d544140980..2f4a0e10427d8 100644 --- a/tests/ui/any/any_static.old.stderr +++ b/tests/ui/any/any_static.old.stderr @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of function LL | fn extend(a: &Payload) -> &'static Payload { | - - let's call the lifetime of this reference `'1` | | - | `a` is a reference that is only valid in the function body + | `a` is only valid in the function body LL | let b: &(dyn Any + 'static) = try_as_dyn::<&Payload, dyn Any + 'static>(&a).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | diff --git a/tests/ui/any/static_method_bound.stderr b/tests/ui/any/static_method_bound.stderr index 152672d024ab1..a886e4d8ae6d0 100644 --- a/tests/ui/any/static_method_bound.stderr +++ b/tests/ui/any/static_method_bound.stderr @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of function LL | fn extend(a: &Payload) -> &'static Payload { | - - let's call the lifetime of this reference `'1` | | - | `a` is a reference that is only valid in the function body + | `a` is only valid in the function body LL | let b: &(dyn Trait + 'static) = try_as_dyn::<&Payload, dyn Trait + 'static>(&a).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | diff --git a/tests/ui/associated-consts/issue-58022.stderr b/tests/ui/associated-consts/issue-58022.stderr index 24cec6e141bea..2ef3083d0e925 100644 --- a/tests/ui/associated-consts/issue-58022.stderr +++ b/tests/ui/associated-consts/issue-58022.stderr @@ -9,7 +9,7 @@ note: required because it appears within the type `Bar<[u8]>` --> $DIR/issue-58022.rs:8:12 | LL | pub struct Bar(T); - | ^^^ + | ^^^ - required by this field = note: the return type of a function must have a statically known size error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type diff --git a/tests/ui/async-await/issue-70935-complex-spans.stderr b/tests/ui/async-await/issue-70935-complex-spans.stderr index b9180c620b0dc..9f8f1461bd309 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.stderr +++ b/tests/ui/async-await/issue-70935-complex-spans.stderr @@ -11,7 +11,7 @@ note: required because it appears within the type `NotSync` --> $DIR/issue-70935-complex-spans.rs:9:8 | LL | struct NotSync(PhantomData<*mut ()>); - | ^^^^^^^ + | ^^^^^^^ -------------------- required by this field = note: required for `&NotSync` to implement `Send` note: required because it's used within this closure --> $DIR/issue-70935-complex-spans.rs:18:13 diff --git a/tests/ui/async-await/issue-72590-type-error-sized.stderr b/tests/ui/async-await/issue-72590-type-error-sized.stderr index 1d030278fd64e..70f615f03186e 100644 --- a/tests/ui/async-await/issue-72590-type-error-sized.stderr +++ b/tests/ui/async-await/issue-72590-type-error-sized.stderr @@ -22,6 +22,9 @@ note: required because it appears within the type `Foo` | LL | struct Foo { | ^^^ +LL | foo: Nonexistent, +LL | other: str + | ---------- required by this field = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | diff --git a/tests/ui/async-await/issues/issue-62097.stderr b/tests/ui/async-await/issues/issue-62097.stderr index adc8265e6c482..1422d315f88b0 100644 --- a/tests/ui/async-await/issues/issue-62097.stderr +++ b/tests/ui/async-await/issues/issue-62097.stderr @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of method LL | pub async fn run_dummy_fn(&self) { | ----- | | - | `self` is a reference that is only valid in the method body + | `self` is only valid in the method body | let's call the lifetime of this reference `'1` LL | foo(|| self.bar()).await; | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/issues/issue-72312.rs b/tests/ui/async-await/issues/issue-72312.rs index ba4c391058586..c2f01071f4a42 100644 --- a/tests/ui/async-await/issues/issue-72312.rs +++ b/tests/ui/async-await/issues/issue-72312.rs @@ -8,7 +8,7 @@ struct Problem; impl Problem { pub async fn start(&self) { //~^ NOTE let's call - //~| NOTE `self` is a reference + //~| NOTE `self` is only valid require_static(async move { //~^ ERROR borrowed data escapes //~| NOTE `self` escapes diff --git a/tests/ui/async-await/issues/issue-72312.stderr b/tests/ui/async-await/issues/issue-72312.stderr index 8e6fb138a1faa..33092a1abd3ab 100644 --- a/tests/ui/async-await/issues/issue-72312.stderr +++ b/tests/ui/async-await/issues/issue-72312.stderr @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of method LL | pub async fn start(&self) { | ----- | | - | `self` is a reference that is only valid in the method body + | `self` is only valid in the method body | let's call the lifetime of this reference `'1` ... LL | / require_static(async move { diff --git a/tests/ui/async-await/pin-needed-to-poll-2.stderr b/tests/ui/async-await/pin-needed-to-poll-2.stderr index 8eb671531e792..b7ca47ac4dde2 100644 --- a/tests/ui/async-await/pin-needed-to-poll-2.stderr +++ b/tests/ui/async-await/pin-needed-to-poll-2.stderr @@ -12,7 +12,7 @@ note: required because it appears within the type `Sleep` --> $DIR/pin-needed-to-poll-2.rs:8:8 | LL | struct Sleep(std::marker::PhantomPinned); - | ^^^^^ + | ^^^^^ -------------------------- required by this field note: required by a bound in `Pin::::new` --> $SRC_DIR/core/src/pin.rs:LL:COL diff --git a/tests/ui/auto-traits/auto-trait-phantom-data-bounds.stderr b/tests/ui/auto-traits/auto-trait-phantom-data-bounds.stderr index 56c2e8ff257b7..c37695411d736 100644 --- a/tests/ui/auto-traits/auto-trait-phantom-data-bounds.stderr +++ b/tests/ui/auto-traits/auto-trait-phantom-data-bounds.stderr @@ -18,6 +18,8 @@ note: required because it appears within the type `Guard<'_, T>` | LL | struct Guard<'a, T: 'a> { | ^^^^^ +LL | _marker: PhantomData<&'a T>, + | --------------------------- required by this field note: required by a bound in `is_zen` --> $DIR/auto-trait-phantom-data-bounds.rs:18:14 | @@ -48,11 +50,13 @@ note: required because it appears within the type `Guard<'_, T>` | LL | struct Guard<'a, T: 'a> { | ^^^^^ +LL | _marker: PhantomData<&'a T>, + | --------------------------- required by this field note: required because it appears within the type `Nested>` --> $DIR/auto-trait-phantom-data-bounds.rs:16:8 | LL | struct Nested(T); - | ^^^^^^ + | ^^^^^^ - required by this field note: required by a bound in `is_zen` --> $DIR/auto-trait-phantom-data-bounds.rs:18:14 | diff --git a/tests/ui/borrowck/anonymous-region-in-apit.stderr b/tests/ui/borrowck/anonymous-region-in-apit.stderr index 72dfbb797ebc7..1652c7f3a4e5d 100644 --- a/tests/ui/borrowck/anonymous-region-in-apit.stderr +++ b/tests/ui/borrowck/anonymous-region-in-apit.stderr @@ -9,7 +9,7 @@ LL | |baz: &str| foo.bar(baz); | | | `baz` escapes the closure body here | | | argument requires that `'1` must outlive `'2` | | let's call the lifetime of this reference `'1` - | `baz` is a reference that is only valid in the closure body + | `baz` is only valid in the closure body error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/fn-item-check-type-params.stderr b/tests/ui/borrowck/fn-item-check-type-params.stderr index 7a0a7752a14b2..b5738135e54a1 100644 --- a/tests/ui/borrowck/fn-item-check-type-params.stderr +++ b/tests/ui/borrowck/fn-item-check-type-params.stderr @@ -2,7 +2,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/fn-item-check-type-params.rs:31:5 | LL | pub fn test_call<'a>(val: &'a str) { - | -- --- `val` is a reference that is only valid in the function body + | -- --- `val` is only valid in the function body | | | lifetime `'a` defined here LL | extend_lt(val); diff --git a/tests/ui/borrowck/ice-on-non-ref-sig-ty.stderr b/tests/ui/borrowck/ice-on-non-ref-sig-ty.stderr index 2b900a8e68a7b..daedf243712f8 100644 --- a/tests/ui/borrowck/ice-on-non-ref-sig-ty.stderr +++ b/tests/ui/borrowck/ice-on-non-ref-sig-ty.stderr @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of method LL | impl<'a> W<'a> for &'static () { | -- lifetime `'a` defined here LL | fn g(self, x: &'a T) -> &'static T { - | ---- - `x` is a reference that is only valid in the method body + | ---- - `x` is only valid in the method body | | | `self` declared here, outside of the method body LL | f(&self, x) diff --git a/tests/ui/borrowck/issue-103624.stderr b/tests/ui/borrowck/issue-103624.stderr index caae758a48070..77e961ee48fc2 100644 --- a/tests/ui/borrowck/issue-103624.stderr +++ b/tests/ui/borrowck/issue-103624.stderr @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of method LL | async fn foo(&self) { | ----- | | - | `self` is a reference that is only valid in the method body + | `self` is only valid in the method body | let's call the lifetime of this reference `'1` LL | let bar = self.b.bar().await; LL | / spawn_blocking(move || { diff --git a/tests/ui/borrowck/issue-45983.stderr b/tests/ui/borrowck/issue-45983.stderr index 19a4a98bb1f49..ae4a32bca38ee 100644 --- a/tests/ui/borrowck/issue-45983.stderr +++ b/tests/ui/borrowck/issue-45983.stderr @@ -6,7 +6,7 @@ LL | let mut x = None; LL | give_any(|y| x = Some(y)); | - ^^^^^^^^^^^ `y` escapes the closure body here | | - | `y` is a reference that is only valid in the closure body + | `y` is only valid in the closure body error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/issue-7573.rs b/tests/ui/borrowck/issue-7573.rs index f94cd75ab6e2e..e6c11ab8675b9 100644 --- a/tests/ui/borrowck/issue-7573.rs +++ b/tests/ui/borrowck/issue-7573.rs @@ -13,7 +13,7 @@ pub fn remove_package_from_database() { let mut lines_to_use: Vec<&CrateId> = Vec::new(); //~^ NOTE `lines_to_use` declared here, outside of the closure body let push_id = |installed_id: &CrateId| { - //~^ NOTE `installed_id` is a reference that is only valid in the closure body + //~^ NOTE `installed_id` is only valid in the closure body lines_to_use.push(installed_id); //~^ ERROR borrowed data escapes outside of closure //~| NOTE `installed_id` escapes the closure body here diff --git a/tests/ui/borrowck/issue-7573.stderr b/tests/ui/borrowck/issue-7573.stderr index d0121f4ec174f..927cebe620b88 100644 --- a/tests/ui/borrowck/issue-7573.stderr +++ b/tests/ui/borrowck/issue-7573.stderr @@ -5,7 +5,7 @@ LL | let mut lines_to_use: Vec<&CrateId> = Vec::new(); | ---------------- `lines_to_use` declared here, outside of the closure body LL | LL | let push_id = |installed_id: &CrateId| { - | ------------ `installed_id` is a reference that is only valid in the closure body + | ------------ `installed_id` is only valid in the closure body LL | LL | lines_to_use.push(installed_id); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `installed_id` escapes the closure body here diff --git a/tests/ui/borrowck/regions-escape-bound-fn-2.stderr b/tests/ui/borrowck/regions-escape-bound-fn-2.stderr index 9c070de445710..893dffe0601d0 100644 --- a/tests/ui/borrowck/regions-escape-bound-fn-2.stderr +++ b/tests/ui/borrowck/regions-escape-bound-fn-2.stderr @@ -6,7 +6,7 @@ LL | let mut x = None; LL | with_int(|y| x = Some(y)); | - ^^^^^^^^^^^ `y` escapes the closure body here | | - | `y` is a reference that is only valid in the closure body + | `y` is only valid in the closure body error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/regions-escape-bound-fn.stderr b/tests/ui/borrowck/regions-escape-bound-fn.stderr index 868ba9c89be2f..92006eea3d9ad 100644 --- a/tests/ui/borrowck/regions-escape-bound-fn.stderr +++ b/tests/ui/borrowck/regions-escape-bound-fn.stderr @@ -6,7 +6,7 @@ LL | let mut x: Option<&isize> = None; LL | with_int(|y| x = Some(y)); | - ^^^^^^^^^^^ `y` escapes the closure body here | | - | `y` is a reference that is only valid in the closure body + | `y` is only valid in the closure body error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/regions-escape-unboxed-closure.stderr b/tests/ui/borrowck/regions-escape-unboxed-closure.stderr index c861f772be0d3..6efc75bf1d4bb 100644 --- a/tests/ui/borrowck/regions-escape-unboxed-closure.stderr +++ b/tests/ui/borrowck/regions-escape-unboxed-closure.stderr @@ -6,7 +6,7 @@ LL | let mut x: Option<&isize> = None; LL | with_int(&mut |y| x = Some(y)); | - ^^^^^^^^^^^ `y` escapes the closure body here | | - | `y` is a reference that is only valid in the closure body + | `y` is only valid in the closure body error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/var-matching-lifetime-but-unused-not-mentioned.stderr b/tests/ui/borrowck/var-matching-lifetime-but-unused-not-mentioned.stderr index fadb26ace969f..a3cde891b7cac 100644 --- a/tests/ui/borrowck/var-matching-lifetime-but-unused-not-mentioned.stderr +++ b/tests/ui/borrowck/var-matching-lifetime-but-unused-not-mentioned.stderr @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of function LL | fn foo<'a>( | -- lifetime `'a` defined here LL | used_arg: &'a u8, - | -------- `used_arg` is a reference that is only valid in the function body + | -------- `used_arg` is only valid in the function body ... LL | consume(c); | ^^^^^^^^^^ diff --git a/tests/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr b/tests/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr index 39a04186981f3..ff26f715d158e 100644 --- a/tests/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr +++ b/tests/ui/builtin-superkinds/builtin-superkinds-in-metadata.stderr @@ -8,7 +8,7 @@ note: required because it appears within the type `X` --> $DIR/builtin-superkinds-in-metadata.rs:9:8 | LL | struct X(T); - | ^ + | ^ - required by this field note: required by a bound in `RequiresRequiresShareAndSend` --> $DIR/auxiliary/trait_superkinds_in_metadata.rs:7:58 | diff --git a/tests/ui/c-variadic/naked-invalid.rs b/tests/ui/c-variadic/naked-invalid.rs index e0f06dad5c93b..0cd37c94b6764 100644 --- a/tests/ui/c-variadic/naked-invalid.rs +++ b/tests/ui/c-variadic/naked-invalid.rs @@ -9,12 +9,9 @@ #![no_core] extern crate minicore; +use minicore::ffi::VaList; use minicore::*; -#[repr(C)] -#[lang = "va_list"] -pub struct VaList; - #[unsafe(naked)] unsafe extern "sysv64" fn c_variadic_sysv64(_: ...) { naked_asm!("ret") diff --git a/tests/ui/c-variadic/naked-invalid.stderr b/tests/ui/c-variadic/naked-invalid.stderr index a1fc8c1664272..0842be296fe33 100644 --- a/tests/ui/c-variadic/naked-invalid.stderr +++ b/tests/ui/c-variadic/naked-invalid.stderr @@ -1,5 +1,5 @@ error: `...` is not supported for `extern "Rust"` naked functions - --> $DIR/naked-invalid.rs:29:41 + --> $DIR/naked-invalid.rs:26:41 | LL | unsafe extern "Rust" fn c_variadic_rust(_: ...) { | ------------- ^^^^^^ @@ -9,7 +9,7 @@ LL | unsafe extern "Rust" fn c_variadic_rust(_: ...) { = help: C-variadic function must have a compatible calling convention error: `...` is not supported for `extern "x86-interrupt"` naked functions - --> $DIR/naked-invalid.rs:35:59 + --> $DIR/naked-invalid.rs:32:59 | LL | unsafe extern "x86-interrupt" fn c_variadic_x86_interrupt(_: ...) { | ---------------------- ^^^^^^ @@ -19,7 +19,7 @@ LL | unsafe extern "x86-interrupt" fn c_variadic_x86_interrupt(_: ...) { = help: C-variadic function must have a compatible calling convention error[E0703]: invalid ABI: found `nonsense` - --> $DIR/naked-invalid.rs:41:15 + --> $DIR/naked-invalid.rs:38:15 | LL | unsafe extern "nonsense" fn c_variadic_x86_nonsense(_: ...) { | ^^^^^^^^^^ invalid ABI diff --git a/tests/ui/c-variadic/unsupported-abi.rs b/tests/ui/c-variadic/unsupported-abi.rs index 1b62003a9275b..606b95da98dbe 100644 --- a/tests/ui/c-variadic/unsupported-abi.rs +++ b/tests/ui/c-variadic/unsupported-abi.rs @@ -8,6 +8,7 @@ // Test that ABIs for which C-variadics are not supported report an error. extern crate minicore; +use minicore::ffi::VaList; use minicore::*; #[rustfmt::skip] @@ -28,9 +29,6 @@ mod foreign { //~^ ERROR C-variadic functions with the "thiscall-unwind" calling convention are not supported } -#[lang = "va_list"] -struct VaList(*mut u8); - unsafe fn rust_free(_: ...) {} //~^ ERROR `...` is not supported for non-extern functions unsafe extern "Rust" fn rust_free_explicit(_: ...) {} diff --git a/tests/ui/c-variadic/unsupported-abi.stderr b/tests/ui/c-variadic/unsupported-abi.stderr index ee1f5ece82ced..2418b31836fef 100644 --- a/tests/ui/c-variadic/unsupported-abi.stderr +++ b/tests/ui/c-variadic/unsupported-abi.stderr @@ -1,5 +1,5 @@ error: `...` is not supported for non-extern functions - --> $DIR/unsupported-abi.rs:34:21 + --> $DIR/unsupported-abi.rs:32:21 | LL | unsafe fn rust_free(_: ...) {} | ^^^^^^ @@ -7,7 +7,7 @@ LL | unsafe fn rust_free(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "Rust"` functions - --> $DIR/unsupported-abi.rs:36:44 + --> $DIR/unsupported-abi.rs:34:44 | LL | unsafe extern "Rust" fn rust_free_explicit(_: ...) {} | ------------- ^^^^^^ @@ -17,7 +17,7 @@ LL | unsafe extern "Rust" fn rust_free_explicit(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "cdecl"` functions - --> $DIR/unsupported-abi.rs:42:37 + --> $DIR/unsupported-abi.rs:40:37 | LL | unsafe extern "cdecl" fn cdecl_free(_: ...) {} | -------------- ^^^^^^ @@ -27,7 +27,7 @@ LL | unsafe extern "cdecl" fn cdecl_free(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "cdecl-unwind"` functions - --> $DIR/unsupported-abi.rs:44:51 + --> $DIR/unsupported-abi.rs:42:51 | LL | unsafe extern "cdecl-unwind" fn cdecl_unwind_free(_: ...) {} | --------------------- ^^^^^^ @@ -37,7 +37,7 @@ LL | unsafe extern "cdecl-unwind" fn cdecl_unwind_free(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "stdcall"` functions - --> $DIR/unsupported-abi.rs:46:41 + --> $DIR/unsupported-abi.rs:44:41 | LL | unsafe extern "stdcall" fn stdcall_free(_: ...) {} | ---------------- ^^^^^^ @@ -47,7 +47,7 @@ LL | unsafe extern "stdcall" fn stdcall_free(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "stdcall-unwind"` functions - --> $DIR/unsupported-abi.rs:48:55 + --> $DIR/unsupported-abi.rs:46:55 | LL | unsafe extern "stdcall-unwind" fn stdcall_unwind_free(_: ...) {} | ----------------------- ^^^^^^ @@ -57,7 +57,7 @@ LL | unsafe extern "stdcall-unwind" fn stdcall_unwind_free(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "thiscall"` functions - --> $DIR/unsupported-abi.rs:50:43 + --> $DIR/unsupported-abi.rs:48:43 | LL | unsafe extern "thiscall" fn thiscall_free(_: ...) {} | ----------------- ^^^^^^ @@ -67,7 +67,7 @@ LL | unsafe extern "thiscall" fn thiscall_free(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "thiscall-unwind"` functions - --> $DIR/unsupported-abi.rs:52:57 + --> $DIR/unsupported-abi.rs:50:57 | LL | unsafe extern "thiscall-unwind" fn thiscall_unwind_free(_: ...) {} | ------------------------ ^^^^^^ @@ -77,7 +77,7 @@ LL | unsafe extern "thiscall-unwind" fn thiscall_unwind_free(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for non-extern functions - --> $DIR/unsupported-abi.rs:58:27 + --> $DIR/unsupported-abi.rs:56:27 | LL | unsafe fn rust_method(_: ...) {} | ^^^^^^ @@ -85,7 +85,7 @@ LL | unsafe fn rust_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "Rust"` functions - --> $DIR/unsupported-abi.rs:60:50 + --> $DIR/unsupported-abi.rs:58:50 | LL | unsafe extern "Rust" fn rust_method_explicit(_: ...) {} | ------------- ^^^^^^ @@ -95,7 +95,7 @@ LL | unsafe extern "Rust" fn rust_method_explicit(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "cdecl"` functions - --> $DIR/unsupported-abi.rs:66:43 + --> $DIR/unsupported-abi.rs:64:43 | LL | unsafe extern "cdecl" fn cdecl_method(_: ...) {} | -------------- ^^^^^^ @@ -105,7 +105,7 @@ LL | unsafe extern "cdecl" fn cdecl_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "cdecl-unwind"` functions - --> $DIR/unsupported-abi.rs:68:57 + --> $DIR/unsupported-abi.rs:66:57 | LL | unsafe extern "cdecl-unwind" fn cdecl_unwind_method(_: ...) {} | --------------------- ^^^^^^ @@ -115,7 +115,7 @@ LL | unsafe extern "cdecl-unwind" fn cdecl_unwind_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "stdcall"` functions - --> $DIR/unsupported-abi.rs:70:47 + --> $DIR/unsupported-abi.rs:68:47 | LL | unsafe extern "stdcall" fn stdcall_method(_: ...) {} | ---------------- ^^^^^^ @@ -125,7 +125,7 @@ LL | unsafe extern "stdcall" fn stdcall_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "stdcall-unwind"` functions - --> $DIR/unsupported-abi.rs:72:61 + --> $DIR/unsupported-abi.rs:70:61 | LL | unsafe extern "stdcall-unwind" fn stdcall_unwind_method(_: ...) {} | ----------------------- ^^^^^^ @@ -135,7 +135,7 @@ LL | unsafe extern "stdcall-unwind" fn stdcall_unwind_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "thiscall"` functions - --> $DIR/unsupported-abi.rs:74:49 + --> $DIR/unsupported-abi.rs:72:49 | LL | unsafe extern "thiscall" fn thiscall_method(_: ...) {} | ----------------- ^^^^^^ @@ -145,7 +145,7 @@ LL | unsafe extern "thiscall" fn thiscall_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "thiscall-unwind"` functions - --> $DIR/unsupported-abi.rs:76:63 + --> $DIR/unsupported-abi.rs:74:63 | LL | unsafe extern "thiscall-unwind" fn thiscall_unwind_method(_: ...) {} | ------------------------ ^^^^^^ @@ -155,7 +155,7 @@ LL | unsafe extern "thiscall-unwind" fn thiscall_unwind_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for non-extern functions - --> $DIR/unsupported-abi.rs:81:33 + --> $DIR/unsupported-abi.rs:79:33 | LL | unsafe fn rust_trait_method(_: ...) {} | ^^^^^^ @@ -163,7 +163,7 @@ LL | unsafe fn rust_trait_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "Rust"` functions - --> $DIR/unsupported-abi.rs:83:56 + --> $DIR/unsupported-abi.rs:81:56 | LL | unsafe extern "Rust" fn rust_trait_method_explicit(_: ...) {} | ------------- ^^^^^^ @@ -173,7 +173,7 @@ LL | unsafe extern "Rust" fn rust_trait_method_explicit(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "cdecl"` functions - --> $DIR/unsupported-abi.rs:89:49 + --> $DIR/unsupported-abi.rs:87:49 | LL | unsafe extern "cdecl" fn cdecl_trait_method(_: ...) {} | -------------- ^^^^^^ @@ -183,7 +183,7 @@ LL | unsafe extern "cdecl" fn cdecl_trait_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "cdecl-unwind"` functions - --> $DIR/unsupported-abi.rs:91:63 + --> $DIR/unsupported-abi.rs:89:63 | LL | unsafe extern "cdecl-unwind" fn cdecl_unwind_trait_method(_: ...) {} | --------------------- ^^^^^^ @@ -193,7 +193,7 @@ LL | unsafe extern "cdecl-unwind" fn cdecl_unwind_trait_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "stdcall"` functions - --> $DIR/unsupported-abi.rs:93:53 + --> $DIR/unsupported-abi.rs:91:53 | LL | unsafe extern "stdcall" fn stdcall_trait_method(_: ...) {} | ---------------- ^^^^^^ @@ -203,7 +203,7 @@ LL | unsafe extern "stdcall" fn stdcall_trait_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "stdcall-unwind"` functions - --> $DIR/unsupported-abi.rs:95:67 + --> $DIR/unsupported-abi.rs:93:67 | LL | unsafe extern "stdcall-unwind" fn stdcall_unwind_trait_method(_: ...) {} | ----------------------- ^^^^^^ @@ -213,7 +213,7 @@ LL | unsafe extern "stdcall-unwind" fn stdcall_unwind_trait_method(_: ...) { = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "thiscall"` functions - --> $DIR/unsupported-abi.rs:97:55 + --> $DIR/unsupported-abi.rs:95:55 | LL | unsafe extern "thiscall" fn thiscall_trait_method(_: ...) {} | ----------------- ^^^^^^ @@ -223,7 +223,7 @@ LL | unsafe extern "thiscall" fn thiscall_trait_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "thiscall-unwind"` functions - --> $DIR/unsupported-abi.rs:99:69 + --> $DIR/unsupported-abi.rs:97:69 | LL | unsafe extern "thiscall-unwind" fn thiscall_unwind_trait_method(_: ...) {} | ------------------------ ^^^^^^ @@ -233,7 +233,7 @@ LL | unsafe extern "thiscall-unwind" fn thiscall_unwind_trait_method(_: ...) = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for non-extern functions - --> $DIR/unsupported-abi.rs:104:33 + --> $DIR/unsupported-abi.rs:102:33 | LL | unsafe fn rust_trait_method(_: ...) {} | ^^^^^^ @@ -241,7 +241,7 @@ LL | unsafe fn rust_trait_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "Rust"` functions - --> $DIR/unsupported-abi.rs:106:56 + --> $DIR/unsupported-abi.rs:104:56 | LL | unsafe extern "Rust" fn rust_trait_method_explicit(_: ...) {} | ------------- ^^^^^^ @@ -251,7 +251,7 @@ LL | unsafe extern "Rust" fn rust_trait_method_explicit(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "cdecl"` functions - --> $DIR/unsupported-abi.rs:112:49 + --> $DIR/unsupported-abi.rs:110:49 | LL | unsafe extern "cdecl" fn cdecl_trait_method(_: ...) {} | -------------- ^^^^^^ @@ -261,7 +261,7 @@ LL | unsafe extern "cdecl" fn cdecl_trait_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "cdecl-unwind"` functions - --> $DIR/unsupported-abi.rs:114:63 + --> $DIR/unsupported-abi.rs:112:63 | LL | unsafe extern "cdecl-unwind" fn cdecl_unwind_trait_method(_: ...) {} | --------------------- ^^^^^^ @@ -271,7 +271,7 @@ LL | unsafe extern "cdecl-unwind" fn cdecl_unwind_trait_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "stdcall"` functions - --> $DIR/unsupported-abi.rs:116:53 + --> $DIR/unsupported-abi.rs:114:53 | LL | unsafe extern "stdcall" fn stdcall_trait_method(_: ...) {} | ---------------- ^^^^^^ @@ -281,7 +281,7 @@ LL | unsafe extern "stdcall" fn stdcall_trait_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "stdcall-unwind"` functions - --> $DIR/unsupported-abi.rs:118:67 + --> $DIR/unsupported-abi.rs:116:67 | LL | unsafe extern "stdcall-unwind" fn stdcall_unwind_trait_method(_: ...) {} | ----------------------- ^^^^^^ @@ -291,7 +291,7 @@ LL | unsafe extern "stdcall-unwind" fn stdcall_unwind_trait_method(_: ...) { = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "thiscall"` functions - --> $DIR/unsupported-abi.rs:120:55 + --> $DIR/unsupported-abi.rs:118:55 | LL | unsafe extern "thiscall" fn thiscall_trait_method(_: ...) {} | ----------------- ^^^^^^ @@ -301,7 +301,7 @@ LL | unsafe extern "thiscall" fn thiscall_trait_method(_: ...) {} = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: `...` is not supported for `extern "thiscall-unwind"` functions - --> $DIR/unsupported-abi.rs:122:69 + --> $DIR/unsupported-abi.rs:120:69 | LL | unsafe extern "thiscall-unwind" fn thiscall_unwind_trait_method(_: ...) {} | ------------------------ ^^^^^^ @@ -311,31 +311,31 @@ LL | unsafe extern "thiscall-unwind" fn thiscall_unwind_trait_method(_: ...) = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error[E0045]: C-variadic functions with the "Rust" calling convention are not supported - --> $DIR/unsupported-abi.rs:15:22 + --> $DIR/unsupported-abi.rs:16:22 | LL | extern "Rust" { fn rust_foreign_explicit(_: ...); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention error[E0045]: C-variadic functions with the "stdcall" calling convention are not supported - --> $DIR/unsupported-abi.rs:21:25 + --> $DIR/unsupported-abi.rs:22:25 | LL | extern "stdcall" { fn stdcall_foreign(_: ...); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention error[E0045]: C-variadic functions with the "stdcall-unwind" calling convention are not supported - --> $DIR/unsupported-abi.rs:23:32 + --> $DIR/unsupported-abi.rs:24:32 | LL | extern "stdcall-unwind" { fn stdcall_unwind_foreign(_: ...); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention error[E0045]: C-variadic functions with the "thiscall" calling convention are not supported - --> $DIR/unsupported-abi.rs:25:26 + --> $DIR/unsupported-abi.rs:26:26 | LL | extern "thiscall" { fn thiscall_foreign(_: ...); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention error[E0045]: C-variadic functions with the "thiscall-unwind" calling convention are not supported - --> $DIR/unsupported-abi.rs:27:33 + --> $DIR/unsupported-abi.rs:28:33 | LL | extern "thiscall-unwind" { fn thiscall_unwind_foreign(_: ...); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention diff --git a/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.stderr b/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.stderr index 74a92f459aa62..92a08d0a58d74 100644 --- a/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.stderr +++ b/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.stderr @@ -231,7 +231,7 @@ LL | fn extend_to_static<'a>(ptr: *const dyn Trait<'a>) { | -- --- | | | | | `ptr` declared here, outside of the function body - | | `ptr` is a reference that is only valid in the function body + | | `ptr` is only valid in the function body | lifetime `'a` defined here LL | require_static(ptr as _) | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/closures/closure-bounds-static-cant-capture-borrowed.stderr b/tests/ui/closures/closure-bounds-static-cant-capture-borrowed.stderr index 798c3bc815696..654ca665ae09c 100644 --- a/tests/ui/closures/closure-bounds-static-cant-capture-borrowed.stderr +++ b/tests/ui/closures/closure-bounds-static-cant-capture-borrowed.stderr @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of function LL | fn foo(x: &()) { | - - let's call the lifetime of this reference `'1` | | - | `x` is a reference that is only valid in the function body + | `x` is only valid in the function body LL | / bar(|| { LL | | LL | | diff --git a/tests/ui/closures/closure-expected-type/expect-region-supply-region.stderr b/tests/ui/closures/closure-expected-type/expect-region-supply-region.stderr index 0d97fa7e23014..d8cc760f44e7e 100644 --- a/tests/ui/closures/closure-expected-type/expect-region-supply-region.stderr +++ b/tests/ui/closures/closure-expected-type/expect-region-supply-region.stderr @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of closure LL | let mut f: Option<&u32> = None; | ----- `f` declared here, outside of the closure body LL | closure_expecting_bound(|x| { - | - `x` is a reference that is only valid in the closure body + | - `x` is only valid in the closure body LL | f = Some(x); | ^^^^^^^^^^^ `x` escapes the closure body here @@ -14,7 +14,7 @@ error[E0521]: borrowed data escapes outside of closure LL | let mut f: Option<&u32> = None; | ----- `f` declared here, outside of the closure body LL | closure_expecting_bound(|x: &u32| { - | - `x` is a reference that is only valid in the closure body + | - `x` is only valid in the closure body LL | f = Some(x); | ^^^^^^^^^^^ `x` escapes the closure body here diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.rs index 40a0f152e3005..1dd49f22f8077 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.rs @@ -7,11 +7,9 @@ #![no_core] extern crate minicore; +use minicore::ffi::VaList; use minicore::*; -#[lang = "va_list"] -struct VaList(*mut u8); - unsafe extern "cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { //~^ ERROR `...` is not supported for `extern "cmse-nonsecure-entry"` functions } @@ -20,6 +18,7 @@ unsafe extern "cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { async unsafe extern "cmse-nonsecure-entry" fn async_and_c_variadic(_: ...) { //~^ ERROR `...` is not supported for `extern "cmse-nonsecure-entry"` functions //~| ERROR functions cannot be both `async` and C-variadic + //~| ERROR hidden type for `impl Future` captures lifetime that does not appear in bounds } // Async on its own is also not allowed. diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.stderr index 2a2d769c7cf89..f4d9f8a2ed29d 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.stderr @@ -1,5 +1,5 @@ error: `...` is not supported for `extern "cmse-nonsecure-entry"` functions - --> $DIR/c-variadic.rs:15:60 + --> $DIR/c-variadic.rs:13:60 | LL | unsafe extern "cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { | ----------------------------- ^^^^^^ @@ -9,13 +9,13 @@ LL | unsafe extern "cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error: functions cannot be both `async` and C-variadic - --> $DIR/c-variadic.rs:20:1 + --> $DIR/c-variadic.rs:18:1 | LL | async unsafe extern "cmse-nonsecure-entry" fn async_and_c_variadic(_: ...) { | ^^^^^ `async` because of this ^^^^^^ C-variadic because of this error: `...` is not supported for `extern "cmse-nonsecure-entry"` functions - --> $DIR/c-variadic.rs:20:68 + --> $DIR/c-variadic.rs:18:68 | LL | async unsafe extern "cmse-nonsecure-entry" fn async_and_c_variadic(_: ...) { | ----------------------------- ^^^^^^ @@ -25,11 +25,24 @@ LL | async unsafe extern "cmse-nonsecure-entry" fn async_and_c_variadic(_: ...) = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error[E0798]: `impl Trait` is not allowed in `extern "cmse-nonsecure-entry"` signatures - --> $DIR/c-variadic.rs:26:69 + --> $DIR/c-variadic.rs:25:69 | LL | async unsafe extern "cmse-nonsecure-entry" fn async_is_not_allowed() { | ^ -error: aborting due to 4 previous errors +error[E0700]: hidden type for `impl Future` captures lifetime that does not appear in bounds + --> $DIR/c-variadic.rs:18:76 + | +LL | async unsafe extern "cmse-nonsecure-entry" fn async_and_c_variadic(_: ...) { + | _---------------------------------------------------------------------------^ + | | | | + | | | opaque type defined here + | | hidden type `{async fn body of async_and_c_variadic()}` captures the anonymous lifetime as defined here +... | +LL | | } + | |_^ + +error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0798`. +Some errors have detailed explanations: E0700, E0798. +For more information about an error, try `rustc --explain E0700`. diff --git a/tests/ui/coherence/deep-bad-copy-reason.rs b/tests/ui/coherence/deep-bad-copy-reason.rs index f1c2698bad5cc..d93a46f1fcb1a 100644 --- a/tests/ui/coherence/deep-bad-copy-reason.rs +++ b/tests/ui/coherence/deep-bad-copy-reason.rs @@ -9,6 +9,7 @@ pub struct ListS { len: usize, data: [T; 0], opaque: OpaqueListContents, + //~^ NOTE required by this field } pub struct Interned<'a, T>(&'a T); diff --git a/tests/ui/coherence/deep-bad-copy-reason.stderr b/tests/ui/coherence/deep-bad-copy-reason.stderr index 534f26c39c2d4..198ea1d75e388 100644 --- a/tests/ui/coherence/deep-bad-copy-reason.stderr +++ b/tests/ui/coherence/deep-bad-copy-reason.stderr @@ -1,5 +1,5 @@ error[E0204]: the trait `Copy` cannot be implemented for this type - --> $DIR/deep-bad-copy-reason.rs:38:24 + --> $DIR/deep-bad-copy-reason.rs:39:24 | LL | pub struct List<'tcx, T>(Interned<'tcx, ListS>); | ------------------------ this field does not implement `Copy` @@ -8,13 +8,13 @@ LL | impl<'tcx, T> Copy for List<'tcx, T> {} | ^^^^^^^^^^^^^ | note: the `Copy` impl for `Interned<'tcx, ListS>` requires that `OpaqueListContents: Sized` - --> $DIR/deep-bad-copy-reason.rs:26:26 + --> $DIR/deep-bad-copy-reason.rs:27:26 | LL | pub struct List<'tcx, T>(Interned<'tcx, ListS>); | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the size for values of type `OpaqueListContents` cannot be known at compilation time - --> $DIR/deep-bad-copy-reason.rs:26:26 + --> $DIR/deep-bad-copy-reason.rs:27:26 | LL | pub struct List<'tcx, T>(Interned<'tcx, ListS>); | ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -25,8 +25,11 @@ note: required because it appears within the type `ListS` | LL | pub struct ListS { | ^^^^^ +... +LL | opaque: OpaqueListContents, + | -------------------------- required by this field note: required by an implicit `Sized` bound in `Interned` - --> $DIR/deep-bad-copy-reason.rs:14:25 + --> $DIR/deep-bad-copy-reason.rs:15:25 | LL | pub struct Interned<'a, T>(&'a T); | ^ required by the implicit `Sized` requirement on this type parameter in `Interned` diff --git a/tests/ui/const-generics/suggest_const_for_array.generic_const_args.stderr b/tests/ui/const-generics/suggest_const_for_array.generic_const_args.stderr new file mode 100644 index 0000000000000..089c7f6b4a25c --- /dev/null +++ b/tests/ui/const-generics/suggest_const_for_array.generic_const_args.stderr @@ -0,0 +1,27 @@ +error[E0747]: type provided when a constant was expected + --> $DIR/suggest_const_for_array.rs:9:15 + | +LL | example::<[usize; 3]>(); + | ^^^^^^^^^^ array type provided where a `usize` was expected + | +help: you might have meant to use the array's length's value + | +LL - example::<[usize; 3]>(); +LL + example::<3>(); + | + +error[E0747]: type provided when a constant was expected + --> $DIR/suggest_const_for_array.rs:11:15 + | +LL | example::<[usize; 4 + 5]>(); + | ^^^^^^^^^^^^^^ array type provided where a `usize` was expected + | +help: you might have meant to use the array's length's value + | +LL - example::<[usize; 4 + 5]>(); +LL + example::<{ 4 + 5 }>(); + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0747`. diff --git a/tests/ui/const-generics/suggest_const_for_array.min_generic_const_args.stderr b/tests/ui/const-generics/suggest_const_for_array.min_generic_const_args.stderr new file mode 100644 index 0000000000000..089c7f6b4a25c --- /dev/null +++ b/tests/ui/const-generics/suggest_const_for_array.min_generic_const_args.stderr @@ -0,0 +1,27 @@ +error[E0747]: type provided when a constant was expected + --> $DIR/suggest_const_for_array.rs:9:15 + | +LL | example::<[usize; 3]>(); + | ^^^^^^^^^^ array type provided where a `usize` was expected + | +help: you might have meant to use the array's length's value + | +LL - example::<[usize; 3]>(); +LL + example::<3>(); + | + +error[E0747]: type provided when a constant was expected + --> $DIR/suggest_const_for_array.rs:11:15 + | +LL | example::<[usize; 4 + 5]>(); + | ^^^^^^^^^^^^^^ array type provided where a `usize` was expected + | +help: you might have meant to use the array's length's value + | +LL - example::<[usize; 4 + 5]>(); +LL + example::<{ 4 + 5 }>(); + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0747`. diff --git a/tests/ui/const-generics/suggest_const_for_array.regular.stderr b/tests/ui/const-generics/suggest_const_for_array.regular.stderr new file mode 100644 index 0000000000000..089c7f6b4a25c --- /dev/null +++ b/tests/ui/const-generics/suggest_const_for_array.regular.stderr @@ -0,0 +1,27 @@ +error[E0747]: type provided when a constant was expected + --> $DIR/suggest_const_for_array.rs:9:15 + | +LL | example::<[usize; 3]>(); + | ^^^^^^^^^^ array type provided where a `usize` was expected + | +help: you might have meant to use the array's length's value + | +LL - example::<[usize; 3]>(); +LL + example::<3>(); + | + +error[E0747]: type provided when a constant was expected + --> $DIR/suggest_const_for_array.rs:11:15 + | +LL | example::<[usize; 4 + 5]>(); + | ^^^^^^^^^^^^^^ array type provided where a `usize` was expected + | +help: you might have meant to use the array's length's value + | +LL - example::<[usize; 4 + 5]>(); +LL + example::<{ 4 + 5 }>(); + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0747`. diff --git a/tests/ui/const-generics/suggest_const_for_array.rs b/tests/ui/const-generics/suggest_const_for_array.rs index b52fd152f976a..b85491130c9e8 100644 --- a/tests/ui/const-generics/suggest_const_for_array.rs +++ b/tests/ui/const-generics/suggest_const_for_array.rs @@ -1,4 +1,7 @@ +//@revisions: min_generic_const_args generic_const_args regular #![crate_type = "lib"] +#![cfg_attr(min_generic_const_args, feature(min_generic_const_args))] +#![cfg_attr(generic_const_args, feature(min_generic_const_args))] fn example() {} diff --git a/tests/ui/const-generics/suggest_const_for_array.stderr b/tests/ui/const-generics/suggest_const_for_array.stderr deleted file mode 100644 index f0ad8368e5d71..0000000000000 --- a/tests/ui/const-generics/suggest_const_for_array.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0747]: type provided when a constant was expected - --> $DIR/suggest_const_for_array.rs:6:15 - | -LL | example::<[usize; 3]>(); - | ^^^^^^^^^^ help: array type provided where a `usize` was expected, try: `{ 3 }` - -error[E0747]: type provided when a constant was expected - --> $DIR/suggest_const_for_array.rs:8:15 - | -LL | example::<[usize; 4 + 5]>(); - | ^^^^^^^^^^^^^^ help: array type provided where a `usize` was expected, try: `{ 4 + 5 }` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0747`. diff --git a/tests/ui/coroutine/resume-arg-outlives-2.stderr b/tests/ui/coroutine/resume-arg-outlives-2.stderr index 92192d9a55721..9f6aab8d97ba7 100644 --- a/tests/ui/coroutine/resume-arg-outlives-2.stderr +++ b/tests/ui/coroutine/resume-arg-outlives-2.stderr @@ -2,7 +2,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/resume-arg-outlives-2.rs:21:5 | LL | fn demo<'not_static>(s: &'not_static str) -> thread::JoinHandle<()> { - | ----------- - `s` is a reference that is only valid in the function body + | ----------- - `s` is only valid in the function body | | | lifetime `'not_static` defined here ... diff --git a/tests/ui/deref/pin-impl-deref.stderr b/tests/ui/deref/pin-impl-deref.stderr index 4143d66f42723..5e0e0aa06715b 100644 --- a/tests/ui/deref/pin-impl-deref.stderr +++ b/tests/ui/deref/pin-impl-deref.stderr @@ -44,7 +44,7 @@ note: required because it appears within the type `MyPinType` --> $DIR/pin-impl-deref.rs:15:8 | LL | struct MyPinType(core::marker::PhantomPinned); - | ^^^^^^^^^ + | ^^^^^^^^^ --------------------------- required by this field = note: required for `Pin<&MyPinType>` to implement `DerefMut` note: required by a bound in `impl_deref_mut` --> $DIR/pin-impl-deref.rs:22:27 @@ -66,7 +66,7 @@ note: required because it appears within the type `MyPinType` --> $DIR/pin-impl-deref.rs:15:8 | LL | struct MyPinType(core::marker::PhantomPinned); - | ^^^^^^^^^ + | ^^^^^^^^^ --------------------------- required by this field = note: required for `Pin<&mut MyPinType>` to implement `DerefMut` note: required by a bound in `impl_deref_mut` --> $DIR/pin-impl-deref.rs:22:27 diff --git a/tests/ui/did_you_mean/recursion_limit.stderr b/tests/ui/did_you_mean/recursion_limit.stderr index 2ecee2030b03f..7960efec9957e 100644 --- a/tests/ui/did_you_mean/recursion_limit.stderr +++ b/tests/ui/did_you_mean/recursion_limit.stderr @@ -8,46 +8,73 @@ LL | is_send::(); note: required because it appears within the type `I` --> $DIR/recursion_limit.rs:23:9 | +LL | enum $id { $id($t) } + | -- required by this field +... LL | link! { I, J } | ^ note: required because it appears within the type `H` --> $DIR/recursion_limit.rs:22:9 | +LL | enum $id { $id($t) } + | -- required by this field +... LL | link! { H, I } | ^ note: required because it appears within the type `G` --> $DIR/recursion_limit.rs:21:9 | +LL | enum $id { $id($t) } + | -- required by this field +... LL | link! { G, H } | ^ note: required because it appears within the type `F` --> $DIR/recursion_limit.rs:20:9 | +LL | enum $id { $id($t) } + | -- required by this field +... LL | link! { F, G } | ^ note: required because it appears within the type `E` --> $DIR/recursion_limit.rs:19:9 | +LL | enum $id { $id($t) } + | -- required by this field +... LL | link! { E, F } | ^ note: required because it appears within the type `D` --> $DIR/recursion_limit.rs:18:9 | +LL | enum $id { $id($t) } + | -- required by this field +... LL | link! { D, E } | ^ note: required because it appears within the type `C` --> $DIR/recursion_limit.rs:17:9 | +LL | enum $id { $id($t) } + | -- required by this field +... LL | link! { C, D } | ^ note: required because it appears within the type `B` --> $DIR/recursion_limit.rs:16:9 | +LL | enum $id { $id($t) } + | -- required by this field +... LL | link! { B, C } | ^ note: required because it appears within the type `A` --> $DIR/recursion_limit.rs:15:9 | +LL | enum $id { $id($t) } + | -- required by this field +... LL | link! { A, B } | ^ note: required by a bound in `is_send` diff --git a/tests/ui/dst/dst-bad-deep-2.stderr b/tests/ui/dst/dst-bad-deep-2.stderr index de3f71d206fb4..790e6dff9b5ef 100644 --- a/tests/ui/dst/dst-bad-deep-2.stderr +++ b/tests/ui/dst/dst-bad-deep-2.stderr @@ -9,7 +9,7 @@ note: required because it appears within the type `Fat<[isize]>` --> $DIR/dst-bad-deep-2.rs:6:8 | LL | struct Fat(T); - | ^^^ + | ^^^ - required by this field = note: all function arguments must have a statically known size = help: unsized fn params are gated as an unstable feature diff --git a/tests/ui/dst/dst-bad-deep.stderr b/tests/ui/dst/dst-bad-deep.stderr index 1b0f9738ab09a..bf9baa8e7e3c9 100644 --- a/tests/ui/dst/dst-bad-deep.stderr +++ b/tests/ui/dst/dst-bad-deep.stderr @@ -10,6 +10,8 @@ note: required because it appears within the type `Fat<[isize]>` | LL | struct Fat { | ^^^ +LL | ptr: T + | ------ required by this field = note: structs must have a statically known size to be initialized error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0277-2.stderr b/tests/ui/error-codes/E0277-2.stderr index 9a262f7559075..9cf2d5c4fcc65 100644 --- a/tests/ui/error-codes/E0277-2.stderr +++ b/tests/ui/error-codes/E0277-2.stderr @@ -10,16 +10,22 @@ note: required because it appears within the type `Baz` | LL | struct Baz { | ^^^ +LL | x: *const u8 + | ------------ required by this field note: required because it appears within the type `Bar` --> $DIR/E0277-2.rs:5:8 | LL | struct Bar { | ^^^ +LL | baz: Baz + | -------- required by this field note: required because it appears within the type `Foo` --> $DIR/E0277-2.rs:1:8 | LL | struct Foo { | ^^^ +LL | bar: Bar + | -------- required by this field note: required by a bound in `is_send` --> $DIR/E0277-2.rs:13:15 | diff --git a/tests/ui/extern/extern-types-unsized.stderr b/tests/ui/extern/extern-types-unsized.stderr index 6c1d7a7b61b3c..c4c919cd646b4 100644 --- a/tests/ui/extern/extern-types-unsized.stderr +++ b/tests/ui/extern/extern-types-unsized.stderr @@ -27,6 +27,9 @@ note: required because it appears within the type `Foo` | LL | struct Foo { | ^^^ +LL | x: u8, +LL | tail: A, + | ------- required by this field note: required by an implicit `Sized` bound in `assert_sized` --> $DIR/extern-types-unsized.rs:19:17 | @@ -49,6 +52,9 @@ note: required because it appears within the type `Bar` | LL | struct Bar { | ^^^ +LL | x: u8, +LL | tail: T, + | ------- required by this field note: required by an implicit `Sized` bound in `assert_sized` --> $DIR/extern-types-unsized.rs:19:17 | @@ -84,6 +90,9 @@ note: required because it appears within the type `Bar` | LL | struct Bar { | ^^^ +LL | x: u8, +LL | tail: T, + | ------- required by this field note: required by an implicit `Sized` bound in `assert_sized` --> $DIR/extern-types-unsized.rs:19:17 | diff --git a/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.avr.stderr b/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.avr.stderr index df7697845814e..e37d96a01e3b4 100644 --- a/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.avr.stderr +++ b/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.avr.stderr @@ -1,5 +1,5 @@ error[E0658]: C-variadic function definitions on this target are unstable - --> $DIR/feature-gate-c_variadic_experimental_arch.rs:39:39 + --> $DIR/feature-gate-c_variadic_experimental_arch.rs:28:39 | LL | pub unsafe extern "C" fn test(_: i32, ap: ...) {} | ^^^^^^^ @@ -9,7 +9,7 @@ LL | pub unsafe extern "C" fn test(_: i32, ap: ...) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: C-variadic function definitions on this target are unstable - --> $DIR/feature-gate-c_variadic_experimental_arch.rs:43:45 + --> $DIR/feature-gate-c_variadic_experimental_arch.rs:32:45 | LL | unsafe extern "C" fn trait_test(_: i32, ap: ...) {} | ^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.m68k.stderr b/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.m68k.stderr index df7697845814e..e37d96a01e3b4 100644 --- a/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.m68k.stderr +++ b/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.m68k.stderr @@ -1,5 +1,5 @@ error[E0658]: C-variadic function definitions on this target are unstable - --> $DIR/feature-gate-c_variadic_experimental_arch.rs:39:39 + --> $DIR/feature-gate-c_variadic_experimental_arch.rs:28:39 | LL | pub unsafe extern "C" fn test(_: i32, ap: ...) {} | ^^^^^^^ @@ -9,7 +9,7 @@ LL | pub unsafe extern "C" fn test(_: i32, ap: ...) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: C-variadic function definitions on this target are unstable - --> $DIR/feature-gate-c_variadic_experimental_arch.rs:43:45 + --> $DIR/feature-gate-c_variadic_experimental_arch.rs:32:45 | LL | unsafe extern "C" fn trait_test(_: i32, ap: ...) {} | ^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.msp430.stderr b/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.msp430.stderr index df7697845814e..e37d96a01e3b4 100644 --- a/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.msp430.stderr +++ b/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.msp430.stderr @@ -1,5 +1,5 @@ error[E0658]: C-variadic function definitions on this target are unstable - --> $DIR/feature-gate-c_variadic_experimental_arch.rs:39:39 + --> $DIR/feature-gate-c_variadic_experimental_arch.rs:28:39 | LL | pub unsafe extern "C" fn test(_: i32, ap: ...) {} | ^^^^^^^ @@ -9,7 +9,7 @@ LL | pub unsafe extern "C" fn test(_: i32, ap: ...) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: C-variadic function definitions on this target are unstable - --> $DIR/feature-gate-c_variadic_experimental_arch.rs:43:45 + --> $DIR/feature-gate-c_variadic_experimental_arch.rs:32:45 | LL | unsafe extern "C" fn trait_test(_: i32, ap: ...) {} | ^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.riscv32e.stderr b/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.riscv32e.stderr index df7697845814e..e37d96a01e3b4 100644 --- a/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.riscv32e.stderr +++ b/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.riscv32e.stderr @@ -1,5 +1,5 @@ error[E0658]: C-variadic function definitions on this target are unstable - --> $DIR/feature-gate-c_variadic_experimental_arch.rs:39:39 + --> $DIR/feature-gate-c_variadic_experimental_arch.rs:28:39 | LL | pub unsafe extern "C" fn test(_: i32, ap: ...) {} | ^^^^^^^ @@ -9,7 +9,7 @@ LL | pub unsafe extern "C" fn test(_: i32, ap: ...) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: C-variadic function definitions on this target are unstable - --> $DIR/feature-gate-c_variadic_experimental_arch.rs:43:45 + --> $DIR/feature-gate-c_variadic_experimental_arch.rs:32:45 | LL | unsafe extern "C" fn trait_test(_: i32, ap: ...) {} | ^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.rs b/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.rs index 49c0bdf3a724b..7d189927bd73d 100644 --- a/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.rs +++ b/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.rs @@ -22,20 +22,9 @@ #![no_core] extern crate minicore; +use minicore::ffi::VaList; use minicore::*; -#[repr(transparent)] -struct VaListInner { - ptr: *const c_void, -} - -#[repr(transparent)] -#[lang = "va_list"] -pub struct VaList<'a> { - inner: VaListInner, - _marker: PhantomData<&'a mut ()>, -} - pub unsafe extern "C" fn test(_: i32, ap: ...) {} //~^ ERROR C-variadic function definitions on this target are unstable diff --git a/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.sparc.stderr b/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.sparc.stderr index df7697845814e..e37d96a01e3b4 100644 --- a/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.sparc.stderr +++ b/tests/ui/feature-gates/feature-gate-c_variadic_experimental_arch.sparc.stderr @@ -1,5 +1,5 @@ error[E0658]: C-variadic function definitions on this target are unstable - --> $DIR/feature-gate-c_variadic_experimental_arch.rs:39:39 + --> $DIR/feature-gate-c_variadic_experimental_arch.rs:28:39 | LL | pub unsafe extern "C" fn test(_: i32, ap: ...) {} | ^^^^^^^ @@ -9,7 +9,7 @@ LL | pub unsafe extern "C" fn test(_: i32, ap: ...) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: C-variadic function definitions on this target are unstable - --> $DIR/feature-gate-c_variadic_experimental_arch.rs:43:45 + --> $DIR/feature-gate-c_variadic_experimental_arch.rs:32:45 | LL | unsafe extern "C" fn trait_test(_: i32, ap: ...) {} | ^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-offset-of-slice.stderr b/tests/ui/feature-gates/feature-gate-offset-of-slice.stderr index 83b0acf88bdb5..4ac4472b78e0e 100644 --- a/tests/ui/feature-gates/feature-gate-offset-of-slice.stderr +++ b/tests/ui/feature-gates/feature-gate-offset-of-slice.stderr @@ -18,6 +18,9 @@ note: required because it appears within the type `S` | LL | struct S { | ^ +... +LL | c: [i32], + | -------- required by this field error[E0277]: the size for values of type `[i32]` cannot be known at compilation time --> $DIR/feature-gate-offset-of-slice.rs:25:5 diff --git a/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr b/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr index e9bee1597c5cd..76695064dec16 100644 --- a/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr +++ b/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr @@ -141,6 +141,8 @@ note: required because it appears within the type `Dst<(dyn A + 'static)>` | LL | struct Dst { | ^^^ +LL | x: X, + | ---- required by this field help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] diff --git a/tests/ui/generic-associated-types/bugs/hrtb-implied-2.stderr b/tests/ui/generic-associated-types/bugs/hrtb-implied-2.stderr index 1a397f6cdb21a..2c827725bd4cc 100644 --- a/tests/ui/generic-associated-types/bugs/hrtb-implied-2.stderr +++ b/tests/ui/generic-associated-types/bugs/hrtb-implied-2.stderr @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of function LL | fn fails(iter: &mut I, f: F) -> bool | ---- - let's call the lifetime of this reference `'1` | | - | `iter` is a reference that is only valid in the function body + | `iter` is only valid in the function body ... LL | let _next = iter2.next(); | ^^^^^^^^^^^^ diff --git a/tests/ui/generic-associated-types/bugs/hrtb-implied-3.stderr b/tests/ui/generic-associated-types/bugs/hrtb-implied-3.stderr index aaafcb3b7afb4..3c147130925ca 100644 --- a/tests/ui/generic-associated-types/bugs/hrtb-implied-3.stderr +++ b/tests/ui/generic-associated-types/bugs/hrtb-implied-3.stderr @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of function LL | fn fails(iter: &str) { | ---- - let's call the lifetime of this reference `'1` | | - | `iter` is a reference that is only valid in the function body + | `iter` is only valid in the function body LL | trivial_bound(iter); | ^^^^^^^^^^^^^^^^^^^ | | diff --git a/tests/ui/impl-header-lifetime-elision/dyn-trait.stderr b/tests/ui/impl-header-lifetime-elision/dyn-trait.stderr index 2ef35a377e2fc..416e5bedf1a24 100644 --- a/tests/ui/impl-header-lifetime-elision/dyn-trait.stderr +++ b/tests/ui/impl-header-lifetime-elision/dyn-trait.stderr @@ -2,7 +2,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/dyn-trait.rs:24:5 | LL | fn with_dyn_debug_static<'a>(x: Box) { - | -- - `x` is a reference that is only valid in the function body + | -- - `x` is only valid in the function body | | | lifetime `'a` defined here LL | static_val(x); diff --git a/tests/ui/impl-trait/higher-order-assoc-issue-129372.rs b/tests/ui/impl-trait/higher-order-assoc-issue-129372.rs new file mode 100644 index 0000000000000..5fc7c2814c849 --- /dev/null +++ b/tests/ui/impl-trait/higher-order-assoc-issue-129372.rs @@ -0,0 +1,58 @@ +//@ edition: 2021 +//@ revisions: current next +//@ [next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ check-pass + +// Regression test for . +// Used to ICE + +pub struct Wrapper(T); +struct Struct; + +pub trait TraitA { + type AssocA<'t>; +} +pub trait TraitB { + type AssocB; +} + +pub fn helper(v: impl MethodTrait) { + let _local_that_causes_ice = v.method(); +} + +pub fn main() { + helper(Wrapper(Struct)); +} + +pub trait MethodTrait { + type Assoc<'a>; + + fn method(self) -> impl for<'a> FnMut(&'a ()) -> Self::Assoc<'a>; +} + +impl MethodTrait for T +where + ::AssocB: TraitA, +{ + type Assoc<'a> = ::AssocA<'a>; + + fn method(self) -> impl for<'a> FnMut(&'a ()) -> Self::Assoc<'a> { + move |_| loop {} + } +} + +impl TraitB for Wrapper +where + B: TraitB, +{ + type AssocB = T; +} + +impl TraitB for Struct { + type AssocB = Struct; +} + +impl TraitA for Struct { + type AssocA<'t> = Self; +} diff --git a/tests/ui/impl-trait/opaque-closure-field-capture-issue-155151.rs b/tests/ui/impl-trait/opaque-closure-field-capture-issue-155151.rs new file mode 100644 index 0000000000000..6c5787102e8ad --- /dev/null +++ b/tests/ui/impl-trait/opaque-closure-field-capture-issue-155151.rs @@ -0,0 +1,25 @@ +//@ revisions: current next +//@ [next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ check-pass + +// Regression test for . +// Used to say binding `x` isn't initialized + +pub fn wut() -> impl Sized { + struct Foo { + x: u32, + } + + if false { + let foo = wut(); + let _closure = move || { + let Foo { x } = foo; + let _y = x; + }; + } + + Foo { x: 7 } +} + +fn main() {} diff --git a/tests/ui/label/label_misspelled.stderr b/tests/ui/label/label_misspelled.stderr index 9f9d32dce6b5d..95ec9beeddc4d 100644 --- a/tests/ui/label/label_misspelled.stderr +++ b/tests/ui/label/label_misspelled.stderr @@ -40,10 +40,12 @@ error[E0425]: cannot find value `LOOP` in this scope LL | 'LOOP: loop { | ----- a label with a similar name exists LL | break LOOP; - | ^^^^ - | | - | not found in this scope - | help: use the similarly named label: `'LOOP` + | ^^^^ not found in this scope + | +help: use the similarly named label + | +LL | break 'LOOP; + | + error[E0425]: cannot find value `while_loop` in this scope --> $DIR/label_misspelled.rs:32:15 @@ -51,10 +53,12 @@ error[E0425]: cannot find value `while_loop` in this scope LL | 'while_loop: while true { | ----------- a label with a similar name exists LL | break while_loop; - | ^^^^^^^^^^ - | | - | not found in this scope - | help: use the similarly named label: `'while_loop` + | ^^^^^^^^^^ not found in this scope + | +help: use the similarly named label + | +LL | break 'while_loop; + | + error[E0425]: cannot find value `while_let` in this scope --> $DIR/label_misspelled.rs:36:15 @@ -62,10 +66,12 @@ error[E0425]: cannot find value `while_let` in this scope LL | 'while_let: while let Some(_) = Some(()) { | ---------- a label with a similar name exists LL | break while_let; - | ^^^^^^^^^ - | | - | not found in this scope - | help: use the similarly named label: `'while_let` + | ^^^^^^^^^ not found in this scope + | +help: use the similarly named label + | +LL | break 'while_let; + | + error[E0425]: cannot find value `for_loop` in this scope --> $DIR/label_misspelled.rs:40:15 @@ -73,10 +79,12 @@ error[E0425]: cannot find value `for_loop` in this scope LL | 'for_loop: for _ in 0..3 { | --------- a label with a similar name exists LL | break for_loop; - | ^^^^^^^^ - | | - | not found in this scope - | help: use the similarly named label: `'for_loop` + | ^^^^^^^^ not found in this scope + | +help: use the similarly named label + | +LL | break 'for_loop; + | + warning: denote infinite loops with `loop { ... }` --> $DIR/label_misspelled.rs:4:5 diff --git a/tests/ui/label/label_misspelled_2.stderr b/tests/ui/label/label_misspelled_2.stderr index 10b0e7b4e0888..e11e4056d80e2 100644 --- a/tests/ui/label/label_misspelled_2.stderr +++ b/tests/ui/label/label_misspelled_2.stderr @@ -26,10 +26,12 @@ error[E0425]: cannot find value `b` in this scope LL | 'b: for _ in 0..1 { | -- a label with a similar name exists LL | break b; - | ^ - | | - | not found in this scope - | help: use the similarly named label: `'b` + | ^ not found in this scope + | +help: use the similarly named label + | +LL | break 'b; + | + error[E0425]: cannot find value `d` in this scope --> $DIR/label_misspelled_2.rs:14:15 @@ -37,10 +39,12 @@ error[E0425]: cannot find value `d` in this scope LL | d: for _ in 0..1 { | - a label with a similar name exists LL | break d; - | ^ - | | - | not found in this scope - | help: use the similarly named label: `'d` + | ^ not found in this scope + | +help: use the similarly named label + | +LL | break 'd; + | + error: aborting due to 4 previous errors diff --git a/tests/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr b/tests/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr index 4df2e906e222f..6fbc14a1cf4f2 100644 --- a/tests/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr +++ b/tests/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr @@ -18,7 +18,7 @@ error[E0521]: borrowed data escapes outside of function LL | fn inner(mut foo: &[u8]) { | ------- - let's call the lifetime of this reference `'1` | | - | `foo` is a reference that is only valid in the function body + | `foo` is only valid in the function body ... LL | read_thing(read); | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lifetimes/lifetime-bound-will-change-warning.stderr b/tests/ui/lifetimes/lifetime-bound-will-change-warning.stderr index c51580f287eee..b28206044b772 100644 --- a/tests/ui/lifetimes/lifetime-bound-will-change-warning.stderr +++ b/tests/ui/lifetimes/lifetime-bound-will-change-warning.stderr @@ -2,7 +2,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/lifetime-bound-will-change-warning.rs:34:5 | LL | fn test2<'a>(x: &'a Box) { - | -- - `x` is a reference that is only valid in the function body + | -- - `x` is only valid in the function body | | | lifetime `'a` defined here LL | // but ref_obj will not, so warn. @@ -16,7 +16,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/lifetime-bound-will-change-warning.rs:40:5 | LL | fn test2cc<'a>(x: &'a Box) { - | -- - `x` is a reference that is only valid in the function body + | -- - `x` is only valid in the function body | | | lifetime `'a` defined here LL | // same as test2, but cross crate diff --git a/tests/ui/lint/non-local-defs/consts.stderr b/tests/ui/lint/non-local-defs/consts.stderr index fc5ce85ac613f..4391b66ff9a4e 100644 --- a/tests/ui/lint/non-local-defs/consts.stderr +++ b/tests/ui/lint/non-local-defs/consts.stderr @@ -2,10 +2,7 @@ warning: non-local `impl` definition, `impl` blocks should be written at the sam --> $DIR/consts.rs:13:5 | LL | const Z: () = { - | ----------- - | | | - | | help: use a const-anon item to suppress this lint: `_` - | move the `impl` block outside of this constant `Z` + | ----------- move the `impl` block outside of this constant `Z` ... LL | impl Uto for &Test {} | ^^^^^---^^^^^^---- @@ -16,6 +13,11 @@ LL | impl Uto for &Test {} = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint = note: `#[warn(non_local_definitions)]` on by default +help: use a const-anon item to suppress this lint + | +LL - const Z: () = { +LL + const _: () = { + | warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item --> $DIR/consts.rs:24:5 diff --git a/tests/ui/lint/recommend-literal.rs b/tests/ui/lint/recommend-literal.rs index 4eae569df130f..93869d8b90a2a 100644 --- a/tests/ui/lint/recommend-literal.rs +++ b/tests/ui/lint/recommend-literal.rs @@ -1,43 +1,43 @@ type Real = double; //~^ ERROR cannot find type `double` in this scope -//~| HELP perhaps you intended to use this type +//~| HELP `f64` primitive type fn main() { let x: Real = 3.5; let y: long = 74802374902374923; //~^ ERROR cannot find type `long` in this scope - //~| HELP perhaps you intended to use this type + //~| HELP `i64` primitive type let v1: Boolean = true; //~^ ERROR: cannot find type `Boolean` in this scope [E0425] - //~| HELP perhaps you intended to use this type + //~| HELP `bool` primitive type let v2: Bool = true; //~^ ERROR: cannot find type `Bool` in this scope [E0425] //~| HELP a builtin type with a similar name exists - //~| HELP perhaps you intended to use this type + //~| HELP `bool` primitive type //~| HELP: there is an enum variant `std::mem::type_info::TypeKind::Bool`; try using the variant's enum } fn z(a: boolean) { //~^ ERROR cannot find type `boolean` in this scope - //~| HELP perhaps you intended to use this type + //~| HELP `bool` primitive type } fn a() -> byte { //~^ ERROR cannot find type `byte` in this scope -//~| HELP perhaps you intended to use this type +//~| HELP `u8` primitive type 3 } struct Data { //~ HELP you might be missing a type parameter width: float, //~^ ERROR cannot find type `float` in this scope - //~| HELP perhaps you intended to use this type + //~| HELP `f32` primitive type depth: Option, //~^ ERROR cannot find type `int` in this scope - //~| HELP perhaps you intended to use this type + //~| HELP `i32` primitive type } trait Stuff {} impl Stuff for short {} //~^ ERROR cannot find type `short` in this scope -//~| HELP perhaps you intended to use this type +//~| HELP `i16` primitive type diff --git a/tests/ui/lint/recommend-literal.stderr b/tests/ui/lint/recommend-literal.stderr index 2dc2259a56742..9dcce3fd381fd 100644 --- a/tests/ui/lint/recommend-literal.stderr +++ b/tests/ui/lint/recommend-literal.stderr @@ -2,28 +2,37 @@ error[E0425]: cannot find type `double` in this scope --> $DIR/recommend-literal.rs:1:13 | LL | type Real = double; - | ^^^^^^ - | | - | not found in this scope - | help: perhaps you intended to use this type: `f64` + | ^^^^^^ not found in this scope + | +help: you might have intended to use the `f64` primitive type + | +LL - type Real = double; +LL + type Real = f64; + | error[E0425]: cannot find type `long` in this scope --> $DIR/recommend-literal.rs:7:12 | LL | let y: long = 74802374902374923; - | ^^^^ - | | - | not found in this scope - | help: perhaps you intended to use this type: `i64` + | ^^^^ not found in this scope + | +help: you might have intended to use the `i64` primitive type + | +LL - let y: long = 74802374902374923; +LL + let y: i64 = 74802374902374923; + | error[E0425]: cannot find type `Boolean` in this scope --> $DIR/recommend-literal.rs:10:13 | LL | let v1: Boolean = true; - | ^^^^^^^ - | | - | not found in this scope - | help: perhaps you intended to use this type: `bool` + | ^^^^^^^ not found in this scope + | +help: you might have intended to use the `bool` primitive type + | +LL - let v1: Boolean = true; +LL + let v1: bool = true; + | error[E0425]: cannot find type `Bool` in this scope --> $DIR/recommend-literal.rs:13:13 @@ -41,7 +50,7 @@ help: a builtin type with a similar name exists LL - let v2: Bool = true; LL + let v2: bool = true; | -help: perhaps you intended to use this type +help: you might have intended to use the `bool` primitive type | LL - let v2: Bool = true; LL + let v2: bool = true; @@ -51,28 +60,37 @@ error[E0425]: cannot find type `boolean` in this scope --> $DIR/recommend-literal.rs:20:9 | LL | fn z(a: boolean) { - | ^^^^^^^ - | | - | not found in this scope - | help: perhaps you intended to use this type: `bool` + | ^^^^^^^ not found in this scope + | +help: you might have intended to use the `bool` primitive type + | +LL - fn z(a: boolean) { +LL + fn z(a: bool) { + | error[E0425]: cannot find type `byte` in this scope --> $DIR/recommend-literal.rs:25:11 | LL | fn a() -> byte { - | ^^^^ - | | - | not found in this scope - | help: perhaps you intended to use this type: `u8` + | ^^^^ not found in this scope + | +help: you might have intended to use the `u8` primitive type + | +LL - fn a() -> byte { +LL + fn a() -> u8 { + | error[E0425]: cannot find type `float` in this scope --> $DIR/recommend-literal.rs:32:12 | LL | width: float, - | ^^^^^ - | | - | not found in this scope - | help: perhaps you intended to use this type: `f32` + | ^^^^^ not found in this scope + | +help: you might have intended to use the `f32` primitive type + | +LL - width: float, +LL + width: f32, + | error[E0425]: cannot find type `int` in this scope --> $DIR/recommend-literal.rs:35:19 @@ -80,7 +98,7 @@ error[E0425]: cannot find type `int` in this scope LL | depth: Option, | ^^^ not found in this scope | -help: perhaps you intended to use this type +help: you might have intended to use the `i32` primitive type | LL - depth: Option, LL + depth: Option, @@ -94,10 +112,13 @@ error[E0425]: cannot find type `short` in this scope --> $DIR/recommend-literal.rs:41:16 | LL | impl Stuff for short {} - | ^^^^^ - | | - | not found in this scope - | help: perhaps you intended to use this type: `i16` + | ^^^^^ not found in this scope + | +help: you might have intended to use the `i16` primitive type + | +LL - impl Stuff for short {} +LL + impl Stuff for i16 {} + | error: aborting due to 9 previous errors diff --git a/tests/ui/loops/loop-break-value.stderr b/tests/ui/loops/loop-break-value.stderr index 432f6be699cbf..e0f49a24f9fd3 100644 --- a/tests/ui/loops/loop-break-value.stderr +++ b/tests/ui/loops/loop-break-value.stderr @@ -22,10 +22,12 @@ error[E0425]: cannot find value `LOOP` in this scope LL | 'LOOP: for _ in 0 .. 9 { | ----- a label with a similar name exists LL | break LOOP; - | ^^^^ - | | - | not found in this scope - | help: use the similarly named label: `'LOOP` + | ^^^^ not found in this scope + | +help: use the similarly named label + | +LL | break 'LOOP; + | + warning: denote infinite loops with `loop { ... }` --> $DIR/loop-break-value.rs:28:5 diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr b/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr index 62e872639671b..ab52f3d3ee43e 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr @@ -45,7 +45,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/closure-arg-type-mismatch.rs:10:5 | LL | fn _test<'a>(f: fn(*mut &'a u32)) { - | -- - `f` is a reference that is only valid in the function body + | -- - `f` is only valid in the function body | | | lifetime `'a` defined here LL | baz(f); diff --git a/tests/ui/mut/mutable-enum-indirect.stderr b/tests/ui/mut/mutable-enum-indirect.stderr index b15492357f5c8..40ece8bce9ab5 100644 --- a/tests/ui/mut/mutable-enum-indirect.stderr +++ b/tests/ui/mut/mutable-enum-indirect.stderr @@ -15,7 +15,7 @@ note: required because it appears within the type `Foo` --> $DIR/mutable-enum-indirect.rs:11:6 | LL | enum Foo { A(NoSync) } - | ^^^ + | ^^^ ------ required by this field = note: required because it appears within the type `&Foo` note: required by a bound in `bar` --> $DIR/mutable-enum-indirect.rs:13:11 diff --git a/tests/ui/nll/check-normalized-sig-for-wf.current.stderr b/tests/ui/nll/check-normalized-sig-for-wf.current.stderr index b25ae72f7fb9a..bbfdf9f8f3336 100644 --- a/tests/ui/nll/check-normalized-sig-for-wf.current.stderr +++ b/tests/ui/nll/check-normalized-sig-for-wf.current.stderr @@ -19,7 +19,7 @@ error[E0521]: borrowed data escapes outside of function LL | fn extend(input: &T) -> &'static T { | ----- - let's call the lifetime of this reference `'1` | | - | `input` is a reference that is only valid in the function body + | `input` is only valid in the function body ... LL | n(input).0 | ^^^^^^^^ @@ -31,7 +31,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/check-normalized-sig-for-wf.rs:27:5 | LL | fn extend_mut<'a, T>(input: &'a mut T) -> &'static mut T { - | -- ----- `input` is a reference that is only valid in the function body + | -- ----- `input` is only valid in the function body | | | lifetime `'a` defined here ... diff --git a/tests/ui/nll/check-normalized-sig-for-wf.next.stderr b/tests/ui/nll/check-normalized-sig-for-wf.next.stderr index b25ae72f7fb9a..bbfdf9f8f3336 100644 --- a/tests/ui/nll/check-normalized-sig-for-wf.next.stderr +++ b/tests/ui/nll/check-normalized-sig-for-wf.next.stderr @@ -19,7 +19,7 @@ error[E0521]: borrowed data escapes outside of function LL | fn extend(input: &T) -> &'static T { | ----- - let's call the lifetime of this reference `'1` | | - | `input` is a reference that is only valid in the function body + | `input` is only valid in the function body ... LL | n(input).0 | ^^^^^^^^ @@ -31,7 +31,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/check-normalized-sig-for-wf.rs:27:5 | LL | fn extend_mut<'a, T>(input: &'a mut T) -> &'static mut T { - | -- ----- `input` is a reference that is only valid in the function body + | -- ----- `input` is only valid in the function body | | | lifetime `'a` defined here ... diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr index f7cbc5b0f68f7..2fe03bff19884 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr @@ -23,7 +23,7 @@ error[E0521]: borrowed data escapes outside of closure --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:22:9 | LL | foo(cell, |cell_a, cell_x| { - | ------ ------ `cell_x` is a reference that is only valid in the closure body + | ------ ------ `cell_x` is only valid in the closure body | | | `cell_a` declared here, outside of the closure body LL | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr index 9e9eae985973a..0a3d22873d0fb 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr @@ -31,7 +31,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:34:9 | LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { - | -- ------ `cell_a` is a reference that is only valid in the function body + | -- ------ `cell_a` is only valid in the function body | | | lifetime `'a` defined here ... diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr index 303fcd4cdfcf3..3035b841d5c60 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr @@ -32,7 +32,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:37:9 | LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { - | -- ------ `cell_a` is a reference that is only valid in the function body + | -- ------ `cell_a` is only valid in the function body | | | lifetime `'a` defined here ... diff --git a/tests/ui/nll/issue-54779-anon-static-lifetime.stderr b/tests/ui/nll/issue-54779-anon-static-lifetime.stderr index 03a5590661422..cc549c34479ca 100644 --- a/tests/ui/nll/issue-54779-anon-static-lifetime.stderr +++ b/tests/ui/nll/issue-54779-anon-static-lifetime.stderr @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of method LL | cx: &dyn DebugContext, | -- - let's call the lifetime of this reference `'1` | | - | `cx` is a reference that is only valid in the method body + | `cx` is only valid in the method body ... LL | bar.debug_with(cx); | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/nll/user-annotations/closure-substs.stderr b/tests/ui/nll/user-annotations/closure-substs.stderr index 1e8de4ba90541..ce37f205f0642 100644 --- a/tests/ui/nll/user-annotations/closure-substs.stderr +++ b/tests/ui/nll/user-annotations/closure-substs.stderr @@ -30,7 +30,7 @@ error[E0521]: borrowed data escapes outside of closure LL | |x: &i32, b: fn(&'static i32)| { | - - let's call the lifetime of this reference `'1` | | - | `x` is a reference that is only valid in the closure body + | `x` is only valid in the closure body LL | b(x); | ^^^^ | | diff --git a/tests/ui/object-lifetime/object-lifetime-default-mybox.stderr b/tests/ui/object-lifetime/object-lifetime-default-mybox.stderr index a1ef0243e3a87..877c578fbd3b7 100644 --- a/tests/ui/object-lifetime/object-lifetime-default-mybox.stderr +++ b/tests/ui/object-lifetime/object-lifetime-default-mybox.stderr @@ -15,7 +15,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/object-lifetime-default-mybox.rs:32:5 | LL | fn load2<'a>(ss: &MyBox) -> MyBox { - | -- -- `ss` is a reference that is only valid in the function body + | -- -- `ss` is only valid in the function body | | | lifetime `'a` defined here LL | load0(ss) diff --git a/tests/ui/offset-of/offset-of-dst-field.stderr b/tests/ui/offset-of/offset-of-dst-field.stderr index 77ae34b0872fa..1bceb3c409177 100644 --- a/tests/ui/offset-of/offset-of-dst-field.stderr +++ b/tests/ui/offset-of/offset-of-dst-field.stderr @@ -58,6 +58,9 @@ note: required because it appears within the type `Alpha` | LL | struct Alpha { | ^^^^^ +... +LL | z: [u8], + | ------- required by this field error[E0277]: the size for values of type `T` cannot be known at compilation time --> $DIR/offset-of-dst-field.rs:51:5 diff --git a/tests/ui/parser/recover/recover-unticked-labels.stderr b/tests/ui/parser/recover/recover-unticked-labels.stderr index 5cf463677af1d..afa3b71bb666c 100644 --- a/tests/ui/parser/recover/recover-unticked-labels.stderr +++ b/tests/ui/parser/recover/recover-unticked-labels.stderr @@ -24,11 +24,14 @@ error[E0425]: cannot find value `label` in this scope --> $DIR/recover-unticked-labels.rs:4:26 | LL | 'label: loop { break label }; - | ------ ^^^^^ - | | | - | | not found in this scope - | | help: use the similarly named label: `'label` + | ------ ^^^^^ not found in this scope + | | | a label with a similar name exists + | +help: use the similarly named label + | +LL | 'label: loop { break 'label }; + | + error: aborting due to 3 previous errors diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2021.stderr index 4fa82a603a8e4..011b0fb819945 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2021.stderr @@ -21,7 +21,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &match_ctor!(y) = &mut &mut [0]; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/mixed-editions.rs:84:17 @@ -29,7 +29,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &[bind!(z)] = &mut &mut [0]; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/mixed-editions.rs:110:28 @@ -43,7 +43,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &bind_ref_mut!(x) = &mut 0; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/mixed-editions.rs:116:29 @@ -57,7 +57,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let [&bind_ref_mut!(x)] = &mut [0]; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error: cannot explicitly borrow within an implicitly-borrowing pattern --> $DIR/mixed-editions.rs:30:10 diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2024.stderr index ee152c2871f4e..3519e79220a2f 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.classic2024.stderr @@ -20,7 +20,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &match_ctor!(y) = &mut &mut [0]; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/mixed-editions.rs:84:17 @@ -28,7 +28,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &[bind!(z)] = &mut &mut [0]; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/mixed-editions.rs:110:28 @@ -42,7 +42,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &bind_ref_mut!(x) = &mut 0; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/mixed-editions.rs:116:29 @@ -56,7 +56,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let [&bind_ref_mut!(x)] = &mut [0]; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error: cannot explicitly borrow within an implicitly-borrowing pattern --> $DIR/mixed-editions.rs:26:21 diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.structural2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.structural2021.stderr index 69ddb0720526e..6d2df9f91dd01 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.structural2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.structural2021.stderr @@ -21,7 +21,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &bind_ref_mut!(x) = &mut 0; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/mixed-editions.rs:116:29 @@ -35,7 +35,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let [&bind_ref_mut!(x)] = &mut [0]; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error: cannot explicitly borrow within an implicitly-borrowing pattern --> $DIR/mixed-editions.rs:30:10 diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.structural2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.structural2024.stderr index bc1fee35a6bb4..4034cf22240bb 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.structural2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mixed-editions.structural2024.stderr @@ -20,7 +20,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &bind_ref_mut!(x) = &mut 0; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/mixed-editions.rs:116:29 @@ -34,7 +34,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let [&bind_ref_mut!(x)] = &mut [0]; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error: cannot explicitly borrow within an implicitly-borrowing pattern --> $DIR/mixed-editions.rs:26:21 diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2021.stderr index 8127ca92e025e..5b0d08b720284 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2021.stderr @@ -4,7 +4,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | if let Some(&Some(ref mut x)) = &mut Some(Some(0)) { | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:22:31 @@ -12,7 +12,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | if let &Some(Some(ref mut x)) = &mut Some(Some(0)) { | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:31:15 @@ -20,7 +20,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &pat!(x) = &mut 0; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:36:19 @@ -28,7 +28,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &(ref mut a, ref mut b) = &mut (true, false); | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:36:30 @@ -36,7 +36,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &(ref mut a, ref mut b) = &mut (true, false); | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:43:11 @@ -44,7 +44,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &[x] = &mut &mut [0]; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error: aborting due to 6 previous errors diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2024.stderr index 8127ca92e025e..5b0d08b720284 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2024.stderr @@ -4,7 +4,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | if let Some(&Some(ref mut x)) = &mut Some(Some(0)) { | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:22:31 @@ -12,7 +12,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | if let &Some(Some(ref mut x)) = &mut Some(Some(0)) { | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:31:15 @@ -20,7 +20,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &pat!(x) = &mut 0; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:36:19 @@ -28,7 +28,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &(ref mut a, ref mut b) = &mut (true, false); | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:36:30 @@ -36,7 +36,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &(ref mut a, ref mut b) = &mut (true, false); | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:43:11 @@ -44,7 +44,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &[x] = &mut &mut [0]; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error: aborting due to 6 previous errors diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2021.stderr index e735cfed2492f..87606f0b1913f 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2021.stderr @@ -4,7 +4,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | if let Some(&Some(ref mut x)) = &mut Some(Some(0)) { | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:22:31 @@ -12,7 +12,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | if let &Some(Some(ref mut x)) = &mut Some(Some(0)) { | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:31:15 @@ -20,7 +20,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &pat!(x) = &mut 0; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:36:19 @@ -28,7 +28,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &(ref mut a, ref mut b) = &mut (true, false); | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:36:30 @@ -36,7 +36,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &(ref mut a, ref mut b) = &mut (true, false); | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error: aborting due to 5 previous errors diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2024.stderr index e735cfed2492f..87606f0b1913f 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2024.stderr @@ -4,7 +4,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | if let Some(&Some(ref mut x)) = &mut Some(Some(0)) { | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:22:31 @@ -12,7 +12,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | if let &Some(Some(ref mut x)) = &mut Some(Some(0)) { | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:31:15 @@ -20,7 +20,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &pat!(x) = &mut 0; | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:36:19 @@ -28,7 +28,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &(ref mut a, ref mut b) = &mut (true, false); | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error[E0596]: cannot borrow as mutable inside an `&` pattern --> $DIR/ref-mut-inside-shared-ref-pat.rs:36:30 @@ -36,7 +36,7 @@ error[E0596]: cannot borrow as mutable inside an `&` pattern LL | let &(ref mut a, ref mut b) = &mut (true, false); | - ^ | | - | help: replace this `&` with `&mut`: `&mut` + | help: replace this `&` with `&mut` error: aborting due to 5 previous errors diff --git a/tests/ui/pin-ergonomics/pin-pattern.stderr b/tests/ui/pin-ergonomics/pin-pattern.stderr index c0e8b2d40c70f..5262de183e749 100644 --- a/tests/ui/pin-ergonomics/pin-pattern.stderr +++ b/tests/ui/pin-ergonomics/pin-pattern.stderr @@ -36,7 +36,7 @@ note: required because it appears within the type `Foo` --> $DIR/pin-pattern.rs:11:8 | LL | struct Foo(T); - | ^^^ + | ^^^ - required by this field help: consider restricting type parameter `T` with trait `Unpin` | LL | fn tuple_ref_pin_mut_pat_and_mut_of_tuple_pin_mut_ty<'a, T: std::marker::Unpin>( diff --git a/tests/ui/recursion/recursive-requirements.stderr b/tests/ui/recursion/recursive-requirements.stderr index bb63f7cd0dce0..d4197eded7d28 100644 --- a/tests/ui/recursion/recursive-requirements.stderr +++ b/tests/ui/recursion/recursive-requirements.stderr @@ -10,6 +10,8 @@ note: required because it appears within the type `Foo` | LL | pub struct Foo { | ^^^ +LL | bar: *const Bar, + | --------------- required by this field note: required by a bound in `AssertSync` --> $DIR/recursive-requirements.rs:3:22 | @@ -28,6 +30,8 @@ note: required because it appears within the type `Bar` | LL | pub struct Bar { | ^^^ +LL | foo: *const Foo, + | --------------- required by this field note: required because it appears within the type `PhantomData` --> $SRC_DIR/core/src/marker.rs:LL:COL note: required because it appears within the type `Foo` @@ -35,6 +39,9 @@ note: required because it appears within the type `Foo` | LL | pub struct Foo { | ^^^ +LL | bar: *const Bar, +LL | phantom: PhantomData, + | ------------------------- required by this field note: required by a bound in `AssertSync` --> $DIR/recursive-requirements.rs:3:22 | diff --git a/tests/ui/regions/issue-78262.base.stderr b/tests/ui/regions/issue-78262.base.stderr index 113c84c656287..472d46ef93644 100644 --- a/tests/ui/regions/issue-78262.base.stderr +++ b/tests/ui/regions/issue-78262.base.stderr @@ -7,7 +7,7 @@ LL | let f = |x: &dyn TT| x.func(); | | | `x` escapes the closure body here | | | argument requires that `'1` must outlive `'static` | | let's call the lifetime of this reference `'1` - | `x` is a reference that is only valid in the closure body + | `x` is only valid in the closure body error: aborting due to 1 previous error diff --git a/tests/ui/regions/issue-78262.polonius.stderr b/tests/ui/regions/issue-78262.polonius.stderr index 113c84c656287..472d46ef93644 100644 --- a/tests/ui/regions/issue-78262.polonius.stderr +++ b/tests/ui/regions/issue-78262.polonius.stderr @@ -7,7 +7,7 @@ LL | let f = |x: &dyn TT| x.func(); | | | `x` escapes the closure body here | | | argument requires that `'1` must outlive `'static` | | let's call the lifetime of this reference `'1` - | `x` is a reference that is only valid in the closure body + | `x` is only valid in the closure body error: aborting due to 1 previous error diff --git a/tests/ui/regions/regions-nested-fns.stderr b/tests/ui/regions/regions-nested-fns.stderr index a911ecf51dc89..42c59fc38a2c7 100644 --- a/tests/ui/regions/regions-nested-fns.stderr +++ b/tests/ui/regions/regions-nested-fns.stderr @@ -37,7 +37,7 @@ LL | let mut ay = &y; | ------ `ay` declared here, outside of the closure body ... LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { - | - `z` is a reference that is only valid in the closure body + | - `z` is only valid in the closure body ... LL | ay = z; | ^^^^^^ `z` escapes the closure body here diff --git a/tests/ui/regions/regions-static-bound.stderr b/tests/ui/regions/regions-static-bound.stderr index 48aa8f323291d..df31a17ecf113 100644 --- a/tests/ui/regions/regions-static-bound.stderr +++ b/tests/ui/regions/regions-static-bound.stderr @@ -55,7 +55,7 @@ error[E0521]: borrowed data escapes outside of function LL | fn error(u: &(), v: &()) { | - - let's call the lifetime of this reference `'1` | | - | `u` is a reference that is only valid in the function body + | `u` is only valid in the function body LL | static_id(&u); | ^^^^^^^^^^^^^ | | @@ -68,7 +68,7 @@ error[E0521]: borrowed data escapes outside of function LL | fn error(u: &(), v: &()) { | - - let's call the lifetime of this reference `'2` | | - | `v` is a reference that is only valid in the function body + | `v` is only valid in the function body ... LL | static_id_indirect(&v); | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/sized-hierarchy/impls.stderr b/tests/ui/sized-hierarchy/impls.stderr index 25c6c933149fd..1e0f234ce19a4 100644 --- a/tests/ui/sized-hierarchy/impls.stderr +++ b/tests/ui/sized-hierarchy/impls.stderr @@ -292,7 +292,9 @@ note: required because it appears within the type `StructAllFieldsMetaSized` --> $DIR/impls.rs:235:12 | LL | struct StructAllFieldsMetaSized { x: [u8], y: [u8] } - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ ------- ------- required by this field + | | + | required by this field note: required by a bound in `needs_sized` --> $DIR/impls.rs:13:19 | @@ -310,7 +312,9 @@ note: required because it appears within the type `StructAllFieldsUnsized` --> $DIR/impls.rs:243:12 | LL | struct StructAllFieldsUnsized { x: Foo, y: Foo } - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ ------ ------ required by this field + | | + | required by this field note: required by a bound in `needs_sized` --> $DIR/impls.rs:13:19 | @@ -328,7 +332,9 @@ note: required because it appears within the type `StructAllFieldsUnsized` --> $DIR/impls.rs:243:12 | LL | struct StructAllFieldsUnsized { x: Foo, y: Foo } - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ ------ ------ required by this field + | | + | required by this field note: required by a bound in `needs_metasized` --> $DIR/impls.rs:16:23 | @@ -346,7 +352,7 @@ note: required because it appears within the type `StructLastFieldMetaSized` --> $DIR/impls.rs:252:12 | LL | struct StructLastFieldMetaSized { x: u32, y: [u8] } - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ ------- required by this field note: required by a bound in `needs_sized` --> $DIR/impls.rs:13:19 | @@ -364,7 +370,7 @@ note: required because it appears within the type `StructLastFieldUnsized` --> $DIR/impls.rs:259:12 | LL | struct StructLastFieldUnsized { x: u32, y: Foo } - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ ------ required by this field note: required by a bound in `needs_sized` --> $DIR/impls.rs:13:19 | @@ -382,7 +388,7 @@ note: required because it appears within the type `StructLastFieldUnsized` --> $DIR/impls.rs:259:12 | LL | struct StructLastFieldUnsized { x: u32, y: Foo } - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ ------ required by this field note: required by a bound in `needs_metasized` --> $DIR/impls.rs:16:23 | diff --git a/tests/ui/statics/unsized_type2.stderr b/tests/ui/statics/unsized_type2.stderr index 293df7554e99f..5bccabf0bc133 100644 --- a/tests/ui/statics/unsized_type2.stderr +++ b/tests/ui/statics/unsized_type2.stderr @@ -10,6 +10,8 @@ note: required because it appears within the type `Foo` | LL | pub struct Foo { | ^^^ +LL | pub version: str, + | ---------------- required by this field = note: statics and constants must have a statically known size error[E0308]: mismatched types @@ -30,6 +32,8 @@ note: required because it appears within the type `Foo` | LL | pub struct Foo { | ^^^ +LL | pub version: str, + | ---------------- required by this field = note: structs must have a statically known size to be initialized error: aborting due to 3 previous errors diff --git a/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr b/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr index e231d57a26d91..1467de675be56 100644 --- a/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr +++ b/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr @@ -34,6 +34,8 @@ note: required because it appears within the type `Lint` | LL | pub struct Lint { | ^^^^ +LL | pub desc: &'static dyn Qux, + | -------------------------- required by this field = note: required because it appears within the type `&'static Lint` = note: shared static variables must have a type that implements `Sync` diff --git a/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr b/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr index 505765d2b41f6..be6fbbaa573f4 100644 --- a/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr +++ b/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr @@ -29,7 +29,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:66:9 | LL | fn use_it<'a>(val: Box + 'a>) -> &'a () { - | -- --- `val` is a reference that is only valid in the function body + | -- --- `val` is only valid in the function body | | | lifetime `'a` defined here LL | val.use_self() diff --git a/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr b/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr index 6effaf61099ec..8ef1b052384c6 100644 --- a/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr +++ b/tests/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr @@ -2,7 +2,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:21:9 | LL | fn use_it<'a, T>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { - | -- --- `val` is a reference that is only valid in the function body + | -- --- `val` is only valid in the function body | | | lifetime `'a` defined here LL | val.use_self::() @@ -27,7 +27,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:72:9 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { - | -- --- `val` is a reference that is only valid in the function body + | -- --- `val` is only valid in the function body | | | lifetime `'a` defined here LL | val.use_self() @@ -52,7 +52,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:92:9 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> { - | -- --- `val` is a reference that is only valid in the function body + | -- --- `val` is only valid in the function body | | | lifetime `'a` defined here LL | val.use_self() @@ -78,7 +78,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:112:9 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { - | -- --- `val` is a reference that is only valid in the function body + | -- --- `val` is only valid in the function body | | | lifetime `'a` defined here LL | MyTrait::use_self(val) @@ -104,7 +104,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:38:9 | LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () { - | -- --- `val` is a reference that is only valid in the function body + | -- --- `val` is only valid in the function body | | | lifetime `'a` defined here LL | val.use_self() @@ -129,7 +129,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:56:9 | LL | fn use_it<'a>(val: &'a Box) -> &'a () { - | -- --- `val` is a reference that is only valid in the function body + | -- --- `val` is only valid in the function body | | | lifetime `'a` defined here LL | val.use_self() diff --git a/tests/ui/suggestions/suggest-pin-macro.stderr b/tests/ui/suggestions/suggest-pin-macro.stderr index a761a454ad5a3..c1877fae753c8 100644 --- a/tests/ui/suggestions/suggest-pin-macro.stderr +++ b/tests/ui/suggestions/suggest-pin-macro.stderr @@ -11,6 +11,8 @@ note: required because it appears within the type `Test` | LL | struct Test { | ^^^^ +LL | _marker: PhantomPinned, + | ---------------------- required by this field note: required by a bound in `Pin::<&'a mut T>::get_mut` --> $SRC_DIR/core/src/pin.rs:LL:COL diff --git a/tests/ui/threads-sendsync/rc-is-not-send.stderr b/tests/ui/threads-sendsync/rc-is-not-send.stderr index 28a74d89def6c..03e4b582cd0eb 100644 --- a/tests/ui/threads-sendsync/rc-is-not-send.stderr +++ b/tests/ui/threads-sendsync/rc-is-not-send.stderr @@ -18,12 +18,14 @@ note: required because it appears within the type `Port<()>` --> $DIR/rc-is-not-send.rs:7:8 | LL | struct Port(Rc); - | ^^^^ + | ^^^^ ----- required by this field note: required because it appears within the type `Foo` --> $DIR/rc-is-not-send.rs:10:8 | LL | struct Foo { | ^^^ +LL | _x: Port<()>, + | ------------ required by this field note: required because `x` is used within this closure --> $DIR/rc-is-not-send.rs:27:17 | diff --git a/tests/ui/trait-bounds/deep-level-send-bound-check-issue-40827.stderr b/tests/ui/trait-bounds/deep-level-send-bound-check-issue-40827.stderr index 3776c355318d0..bd4cabc78c990 100644 --- a/tests/ui/trait-bounds/deep-level-send-bound-check-issue-40827.stderr +++ b/tests/ui/trait-bounds/deep-level-send-bound-check-issue-40827.stderr @@ -12,12 +12,14 @@ note: required because it appears within the type `Bar` | LL | enum Bar { | ^^^ +LL | A(Rc), + | ------- required by this field = note: required for `Arc` to implement `Send` note: required because it appears within the type `Foo` --> $DIR/deep-level-send-bound-check-issue-40827.rs:4:8 | LL | struct Foo(Arc); - | ^^^ + | ^^^ -------- required by this field note: required by a bound in `f` --> $DIR/deep-level-send-bound-check-issue-40827.rs:11:9 | @@ -38,12 +40,14 @@ note: required because it appears within the type `Bar` | LL | enum Bar { | ^^^ +LL | A(Rc), + | ------- required by this field = note: required for `Arc` to implement `Send` note: required because it appears within the type `Foo` --> $DIR/deep-level-send-bound-check-issue-40827.rs:4:8 | LL | struct Foo(Arc); - | ^^^ + | ^^^ -------- required by this field note: required by a bound in `f` --> $DIR/deep-level-send-bound-check-issue-40827.rs:11:9 | diff --git a/tests/ui/traits/alloc-crash-issue-155092.current.stderr b/tests/ui/traits/alloc-crash-issue-155092.current.stderr new file mode 100644 index 0000000000000..4638772f06da0 --- /dev/null +++ b/tests/ui/traits/alloc-crash-issue-155092.current.stderr @@ -0,0 +1,20 @@ +error[E0283]: type annotations needed + --> $DIR/alloc-crash-issue-155092.rs:19:5 + | +LL | T::a(); + | ^^^^ cannot infer type of the type parameter `T` declared on the associated function `a` + | + = note: the type must implement `TraitItem` +note: required by a bound in `Trait::a` + --> $DIR/alloc-crash-issue-155092.rs:14:13 + | +LL | fn a() -> as TraitInner>::Encoder { + | ^^^^^^^^^ required by this bound in `Trait::a` +help: consider specifying a concrete type for the type parameter `T` + | +LL | T::a::(); + | ++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/traits/alloc-crash-issue-155092.next.stderr b/tests/ui/traits/alloc-crash-issue-155092.next.stderr new file mode 100644 index 0000000000000..4638772f06da0 --- /dev/null +++ b/tests/ui/traits/alloc-crash-issue-155092.next.stderr @@ -0,0 +1,20 @@ +error[E0283]: type annotations needed + --> $DIR/alloc-crash-issue-155092.rs:19:5 + | +LL | T::a(); + | ^^^^ cannot infer type of the type parameter `T` declared on the associated function `a` + | + = note: the type must implement `TraitItem` +note: required by a bound in `Trait::a` + --> $DIR/alloc-crash-issue-155092.rs:14:13 + | +LL | fn a() -> as TraitInner>::Encoder { + | ^^^^^^^^^ required by this bound in `Trait::a` +help: consider specifying a concrete type for the type parameter `T` + | +LL | T::a::(); + | ++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/traits/alloc-crash-issue-155092.rs b/tests/ui/traits/alloc-crash-issue-155092.rs new file mode 100644 index 0000000000000..6ec885a29946a --- /dev/null +++ b/tests/ui/traits/alloc-crash-issue-155092.rs @@ -0,0 +1,23 @@ +//@ revisions: current next +//@ [next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) + +// Regression test for . +// Used to crash + +pub trait TraitItem {} +pub trait TraitInner { + type Encoder; +} +trait Trait { + type X: TraitInner; + fn a() -> as TraitInner>::Encoder { + todo!() + } +} +fn a() { + T::a(); + //~^ ERROR type annotations needed +} + +fn main() {} diff --git a/tests/ui/traits/cycle-cache-err-60010.stderr b/tests/ui/traits/cycle-cache-err-60010.stderr index 9665d5badf599..e7aba17e060c3 100644 --- a/tests/ui/traits/cycle-cache-err-60010.stderr +++ b/tests/ui/traits/cycle-cache-err-60010.stderr @@ -20,6 +20,8 @@ note: required because it appears within the type `RootDatabase` | LL | struct RootDatabase { | ^^^^^^^^^^^^ +LL | _runtime: Runtime, + | ------------------------------- required by this field note: required for `RootDatabase` to implement `SourceDatabase` --> $DIR/cycle-cache-err-60010.rs:43:9 | @@ -59,6 +61,8 @@ note: required because it appears within the type `RootDatabase` | LL | struct RootDatabase { | ^^^^^^^^^^^^ +LL | _runtime: Runtime, + | ------------------------------- required by this field note: required for `RootDatabase` to implement `SourceDatabase` --> $DIR/cycle-cache-err-60010.rs:43:9 | diff --git a/tests/ui/traits/cycle-typecheck-issue-146813.rs b/tests/ui/traits/cycle-typecheck-issue-146813.rs new file mode 100644 index 0000000000000..7bfcbf6d984b9 --- /dev/null +++ b/tests/ui/traits/cycle-typecheck-issue-146813.rs @@ -0,0 +1,41 @@ +//@ edition: 2021 +//@ revisions: current next +//@ [next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ check-pass + +// Regression test for . +// Used to detect cycle when type-checking `fails` + +use std::future::Future; + +trait ConnectMiddleware {} + +trait ConnectHandler: Sized { + fn with(self, _: M) -> impl ConnectHandler + where + M: ConnectMiddleware, + { + LayeredConnectHandler + } +} + +struct LayeredConnectHandler; +impl ConnectHandler for LayeredConnectHandler {} +impl ConnectHandler for F where F: FnOnce() {} + +impl ConnectMiddleware for F +where + F: FnOnce() -> Fut, + Fut: Future + Send, +{ +} + +pub async fn fails() { + { || {} } + .with(async || ()) + .with(async || ()) + .with(async || ()); +} + +fn main() {} diff --git a/tests/ui/traits/duplicated-hrtb-hang-issue-142832.current.stderr b/tests/ui/traits/duplicated-hrtb-hang-issue-142832.current.stderr new file mode 100644 index 0000000000000..d6dec1bb854c1 --- /dev/null +++ b/tests/ui/traits/duplicated-hrtb-hang-issue-142832.current.stderr @@ -0,0 +1,9 @@ +error[E0275]: overflow evaluating whether `W<_>` is well-formed + --> $DIR/duplicated-hrtb-hang-issue-142832.rs:16:12 + | +LL | func::>(); + | ^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/duplicated-hrtb-hang-issue-142832.next.stderr b/tests/ui/traits/duplicated-hrtb-hang-issue-142832.next.stderr new file mode 100644 index 0000000000000..3ee11c0d76ea6 --- /dev/null +++ b/tests/ui/traits/duplicated-hrtb-hang-issue-142832.next.stderr @@ -0,0 +1,15 @@ +error[E0275]: overflow evaluating the requirement `W<_>: Trait` + --> $DIR/duplicated-hrtb-hang-issue-142832.rs:16:12 + | +LL | func::>(); + | ^^^^ + | +note: required by a bound in `func` + --> $DIR/duplicated-hrtb-hang-issue-142832.rs:14:12 + | +LL | fn func() {} + | ^^^^^ required by this bound in `func` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/duplicated-hrtb-hang-issue-142832.rs b/tests/ui/traits/duplicated-hrtb-hang-issue-142832.rs new file mode 100644 index 0000000000000..66203df913040 --- /dev/null +++ b/tests/ui/traits/duplicated-hrtb-hang-issue-142832.rs @@ -0,0 +1,18 @@ +//@ revisions: current next +//@ [next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) + +// Regression test for . + +trait Trait {} +struct W(T); +impl Trait for W> +where + W < T > : for < 'a > Trait, + W < T > : for < 'a > Trait, +{ } +fn func() {} +fn main() { + func::>(); + //~^ ERROR overflow +} diff --git a/tests/ui/traits/enum-negative-send-impl.stderr b/tests/ui/traits/enum-negative-send-impl.stderr index 2aad2265797e6..645d6d856eb1c 100644 --- a/tests/ui/traits/enum-negative-send-impl.stderr +++ b/tests/ui/traits/enum-negative-send-impl.stderr @@ -16,6 +16,8 @@ note: required because it appears within the type `Container` | LL | enum Container { | ^^^^^^^^^ +LL | WithNoSend(NoSend), + | ------ required by this field note: required by a bound in `requires_send` --> $DIR/enum-negative-send-impl.rs:16:21 | diff --git a/tests/ui/traits/enum-negative-sync-impl.stderr b/tests/ui/traits/enum-negative-sync-impl.stderr index b4ab69afb421d..8fdfbe6876266 100644 --- a/tests/ui/traits/enum-negative-sync-impl.stderr +++ b/tests/ui/traits/enum-negative-sync-impl.stderr @@ -16,6 +16,8 @@ note: required because it appears within the type `Container` | LL | enum Container { | ^^^^^^^^^ +LL | WithNoSync(NoSync), + | ------ required by this field note: required by a bound in `requires_sync` --> $DIR/enum-negative-sync-impl.rs:16:21 | diff --git a/tests/ui/traits/issue-7013.stderr b/tests/ui/traits/issue-7013.stderr index 1749366317286..8621072272259 100644 --- a/tests/ui/traits/issue-7013.stderr +++ b/tests/ui/traits/issue-7013.stderr @@ -12,6 +12,8 @@ note: required because it appears within the type `B` | LL | struct B { | ^ +LL | v: Option>> + | ------------------------- required by this field = note: required for the cast from `Box` to `Box` error: aborting due to 1 previous error diff --git a/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr b/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr index b7d8484e1041e..356e0b9c18cd6 100644 --- a/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr +++ b/tests/ui/traits/negative-impls/negated-auto-traits-error.stderr @@ -112,7 +112,7 @@ note: required because it appears within the type `Outer2` --> $DIR/negated-auto-traits-error.rs:12:8 | LL | struct Outer2(T); - | ^^^^^^ + | ^^^^^^ - required by this field = note: required for `std::ptr::Unique>` to implement `Send` note: required because it appears within the type `Box>` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL diff --git a/tests/ui/traits/non-send-field-location-issue-146016.current.stderr b/tests/ui/traits/non-send-field-location-issue-146016.current.stderr new file mode 100644 index 0000000000000..1aad4cb4c7685 --- /dev/null +++ b/tests/ui/traits/non-send-field-location-issue-146016.current.stderr @@ -0,0 +1,106 @@ +error[E0277]: `*const c_void` cannot be sent between threads safely + --> $DIR/non-send-field-location-issue-146016.rs:41:20 + | +LL | require_send::>(); + | ^^^^^^^^^^^ `*const c_void` cannot be sent between threads safely + | + = help: within `Record<*const c_void>`, the trait `Send` is not implemented for `*const c_void` +note: required because it appears within the type `Record<*const c_void>` + --> $DIR/non-send-field-location-issue-146016.rs:24:8 + | +LL | struct Record { + | ^^^^^^ +LL | unrelated: u8, +LL | value: T, + | -------- required by this field +note: required by a bound in `require_send` + --> $DIR/non-send-field-location-issue-146016.rs:38:20 + | +LL | fn require_send() {} + | ^^^^ required by this bound in `require_send` + +error[E0277]: `*const c_void` cannot be sent between threads safely + --> $DIR/non-send-field-location-issue-146016.rs:43:20 + | +LL | require_send::>(); + | ^^^^^^^^^^^ `*const c_void` cannot be sent between threads safely + | + = help: within `Nested<*const c_void>`, the trait `Send` is not implemented for `*const c_void` +note: required because it appears within the type `Record<*const c_void>` + --> $DIR/non-send-field-location-issue-146016.rs:24:8 + | +LL | struct Record { + | ^^^^^^ +LL | unrelated: u8, +LL | value: T, + | -------- required by this field +note: required because it appears within the type `Nested<*const c_void>` + --> $DIR/non-send-field-location-issue-146016.rs:29:8 + | +LL | struct Nested { + | ^^^^^^ +LL | value: Record, + | ---------------- required by this field +note: required by a bound in `require_send` + --> $DIR/non-send-field-location-issue-146016.rs:38:20 + | +LL | fn require_send() {} + | ^^^^ required by this bound in `require_send` + +error[E0277]: `*const c_void` cannot be sent between threads safely + --> $DIR/non-send-field-location-issue-146016.rs:45:20 + | +LL | require_send::>(); + | ^^^^^^^^^^^^^ `*const c_void` cannot be sent between threads safely + | + = help: within `Multiple<*const c_void>`, the trait `Send` is not implemented for `*const c_void` +note: required because it appears within the type `Multiple<*const c_void>` + --> $DIR/non-send-field-location-issue-146016.rs:33:6 + | +LL | enum Multiple { + | ^^^^^^^^ +LL | Empty, +LL | Values { first: T, second: T }, + | -------- --------- required by this field + | | + | required by this field +note: required by a bound in `require_send` + --> $DIR/non-send-field-location-issue-146016.rs:38:20 + | +LL | fn require_send() {} + | ^^^^ required by this bound in `require_send` + +error[E0277]: `*const c_void` cannot be sent between threads safely + --> $DIR/non-send-field-location-issue-146016.rs:55:27 + | +LL | let h = thread::spawn(move || match rx.recv().unwrap() { + | _____________-------------_^ + | | | + | | required by a bound introduced by this call +LL | | +LL | | Foo::Case(x) => println!("{:?}", x), +LL | | Foo::Case2(b) => println!("{:?}", b), +LL | | }); + | |_____^ `*const c_void` cannot be sent between threads safely + | + = help: within `Foo`, the trait `Send` is not implemented for `*const c_void` +note: required because it appears within the type `Foo` + --> $DIR/non-send-field-location-issue-146016.rs:19:6 + | +LL | enum Foo { + | ^^^ +LL | Case(i32), +LL | Case2(Bar), + | --- required by this field + = note: required for `std::sync::mpsc::Receiver` to implement `Send` +note: required because `rx` is used within this closure + --> $DIR/non-send-field-location-issue-146016.rs:55:41 + | +LL | let h = thread::spawn(move || match rx.recv().unwrap() { + | ^^ +note: required by a bound in `spawn` + --> $SRC_DIR/std/src/thread/functions.rs:LL:COL + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/non-send-field-location-issue-146016.next.stderr b/tests/ui/traits/non-send-field-location-issue-146016.next.stderr new file mode 100644 index 0000000000000..1aad4cb4c7685 --- /dev/null +++ b/tests/ui/traits/non-send-field-location-issue-146016.next.stderr @@ -0,0 +1,106 @@ +error[E0277]: `*const c_void` cannot be sent between threads safely + --> $DIR/non-send-field-location-issue-146016.rs:41:20 + | +LL | require_send::>(); + | ^^^^^^^^^^^ `*const c_void` cannot be sent between threads safely + | + = help: within `Record<*const c_void>`, the trait `Send` is not implemented for `*const c_void` +note: required because it appears within the type `Record<*const c_void>` + --> $DIR/non-send-field-location-issue-146016.rs:24:8 + | +LL | struct Record { + | ^^^^^^ +LL | unrelated: u8, +LL | value: T, + | -------- required by this field +note: required by a bound in `require_send` + --> $DIR/non-send-field-location-issue-146016.rs:38:20 + | +LL | fn require_send() {} + | ^^^^ required by this bound in `require_send` + +error[E0277]: `*const c_void` cannot be sent between threads safely + --> $DIR/non-send-field-location-issue-146016.rs:43:20 + | +LL | require_send::>(); + | ^^^^^^^^^^^ `*const c_void` cannot be sent between threads safely + | + = help: within `Nested<*const c_void>`, the trait `Send` is not implemented for `*const c_void` +note: required because it appears within the type `Record<*const c_void>` + --> $DIR/non-send-field-location-issue-146016.rs:24:8 + | +LL | struct Record { + | ^^^^^^ +LL | unrelated: u8, +LL | value: T, + | -------- required by this field +note: required because it appears within the type `Nested<*const c_void>` + --> $DIR/non-send-field-location-issue-146016.rs:29:8 + | +LL | struct Nested { + | ^^^^^^ +LL | value: Record, + | ---------------- required by this field +note: required by a bound in `require_send` + --> $DIR/non-send-field-location-issue-146016.rs:38:20 + | +LL | fn require_send() {} + | ^^^^ required by this bound in `require_send` + +error[E0277]: `*const c_void` cannot be sent between threads safely + --> $DIR/non-send-field-location-issue-146016.rs:45:20 + | +LL | require_send::>(); + | ^^^^^^^^^^^^^ `*const c_void` cannot be sent between threads safely + | + = help: within `Multiple<*const c_void>`, the trait `Send` is not implemented for `*const c_void` +note: required because it appears within the type `Multiple<*const c_void>` + --> $DIR/non-send-field-location-issue-146016.rs:33:6 + | +LL | enum Multiple { + | ^^^^^^^^ +LL | Empty, +LL | Values { first: T, second: T }, + | -------- --------- required by this field + | | + | required by this field +note: required by a bound in `require_send` + --> $DIR/non-send-field-location-issue-146016.rs:38:20 + | +LL | fn require_send() {} + | ^^^^ required by this bound in `require_send` + +error[E0277]: `*const c_void` cannot be sent between threads safely + --> $DIR/non-send-field-location-issue-146016.rs:55:27 + | +LL | let h = thread::spawn(move || match rx.recv().unwrap() { + | _____________-------------_^ + | | | + | | required by a bound introduced by this call +LL | | +LL | | Foo::Case(x) => println!("{:?}", x), +LL | | Foo::Case2(b) => println!("{:?}", b), +LL | | }); + | |_____^ `*const c_void` cannot be sent between threads safely + | + = help: within `Foo`, the trait `Send` is not implemented for `*const c_void` +note: required because it appears within the type `Foo` + --> $DIR/non-send-field-location-issue-146016.rs:19:6 + | +LL | enum Foo { + | ^^^ +LL | Case(i32), +LL | Case2(Bar), + | --- required by this field + = note: required for `std::sync::mpsc::Receiver` to implement `Send` +note: required because `rx` is used within this closure + --> $DIR/non-send-field-location-issue-146016.rs:55:41 + | +LL | let h = thread::spawn(move || match rx.recv().unwrap() { + | ^^ +note: required by a bound in `spawn` + --> $SRC_DIR/std/src/thread/functions.rs:LL:COL + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/non-send-field-location-issue-146016.rs b/tests/ui/traits/non-send-field-location-issue-146016.rs new file mode 100644 index 0000000000000..9f9cd6a20e48b --- /dev/null +++ b/tests/ui/traits/non-send-field-location-issue-146016.rs @@ -0,0 +1,62 @@ +//@ revisions: current next +//@ [next] compile-flags: -Znext-solver +//@ edition: 2024 + +//! Regression test for https://github.com/rust-lang/rust/issues/146016. +//! Locate the field that introduces an auto-trait requirement, even through a type alias. + +use std::sync::mpsc; +use std::thread; + +mod other { + use std::ffi::c_void; + + pub type Bar = *const c_void; +} + +use other::Bar; + +enum Foo { + Case(i32), + Case2(Bar), +} + +struct Record { + unrelated: u8, + value: T, +} + +struct Nested { + value: Record, +} + +enum Multiple { + Empty, + Values { first: T, second: T }, +} + +fn require_send() {} + +fn generic_fields() { + require_send::>(); + //~^ ERROR `*const c_void` cannot be sent between threads safely + require_send::>(); + //~^ ERROR `*const c_void` cannot be sent between threads safely + require_send::>(); + //~^ ERROR `*const c_void` cannot be sent between threads safely + + require_send::>(); + require_send::>(); + require_send::>(); +} + +fn main() { + let (tx, rx) = mpsc::channel(); + let h = thread::spawn(move || match rx.recv().unwrap() { + //~^ ERROR `*const c_void` cannot be sent between threads safely + Foo::Case(x) => println!("{:?}", x), + Foo::Case2(b) => println!("{:?}", b), + }); + tx.send(Foo::Case2(std::ptr::null())); + h.join(); +} diff --git a/tests/ui/traits/object/issue-44454-2.stderr b/tests/ui/traits/object/issue-44454-2.stderr index 366b519aeb579..280eeb99e0ba8 100644 --- a/tests/ui/traits/object/issue-44454-2.stderr +++ b/tests/ui/traits/object/issue-44454-2.stderr @@ -2,7 +2,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/issue-44454-2.rs:16:5 | LL | fn extend_lt<'a>(x: &'a str) -> Box + 'static> { - | -- - `x` is a reference that is only valid in the function body + | -- - `x` is only valid in the function body | | | lifetime `'a` defined here LL | type DynTrait = dyn for<'a> Trait<&'a str, Assoc = &'a str>; diff --git a/tests/ui/traits/opaque-trait-size-error-5883.stderr b/tests/ui/traits/opaque-trait-size-error-5883.stderr index 78de250b19a1e..1cb25b281ce84 100644 --- a/tests/ui/traits/opaque-trait-size-error-5883.stderr +++ b/tests/ui/traits/opaque-trait-size-error-5883.stderr @@ -10,6 +10,8 @@ note: required because it appears within the type `Struct` | LL | struct Struct { | ^^^^^^ +LL | r: dyn A + 'static + | ------------------ required by this field = note: the return type of a function must have a statically known size error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time diff --git a/tests/ui/traits/suggest-where-clause.stderr b/tests/ui/traits/suggest-where-clause.stderr index d01cd26730c59..e56c7cd518bd2 100644 --- a/tests/ui/traits/suggest-where-clause.stderr +++ b/tests/ui/traits/suggest-where-clause.stderr @@ -28,7 +28,7 @@ note: required because it appears within the type `Misc` --> $DIR/suggest-where-clause.rs:3:8 | LL | struct Misc(T); - | ^^^^ + | ^^^^ - required by this field note: required by an implicit `Sized` bound in `std::mem::size_of` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL help: consider removing the `?Sized` bound to make the type parameter `Sized` diff --git a/tests/ui/traits/trivial-unsized-projection-2.bad.stderr b/tests/ui/traits/trivial-unsized-projection-2.bad.stderr index bf8d3c40cf653..d3b3b3be61f8f 100644 --- a/tests/ui/traits/trivial-unsized-projection-2.bad.stderr +++ b/tests/ui/traits/trivial-unsized-projection-2.bad.stderr @@ -9,7 +9,7 @@ note: required because it appears within the type `Tail` --> $DIR/trivial-unsized-projection-2.rs:17:8 | LL | struct Tail([()]); - | ^^^^ + | ^^^^ ---- required by this field note: required by a bound in `Bad::Assert` --> $DIR/trivial-unsized-projection-2.rs:14:15 | @@ -34,7 +34,7 @@ note: required because it appears within the type `Tail` --> $DIR/trivial-unsized-projection-2.rs:17:8 | LL | struct Tail([()]); - | ^^^^ + | ^^^^ ---- required by this field note: required by a bound in `Bad::Assert` --> $DIR/trivial-unsized-projection-2.rs:14:15 | diff --git a/tests/ui/traits/trivial-unsized-projection-2.bad_new.stderr b/tests/ui/traits/trivial-unsized-projection-2.bad_new.stderr index fcac02bc0a049..6f8558547026a 100644 --- a/tests/ui/traits/trivial-unsized-projection-2.bad_new.stderr +++ b/tests/ui/traits/trivial-unsized-projection-2.bad_new.stderr @@ -15,7 +15,7 @@ note: required because it appears within the type `Tail` --> $DIR/trivial-unsized-projection-2.rs:17:8 | LL | struct Tail([()]); - | ^^^^ + | ^^^^ ---- required by this field note: required by a bound in `Bad::Assert` --> $DIR/trivial-unsized-projection-2.rs:14:15 | diff --git a/tests/ui/transmutability/references/reject_lifetime_extension.stderr b/tests/ui/transmutability/references/reject_lifetime_extension.stderr index b97029841453f..392aec03b3d2c 100644 --- a/tests/ui/transmutability/references/reject_lifetime_extension.stderr +++ b/tests/ui/transmutability/references/reject_lifetime_extension.stderr @@ -58,7 +58,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/reject_lifetime_extension.rs:80:18 | LL | fn call_extend_hrtb<'a>(src: &'a u8) -> &'static u8 { - | -- --- `src` is a reference that is only valid in the function body + | -- --- `src` is only valid in the function body | | | lifetime `'a` defined here LL | unsafe { extend_hrtb(src) } diff --git a/tests/ui/typeck/typeck-default-trait-impl-negation-sync.stderr b/tests/ui/typeck/typeck-default-trait-impl-negation-sync.stderr index 92629704c8986..00ad61a6d7794 100644 --- a/tests/ui/typeck/typeck-default-trait-impl-negation-sync.stderr +++ b/tests/ui/typeck/typeck-default-trait-impl-negation-sync.stderr @@ -27,6 +27,8 @@ note: required because it appears within the type `MyTypeWUnsafe` | LL | struct MyTypeWUnsafe { | ^^^^^^^^^^^^^ +LL | t: UnsafeCell + | ----------------- required by this field note: required by a bound in `is_sync` --> $DIR/typeck-default-trait-impl-negation-sync.rs:29:15 | @@ -49,6 +51,8 @@ note: required because it appears within the type `MyTypeManaged` | LL | struct MyTypeManaged { | ^^^^^^^^^^^^^ +LL | t: Managed + | ---------- required by this field note: required by a bound in `is_sync` --> $DIR/typeck-default-trait-impl-negation-sync.rs:29:15 | diff --git a/tests/ui/typeck/typeck-unsafe-always-share.stderr b/tests/ui/typeck/typeck-unsafe-always-share.stderr index c680c6ee27bf0..6239db91b52e8 100644 --- a/tests/ui/typeck/typeck-unsafe-always-share.stderr +++ b/tests/ui/typeck/typeck-unsafe-always-share.stderr @@ -42,6 +42,8 @@ note: required because it appears within the type `MySync` | LL | struct MySync { | ^^^^^^ +LL | u: UnsafeCell + | ---------------- required by this field note: required by a bound in `test` --> $DIR/typeck-unsafe-always-share.rs:15:12 | diff --git a/tests/ui/unsized-locals/issue-50940-with-feature.stderr b/tests/ui/unsized-locals/issue-50940-with-feature.stderr index f3fb3ac1a09ff..a0d7e9c6cba31 100644 --- a/tests/ui/unsized-locals/issue-50940-with-feature.stderr +++ b/tests/ui/unsized-locals/issue-50940-with-feature.stderr @@ -9,7 +9,7 @@ note: required because it appears within the type `A` --> $DIR/issue-50940-with-feature.rs:4:12 | LL | struct A(X); - | ^ + | ^ - required by this field = note: the return type of a function must have a statically known size error: aborting due to 1 previous error diff --git a/tests/ui/unsized-locals/unsized-exprs.stderr b/tests/ui/unsized-locals/unsized-exprs.stderr index 0455edbe8e77b..8d6156446d26f 100644 --- a/tests/ui/unsized-locals/unsized-exprs.stderr +++ b/tests/ui/unsized-locals/unsized-exprs.stderr @@ -9,7 +9,7 @@ note: required because it appears within the type `A<[u8]>` --> $DIR/unsized-exprs.rs:3:8 | LL | struct A(X); - | ^ + | ^ - required by this field note: unsized values must be place expressions and cannot be put in temporaries --> $DIR/unsized-exprs.rs:19:22 | @@ -27,7 +27,7 @@ note: required because it appears within the type `A<[u8]>` --> $DIR/unsized-exprs.rs:3:8 | LL | struct A(X); - | ^ + | ^ - required by this field note: unsized values must be place expressions and cannot be put in temporaries --> $DIR/unsized-exprs.rs:21:22 | diff --git a/tests/ui/unsized/unsized-enum2.stderr b/tests/ui/unsized/unsized-enum2.stderr index 71cf782120e57..20cf2556c5df7 100644 --- a/tests/ui/unsized/unsized-enum2.stderr +++ b/tests/ui/unsized/unsized-enum2.stderr @@ -325,7 +325,7 @@ note: required because it appears within the type `Path1` --> $DIR/unsized-enum2.rs:16:8 | LL | struct Path1(dyn PathHelper1); - | ^^^^^ + | ^^^^^ --------------- required by this field = note: no field of an enum variant may have a dynamically sized type = help: change the field's type to have a statically known size help: borrowed types always have a statically known size @@ -348,7 +348,7 @@ note: required because it appears within the type `Path2` --> $DIR/unsized-enum2.rs:17:8 | LL | struct Path2(dyn PathHelper2); - | ^^^^^ + | ^^^^^ --------------- required by this field = note: no field of an enum variant may have a dynamically sized type = help: change the field's type to have a statically known size help: borrowed types always have a statically known size @@ -371,7 +371,7 @@ note: required because it appears within the type `Path3` --> $DIR/unsized-enum2.rs:18:8 | LL | struct Path3(dyn PathHelper3); - | ^^^^^ + | ^^^^^ --------------- required by this field = note: no field of an enum variant may have a dynamically sized type = help: change the field's type to have a statically known size help: borrowed types always have a statically known size @@ -394,7 +394,7 @@ note: required because it appears within the type `Path4` --> $DIR/unsized-enum2.rs:19:8 | LL | struct Path4(dyn PathHelper4); - | ^^^^^ + | ^^^^^ --------------- required by this field = note: no field of an enum variant may have a dynamically sized type = help: change the field's type to have a statically known size help: borrowed types always have a statically known size diff --git a/tests/ui/unsized/unsized-struct.stderr b/tests/ui/unsized/unsized-struct.stderr index 06c4ffb7773c6..d7d392cf9e5f6 100644 --- a/tests/ui/unsized/unsized-struct.stderr +++ b/tests/ui/unsized/unsized-struct.stderr @@ -36,7 +36,7 @@ note: required because it appears within the type `Bar` --> $DIR/unsized-struct.rs:11:8 | LL | struct Bar { data: T } - | ^^^ + | ^^^ ------- required by this field note: required by a bound in `is_sized` --> $DIR/unsized-struct.rs:1:15 | diff --git a/tests/ui/unsized/unsized3.stderr b/tests/ui/unsized/unsized3.stderr index c7a145b1c5171..547bb9ca62e34 100644 --- a/tests/ui/unsized/unsized3.stderr +++ b/tests/ui/unsized/unsized3.stderr @@ -59,6 +59,8 @@ note: required because it appears within the type `S` | LL | struct S { | ^ +LL | x: X, + | ---- required by this field note: required by an implicit `Sized` bound in `f5` --> $DIR/unsized3.rs:24:7 | @@ -87,6 +89,8 @@ note: required because it appears within the type `S` | LL | struct S { | ^ +LL | x: X, + | ---- required by this field = note: only the last element of a tuple may have a dynamically sized type help: consider removing the `?Sized` bound to make the type parameter `Sized` | @@ -107,6 +111,8 @@ note: required because it appears within the type `S` | LL | struct S { | ^ +LL | x: X, + | ---- required by this field = note: required because it appears within the type `({integer}, S)` = note: tuples must have a statically known size to be initialized help: consider removing the `?Sized` bound to make the type parameter `Sized` @@ -130,6 +136,8 @@ note: required because it appears within the type `S` | LL | struct S { | ^ +LL | x: X, + | ---- required by this field = note: required because it appears within the type `({integer}, S)` note: required by an implicit `Sized` bound in `f5` --> $DIR/unsized3.rs:24:7 diff --git a/tests/ui/wf/let-pat-inferred-non-wf.stderr b/tests/ui/wf/let-pat-inferred-non-wf.stderr index 1c524a22b432b..d05ed37578820 100644 --- a/tests/ui/wf/let-pat-inferred-non-wf.stderr +++ b/tests/ui/wf/let-pat-inferred-non-wf.stderr @@ -54,7 +54,7 @@ note: required because it appears within the type `S` --> $DIR/let-pat-inferred-non-wf.rs:8:8 | LL | struct S(T); - | ^ + | ^ - required by this field = note: slice and array elements must have `Sized` type error: aborting due to 6 previous errors