diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs index b20a89859388e..21888720524a5 100644 --- a/compiler/rustc_codegen_llvm/src/asm.rs +++ b/compiler/rustc_codegen_llvm/src/asm.rs @@ -791,12 +791,10 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) -> } else if let Some(idx) = hexagon_vreg_pair_index(reg) { // LLVM uses `wN` for Hexagon HVX vector pair registers. format!("{{w{}}}", idx) - } else if reg == InlineAsmReg::Arm(ArmInlineAsmReg::r14) - && llvm_util::get_version() < (23, 0, 0) - { + } else if reg == InlineAsmReg::Arm(ArmInlineAsmReg::r14) { // FIXME(llvm): LLVM <23 does not recognize `r14` as a register name // in inline assembly. - // This workaround can be removed when support for LLVM 22 is dropped. + // We can make this branch fallthrough again for LLVM 23+ when https://github.com/llvm/llvm-project/pull/225746 gets released. "{lr}".to_string() } else if let InlineAsmReg::Sparc(reg) = reg && let Some(num) = reg.dreg_number() diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 25a82b22707cc..97b8557b95ef6 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -384,7 +384,6 @@ pub enum StashKey { /// FRU syntax MaybeFruTypo, CallAssocMethod, - AssociatedTypeSuggestion, UndeterminedMacroResolution, /// Used by `Parser::maybe_recover_trailing_expr` ExprInPat, diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs index a3cba8ce15fda..9123afd5986f5 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs @@ -2,10 +2,7 @@ use rustc_ast::TraitObjectSyntax; use rustc_attr_ir::lang_items::LangItem; use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; use rustc_errors::codes::*; -use rustc_errors::{ - Applicability, Diag, DiagCtxtHandle, Diagnostic, Level, StashKey, Suggestions, - struct_span_code_err, -}; +use rustc_errors::{Applicability, Diag, DiagCtxtHandle, Diagnostic, Level, struct_span_code_err}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::{self as hir, HirId}; @@ -17,6 +14,7 @@ use rustc_middle::ty::{ }; use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::{ErrorGuaranteed, Span}; +use rustc_trait_selection::diagnostics::AssocTypeWithSameName; use rustc_trait_selection::error_reporting::traits::report_dyn_incompatibility; use rustc_trait_selection::error_reporting::traits::suggestions::NextTypeParamName; use rustc_trait_selection::traits; @@ -655,15 +653,14 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { poly_trait_ref.trait_ref.trait_def_id(), &mut diag, ); - // In case there is an associated type with the same name - // Add the suggestion to this error - if let Some(mut sugg) = - self.dcx().steal_non_err(span, StashKey::AssociatedTypeSuggestion) - && let Suggestions::Enabled(ref mut s1) = diag.suggestions - && let Suggestions::Enabled(ref mut s2) = sugg.suggestions + // If there is an associated type with the same name, add the suggestion to this error. + if self + .tcx() + .resolutions(()) + .paths_matching_assoc_types + .contains(&span.with_parent(None)) { - s1.append(s2); - sugg.cancel(); + diag.subdiagnostic(AssocTypeWithSameName { span: span.shrink_to_lo() }); } Some(diag.emit_err()) } else { diff --git a/compiler/rustc_lint/src/diagnostics.rs b/compiler/rustc_lint/src/diagnostics.rs index 0f914893bf673..98a11f8e1df08 100644 --- a/compiler/rustc_lint/src/diagnostics.rs +++ b/compiler/rustc_lint/src/diagnostics.rs @@ -1040,9 +1040,10 @@ pub(crate) struct ForgetCopyDiag<'a> { #[derive(Diagnostic)] #[diag( - "calls to `std::mem::drop` with `std::mem::ManuallyDrop` instead of the inner value does nothing" + "calls to `{$krate}::mem::drop` with `{$krate}::mem::ManuallyDrop` instead of the inner value does nothing" )] pub(crate) struct UndroppedManuallyDropsDiag<'a> { + pub krate: &'static str, pub arg_ty: Ty<'a>, #[label("argument has type `{$arg_ty}`")] pub label: Span, @@ -1052,11 +1053,12 @@ pub(crate) struct UndroppedManuallyDropsDiag<'a> { #[derive(Subdiagnostic)] #[multipart_suggestion( - "use `std::mem::ManuallyDrop::into_inner` to get the inner value", + "use `{$krate}::mem::ManuallyDrop::into_inner` to get the inner value", applicability = "machine-applicable" )] pub(crate) struct UndroppedManuallyDropsSuggestion { - #[suggestion_part(code = "std::mem::ManuallyDrop::into_inner(")] + pub krate: &'static str, + #[suggestion_part(code = "{krate}::mem::ManuallyDrop::into_inner(")] pub start_span: Span, #[suggestion_part(code = ")")] pub end_span: Span, @@ -1064,9 +1066,10 @@ pub(crate) struct UndroppedManuallyDropsSuggestion { #[derive(Diagnostic)] #[diag( - "calls to `drop_in_place` with a pointer to a `std::mem::ManuallyDrop` instead of the inner value does nothing" + "calls to `drop_in_place` with a pointer to a `{$krate}::mem::ManuallyDrop` instead of the inner value does nothing" )] pub(crate) struct UndroppedManuallyDropsInPlaceDiag<'a> { + pub krate: &'static str, pub arg_ty: Ty<'a>, #[label("argument has type `{$arg_ty}`")] pub label: Span, @@ -1076,11 +1079,12 @@ pub(crate) struct UndroppedManuallyDropsInPlaceDiag<'a> { #[derive(Subdiagnostic)] #[multipart_suggestion( - "use `std::mem::ManuallyDrop::drop` to drop the inner value", + "use `{$krate}::mem::ManuallyDrop::drop` to drop the inner value", applicability = "maybe-incorrect" )] pub(crate) struct UndroppedManuallyDropsInPlaceSuggestion { - #[suggestion_part(code = "std::mem::ManuallyDrop::drop(&mut *")] + pub krate: &'static str, + #[suggestion_part(code = "{krate}::mem::ManuallyDrop::drop(&mut *")] pub start_span: Span, #[suggestion_part(code = ")")] pub end_span: Span, @@ -2074,9 +2078,6 @@ impl<'a> Diagnostic<'a> for DropGlue<'_> { #[note( "exposed provenance semantics can be used to create a pointer based on some previously exposed provenance" )] -#[help( - "if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`" -)] #[help( "for more information about transmute, see " )] @@ -2084,34 +2085,46 @@ impl<'a> Diagnostic<'a> for DropGlue<'_> { "for more information about exposed provenance, see " )] pub(crate) struct IntegerToPtrTransmutes<'tcx> { + #[subdiagnostic] + pub without_prov: Option, #[subdiagnostic] pub suggestion: Option>, } +#[derive(Subdiagnostic)] +#[help( + "if you truly mean to create a pointer without provenance, use `{$krate}::ptr::without_provenance_mut`" +)] +pub(crate) struct IntegerToPtrWithoutProvHelp { + pub krate: &'static str, +} + #[derive(Subdiagnostic)] pub(crate) enum IntegerToPtrTransmutesSuggestion<'tcx> { #[multipart_suggestion( - "use `std::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance", + "use `{$krate}::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance", applicability = "machine-applicable", style = "verbose" )] ToPtr { + krate: &'static str, dst: Ty<'tcx>, suffix: &'static str, - #[suggestion_part(code = "std::ptr::with_exposed_provenance{suffix}::<{dst}>(")] + #[suggestion_part(code = "{krate}::ptr::with_exposed_provenance{suffix}::<{dst}>(")] start_call: Span, }, #[multipart_suggestion( - "use `std::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance", + "use `{$krate}::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance", applicability = "machine-applicable", style = "verbose" )] ToRef { + krate: &'static str, dst: Ty<'tcx>, suffix: &'static str, ref_mutbl: &'static str, #[suggestion_part( - code = "&{ref_mutbl}*std::ptr::with_exposed_provenance{suffix}::<{dst}>(" + code = "&{ref_mutbl}*{krate}::ptr::with_exposed_provenance{suffix}::<{dst}>(" )] start_call: Span, }, @@ -2348,25 +2361,30 @@ pub(crate) enum AmbiguousWidePointerComparisons<'a> { #[diag( "ambiguous wide pointer comparison, the comparison includes metadata which may not be expected" )] - #[help("use explicit `std::ptr::eq` method to compare metadata and addresses")] - #[help("use `std::ptr::addr_eq` or untyped pointers to only compare their addresses")] - Spanless, + #[help("use explicit `{$krate}::ptr::eq` method to compare metadata and addresses")] + #[help("use `{$krate}::ptr::addr_eq` or untyped pointers to only compare their addresses")] + Spanless { krate: &'static str }, + #[diag( + "ambiguous wide pointer comparison, the comparison includes metadata which may not be expected" + )] + Warn, } #[derive(Subdiagnostic)] #[multipart_suggestion( - "use explicit `std::ptr::eq` method to compare metadata and addresses", + "use explicit `{$krate}::ptr::eq` method to compare metadata and addresses", style = "verbose", // FIXME(#53934): make machine-applicable again applicability = "maybe-incorrect" )] pub(crate) struct AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a> { + pub krate: &'static str, pub ne: &'a str, pub deref_left: &'a str, pub deref_right: &'a str, pub l_modifiers: &'a str, pub r_modifiers: &'a str, - #[suggestion_part(code = "{ne}std::ptr::eq({deref_left}")] + #[suggestion_part(code = "{ne}{krate}::ptr::eq({deref_left}")] pub left: Span, #[suggestion_part(code = "{l_modifiers}, {deref_right}")] pub middle: Span, @@ -2376,18 +2394,19 @@ pub(crate) struct AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a> { #[derive(Subdiagnostic)] #[multipart_suggestion( - "use `std::ptr::addr_eq` or untyped pointers to only compare their addresses", + "use `{$krate}::ptr::addr_eq` or untyped pointers to only compare their addresses", style = "verbose", // FIXME(#53934): make machine-applicable again applicability = "maybe-incorrect" )] pub(crate) struct AmbiguousWidePointerComparisonsAddrSuggestion<'a> { + pub(crate) krate: &'static str, pub(crate) ne: &'a str, pub(crate) deref_left: &'a str, pub(crate) deref_right: &'a str, pub(crate) l_modifiers: &'a str, pub(crate) r_modifiers: &'a str, - #[suggestion_part(code = "{ne}std::ptr::addr_eq({deref_left}")] + #[suggestion_part(code = "{ne}{krate}::ptr::addr_eq({deref_left}")] pub(crate) left: Span, #[suggestion_part(code = "{l_modifiers}, {deref_right}")] pub(crate) middle: Span, @@ -2470,15 +2489,16 @@ pub(crate) enum UnpredictableFunctionPointerComparisons<'a, 'tcx> { #[derive(Subdiagnostic)] pub(crate) enum UnpredictableFunctionPointerComparisonsSuggestion<'a, 'tcx> { #[multipart_suggestion( - "refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint", + "refactor your code, or use `{$krate}::ptr::fn_addr_eq` to suppress the lint", style = "verbose", applicability = "maybe-incorrect" )] FnAddrEq { + krate: &'static str, ne: &'a str, deref_left: &'a str, deref_right: &'a str, - #[suggestion_part(code = "{ne}std::ptr::fn_addr_eq({deref_left}")] + #[suggestion_part(code = "{ne}{krate}::ptr::fn_addr_eq({deref_left}")] left: Span, #[suggestion_part(code = ", {deref_right}")] middle: Span, @@ -2486,16 +2506,17 @@ pub(crate) enum UnpredictableFunctionPointerComparisonsSuggestion<'a, 'tcx> { right: Span, }, #[multipart_suggestion( - "refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint", + "refactor your code, or use `{$krate}::ptr::fn_addr_eq` to suppress the lint", style = "verbose", applicability = "maybe-incorrect" )] FnAddrEqWithCast { + krate: &'static str, ne: &'a str, deref_left: &'a str, deref_right: &'a str, fn_sig: rustc_middle::ty::PolyFnSig<'tcx>, - #[suggestion_part(code = "{ne}std::ptr::fn_addr_eq({deref_left}")] + #[suggestion_part(code = "{ne}{krate}::ptr::fn_addr_eq({deref_left}")] left: Span, #[suggestion_part(code = ", {deref_right}")] middle: Span, diff --git a/compiler/rustc_lint/src/drop_forget_useless.rs b/compiler/rustc_lint/src/drop_forget_useless.rs index b952b62ada314..9689f6a053275 100644 --- a/compiler/rustc_lint/src/drop_forget_useless.rs +++ b/compiler/rustc_lint/src/drop_forget_useless.rs @@ -9,6 +9,7 @@ use crate::diagnostics::{ UndroppedManuallyDropsInPlaceSuggestion, UndroppedManuallyDropsSuggestion, UseLetUnderscoreIgnoreSuggestion, }; +use crate::utils::std_or_core; use crate::{LateContext, LateLintPass, LintContext}; declare_lint! { @@ -252,15 +253,18 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless { } sym::mem_drop if let ty::Adt(adt, _) = arg_ty.kind() - && adt.is_manually_drop() => + && adt.is_manually_drop() + && let Some(krate) = std_or_core(cx) => { cx.emit_span_lint( UNDROPPED_MANUALLY_DROPS, expr.span, UndroppedManuallyDropsDiag { + krate, arg_ty, label: arg.span, suggestion: UndroppedManuallyDropsSuggestion { + krate, start_span: arg.span.shrink_to_lo(), end_span: arg.span.shrink_to_hi(), }, @@ -270,15 +274,18 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless { sym::ptr_drop_in_place | sym::ptr_drop_in_place_self if let &ty::RawPtr(inner_ty, _mutbl) = arg_ty.kind() && let ty::Adt(adt, _) = inner_ty.kind() - && adt.is_manually_drop() => + && adt.is_manually_drop() + && let Some(krate) = std_or_core(cx) => { cx.emit_span_lint( UNDROPPED_MANUALLY_DROPS, expr.span, UndroppedManuallyDropsInPlaceDiag { + krate, arg_ty, label: arg.span, suggestion: UndroppedManuallyDropsInPlaceSuggestion { + krate, start_span: expr.span.shrink_to_lo().until(arg.span.shrink_to_lo()), end_span: arg.span.shrink_to_hi().until(expr.span.shrink_to_hi()), }, diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 95033707cf110..deea9e1bbc13c 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -148,6 +148,7 @@ pub use rustc_lint_defs::{ Applicability, FutureIncompatibleInfo, Lint, LintId, LintPass, LintVec, declare_lint, declare_lint_pass, declare_tool_lint, impl_lint_pass, }; +pub use utils::std_or_core; pub fn provide(providers: &mut Providers) { levels::provide(providers); diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs index fbe8eb837f852..6598110cbfa8f 100644 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ b/compiler/rustc_lint/src/non_fmt_panic.rs @@ -143,7 +143,14 @@ impl<'a, 'b, 'tcx> Diagnostic<'a> for PanicMessageNotLiteral<'b, 'tcx> { .get_diagnostic_item(sym::Debug) .is_some_and(|t| infcx.type_implements_trait(t, [ty], param_env).may_apply()); - let suggest_panic_any = !is_str && panic == Some(sym::std_panic_macro); + let suggest_panic_any = !is_str + && panic == Some(sym::std_panic_macro) + && cx + .tcx + .all_diagnostic_items(()) + .name_to_id + .keys() + .any(|name| name.as_str() == "panic_any"); let fmt_applicability = if suggest_panic_any { // If we can use panic_any, use that as the MachineApplicable suggestion. diff --git a/compiler/rustc_lint/src/transmute.rs b/compiler/rustc_lint/src/transmute.rs index 3a4092a46a6b6..3b269a215cb6b 100644 --- a/compiler/rustc_lint/src/transmute.rs +++ b/compiler/rustc_lint/src/transmute.rs @@ -8,7 +8,10 @@ use rustc_macros::Diagnostic; use rustc_middle::ty::{self, Ty}; use rustc_span::sym; -use crate::diagnostics::{IntegerToPtrTransmutes, IntegerToPtrTransmutesSuggestion}; +use crate::diagnostics::{ + IntegerToPtrTransmutes, IntegerToPtrTransmutesSuggestion, IntegerToPtrWithoutProvHelp, +}; +use crate::utils::std_or_core; use crate::{LateContext, LateLintPass}; declare_lint! { @@ -166,30 +169,30 @@ fn check_int_to_ptr_transmute<'tcx>( } let suffix = if mutbl.is_mut() { "_mut" } else { "" }; + let krate = std_or_core(cx); cx.tcx.emit_node_span_lint( INTEGER_TO_PTR_TRANSMUTES, expr.hir_id, expr.span, IntegerToPtrTransmutes { - suggestion: if layout_inner_ty.is_sized() { - Some(if dst.is_ref() { - IntegerToPtrTransmutesSuggestion::ToRef { + without_prov: krate.map(|krate| IntegerToPtrWithoutProvHelp { krate }), + suggestion: match (krate, layout_inner_ty.is_sized()) { + (Some(krate), true) if dst.is_ref() => { + Some(IntegerToPtrTransmutesSuggestion::ToRef { + krate, dst: *inner_ty, suffix, ref_mutbl: mutbl.prefix_str(), start_call: expr.span.shrink_to_lo().until(arg.span), - } - } else { - IntegerToPtrTransmutesSuggestion::ToPtr { - dst: *inner_ty, - suffix, - start_call: expr.span.shrink_to_lo().until(arg.span), - } - }) - } else { - // We can't suggest using `with_exposed_provenance` for unsized type - // so don't suggest anything. - None + }) + } + (Some(krate), true) => Some(IntegerToPtrTransmutesSuggestion::ToPtr { + krate, + dst: *inner_ty, + suffix, + start_call: expr.span.shrink_to_lo().until(arg.span), + }), + _ => None, }, }, ); diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index eab950f4d66a8..9897e9cbb4f07 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -25,6 +25,7 @@ use crate::diagnostics::{ UnpredictableFunctionPointerComparisonsSuggestion, UnusedComparisons, VariantSizeDifferencesDiag, }; +use crate::utils::std_or_core; use crate::{LateContext, LateLintPass, LintContext}; mod literal; @@ -348,13 +349,21 @@ fn lint_wide_pointer<'tcx>( return; }; + let Some(krate) = std_or_core(cx) else { + return cx.emit_span_lint( + AMBIGUOUS_WIDE_POINTER_COMPARISONS, + e.span, + AmbiguousWidePointerComparisons::Warn, + ); + }; + let (Some(l_span), Some(r_span)) = (l.span.find_ancestor_inside(e.span), r.span.find_ancestor_inside(e.span)) else { return cx.emit_span_lint( AMBIGUOUS_WIDE_POINTER_COMPARISONS, e.span, - AmbiguousWidePointerComparisons::Spanless, + AmbiguousWidePointerComparisons::Spanless { krate }, ); }; @@ -380,6 +389,7 @@ fn lint_wide_pointer<'tcx>( AmbiguousWidePointerComparisons::SpanfulEq { addr_metadata_suggestion: (!is_dyn_comparison).then(|| { AmbiguousWidePointerComparisonsAddrMetadataSuggestion { + krate, ne, deref_left, deref_right, @@ -391,6 +401,7 @@ fn lint_wide_pointer<'tcx>( } }), addr_suggestion: AmbiguousWidePointerComparisonsAddrSuggestion { + krate, ne, deref_left, deref_right, @@ -512,6 +523,14 @@ fn lint_fn_pointer<'tcx>( let middle = l_span.shrink_to_hi().until(r_span.shrink_to_lo()); let right = r_span.shrink_to_hi().until(e.span.shrink_to_hi()); + let Some(krate) = std_or_core(cx) else { + return cx.emit_span_lint( + UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS, + e.span, + UnpredictableFunctionPointerComparisons::Warn, + ); + }; + let sugg = // We only check for a right cast as `FnDef` == `FnPtr` is not possible, // only `FnPtr == FnDef` is possible. @@ -519,6 +538,7 @@ fn lint_fn_pointer<'tcx>( let fn_sig = r_ty.fn_sig(cx.tcx); UnpredictableFunctionPointerComparisonsSuggestion::FnAddrEqWithCast { + krate, ne, fn_sig, deref_left, @@ -529,6 +549,7 @@ fn lint_fn_pointer<'tcx>( } } else { UnpredictableFunctionPointerComparisonsSuggestion::FnAddrEq { + krate, ne, deref_left, deref_right, diff --git a/compiler/rustc_lint/src/utils.rs b/compiler/rustc_lint/src/utils.rs index 5854e89d801de..e3c0198775433 100644 --- a/compiler/rustc_lint/src/utils.rs +++ b/compiler/rustc_lint/src/utils.rs @@ -1,4 +1,4 @@ -use rustc_hir::{Expr, ExprKind}; +use rustc_hir::{Expr, ExprKind, find_attr}; use rustc_span::sym; use crate::LateContext; @@ -47,3 +47,14 @@ pub(crate) fn peel_casts<'tcx>( e } + +/// Crate to use for rustfix / diagnostic paths that exist in both `std` and `core`. Returns `None` for `#![no_core]`. +pub fn std_or_core(cx: &LateContext<'_>) -> Option<&'static str> { + if find_attr!(cx.tcx, crate, NoCore) { + None + } else if find_attr!(cx.tcx, crate, NoStd) { + Some("core") + } else { + Some("std") + } +} diff --git a/compiler/rustc_middle/src/middle/resolve.rs b/compiler/rustc_middle/src/middle/resolve.rs index 8267cde89ad27..491fec97db6c1 100644 --- a/compiler/rustc_middle/src/middle/resolve.rs +++ b/compiler/rustc_middle/src/middle/resolve.rs @@ -180,6 +180,9 @@ pub struct ResolverGlobalCtxt { /// A list of proc macro LocalDefIds, written out in the order in which /// they are declared in the static array generated by proc_macro_harness. pub proc_macros: Vec, + /// Path spans where the ident matches an associated type for an enclosing trait. Used to + /// improve certain error messages. + pub paths_matching_assoc_types: UnordSet, /// Mapping from ident span to path span for paths that don't exist as written, but that /// exist under `std`. For example, wrote `str::from_utf8` instead of `std::str::from_utf8`. pub confused_type_with_std_module: FxIndexMap, diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 8c4a9babe2213..cb6642a696504 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -22,7 +22,7 @@ use rustc_data_structures::unord::{UnordMap, UnordSet}; use rustc_errors::codes::*; use rustc_errors::{ Applicability, Diag, DiagArgValue, Diagnostic, ErrorGuaranteed, IntoDiagArg, MultiSpan, - StashKey, Suggestions, elided_lifetime_in_path_suggestion, pluralize, + Suggestions, elided_lifetime_in_path_suggestion, pluralize, }; use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::{CtorKind, DefKind, NonMacroAttrKind, PerNS}; @@ -4823,7 +4823,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { source, ) { Ok(Some(partial_res)) if let Some(res) = partial_res.full_res() => { - // if we also have an associated type that matches the ident, stash a suggestion + // If we also have an associated type that matches the ident, record that. if let Some(items) = self.diag_metadata.current_trait_assoc_items && let [Segment { ident, .. }] = path && items.iter().any(|item| { @@ -4836,14 +4836,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } }) { - let mut diag = self.r.tcx.dcx().struct_allow(""); - diag.span_suggestion_verbose( - path_span.shrink_to_lo(), - "there is an associated type with the same name", - "Self::", - Applicability::MaybeIncorrect, - ); - diag.stash(path_span, StashKey::AssociatedTypeSuggestion); + self.r.paths_matching_assoc_types.insert(path_span.with_parent(None)); } if source.is_expected(res) || res == Res::Err { diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 7c80a892fa131..a913149733614 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1529,6 +1529,7 @@ pub struct Resolver<'ra, 'tcx> { /// A list of proc macro LocalDefIds, written out in the order in which /// they are declared in the static array generated by proc_macro_harness. proc_macros: Vec = Vec::new(), + paths_matching_assoc_types: UnordSet, confused_type_with_std_module: FxIndexMap, /// Names of items that were stripped out via cfg with their corresponding cfg meta item. @@ -1892,6 +1893,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { invocation_parents, trait_impls: Default::default(), confused_type_with_std_module: Default::default(), + paths_matching_assoc_types: Default::default(), stripped_cfg_items: Default::default(), effective_visibilities: Default::default(), macro_reachable_adts: Default::default(), @@ -1970,6 +1972,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let glob_map = self.glob_map; let main_def = self.main_def; let confused_type_with_std_module = self.confused_type_with_std_module; + let paths_matching_assoc_types = self.paths_matching_assoc_types; let effective_visibilities = self.effective_visibilities; let stripped_cfg_items = self @@ -2000,6 +2003,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { trait_impls: self.trait_impls, proc_macros, confused_type_with_std_module, + paths_matching_assoc_types, doc_link_resolutions: self.doc_link_resolutions, doc_link_traits_in_scope: self.doc_link_traits_in_scope, all_macro_rules: self.all_macro_rules, diff --git a/compiler/rustc_trait_selection/src/diagnostics.rs b/compiler/rustc_trait_selection/src/diagnostics.rs index 4b7be976cdb30..80ffbba041ccd 100644 --- a/compiler/rustc_trait_selection/src/diagnostics.rs +++ b/compiler/rustc_trait_selection/src/diagnostics.rs @@ -2083,3 +2083,15 @@ pub(crate) struct NonGenericOpaqueTypeParam<'a, 'tcx> { }")] pub param_span: Span, } + +#[derive(Subdiagnostic)] +#[suggestion( + "there is an associated type with the same name", + style = "verbose", + code = "Self::", + applicability = "maybe-incorrect" +)] +pub struct AssocTypeWithSameName { + #[primary_span] + pub span: Span, +} diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 4cb5465b5bbee..062b087413e4f 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -13,8 +13,8 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::unord::UnordSet; use rustc_errors::codes::*; use rustc_errors::{ - Applicability, Diag, ErrorGuaranteed, MultiSpan, StashKey, StringPart, Sublevel, Suggestions, - msg, pluralize, struct_span_code_err, + Applicability, Diag, ErrorGuaranteed, MultiSpan, StringPart, Sublevel, msg, pluralize, + struct_span_code_err, }; use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId}; use rustc_hir::intravisit::Visitor; @@ -42,7 +42,8 @@ use tracing::{debug, instrument}; use super::suggestions::get_explanation_based_on_obligation; use super::{ArgKind, CandidateSimilarity, GetSafeTransmuteErrorAndReason, ImplCandidate}; use crate::diagnostics::{ - ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch, CoroClosureNotFn, + AssocTypeWithSameName, ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch, + CoroClosureNotFn, }; use crate::error_reporting::TypeErrCtxt; use crate::error_reporting::infer::TyCategory; @@ -3107,13 +3108,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ); self.suggest_unsized_bound_if_applicable(err, obligation); if let Some(span) = err.span.primary_span() - && let Some(mut diag) = - self.dcx().steal_non_err(span, StashKey::AssociatedTypeSuggestion) - && let Suggestions::Enabled(ref mut s1) = err.suggestions - && let Suggestions::Enabled(ref mut s2) = diag.suggestions + && self + .tcx + .resolutions(()) + .paths_matching_assoc_types + .contains(&span.with_parent(None)) { - s1.append(s2); - diag.cancel() + err.subdiagnostic(AssocTypeWithSameName { span: span.shrink_to_lo() }); } } } diff --git a/compiler/rustc_type_ir/src/search_graph/mod.rs b/compiler/rustc_type_ir/src/search_graph/mod.rs index c081898f26f56..228b6c34b06ed 100644 --- a/compiler/rustc_type_ir/src/search_graph/mod.rs +++ b/compiler/rustc_type_ir/src/search_graph/mod.rs @@ -628,8 +628,8 @@ pub struct SearchGraph, X: Cx = ::Cx> { /// don't need to track the nested goals used while computing a provisional /// cache entry. enum UpdateParentGoalCtxt<'a, X: Cx> { - Ordinary { nested_goals: &'a NestedGoals, min_reachable_available_depth: AvailableDepth }, - CycleOnStack(X::Input), + Ordinary { nested_goals: &'a NestedGoals }, + CycleOnStack { head: X::Input }, ProvisionalCacheHit, } @@ -653,9 +653,12 @@ impl, X: Cx> SearchGraph { heads: impl Iterator, encountered_overflow: bool, context: UpdateParentGoalCtxt<'_, X>, + min_reachable_available_depth: AvailableDepth, ) { if let Some((parent_index, parent)) = stack.last_mut_with_index() { parent.encountered_overflow |= encountered_overflow; + parent.min_reached_available_depth = + parent.min_reached_available_depth.min(min_reachable_available_depth); for (head_index, head) in heads { if let Some(candidate_usages) = &mut parent.candidate_usages { @@ -679,13 +682,11 @@ impl, X: Cx> SearchGraph { } } let parent_depends_on_cycle = match context { - UpdateParentGoalCtxt::Ordinary { nested_goals, min_reachable_available_depth } => { - parent.min_reached_available_depth = - parent.min_reached_available_depth.min(min_reachable_available_depth); + UpdateParentGoalCtxt::Ordinary { nested_goals } => { parent.nested_goals.extend_from_child(step_kind_from_parent, nested_goals); !nested_goals.is_empty() } - UpdateParentGoalCtxt::CycleOnStack(head) => { + UpdateParentGoalCtxt::CycleOnStack { head } => { // We lookup provisional cache entries before detecting cycles. // We therefore can't use a global cache entry if it contains a cycle // whose head is in the provisional cache. @@ -811,7 +812,9 @@ impl, X: Cx> SearchGraph { // - A // - BA cycle // - CB :x: - if let Some(result) = self.lookup_provisional_cache(input, step_kind_from_parent) { + if let Some(result) = + self.lookup_provisional_cache(input, step_kind_from_parent, available_depth) + { return result; } @@ -839,7 +842,9 @@ impl, X: Cx> SearchGraph { // avoid iterating over the stack in case a goal has already been computed. // This may not have an actual performance impact and we could reorder them // as it may reduce the number of `nested_goals` we need to track. - if let Some(result) = self.check_cycle_on_stack(cx, input, step_kind_from_parent) { + if let Some(result) = + self.check_cycle_on_stack(cx, input, step_kind_from_parent, available_depth) + { debug_assert!(validate_cache.is_none(), "global cache and cycle on stack: {input:?}"); return result; } @@ -874,10 +879,8 @@ impl, X: Cx> SearchGraph { step_kind_from_parent, evaluation_result.heads.iter(), evaluation_result.encountered_overflow, - UpdateParentGoalCtxt::Ordinary { - nested_goals: &evaluation_result.nested_goals, - min_reachable_available_depth: available_depth - evaluation_result.required_depth, - }, + UpdateParentGoalCtxt::Ordinary { nested_goals: &evaluation_result.nested_goals }, + available_depth - evaluation_result.required_depth, ); let result = evaluation_result.result; @@ -1119,6 +1122,7 @@ impl, X: Cx> SearchGraph { &mut self, input: X::Input, step_kind_from_parent: PathKind, + available_depth: AvailableDepth, ) -> Option { if !D::ENABLE_PROVISIONAL_CACHE { return None; @@ -1157,6 +1161,7 @@ impl, X: Cx> SearchGraph { heads.iter(), encountered_overflow, UpdateParentGoalCtxt::ProvisionalCacheHit, + available_depth, ); debug!(?head_index, ?path_from_head, "provisional cache hit"); return Some(result); @@ -1278,10 +1283,8 @@ impl, X: Cx> SearchGraph { step_kind_from_parent, heads, encountered_overflow, - UpdateParentGoalCtxt::Ordinary { - nested_goals, - min_reachable_available_depth: available_depth - required_depth, - }, + UpdateParentGoalCtxt::Ordinary { nested_goals }, + available_depth - required_depth, ); debug!(?required_depth, "global cache hit"); @@ -1294,6 +1297,7 @@ impl, X: Cx> SearchGraph { cx: X, input: X::Input, step_kind_from_parent: PathKind, + available_depth: AvailableDepth, ) -> Option { let head_index = self.stack.find(input)?; // We have a nested goal which directly relies on a goal deeper in the stack. @@ -1312,7 +1316,8 @@ impl, X: Cx> SearchGraph { step_kind_from_parent, iter::once((head_index, head)), false, - UpdateParentGoalCtxt::CycleOnStack(input), + UpdateParentGoalCtxt::CycleOnStack { head: input }, + available_depth, ); // Return the provisional result or, if we're in the first iteration, diff --git a/library/std/src/os/wasip2/mod.rs b/library/std/src/os/wasip2/mod.rs index 809a288f20d04..6932bb577cff2 100644 --- a/library/std/src/os/wasip2/mod.rs +++ b/library/std/src/os/wasip2/mod.rs @@ -3,4 +3,5 @@ //! This module is currently empty, but will be filled over time as wasi-libc support for WASI Preview 2 is stabilized. #![forbid(unsafe_op_in_unsafe_fn)] -#![stable(feature = "raw_ext", since = "1.1.0")] +#![unstable(feature = "wasip2", issue = "none")] +#![doc(cfg(all(target_os = "wasi", target_env = "p2")))] diff --git a/src/librustdoc/html/render/sidebar.rs b/src/librustdoc/html/render/sidebar.rs index 6fa033f927c85..011079f9e4f2b 100644 --- a/src/librustdoc/html/render/sidebar.rs +++ b/src/librustdoc/html/render/sidebar.rs @@ -3,7 +3,7 @@ use std::cmp::Ordering; use std::fmt; use askama::Template; -use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::def::CtorKind; use rustc_hir::def_id::{DefIdMap, DefIdSet}; use rustc_middle::ty::TyCtxt; @@ -442,7 +442,7 @@ fn sidebar_assoc_items<'a>( let mut assoc_fns = Vec::new(); let mut methods = Vec::new(); if let Some(v) = cache.impls.get(&did) { - let mut used_links = FxHashSet::default(); + let mut used_links = UsedLinks::default(); let mut id_map = IdMap::new(); { @@ -524,7 +524,7 @@ fn sidebar_deref_methods<'a>( impl_: &Impl, v: &[Impl], derefs: &mut DefIdSet, - used_links: &mut FxHashSet, + used_links: &mut UsedLinks, deref_id_map: &'a DefIdMap, ) { let c = cx.cache(); @@ -745,15 +745,14 @@ fn sidebar_render_assoc_items( ]); } -fn get_next_url(used_links: &mut FxHashSet, url: String) -> String { - if used_links.insert(url.clone()) { - return url; - } - let mut add = 1; - while !used_links.insert(format!("{url}-{add}")) { - add += 1; - } - format!("{url}-{add}") +/// Tracks sidebar link anchors so duplicates get unique names. +type UsedLinks = FxHashMap; + +fn get_next_url(used_links: &mut UsedLinks, url: String) -> String { + let count = used_links.entry(url.clone()).or_insert(0); + let res = if *count == 0 { url } else { format!("{url}-{count}") }; + *count += 1; + res } enum GetMethodsMode<'r, 'l> { @@ -764,7 +763,7 @@ enum GetMethodsMode<'r, 'l> { fn get_methods<'a>( i: &'a clean::Impl, mut mode: GetMethodsMode<'_, 'a>, - used_links: &mut FxHashSet, + used_links: &mut UsedLinks, tcx: TyCtxt<'_>, ) -> impl Iterator> { i.items.iter().filter_map(move |item| { @@ -802,7 +801,7 @@ fn get_methods<'a>( fn get_associated_constants<'a>( i: &'a clean::Impl, - used_links: &mut FxHashSet, + used_links: &mut UsedLinks, ) -> impl Iterator> { i.items.iter().filter_map(|item| { if let Some(ref name) = item.name @@ -820,7 +819,7 @@ fn get_associated_constants<'a>( fn get_associated_types<'a>( i: &'a clean::Impl, - used_links: &mut FxHashSet, + used_links: &mut UsedLinks, ) -> impl Iterator> { i.items.iter().filter_map(|item| { if let Some(ref name) = item.name diff --git a/src/tools/miri/.gitignore b/src/tools/miri/.gitignore index 23f2513addb74..6851dc9190fce 100644 --- a/src/tools/miri/.gitignore +++ b/src/tools/miri/.gitignore @@ -13,5 +13,6 @@ flamegraph*.svg rustc-ice*.txt tests/native-lib/libtestlib.so .auto-* +miri.toml /genmc/ diff --git a/src/tools/miri/CONTRIBUTING.md b/src/tools/miri/CONTRIBUTING.md index 0a330cdd45537..4bc02217c6f7b 100644 --- a/src/tools/miri/CONTRIBUTING.md +++ b/src/tools/miri/CONTRIBUTING.md @@ -111,13 +111,36 @@ install that exact version of rustc as a toolchain: This will set up a rustup toolchain called `miri` and set it as an override for the current directory. -You can also create a `.auto-everything` file (contents don't matter, can be empty), which -will cause any `./miri` command to automatically call `./miri toolchain`, `clippy` and `rustfmt` -for you. If you don't want all of these to happen, you can add individual `.auto-toolchain`, -`.auto-clippy` and `.auto-fmt` files respectively. - [`rustup-toolchain-install-master`]: https://github.com/kennytm/rustup-toolchain-install-master +### Configuring `./miri` + +The `./miri` script supports optional configuration via a `miri.toml` file. +The following configuration keys are currently supported, with the given default values: + +```toml +[toolchain] +# Overwrite the default toolchain name used by `./miri toolchain`. +# Note that all other commands will just use the currently active rustup toolchain! +# (Though note that if you have `auto.toolchain` enabled, most commands will run `./miri toolchain` +# first, which will activate the toolchain given here.) +name = "miri" +# Additional components to install with the toolchain. Note that if you remove `clippy` or `rustfmt` +# from this list then obviously `./miri clippy`/`./miri fmt` will not work. +# Only takes effect when a new toolchain is installed. Run `rustup toolchain remove ` followed +# by `./miri toolchain` to force this to have effect. +components = ["clippy", "rustfmt"] + +[auto] +# Automatically run `./miri toolchain` before most commands. +# Uses the toolchain name configured above, if any. +toolchain = false +# Automatically run `./miri clippy` before most commands. +clippy = false +# Automatically run `./miri fmt` before most commands. +fmt = false +``` + ## Building and testing Miri Invoking Miri requires getting a bunch of flags right and setting up a custom diff --git a/src/tools/miri/cargo-miri/src/util.rs b/src/tools/miri/cargo-miri/src/util.rs index 162ddcb18bd5f..fb93f177aac9e 100644 --- a/src/tools/miri/cargo-miri/src/util.rs +++ b/src/tools/miri/cargo-miri/src/util.rs @@ -42,9 +42,17 @@ impl CrateRunInfo { let env = env::vars_os() .filter(|(var, _val)| { // We only need to bother with env vars cargo actually sets. - // We try to avoid storing anything that may contain secrets. var.to_str().is_some_and(|var| { - var == "OUT_DIR" || (var.starts_with("CARGO_") && !var.ends_with("_TOKEN")) + ( // Env vars cargo sets for crates. + // + var == "OUT_DIR" + || var.starts_with("CARGO_") + // Env vars rustdoc sets for its rustc invocation. + || var.starts_with("UNSTABLE_RUSTDOC_") + || var.starts_with("RUSTDOC_") + ) + // We try to avoid storing anything that may contain secrets. + && !var.ends_with("_TOKEN") }) }) .collect(); diff --git a/src/tools/miri/etc/rust_analyzer_vscode.json b/src/tools/miri/etc/rust_analyzer_vscode.json index e82c648f59ab4..42b9d830facf5 100644 --- a/src/tools/miri/etc/rust_analyzer_vscode.json +++ b/src/tools/miri/etc/rust_analyzer_vscode.json @@ -25,4 +25,6 @@ "--compile-time-deps", "--message-format=json", ], + // RA reports false errors due to + "rust-analyzer.diagnostics.enable": false, } diff --git a/src/tools/miri/miri-script/Cargo.lock b/src/tools/miri/miri-script/Cargo.lock index d946d77987cf3..3a5afb25a74e5 100644 --- a/src/tools/miri/miri-script/Cargo.lock +++ b/src/tools/miri/miri-script/Cargo.lock @@ -274,6 +274,7 @@ dependencies = [ "serde_json", "shell-words", "tempfile", + "toml", "walkdir", "xshell", ] @@ -409,6 +410,15 @@ dependencies = [ "zmij", ] +[[package]] +name = "serde_spanned" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26" +dependencies = [ + "serde_core", +] + [[package]] name = "shell-words" version = "1.1.1" @@ -445,6 +455,37 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "toml" +version = "1.1.4+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3aace63f4bbcdfc2c965b059de67119c89c4017a70d633be6c104910f67056f5" +dependencies = [ + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "1.1.1+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_parser" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" +dependencies = [ + "winnow", +] + [[package]] name = "unicode-ident" version = "1.0.24" @@ -549,6 +590,12 @@ dependencies = [ "windows-link", ] +[[package]] +name = "winnow" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" + [[package]] name = "wit-bindgen" version = "0.46.0" diff --git a/src/tools/miri/miri-script/Cargo.toml b/src/tools/miri/miri-script/Cargo.toml index fd9a563e1fafd..1b0a34de3e3db 100644 --- a/src/tools/miri/miri-script/Cargo.toml +++ b/src/tools/miri/miri-script/Cargo.toml @@ -22,7 +22,8 @@ xshell = "0.2.6" rustc_version = "0.4" dunce = "1.0.4" serde = "1" +serde_derive = "1" # direct dependency better parallelizes builds serde_json = "1" -serde_derive = "1" tempfile = "3.13.0" clap = { version = "4.5.21", features = ["derive"] } +toml = {version = "1", default-features = false, features = ["serde", "parse"] } diff --git a/src/tools/miri/miri-script/src/commands.rs b/src/tools/miri/miri-script/src/commands.rs index e9b9273611510..90fdef1da949a 100644 --- a/src/tools/miri/miri-script/src/commands.rs +++ b/src/tools/miri/miri-script/src/commands.rs @@ -14,6 +14,7 @@ use walkdir::WalkDir; use xshell::{Shell, cmd}; use crate::Command; +use crate::config::{Config, Toolchain}; use crate::util::*; impl MiriEnv { @@ -67,25 +68,19 @@ impl MiriEnv { } impl Command { - fn auto_actions() -> Result<()> { + fn auto_actions(config: &Config) -> Result<()> { if env::var_os("MIRI_AUTO_OPS").is_some_and(|x| x == "no") { return Ok(()); } - let miri_dir = miri_dir()?; - let auto_everything = path!(miri_dir / ".auto-everything").exists(); - let auto_toolchain = auto_everything || path!(miri_dir / ".auto-toolchain").exists(); - let auto_fmt = auto_everything || path!(miri_dir / ".auto-fmt").exists(); - let auto_clippy = auto_everything || path!(miri_dir / ".auto-clippy").exists(); - // `toolchain` goes first as it could affect the others - if auto_toolchain { - Self::toolchain(None, vec![])?; + if config.auto.toolchain { + Self::toolchain(None, None, vec![], config)?; } - if auto_fmt { + if config.auto.fmt { Self::fmt(vec![])?; } - if auto_clippy { + if config.auto.clippy { // no features for auto actions, see // https://github.com/rust-lang/miri/pull/4396#discussion_r2149654845 Self::clippy(vec![], vec![])?; @@ -94,7 +89,7 @@ impl Command { Ok(()) } - pub fn exec(self) -> Result<()> { + pub fn exec(self, config: &Config) -> Result<()> { // First, and crucially only once, run the auto-actions -- but not for all commands. match &self { Command::Install { .. } @@ -104,7 +99,7 @@ impl Command { | Command::Run { .. } | Command::Fmt { .. } | Command::Doc { .. } - | Command::Clippy { .. } => Self::auto_actions()?, + | Command::Clippy { .. } => Self::auto_actions(config)?, | Command::Toolchain { .. } | Command::Bench { .. } | Command::Squash => {} } // Then run the actual command. @@ -121,12 +116,21 @@ impl Command { Command::Clippy { features, flags } => Self::clippy(features, flags), Command::Bench { target, no_install, save_baseline, load_baseline, benches } => Self::bench(target, no_install, save_baseline, load_baseline, benches), - Command::Toolchain { commit, flags } => Self::toolchain(commit, flags), + Command::Toolchain { name, commit, flags } => + Self::toolchain(name, commit, flags, config), Command::Squash => Self::squash(), } } - fn toolchain(new_commit: Option, flags: Vec) -> Result<()> { + fn toolchain( + name: Option, + new_commit: Option, + flags: Vec, + config: &Config, + ) -> Result<()> { + let name = + name.as_deref().or(config.toolchain.name.as_deref()).unwrap_or(Toolchain::DEFAULT_NAME); + let sh = Shell::new()?; sh.change_dir(miri_dir()?); let new_commit = match new_commit { @@ -134,7 +138,7 @@ impl Command { None => sh.read_file("rust-version")?.trim().to_owned(), }; let current_commit = { - let rustc_info = cmd!(sh, "rustc +miri --version -v").read(); + let rustc_info = cmd!(sh, "rustc +{name} --version -v").read(); if let Ok(rustc_info) = rustc_info { let metadata = rustc_version::version_meta_for(&rustc_info)?; Some( @@ -148,18 +152,25 @@ impl Command { }; // Check if we already are at that commit. if current_commit.as_ref() == Some(&new_commit) { - if active_toolchain()? != "miri" { - cmd!(sh, "rustup override set miri").run()?; + // The toolchain is already at the right version. Make sure it is active in `miri_dir`. + // Ignore errors from `active_toolchain`, the active toolchain might be uninstalled. + if active_toolchain().ok().is_none_or(|toolchain| toolchain != name) { + cmd!(sh, "rustup override set {name}").run()?; } return Ok(()); } - // Install and setup new toolchain. - cmd!(sh, "rustup toolchain uninstall miri").run()?; - cmd!(sh, "rustup-toolchain-install-master -n miri -c cargo -c rust-src -c rustc-dev -c llvm-tools -c rustfmt -c clippy {flags...} -- {new_commit}") + // Compute rustup-toolchain-install-master flags for additional components. + let components = + config.toolchain.components.as_deref().unwrap_or(Toolchain::DEFAULT_COMPONENTS); + let component_flags = components.iter().flat_map(|component| ["-c", component]); + + // Install and setup new toolchain. + cmd!(sh, "rustup toolchain uninstall {name}").run()?; + cmd!(sh, "rustup-toolchain-install-master -n {name} -c cargo -c rust-src -c rustc-dev -c llvm-tools {component_flags...} {flags...} -- {new_commit}") .run() .context("Failed to run rustup-toolchain-install-master. If it is not installed, run 'cargo install --locked rustup-toolchain-install-master'.")?; - cmd!(sh, "rustup override set miri").run()?; + cmd!(sh, "rustup override set {name}").run()?; // Cleanup. cmd!(sh, "cargo clean").run()?; // Call `cargo metadata` on the sources in case that changes the lockfile diff --git a/src/tools/miri/miri-script/src/config.rs b/src/tools/miri/miri-script/src/config.rs new file mode 100644 index 0000000000000..b5f4e729c9d35 --- /dev/null +++ b/src/tools/miri/miri-script/src/config.rs @@ -0,0 +1,59 @@ +use std::borrow::Cow; +use std::{fs, io}; + +use anyhow::{Context, Result, bail}; +use path_macro::path; +use serde_derive::Deserialize; + +use crate::util::miri_dir; + +#[derive(Deserialize, Default)] +pub struct Config { + #[serde(default)] + pub toolchain: Toolchain, + #[serde(default)] + pub auto: Auto, +} + +#[derive(Deserialize, Default)] +pub struct Toolchain { + pub name: Option, + pub components: Option>>, +} + +impl Toolchain { + pub const DEFAULT_NAME: &str = "miri"; + pub const DEFAULT_COMPONENTS: &[Cow<'static, str>] = + &[Cow::Borrowed("clippy"), Cow::Borrowed("rustfmt")]; +} + +#[derive(Deserialize, Default)] +pub struct Auto { + #[serde(default)] + pub toolchain: bool, + #[serde(default)] + pub fmt: bool, + #[serde(default)] + pub clippy: bool, +} + +impl Config { + pub fn load() -> Result { + let miri_dir = miri_dir()?; + + Ok(match fs::read(path!(miri_dir / "miri.toml")) { + Ok(config) => toml::from_slice(&config).context("failed to parse `miri.toml`")?, + Err(err) if err.kind() == io::ErrorKind::NotFound => { + // Just ignore error if the file does not exist. Fall back to parsing the `.auto-*` + // files. + let mut config = Config::default(); + let everything = path!(miri_dir / ".auto-everything").exists(); + config.auto.toolchain = everything || path!(miri_dir / ".auto-toolchain").exists(); + config.auto.fmt = everything || path!(miri_dir / ".auto-fmt").exists(); + config.auto.clippy = everything || path!(miri_dir / ".auto-clippy").exists(); + config + } + Err(err) => bail!("unable to open `miri.toml`: {err}"), + }) + } +} diff --git a/src/tools/miri/miri-script/src/main.rs b/src/tools/miri/miri-script/src/main.rs index b575842fc6c78..bcad8f148d23f 100644 --- a/src/tools/miri/miri-script/src/main.rs +++ b/src/tools/miri/miri-script/src/main.rs @@ -1,6 +1,7 @@ #![allow(clippy::needless_question_mark, rustc::internal)] mod commands; +mod config; mod coverage; mod util; @@ -137,11 +138,15 @@ pub enum Command { /// List of benchmarks to run (default: run all benchmarks). benches: Vec, }, - /// Update and activate the rustup toolchain 'miri'. + /// Update and activate the rustup toolchain 'miri' (or whatever name is configured in + /// `miri.toml`). /// /// The `rust-version` file is used to determine the commit that will be intsalled. /// `rustup-toolchain-install-master` must be installed for this to work. Toolchain { + /// Overwrite the name the toolchain will have in `rustup`. + #[arg(long)] + name: Option, /// Overwrite the commit to install. #[arg(long)] commit: Option, @@ -200,6 +205,10 @@ fn main() -> Result<()> { let args = Cli::parse_from(miri_args); let mut command = args.command; command.add_remainder(remainder)?; - command.exec()?; - Ok(()) + + // Parse config file. + let config = config::Config::load()?; + + // Run the thing. + command.exec(&config) } diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index e861a160a977a..89c3e1334a546 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -feaadeeaca7db0594da854e7c8c07495341c7439 +88638df1e741778019e42fcdf307072865d19501 diff --git a/src/tools/miri/test-cargo-miri/run-test.py b/src/tools/miri/test-cargo-miri/run-test.py index 9764700347c8f..f593a16df9869 100755 --- a/src/tools/miri/test-cargo-miri/run-test.py +++ b/src/tools/miri/test-cargo-miri/run-test.py @@ -49,6 +49,7 @@ def check_output(actual, path, name): if expected == actual: return True print(f"{name} output did not match reference in {path}!") + print("Run `./run-test.py --bless` to update reference files.") print(f"--- BEGIN diff {name} ---") for text in difflib.unified_diff(expected.split("\n"), actual.split("\n")): print(text) diff --git a/src/tools/miri/test-cargo-miri/src/doctest.rs b/src/tools/miri/test-cargo-miri/src/doctest.rs new file mode 100644 index 0000000000000..9e1dd68dc1a2b --- /dev/null +++ b/src/tools/miri/test-cargo-miri/src/doctest.rs @@ -0,0 +1,4 @@ +// Imported into a doctest via `#[path]`. +pub fn make_true() -> bool { + true +} diff --git a/src/tools/miri/test-cargo-miri/src/lib.rs b/src/tools/miri/test-cargo-miri/src/lib.rs index 3b63f8afc9023..0b268e6969d68 100644 --- a/src/tools/miri/test-cargo-miri/src/lib.rs +++ b/src/tools/miri/test-cargo-miri/src/lib.rs @@ -26,6 +26,13 @@ /// /// let _val = Fail::::C; /// ``` +/// +/// Doctest with `#[path]`: +/// +/// ```rust +/// #[path = "doctest.rs"] mod doctest; +/// assert!(doctest::make_true()); +/// ``` // This is imported in `main.rs`. #[unsafe(no_mangle)] pub fn make_true() -> bool { diff --git a/src/tools/miri/test-cargo-miri/test.default.stdout.ref b/src/tools/miri/test-cargo-miri/test.default.stdout.ref index deb7cd839f125..b800d17b83b29 100644 --- a/src/tools/miri/test-cargo-miri/test.default.stdout.ref +++ b/src/tools/miri/test-cargo-miri/test.default.stdout.ref @@ -10,8 +10,8 @@ running 6 tests test result: ok. 5 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in $TIME -running 5 tests -..... -test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +running 6 tests +...... +test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/src/tools/miri/test-cargo-miri/test.filter.stdout.ref b/src/tools/miri/test-cargo-miri/test.filter.stdout.ref index a4d912e7a8d0a..5b0c846b8a1e0 100644 --- a/src/tools/miri/test-cargo-miri/test.filter.stdout.ref +++ b/src/tools/miri/test-cargo-miri/test.filter.stdout.ref @@ -13,6 +13,6 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out; fini running 0 tests -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out; finished in $TIME +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 6 filtered out; finished in $TIME all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/src/tools/miri/test-cargo-miri/test.multiple_targets.stdout.ref b/src/tools/miri/test-cargo-miri/test.multiple_targets.stdout.ref index b36fb3af66641..d4f9de09366b1 100644 --- a/src/tools/miri/test-cargo-miri/test.multiple_targets.stdout.ref +++ b/src/tools/miri/test-cargo-miri/test.multiple_targets.stdout.ref @@ -21,14 +21,14 @@ running 6 tests test result: ok. 5 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in $TIME -running 5 tests -..... -test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +running 6 tests +...... +test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME all doctests ran in $TIME; merged doctests compilation took $TIME -running 5 tests -..... -test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +running 6 tests +...... +test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/src/tools/miri/test-cargo-miri/test.workspace.stdout.ref b/src/tools/miri/test-cargo-miri/test.workspace.stdout.ref index c890af4bd974c..2400dff6c3197 100644 --- a/src/tools/miri/test-cargo-miri/test.workspace.stdout.ref +++ b/src/tools/miri/test-cargo-miri/test.workspace.stdout.ref @@ -21,9 +21,9 @@ running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME -running 5 tests -..... -test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +running 6 tests +...... +test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/tests/codegen-llvm/asm-arm-r14.rs b/tests/codegen-llvm/asm-arm-r14.rs index 2404e84c1701e..2af9e372a462d 100644 --- a/tests/codegen-llvm/asm-arm-r14.rs +++ b/tests/codegen-llvm/asm-arm-r14.rs @@ -1,9 +1,6 @@ //@ add-minicore //@ compile-flags: --target armv7-unknown-linux-gnueabihf //@ needs-llvm-components: arm -//@ revisions: LLVM22 LLVM23 -//@ [LLVM22] max-llvm-major-version: 22 -//@ [LLVM23] min-llvm-version: 23 #![feature(no_core)] #![no_core] @@ -15,8 +12,7 @@ use minicore::*; #[no_mangle] pub unsafe fn r14_output() -> u32 { // CHECK-LABEL: define{{.*}}@r14_output - // LLVM22: asm sideeffect{{.*}}"=&{lr},~{cc},~{memory}" - // LLVM23: asm sideeffect{{.*}}"=&{r14},~{cc},~{memory}" + // CHECK: asm sideeffect{{.*}}"=&{lr},~{cc},~{memory}" let output: u32; asm!("", out("r14") output); output diff --git a/tests/rustdoc-html/deref/sidebar-links-deref-chain.rs b/tests/rustdoc-html/deref/sidebar-links-deref-chain.rs new file mode 100644 index 0000000000000..2b67228f5de30 --- /dev/null +++ b/tests/rustdoc-html/deref/sidebar-links-deref-chain.rs @@ -0,0 +1,21 @@ +// Regression test for . +#![crate_name = "foo"] + +pub struct S0; +pub struct S1; +pub struct S2; +pub struct S3; + +impl S0 { pub fn foo(&self) {} } +impl S1 { pub fn foo(&self) {} } +impl S2 { pub fn foo(&self) {} } +impl S3 { pub fn foo(&self) {} } + +impl std::ops::Deref for S0 { type Target = S1; fn deref(&self) -> &S1 { &S1 } } +impl std::ops::Deref for S1 { type Target = S2; fn deref(&self) -> &S2 { &S2 } } +impl std::ops::Deref for S2 { type Target = S3; fn deref(&self) -> &S3 { &S3 } } + +//@ has foo/struct.S0.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.foo"]' 'foo' +//@ has foo/struct.S0.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.foo-1"]' 'foo' +//@ has foo/struct.S0.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.foo-2"]' 'foo' +//@ has foo/struct.S0.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.foo-3"]' 'foo' diff --git a/tests/ui/asm/thumbv6m-clobber-abi-r14.rs b/tests/ui/asm/thumbv6m-clobber-abi-r14.rs new file mode 100644 index 0000000000000..342e65b52d9d8 --- /dev/null +++ b/tests/ui/asm/thumbv6m-clobber-abi-r14.rs @@ -0,0 +1,18 @@ +//@ add-minicore +//@ build-pass +//@ compile-flags: --target thumbv6m-none-eabi +//@ needs-llvm-components: arm +//@ ignore-backends: gcc + +#![feature(no_core)] +#![no_core] +#![crate_type = "rlib"] + +extern crate minicore; +use minicore::*; + +pub fn clobber_c_abi() { + unsafe { + asm!("nop", clobber_abi("C")); + } +} diff --git a/tests/ui/eii/default/call_default.rs b/tests/ui/eii/default/call_default.rs index 7769ae00bb0f5..db5b7da45d470 100644 --- a/tests/ui/eii/default/call_default.rs +++ b/tests/ui/eii/default/call_default.rs @@ -3,7 +3,6 @@ //@ aux-build: decl_with_default.rs //@ run-pass //@ check-run-results -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests EIIs with default implementations. diff --git a/tests/ui/eii/default/call_default_panics.rs b/tests/ui/eii/default/call_default_panics.rs index d027748b0ffb3..526e71856046b 100644 --- a/tests/ui/eii/default/call_default_panics.rs +++ b/tests/ui/eii/default/call_default_panics.rs @@ -5,7 +5,6 @@ //@ run-pass //@ needs-unwind //@ exec-env:RUST_BACKTRACE=1 -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // A small test to make sure that unwinding works properly. diff --git a/tests/ui/eii/default/call_impl.rs b/tests/ui/eii/default/call_impl.rs index 4b64033a940f5..7f7d5d0163cfb 100644 --- a/tests/ui/eii/default/call_impl.rs +++ b/tests/ui/eii/default/call_impl.rs @@ -4,7 +4,6 @@ //@ aux-build: impl1.rs //@ run-pass //@ check-run-results -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests EIIs with default implementations. diff --git a/tests/ui/eii/default/local_crate.rs b/tests/ui/eii/default/local_crate.rs index d6e992c409453..bf97c8bd2fd68 100644 --- a/tests/ui/eii/default/local_crate.rs +++ b/tests/ui/eii/default/local_crate.rs @@ -1,6 +1,5 @@ //@ run-pass //@ check-run-results -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests EIIs with default implementations. diff --git a/tests/ui/eii/default/local_crate_explicit.rs b/tests/ui/eii/default/local_crate_explicit.rs index 7c29fa0edd6ae..c2e52f8bd174a 100644 --- a/tests/ui/eii/default/local_crate_explicit.rs +++ b/tests/ui/eii/default/local_crate_explicit.rs @@ -1,6 +1,5 @@ //@ run-pass //@ check-run-results -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests EIIs with default implementations. diff --git a/tests/ui/eii/default/local_crate_explicit.stderr b/tests/ui/eii/default/local_crate_explicit.stderr index d80acf14c516d..51b4d9b545b3d 100644 --- a/tests/ui/eii/default/local_crate_explicit.stderr +++ b/tests/ui/eii/default/local_crate_explicit.stderr @@ -1,5 +1,5 @@ warning: function `decl1` is never used - --> $DIR/local_crate_explicit.rs:11:8 + --> $DIR/local_crate_explicit.rs:10:8 | LL | pub fn decl1(x: u64) { | ^^^^^ diff --git a/tests/ui/eii/duplicate/both_decl_and_impl.rs b/tests/ui/eii/duplicate/both_decl_and_impl.rs index a2fc571d3f497..9cf122e40aac3 100644 --- a/tests/ui/eii/duplicate/both_decl_and_impl.rs +++ b/tests/ui/eii/duplicate/both_decl_and_impl.rs @@ -1,4 +1,3 @@ -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests that one item can't both define and impl an EII at the same time diff --git a/tests/ui/eii/duplicate/both_decl_and_impl.stderr b/tests/ui/eii/duplicate/both_decl_and_impl.stderr index 1cec485a90cff..d109eaee95a5e 100644 --- a/tests/ui/eii/duplicate/both_decl_and_impl.stderr +++ b/tests/ui/eii/duplicate/both_decl_and_impl.stderr @@ -1,23 +1,23 @@ error: a single item cannot both declare and implement EIIs - --> $DIR/both_decl_and_impl.rs:11:1 + --> $DIR/both_decl_and_impl.rs:10:1 | LL | #[eii] | ^^^^^^ error: only a small subset of attributes are supported on externally implementable items - --> $DIR/both_decl_and_impl.rs:21:1 + --> $DIR/both_decl_and_impl.rs:20:1 | LL | fn d(x: u64) {} | ^^^^^^^^^^^^ | note: this attribute is not supported - --> $DIR/both_decl_and_impl.rs:20:1 + --> $DIR/both_decl_and_impl.rs:19:1 | LL | #[c] | ^^^^ error: `#[c]` function required, but not found - --> $DIR/both_decl_and_impl.rs:16:4 + --> $DIR/both_decl_and_impl.rs:15:4 | LL | fn c(x: u64); | ^ expected because `#[c]` was declared here in crate `both_decl_and_impl` diff --git a/tests/ui/eii/duplicate/duplicate1.rs b/tests/ui/eii/duplicate/duplicate1.rs index 54803f31c85f4..9dc9038bec059 100644 --- a/tests/ui/eii/duplicate/duplicate1.rs +++ b/tests/ui/eii/duplicate/duplicate1.rs @@ -2,7 +2,6 @@ //@[dylib] needs-crate-type: dylib //@ aux-build: impl1.rs //@ aux-build: impl2.rs -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // tests that EIIs error properly, even if the conflicting implementations live in another crate. diff --git a/tests/ui/eii/duplicate/duplicate2.rs b/tests/ui/eii/duplicate/duplicate2.rs index 8b4d7c4913c91..95121e1e6d9b8 100644 --- a/tests/ui/eii/duplicate/duplicate2.rs +++ b/tests/ui/eii/duplicate/duplicate2.rs @@ -1,7 +1,6 @@ //@ aux-build: impl1.rs //@ aux-build: impl2.rs //@ aux-build: impl3.rs -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests the error message when there are multiple implementations of an EII in many crates. diff --git a/tests/ui/eii/duplicate/duplicate3.rs b/tests/ui/eii/duplicate/duplicate3.rs index 96d6543130ccb..d50b87865109b 100644 --- a/tests/ui/eii/duplicate/duplicate3.rs +++ b/tests/ui/eii/duplicate/duplicate3.rs @@ -2,7 +2,6 @@ //@ aux-build: impl2.rs //@ aux-build: impl3.rs //@ aux-build: impl4.rs -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests the error message when there are multiple implementations of an EII in many crates. diff --git a/tests/ui/eii/duplicate/dylib_default_duplicate.rs b/tests/ui/eii/duplicate/dylib_default_duplicate.rs index 5480bb13b4a49..a72a137eb9709 100644 --- a/tests/ui/eii/duplicate/dylib_default_duplicate.rs +++ b/tests/ui/eii/duplicate/dylib_default_duplicate.rs @@ -1,7 +1,6 @@ //@ aux-build: dylib_default.rs //@ needs-crate-type: dylib //@ compile-flags: --emit link -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Regression test for https://github.com/rust-lang/rust/issues/156320. diff --git a/tests/ui/eii/duplicate/dylib_default_duplicate.stderr b/tests/ui/eii/duplicate/dylib_default_duplicate.stderr index 04c6a13710e28..91c90edb02449 100644 --- a/tests/ui/eii/duplicate/dylib_default_duplicate.stderr +++ b/tests/ui/eii/duplicate/dylib_default_duplicate.stderr @@ -1,5 +1,5 @@ error: multiple implementations of `#[eii1]` - --> $DIR/dylib_default_duplicate.rs:15:1 + --> $DIR/dylib_default_duplicate.rs:14:1 | LL | fn other(x: u64) { | ^^^^^^^^^^^^^^^^ first implemented here in crate `dylib_default_duplicate` diff --git a/tests/ui/eii/duplicate/multiple_impls.rs b/tests/ui/eii/duplicate/multiple_impls.rs index 3e541cb16b131..8f1feaa530adb 100644 --- a/tests/ui/eii/duplicate/multiple_impls.rs +++ b/tests/ui/eii/duplicate/multiple_impls.rs @@ -1,4 +1,3 @@ -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests that one item can't implement two EIIs diff --git a/tests/ui/eii/duplicate/multiple_impls.stderr b/tests/ui/eii/duplicate/multiple_impls.stderr index efeec635c859a..b2e8871d2087a 100644 --- a/tests/ui/eii/duplicate/multiple_impls.stderr +++ b/tests/ui/eii/duplicate/multiple_impls.stderr @@ -1,17 +1,17 @@ error: a single item cannot implement multiple EIIs - --> $DIR/multiple_impls.rs:15:1 + --> $DIR/multiple_impls.rs:14:1 | LL | #[b] | ^^^^ error: a single item cannot implement multiple EIIs - --> $DIR/multiple_impls.rs:29:1 + --> $DIR/multiple_impls.rs:28:1 | LL | #[d] | ^^^^ error: `#[a]` function required, but not found - --> $DIR/multiple_impls.rs:8:4 + --> $DIR/multiple_impls.rs:7:4 | LL | fn a(x: u64); | ^ expected because `#[a]` was declared here in crate `multiple_impls` @@ -19,7 +19,7 @@ LL | fn a(x: u64); = help: expected at least one implementation in crate `multiple_impls` or any of its dependencies error: `#[c]` static required, but not found - --> $DIR/multiple_impls.rs:21:7 + --> $DIR/multiple_impls.rs:20:7 | LL | #[eii(c)] | ^ expected because `#[c]` was declared here in crate `multiple_impls` diff --git a/tests/ui/eii/eii_impl_with_contract.rs b/tests/ui/eii/eii_impl_with_contract.rs index 1789ec92ea60d..a33d7a0c23751 100644 --- a/tests/ui/eii/eii_impl_with_contract.rs +++ b/tests/ui/eii/eii_impl_with_contract.rs @@ -1,5 +1,4 @@ //@ run-pass -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu diff --git a/tests/ui/eii/linking/codegen_cross_crate.rs b/tests/ui/eii/linking/codegen_cross_crate.rs index ab0d4d4b9eb25..f11c8a04661b6 100644 --- a/tests/ui/eii/linking/codegen_cross_crate.rs +++ b/tests/ui/eii/linking/codegen_cross_crate.rs @@ -2,7 +2,6 @@ //@ check-run-results //@ aux-build: codegen_cross_crate_other_crate.rs //@ compile-flags: -O -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether calling EIIs works with the declaration in another crate. diff --git a/tests/ui/eii/linking/codegen_single_crate.rs b/tests/ui/eii/linking/codegen_single_crate.rs index 4faa30a79040f..81b56cd4261ba 100644 --- a/tests/ui/eii/linking/codegen_single_crate.rs +++ b/tests/ui/eii/linking/codegen_single_crate.rs @@ -1,6 +1,5 @@ //@ run-pass //@ check-run-results -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether calling EIIs works with the declaration in the same crate. diff --git a/tests/ui/eii/linking/same-symbol.rs b/tests/ui/eii/linking/same-symbol.rs index 02518f6bced03..57af6357f3de4 100644 --- a/tests/ui/eii/linking/same-symbol.rs +++ b/tests/ui/eii/linking/same-symbol.rs @@ -1,6 +1,5 @@ //@ run-pass //@ check-run-results -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu #![feature(extern_item_impls)] diff --git a/tests/ui/eii/linking/track_caller_cross_crate.rs b/tests/ui/eii/linking/track_caller_cross_crate.rs index e8ba5dc2b864b..b8d0d53336c39 100644 --- a/tests/ui/eii/linking/track_caller_cross_crate.rs +++ b/tests/ui/eii/linking/track_caller_cross_crate.rs @@ -2,7 +2,6 @@ //@ check-run-results //@ aux-build: track_caller_cross_other_crate.rs //@ compile-flags: -O -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests that `#[track_caller]` on an EII declaration in one crate is derived diff --git a/tests/ui/eii/privacy1.rs b/tests/ui/eii/privacy1.rs index 95544ae867d89..e342441546513 100644 --- a/tests/ui/eii/privacy1.rs +++ b/tests/ui/eii/privacy1.rs @@ -1,7 +1,6 @@ //@ run-pass //@ check-run-results //@ aux-build: other_crate_privacy1.rs -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether re-exports work. diff --git a/tests/ui/eii/shadow_builtin.rs b/tests/ui/eii/shadow_builtin.rs index cd4c14514dc46..f9447b85273af 100644 --- a/tests/ui/eii/shadow_builtin.rs +++ b/tests/ui/eii/shadow_builtin.rs @@ -1,4 +1,3 @@ -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether calling EIIs works with the declaration in the same crate. diff --git a/tests/ui/eii/shadow_builtin.stderr b/tests/ui/eii/shadow_builtin.stderr index 33f60b2d2f13f..bdb580785d15c 100644 --- a/tests/ui/eii/shadow_builtin.stderr +++ b/tests/ui/eii/shadow_builtin.stderr @@ -1,5 +1,5 @@ error[E0659]: `inline` is ambiguous - --> $DIR/shadow_builtin.rs:11:3 + --> $DIR/shadow_builtin.rs:10:3 | LL | #[inline] | ^^^^^^ ambiguous name @@ -7,14 +7,14 @@ LL | #[inline] = note: ambiguous because of a name conflict with a builtin attribute = note: `inline` could refer to a built-in attribute note: `inline` could also refer to the attribute macro defined here - --> $DIR/shadow_builtin.rs:7:1 + --> $DIR/shadow_builtin.rs:6:1 | LL | #[eii(inline)] | ^^^^^^^^^^^^^^ = help: use `crate::inline` to refer to this attribute macro unambiguously error: `#[inline]` function required, but not found - --> $DIR/shadow_builtin.rs:7:7 + --> $DIR/shadow_builtin.rs:6:7 | LL | #[eii(inline)] | ^^^^^^ expected because `#[inline]` was declared here in crate `shadow_builtin` diff --git a/tests/ui/eii/static/argument_required.rs b/tests/ui/eii/static/argument_required.rs index 9b00dcf194387..e8f66e083e983 100644 --- a/tests/ui/eii/static/argument_required.rs +++ b/tests/ui/eii/static/argument_required.rs @@ -1,4 +1,3 @@ -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether EIIs work on statics diff --git a/tests/ui/eii/static/argument_required.stderr b/tests/ui/eii/static/argument_required.stderr index 9e5ee398f77d8..9f722d2065e1e 100644 --- a/tests/ui/eii/static/argument_required.stderr +++ b/tests/ui/eii/static/argument_required.stderr @@ -1,5 +1,5 @@ error: `#[eii]` requires the name as an explicit argument when used on a static - --> $DIR/argument_required.rs:7:1 + --> $DIR/argument_required.rs:6:1 | LL | #[eii] | ^^^^^^ diff --git a/tests/ui/eii/static/cross_crate_decl.rs b/tests/ui/eii/static/cross_crate_decl.rs index 75333c48e40ef..ba038102099f5 100644 --- a/tests/ui/eii/static/cross_crate_decl.rs +++ b/tests/ui/eii/static/cross_crate_decl.rs @@ -2,7 +2,6 @@ //@ check-run-results //@ aux-build: cross_crate_decl.rs //@ compile-flags: -O -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether calling EIIs works with the declaration in another crate. diff --git a/tests/ui/eii/static/cross_crate_def.rs b/tests/ui/eii/static/cross_crate_def.rs index 19dbdaadeef05..0461c1dfe7398 100644 --- a/tests/ui/eii/static/cross_crate_def.rs +++ b/tests/ui/eii/static/cross_crate_def.rs @@ -4,7 +4,6 @@ //@ check-run-results //@ aux-build: cross_crate_def.rs //@ compile-flags: -O -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether calling EIIs works with the declaration and definition in another crate. diff --git a/tests/ui/eii/static/default.rs b/tests/ui/eii/static/default.rs index beb777cc32e82..c4e2208337914 100644 --- a/tests/ui/eii/static/default.rs +++ b/tests/ui/eii/static/default.rs @@ -1,6 +1,5 @@ //@ run-pass //@ check-run-results -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // FIXME(#157649): static EII defaults currently fail to link on Apple targets. diff --git a/tests/ui/eii/static/default_apple.rs b/tests/ui/eii/static/default_apple.rs index f638ee480f4cb..38446a2d17150 100644 --- a/tests/ui/eii/static/default_apple.rs +++ b/tests/ui/eii/static/default_apple.rs @@ -1,5 +1,4 @@ //@ only-apple -//@ ignore-backends: gcc #![feature(extern_item_impls)] #![crate_type = "lib"] diff --git a/tests/ui/eii/static/default_cross_crate.rs b/tests/ui/eii/static/default_cross_crate.rs index 9d6df257ffbef..a53c73876d977 100644 --- a/tests/ui/eii/static/default_cross_crate.rs +++ b/tests/ui/eii/static/default_cross_crate.rs @@ -3,7 +3,6 @@ //@ aux-build: decl_with_default.rs //@ run-pass //@ check-run-results -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // FIXME(#157649): static EII defaults currently fail to link on Apple targets. diff --git a/tests/ui/eii/static/default_cross_crate_explicit.rs b/tests/ui/eii/static/default_cross_crate_explicit.rs index 6ad015b9b601b..4835e2ed323ab 100644 --- a/tests/ui/eii/static/default_cross_crate_explicit.rs +++ b/tests/ui/eii/static/default_cross_crate_explicit.rs @@ -4,7 +4,6 @@ //@ aux-build: impl_default_override.rs //@ run-pass //@ check-run-results -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // FIXME(#157649): static EII defaults currently fail to link on Apple targets. diff --git a/tests/ui/eii/static/default_explicit.rs b/tests/ui/eii/static/default_explicit.rs index 8237b18106031..bc3f44e7e01b5 100644 --- a/tests/ui/eii/static/default_explicit.rs +++ b/tests/ui/eii/static/default_explicit.rs @@ -1,6 +1,5 @@ //@ run-pass //@ check-run-results -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // FIXME(#157649): static EII defaults currently fail to link on Apple targets. diff --git a/tests/ui/eii/static/duplicate.rs b/tests/ui/eii/static/duplicate.rs index a8db02f33051d..54cab82f617e7 100644 --- a/tests/ui/eii/static/duplicate.rs +++ b/tests/ui/eii/static/duplicate.rs @@ -1,4 +1,3 @@ -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether EIIs work on statics diff --git a/tests/ui/eii/static/duplicate.stderr b/tests/ui/eii/static/duplicate.stderr index 270664c8c74c6..e967e9c4e65c8 100644 --- a/tests/ui/eii/static/duplicate.stderr +++ b/tests/ui/eii/static/duplicate.stderr @@ -1,5 +1,5 @@ error: multiple implementations of `#[hello]` - --> $DIR/duplicate.rs:11:1 + --> $DIR/duplicate.rs:10:1 | LL | static HELLO_IMPL1: u64 = 5; | ^^^^^^^^^^^^^^^^^^^^^^^ first implemented here in crate `duplicate` diff --git a/tests/ui/eii/static/mismatch_fn_static.rs b/tests/ui/eii/static/mismatch_fn_static.rs index 8d8fa5b4d06c4..49003388526f8 100644 --- a/tests/ui/eii/static/mismatch_fn_static.rs +++ b/tests/ui/eii/static/mismatch_fn_static.rs @@ -1,4 +1,3 @@ -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether EIIs work on statics diff --git a/tests/ui/eii/static/mismatch_fn_static.stderr b/tests/ui/eii/static/mismatch_fn_static.stderr index e8fa5f85b1f13..e8be6ccb7ef57 100644 --- a/tests/ui/eii/static/mismatch_fn_static.stderr +++ b/tests/ui/eii/static/mismatch_fn_static.stderr @@ -1,5 +1,5 @@ error: `#[hello]` must be used on a function - --> $DIR/mismatch_fn_static.rs:10:1 + --> $DIR/mismatch_fn_static.rs:9:1 | LL | #[hello] | ^^^^^^^^ diff --git a/tests/ui/eii/static/mismatch_mut.rs b/tests/ui/eii/static/mismatch_mut.rs index 61c806fb976ca..b0e35b2bf84dc 100644 --- a/tests/ui/eii/static/mismatch_mut.rs +++ b/tests/ui/eii/static/mismatch_mut.rs @@ -1,4 +1,3 @@ -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether EIIs work on statics diff --git a/tests/ui/eii/static/mismatch_mut.stderr b/tests/ui/eii/static/mismatch_mut.stderr index 537ac0de3c3a2..0812652a6a1bc 100644 --- a/tests/ui/eii/static/mismatch_mut.stderr +++ b/tests/ui/eii/static/mismatch_mut.stderr @@ -1,11 +1,11 @@ error: `#[eii]` cannot be used on mutable statics - --> $DIR/mismatch_mut.rs:7:1 + --> $DIR/mismatch_mut.rs:6:1 | LL | #[eii(hello)] | ^^^^^^^^^^^^^ error: mutability does not match with the definition of`#[hello]` - --> $DIR/mismatch_mut.rs:11:1 + --> $DIR/mismatch_mut.rs:10:1 | LL | #[hello] | ^^^^^^^^ diff --git a/tests/ui/eii/static/mismatch_mut2.rs b/tests/ui/eii/static/mismatch_mut2.rs index ff21af5f0d714..f083e713d1769 100644 --- a/tests/ui/eii/static/mismatch_mut2.rs +++ b/tests/ui/eii/static/mismatch_mut2.rs @@ -1,4 +1,3 @@ -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether EIIs work on statics diff --git a/tests/ui/eii/static/mismatch_mut2.stderr b/tests/ui/eii/static/mismatch_mut2.stderr index 6ac3df57697db..b4b953d61a23f 100644 --- a/tests/ui/eii/static/mismatch_mut2.stderr +++ b/tests/ui/eii/static/mismatch_mut2.stderr @@ -1,5 +1,5 @@ error: mutability does not match with the definition of`#[hello]` - --> $DIR/mismatch_mut2.rs:10:1 + --> $DIR/mismatch_mut2.rs:9:1 | LL | #[hello] | ^^^^^^^^ diff --git a/tests/ui/eii/static/mismatch_safety.rs b/tests/ui/eii/static/mismatch_safety.rs index b8d503adc2d21..667c6fff14189 100644 --- a/tests/ui/eii/static/mismatch_safety.rs +++ b/tests/ui/eii/static/mismatch_safety.rs @@ -1,4 +1,3 @@ -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether EIIs work on statics diff --git a/tests/ui/eii/static/mismatch_safety.stderr b/tests/ui/eii/static/mismatch_safety.stderr index d4fa85778ae11..19a3b0dd86639 100644 --- a/tests/ui/eii/static/mismatch_safety.stderr +++ b/tests/ui/eii/static/mismatch_safety.stderr @@ -1,5 +1,5 @@ error: safety does not match with the definition of`#[hello]` - --> $DIR/mismatch_safety.rs:10:1 + --> $DIR/mismatch_safety.rs:9:1 | LL | #[hello] | ^^^^^^^^ diff --git a/tests/ui/eii/static/mismatch_safety2.rs b/tests/ui/eii/static/mismatch_safety2.rs index 412e2a694c1fc..5240184f6ada5 100644 --- a/tests/ui/eii/static/mismatch_safety2.rs +++ b/tests/ui/eii/static/mismatch_safety2.rs @@ -1,4 +1,3 @@ -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether EIIs work on statics diff --git a/tests/ui/eii/static/mismatch_safety2.stderr b/tests/ui/eii/static/mismatch_safety2.stderr index 6957a6202b614..c49f55f2b911a 100644 --- a/tests/ui/eii/static/mismatch_safety2.stderr +++ b/tests/ui/eii/static/mismatch_safety2.stderr @@ -1,5 +1,5 @@ error: static items cannot be declared with `unsafe` safety qualifier outside of `extern` block - --> $DIR/mismatch_safety2.rs:11:1 + --> $DIR/mismatch_safety2.rs:10:1 | LL | unsafe static HELLO_IMPL: u64 = 5; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/eii/static/mismatch_static_fn.rs b/tests/ui/eii/static/mismatch_static_fn.rs index 06e3d95b7cdcb..b4fd139959d68 100644 --- a/tests/ui/eii/static/mismatch_static_fn.rs +++ b/tests/ui/eii/static/mismatch_static_fn.rs @@ -1,4 +1,3 @@ -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether EIIs work on statics diff --git a/tests/ui/eii/static/mismatch_static_fn.stderr b/tests/ui/eii/static/mismatch_static_fn.stderr index 639e3cfa3beb3..56ea50c00fdd0 100644 --- a/tests/ui/eii/static/mismatch_static_fn.stderr +++ b/tests/ui/eii/static/mismatch_static_fn.stderr @@ -1,5 +1,5 @@ error: `#[hello]` must be used on a static - --> $DIR/mismatch_static_fn.rs:10:1 + --> $DIR/mismatch_static_fn.rs:9:1 | LL | #[hello] | ^^^^^^^^ diff --git a/tests/ui/eii/static/mut.rs b/tests/ui/eii/static/mut.rs index 4c9d84061fb25..c351a6df8fbd2 100644 --- a/tests/ui/eii/static/mut.rs +++ b/tests/ui/eii/static/mut.rs @@ -1,4 +1,3 @@ -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether EIIs work on statics diff --git a/tests/ui/eii/static/mut.stderr b/tests/ui/eii/static/mut.stderr index cd3a0ca23c7f4..299737d1f07b6 100644 --- a/tests/ui/eii/static/mut.stderr +++ b/tests/ui/eii/static/mut.stderr @@ -1,5 +1,5 @@ error: `#[eii]` cannot be used on mutable statics - --> $DIR/mut.rs:7:1 + --> $DIR/mut.rs:6:1 | LL | #[eii(hello)] | ^^^^^^^^^^^^^ diff --git a/tests/ui/eii/static/same_address.rs b/tests/ui/eii/static/same_address.rs index de316b9f5f9ff..a49ffd9a552b7 100644 --- a/tests/ui/eii/static/same_address.rs +++ b/tests/ui/eii/static/same_address.rs @@ -1,6 +1,5 @@ //@ run-pass //@ check-run-results -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether EIIs and their declarations share the same address diff --git a/tests/ui/eii/static/simple.rs b/tests/ui/eii/static/simple.rs index a592609e9153a..84d49bcef638a 100644 --- a/tests/ui/eii/static/simple.rs +++ b/tests/ui/eii/static/simple.rs @@ -1,6 +1,5 @@ //@ run-pass //@ check-run-results -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests whether EIIs work on statics diff --git a/tests/ui/eii/static/subtype.rs b/tests/ui/eii/static/subtype.rs index 4553d7b8c59c0..a417838e2f7b0 100644 --- a/tests/ui/eii/static/subtype.rs +++ b/tests/ui/eii/static/subtype.rs @@ -1,5 +1,4 @@ //@ check-pass -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests that mismatching types of the declaration and definition are rejected diff --git a/tests/ui/eii/static/subtype_wrong.rs b/tests/ui/eii/static/subtype_wrong.rs index ac975592a0f08..9d67d7b458cc7 100644 --- a/tests/ui/eii/static/subtype_wrong.rs +++ b/tests/ui/eii/static/subtype_wrong.rs @@ -1,4 +1,3 @@ -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests that mismatching types of the declaration and definition are rejected diff --git a/tests/ui/eii/static/subtype_wrong.stderr b/tests/ui/eii/static/subtype_wrong.stderr index a20074947c15d..77a1353aecc32 100644 --- a/tests/ui/eii/static/subtype_wrong.stderr +++ b/tests/ui/eii/static/subtype_wrong.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/subtype_wrong.rs:13:1 + --> $DIR/subtype_wrong.rs:12:1 | LL | static HELLO_IMPL: for<'a> fn(&'a u8) -> &'a u8 = |_| todo!(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other diff --git a/tests/ui/eii/static/wrong_ty.rs b/tests/ui/eii/static/wrong_ty.rs index 40b7859b06b01..4f320603c512f 100644 --- a/tests/ui/eii/static/wrong_ty.rs +++ b/tests/ui/eii/static/wrong_ty.rs @@ -1,4 +1,3 @@ -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests that mismatching types of the declaration and definition are rejected diff --git a/tests/ui/eii/static/wrong_ty.stderr b/tests/ui/eii/static/wrong_ty.stderr index 5095513527747..b7569ea82b77f 100644 --- a/tests/ui/eii/static/wrong_ty.stderr +++ b/tests/ui/eii/static/wrong_ty.stderr @@ -1,11 +1,11 @@ error[E0806]: static `HELLO_IMPL` has a type that is incompatible with the declaration of `#[hello]` - --> $DIR/wrong_ty.rs:13:1 + --> $DIR/wrong_ty.rs:12:1 | LL | static HELLO_IMPL: bool = true; | ^^^^^^^^^^^^^^^^^^^^^^^ | note: expected this because of this attribute - --> $DIR/wrong_ty.rs:12:1 + --> $DIR/wrong_ty.rs:11:1 | LL | #[hello] | ^^^^^^^^ diff --git a/tests/ui/eii/track_caller.rs b/tests/ui/eii/track_caller.rs index 5e298fba9675a..52807428f20d0 100644 --- a/tests/ui/eii/track_caller.rs +++ b/tests/ui/eii/track_caller.rs @@ -1,5 +1,4 @@ //@ run-pass -//@ ignore-backends: gcc // FIXME(#125418): linking on Windows GNU targets is not yet supported. //@ ignore-windows-gnu // Tests that `#[track_caller]` on an EII declaration is threaded through both diff --git a/tests/ui/lint/fn-ptr-comparisons-no_std.fixed b/tests/ui/lint/fn-ptr-comparisons-no_std.fixed new file mode 100644 index 0000000000000..dd7477976b108 --- /dev/null +++ b/tests/ui/lint/fn-ptr-comparisons-no_std.fixed @@ -0,0 +1,13 @@ +//@ check-pass +//@ run-rustfix + +#![no_std] +#![crate_type = "lib"] +#![allow(dead_code)] + +fn a() {} + +fn cmp(f: fn()) -> bool { + core::ptr::fn_addr_eq(f, a as fn()) + //~^ WARN function pointer comparisons +} diff --git a/tests/ui/lint/fn-ptr-comparisons-no_std.rs b/tests/ui/lint/fn-ptr-comparisons-no_std.rs new file mode 100644 index 0000000000000..cdeab43b8b2b1 --- /dev/null +++ b/tests/ui/lint/fn-ptr-comparisons-no_std.rs @@ -0,0 +1,13 @@ +//@ check-pass +//@ run-rustfix + +#![no_std] +#![crate_type = "lib"] +#![allow(dead_code)] + +fn a() {} + +fn cmp(f: fn()) -> bool { + f == a + //~^ WARN function pointer comparisons +} diff --git a/tests/ui/lint/fn-ptr-comparisons-no_std.stderr b/tests/ui/lint/fn-ptr-comparisons-no_std.stderr new file mode 100644 index 0000000000000..f51f0bbb7437b --- /dev/null +++ b/tests/ui/lint/fn-ptr-comparisons-no_std.stderr @@ -0,0 +1,18 @@ +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons-no_std.rs:11:5 + | +LL | f == a + | ^^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit + = note: `#[warn(unpredictable_function_pointer_comparisons)]` on by default +help: refactor your code, or use `core::ptr::fn_addr_eq` to suppress the lint + | +LL - f == a +LL + core::ptr::fn_addr_eq(f, a as fn()) + | + +warning: 1 warning emitted + diff --git a/tests/ui/lint/int_to_ptr-no_core.rs b/tests/ui/lint/int_to_ptr-no_core.rs new file mode 100644 index 0000000000000..d62855e43ddb8 --- /dev/null +++ b/tests/ui/lint/int_to_ptr-no_core.rs @@ -0,0 +1,15 @@ +//@ check-pass +//@ add-minicore + +#![feature(no_core)] +#![no_core] +#![crate_type = "lib"] +#![allow(dead_code)] + +extern crate minicore; +use minicore::*; + +pub unsafe fn should_lint(a: usize) -> *const u8 { + unsafe { mem::transmute::(a) } + //~^ WARN transmuting an integer to a pointer +} diff --git a/tests/ui/lint/int_to_ptr-no_core.stderr b/tests/ui/lint/int_to_ptr-no_core.stderr new file mode 100644 index 0000000000000..4977bfe058cde --- /dev/null +++ b/tests/ui/lint/int_to_ptr-no_core.stderr @@ -0,0 +1,14 @@ +warning: transmuting an integer to a pointer creates a pointer without provenance + --> $DIR/int_to_ptr-no_core.rs:13:14 + | +LL | unsafe { mem::transmute::(a) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this is dangerous because dereferencing the resulting pointer is undefined behavior + = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance + = help: for more information about transmute, see + = help: for more information about exposed provenance, see + = note: `#[warn(integer_to_ptr_transmutes)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/lint/int_to_ptr-no_std.fixed b/tests/ui/lint/int_to_ptr-no_std.fixed new file mode 100644 index 0000000000000..4d476c265abb5 --- /dev/null +++ b/tests/ui/lint/int_to_ptr-no_std.fixed @@ -0,0 +1,14 @@ +//@ check-pass +//@ run-rustfix + +#![no_std] +#![crate_type = "lib"] +#![allow(unused_unsafe)] +#![allow(dead_code)] + +pub unsafe fn should_lint(a: usize) { + let _ptr: *const u8 = unsafe { core::ptr::with_exposed_provenance::(a) }; + //~^ WARN transmuting an integer to a pointer + let _ptr: *mut u8 = unsafe { core::ptr::with_exposed_provenance_mut::(a) }; + //~^ WARN transmuting an integer to a pointer +} diff --git a/tests/ui/lint/int_to_ptr-no_std.rs b/tests/ui/lint/int_to_ptr-no_std.rs new file mode 100644 index 0000000000000..f0eb95b3db7d1 --- /dev/null +++ b/tests/ui/lint/int_to_ptr-no_std.rs @@ -0,0 +1,14 @@ +//@ check-pass +//@ run-rustfix + +#![no_std] +#![crate_type = "lib"] +#![allow(unused_unsafe)] +#![allow(dead_code)] + +pub unsafe fn should_lint(a: usize) { + let _ptr: *const u8 = unsafe { core::mem::transmute::(a) }; + //~^ WARN transmuting an integer to a pointer + let _ptr: *mut u8 = unsafe { core::mem::transmute::(a) }; + //~^ WARN transmuting an integer to a pointer +} diff --git a/tests/ui/lint/int_to_ptr-no_std.stderr b/tests/ui/lint/int_to_ptr-no_std.stderr new file mode 100644 index 0000000000000..9de31a80efcc5 --- /dev/null +++ b/tests/ui/lint/int_to_ptr-no_std.stderr @@ -0,0 +1,37 @@ +warning: transmuting an integer to a pointer creates a pointer without provenance + --> $DIR/int_to_ptr-no_std.rs:10:36 + | +LL | let _ptr: *const u8 = unsafe { core::mem::transmute::(a) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this is dangerous because dereferencing the resulting pointer is undefined behavior + = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance + = help: for more information about transmute, see + = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `core::ptr::without_provenance_mut` + = note: `#[warn(integer_to_ptr_transmutes)]` on by default +help: use `core::ptr::with_exposed_provenance` instead to use a previously exposed provenance + | +LL - let _ptr: *const u8 = unsafe { core::mem::transmute::(a) }; +LL + let _ptr: *const u8 = unsafe { core::ptr::with_exposed_provenance::(a) }; + | + +warning: transmuting an integer to a pointer creates a pointer without provenance + --> $DIR/int_to_ptr-no_std.rs:12:34 + | +LL | let _ptr: *mut u8 = unsafe { core::mem::transmute::(a) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this is dangerous because dereferencing the resulting pointer is undefined behavior + = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance + = help: for more information about transmute, see + = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `core::ptr::without_provenance_mut` +help: use `core::ptr::with_exposed_provenance_mut` instead to use a previously exposed provenance + | +LL - let _ptr: *mut u8 = unsafe { core::mem::transmute::(a) }; +LL + let _ptr: *mut u8 = unsafe { core::ptr::with_exposed_provenance_mut::(a) }; + | + +warning: 2 warnings emitted + diff --git a/tests/ui/lint/int_to_ptr-unsized.stderr b/tests/ui/lint/int_to_ptr-unsized.stderr index 9799af8b12c15..559c4011c6c2e 100644 --- a/tests/ui/lint/int_to_ptr-unsized.stderr +++ b/tests/ui/lint/int_to_ptr-unsized.stderr @@ -6,9 +6,9 @@ LL | let _ref = unsafe { std::mem::transmute::( | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = note: `#[warn(integer_to_ptr_transmutes)]` on by default warning: transmuting an integer to a pointer creates a pointer without provenance @@ -19,9 +19,9 @@ LL | let _ptr = unsafe { std::mem::transmute::(0 | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` warning: 2 warnings emitted diff --git a/tests/ui/lint/int_to_ptr.stderr b/tests/ui/lint/int_to_ptr.stderr index 4035bda8fb2cf..fe4cf56373208 100644 --- a/tests/ui/lint/int_to_ptr.stderr +++ b/tests/ui/lint/int_to_ptr.stderr @@ -6,9 +6,9 @@ LL | let _ptr: *const u8 = unsafe { std::mem::transmute::( | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = note: `#[warn(integer_to_ptr_transmutes)]` on by default help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance | @@ -24,9 +24,9 @@ LL | let _ptr: *mut u8 = unsafe { std::mem::transmute::(a) } | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance_mut` instead to use a previously exposed provenance | LL - let _ptr: *mut u8 = unsafe { std::mem::transmute::(a) }; @@ -41,9 +41,9 @@ LL | let _ref: &'static u8 = unsafe { std::mem::transmute:: = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance | LL - let _ref: &'static u8 = unsafe { std::mem::transmute::(a) }; @@ -58,9 +58,9 @@ LL | let _ref: &'static mut u8 = unsafe { std::mem::transmute:: = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance_mut` instead to use a previously exposed provenance | LL - let _ref: &'static mut u8 = unsafe { std::mem::transmute::(a) }; @@ -75,9 +75,9 @@ LL | let _ptr = unsafe { std::mem::transmute::(42usize) }; | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance | LL - let _ptr = unsafe { std::mem::transmute::(42usize) }; @@ -92,9 +92,9 @@ LL | let _ptr = unsafe { std::mem::transmute::(a + a) }; | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance | LL - let _ptr = unsafe { std::mem::transmute::(a + a) }; @@ -109,9 +109,9 @@ LL | let _ptr: *const u8 = unsafe { std::mem::transmute::( | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance | LL - let _ptr: *const u8 = unsafe { std::mem::transmute::(a) }; @@ -126,9 +126,9 @@ LL | let _ptr: *mut u8 = unsafe { std::mem::transmute::(a) } | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance_mut` instead to use a previously exposed provenance | LL - let _ptr: *mut u8 = unsafe { std::mem::transmute::(a) }; @@ -143,9 +143,9 @@ LL | let _ref: &'static u8 = unsafe { std::mem::transmute:: = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance | LL - let _ref: &'static u8 = unsafe { std::mem::transmute::(a) }; @@ -160,9 +160,9 @@ LL | let _ref: &'static mut u8 = unsafe { std::mem::transmute:: = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance_mut` instead to use a previously exposed provenance | LL - let _ref: &'static mut u8 = unsafe { std::mem::transmute::(a) }; @@ -177,9 +177,9 @@ LL | let _ptr = unsafe { std::mem::transmute::(42usize) }; | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance | LL - let _ptr = unsafe { std::mem::transmute::(42usize) }; @@ -194,9 +194,9 @@ LL | let _ptr = unsafe { std::mem::transmute::(a + a) }; | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance | LL - let _ptr = unsafe { std::mem::transmute::(a + a) }; diff --git a/tests/ui/lint/undropped_manually_drops-no_std.fixed b/tests/ui/lint/undropped_manually_drops-no_std.fixed new file mode 100644 index 0000000000000..f3b26a1f2903a --- /dev/null +++ b/tests/ui/lint/undropped_manually_drops-no_std.fixed @@ -0,0 +1,13 @@ +//@ check-fail +//@ run-rustfix + +#![no_std] +#![crate_type = "lib"] +#![allow(dead_code)] + +struct S; + +fn drop_md() { + core::mem::drop(core::mem::ManuallyDrop::into_inner(core::mem::ManuallyDrop::new(S))); + //~^ ERROR calls to `core::mem::drop` +} diff --git a/tests/ui/lint/undropped_manually_drops-no_std.rs b/tests/ui/lint/undropped_manually_drops-no_std.rs new file mode 100644 index 0000000000000..fb9f23282861f --- /dev/null +++ b/tests/ui/lint/undropped_manually_drops-no_std.rs @@ -0,0 +1,13 @@ +//@ check-fail +//@ run-rustfix + +#![no_std] +#![crate_type = "lib"] +#![allow(dead_code)] + +struct S; + +fn drop_md() { + core::mem::drop(core::mem::ManuallyDrop::new(S)); + //~^ ERROR calls to `core::mem::drop` +} diff --git a/tests/ui/lint/undropped_manually_drops-no_std.stderr b/tests/ui/lint/undropped_manually_drops-no_std.stderr new file mode 100644 index 0000000000000..db573e1f7388a --- /dev/null +++ b/tests/ui/lint/undropped_manually_drops-no_std.stderr @@ -0,0 +1,16 @@ +error: calls to `core::mem::drop` with `core::mem::ManuallyDrop` instead of the inner value does nothing + --> $DIR/undropped_manually_drops-no_std.rs:11:5 + | +LL | core::mem::drop(core::mem::ManuallyDrop::new(S)); + | ^^^^^^^^^^^^^^^^-------------------------------^ + | | + | argument has type `ManuallyDrop` + | + = note: `#[deny(undropped_manually_drops)]` on by default +help: use `core::mem::ManuallyDrop::into_inner` to get the inner value + | +LL | core::mem::drop(core::mem::ManuallyDrop::into_inner(core::mem::ManuallyDrop::new(S))); + | ++++++++++++++++++++++++++++++++++++ + + +error: aborting due to 1 previous error + diff --git a/tests/ui/lint/wide_pointer_comparisons-no_std.rs b/tests/ui/lint/wide_pointer_comparisons-no_std.rs new file mode 100644 index 0000000000000..745c9925f22a6 --- /dev/null +++ b/tests/ui/lint/wide_pointer_comparisons-no_std.rs @@ -0,0 +1,10 @@ +//@ check-pass + +#![no_std] +#![crate_type = "lib"] +#![allow(dead_code)] + +fn cmp(a: *mut [u8], b: *mut [u8]) -> bool { + a == b + //~^ WARN ambiguous wide pointer comparison +} diff --git a/tests/ui/lint/wide_pointer_comparisons-no_std.stderr b/tests/ui/lint/wide_pointer_comparisons-no_std.stderr new file mode 100644 index 0000000000000..a5090cb872a41 --- /dev/null +++ b/tests/ui/lint/wide_pointer_comparisons-no_std.stderr @@ -0,0 +1,20 @@ +warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected + --> $DIR/wide_pointer_comparisons-no_std.rs:8:5 + | +LL | a == b + | ^^^^^^ + | + = note: `#[warn(ambiguous_wide_pointer_comparisons)]` on by default +help: use `core::ptr::addr_eq` or untyped pointers to only compare their addresses + | +LL - a == b +LL + core::ptr::addr_eq(a, b) + | +help: use explicit `core::ptr::eq` method to compare metadata and addresses + | +LL - a == b +LL + core::ptr::eq(a, b) + | + +warning: 1 warning emitted + diff --git a/tests/ui/macros/non-fmt-panic-no_std-extern-std.fixed b/tests/ui/macros/non-fmt-panic-no_std-extern-std.fixed new file mode 100644 index 0000000000000..e39a5a5566db4 --- /dev/null +++ b/tests/ui/macros/non-fmt-panic-no_std-extern-std.fixed @@ -0,0 +1,14 @@ +//@ edition:2018 +//@ check-pass +//@ run-rustfix +//@ rustfix-only-machine-applicable + +#![no_std] +#![crate_type = "lib"] + +extern crate std; + +pub fn f() { + std::panic::panic_any(123); + //~^ WARN panic message is not a string literal +} diff --git a/tests/ui/macros/non-fmt-panic-no_std-extern-std.rs b/tests/ui/macros/non-fmt-panic-no_std-extern-std.rs new file mode 100644 index 0000000000000..0e2dd8dab6e3c --- /dev/null +++ b/tests/ui/macros/non-fmt-panic-no_std-extern-std.rs @@ -0,0 +1,14 @@ +//@ edition:2018 +//@ check-pass +//@ run-rustfix +//@ rustfix-only-machine-applicable + +#![no_std] +#![crate_type = "lib"] + +extern crate std; + +pub fn f() { + std::panic!(123); + //~^ WARN panic message is not a string literal +} diff --git a/tests/ui/macros/non-fmt-panic-no_std-extern-std.stderr b/tests/ui/macros/non-fmt-panic-no_std-extern-std.stderr new file mode 100644 index 0000000000000..9c96c1f032cc5 --- /dev/null +++ b/tests/ui/macros/non-fmt-panic-no_std-extern-std.stderr @@ -0,0 +1,22 @@ +warning: panic message is not a string literal + --> $DIR/non-fmt-panic-no_std-extern-std.rs:12:17 + | +LL | std::panic!(123); + | ^^^ + | + = note: this usage of `std::panic!()` is deprecated; it will be a hard error in Rust 2021 + = note: for more information, see + = note: for more information, see + = note: `#[warn(non_fmt_panics)]` (part of `#[warn(rust_2021_compatibility)]`) on by default +help: add a "{}" format string to `Display` the message + | +LL | std::panic!("{}", 123); + | +++++ +help: or use std::panic::panic_any instead + | +LL - std::panic!(123); +LL + std::panic::panic_any(123); + | + +warning: 1 warning emitted + diff --git a/tests/ui/macros/non-fmt-panic-no_std.fixed b/tests/ui/macros/non-fmt-panic-no_std.fixed new file mode 100644 index 0000000000000..f7904b15b2b23 --- /dev/null +++ b/tests/ui/macros/non-fmt-panic-no_std.fixed @@ -0,0 +1,14 @@ +//@ edition:2018 +//@ check-pass +//@ run-rustfix +//@ rustfix-only-machine-applicable + +#![no_std] +#![crate_type = "lib"] + +pub fn f(s: &str) { + panic!("{}", s); + //~^ WARN panic message is not a string literal + core::panic!("{}", s); + //~^ WARN panic message is not a string literal +} diff --git a/tests/ui/macros/non-fmt-panic-no_std.rs b/tests/ui/macros/non-fmt-panic-no_std.rs new file mode 100644 index 0000000000000..b1b0f609e6716 --- /dev/null +++ b/tests/ui/macros/non-fmt-panic-no_std.rs @@ -0,0 +1,14 @@ +//@ edition:2018 +//@ check-pass +//@ run-rustfix +//@ rustfix-only-machine-applicable + +#![no_std] +#![crate_type = "lib"] + +pub fn f(s: &str) { + panic!(s); + //~^ WARN panic message is not a string literal + core::panic!(s); + //~^ WARN panic message is not a string literal +} diff --git a/tests/ui/macros/non-fmt-panic-no_std.stderr b/tests/ui/macros/non-fmt-panic-no_std.stderr new file mode 100644 index 0000000000000..8fdf5bfaf7e13 --- /dev/null +++ b/tests/ui/macros/non-fmt-panic-no_std.stderr @@ -0,0 +1,31 @@ +warning: panic message is not a string literal + --> $DIR/non-fmt-panic-no_std.rs:10:12 + | +LL | panic!(s); + | ^ + | + = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 + = note: for more information, see + = note: for more information, see + = note: `#[warn(non_fmt_panics)]` (part of `#[warn(rust_2021_compatibility)]`) on by default +help: add a "{}" format string to `Display` the message + | +LL | panic!("{}", s); + | +++++ + +warning: panic message is not a string literal + --> $DIR/non-fmt-panic-no_std.rs:12:18 + | +LL | core::panic!(s); + | ^ + | + = note: this usage of `core::panic!()` is deprecated; it will be a hard error in Rust 2021 + = note: for more information, see + = note: for more information, see +help: add a "{}" format string to `Display` the message + | +LL | core::panic!("{}", s); + | +++++ + +warning: 2 warnings emitted + diff --git a/tests/ui/traits/next-solver/overflow/cycle-required-depth.rs b/tests/ui/traits/next-solver/overflow/cycle-required-depth.rs new file mode 100644 index 0000000000000..105460eee8013 --- /dev/null +++ b/tests/ui/traits/next-solver/overflow/cycle-required-depth.rs @@ -0,0 +1,27 @@ +//@ compile-flags: -Znext-solver +//@ check-pass + +// We must properly decrement available_depth when encountering cycles. +// Proving `Foo: Send` results in a cycle: +// - Foo: Send +// ->PhantomData: Send +// ->Foo: Send +// and if we cache this result with too small of a required depth, the second +// `require` call will succeed with the cached result where it would fail if +// the goal were freshly evaluated. + +#![recursion_limit = "6"] + +use std::marker::PhantomData; + +pub struct Foo(PhantomData); +pub struct W(T); + +fn require() {} + +fn main() { + require::(); + require::>>>>>(); + //~^ WARN overflow evaluating the requirement `W>>>>: Send` + //~| WARN this was previously accepted by the compiler but is being phased out +} diff --git a/tests/ui/traits/next-solver/overflow/cycle-required-depth.stderr b/tests/ui/traits/next-solver/overflow/cycle-required-depth.stderr new file mode 100644 index 0000000000000..15e121053c22d --- /dev/null +++ b/tests/ui/traits/next-solver/overflow/cycle-required-depth.stderr @@ -0,0 +1,21 @@ +warning: overflow evaluating the requirement `W>>>>: Send` + --> $DIR/cycle-required-depth.rs:24:5 + | +LL | require::>>>>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: which requires `W>>>: Send` + = note: which requires `W>>: Send` + = note: which requires `W>: Send` + = note: which requires `W: Send` + = note: which requires `Foo: Send` + = note: and so on... + = help: consider adding a manual `impl` of auto traits like `Send` for intermediate types, if auto traits are involved + = help: or consider increasing the recursion limit by adding a `#![recursion_limit = "12"]` attribute to your crate (`cycle_required_depth`) + = note: this lint is attached to the whole crate and can't be disabled on a per-function basis + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #159228 + = note: `#[warn(recursion_depth_exceeding_limit)]` (part of `#[warn(future_incompatible)]`) on by default + +warning: 1 warning emitted + diff --git a/tests/ui/traits/next-solver/overflow/provisional-cache-required-depth.rs b/tests/ui/traits/next-solver/overflow/provisional-cache-required-depth.rs new file mode 100644 index 0000000000000..ad070e2d276a3 --- /dev/null +++ b/tests/ui/traits/next-solver/overflow/provisional-cache-required-depth.rs @@ -0,0 +1,27 @@ +//@ compile-flags: -Znext-solver +//@ check-pass + +#![recursion_limit = "6"] +use std::marker::PhantomData; + +// We need to decrement available_depth on provisional cache hits. +// e.g., in the following example: +// A: Send, avail = 6 +// -> PhantomData: Send, avail = 5 +// -> A: Send, avail = 4 +// -> B: Send, avail = 5 +// -> C: Send, avail = 4 +// -> PhantomData: Send, provisional cache hit, avail = 4 if we don't decrement +struct A(PhantomData, B); +struct B(C); +struct C(PhantomData); +struct W(T); + +fn require() {} + +fn main() { + require::(); + require::>>>>(); + //~^ WARN overflow evaluating the requirement `W>>>: Send` + //~| WARN this was previously accepted by the compiler but is being phased out +} diff --git a/tests/ui/traits/next-solver/overflow/provisional-cache-required-depth.stderr b/tests/ui/traits/next-solver/overflow/provisional-cache-required-depth.stderr new file mode 100644 index 0000000000000..a4ee2a2d87078 --- /dev/null +++ b/tests/ui/traits/next-solver/overflow/provisional-cache-required-depth.stderr @@ -0,0 +1,21 @@ +warning: overflow evaluating the requirement `W>>>: Send` + --> $DIR/provisional-cache-required-depth.rs:24:5 + | +LL | require::>>>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: which requires `W>>: Send` + = note: which requires `W>: Send` + = note: which requires `W: Send` + = note: which requires `A: Send` + = note: which requires `B: Send` + = note: and so on... + = help: consider adding a manual `impl` of auto traits like `Send` for intermediate types, if auto traits are involved + = help: or consider increasing the recursion limit by adding a `#![recursion_limit = "12"]` attribute to your crate (`provisional_cache_required_depth`) + = note: this lint is attached to the whole crate and can't be disabled on a per-function basis + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #159228 + = note: `#[warn(recursion_depth_exceeding_limit)]` (part of `#[warn(future_incompatible)]`) on by default + +warning: 1 warning emitted +