diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 259c6cd7728ce..2fc057ae38823 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -2698,12 +2698,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> { let mut_span = tcx.sess.source_map().span_until_non_whitespace(span); - tcx.emit_diag_node_span_lint( - UNUSED_MUT, - lint_root, - span, - VarNeedNotMut { span: mut_span }, - ) + tcx.emit_node_span_lint(UNUSED_MUT, lint_root, span, VarNeedNotMut { span: mut_span }) } } } diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs index d7f871527e3d1..e9209657984e0 100644 --- a/compiler/rustc_codegen_ssa/src/target_features.rs +++ b/compiler/rustc_codegen_ssa/src/target_features.rs @@ -75,7 +75,7 @@ pub(crate) fn from_target_feature_attr( // For "neon" specifically, we emit an FCW instead of a hard error. // See . if tcx.sess.target.arch == Arch::AArch64 && name.as_str() == "neon" { - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( AARCH64_SOFTFLOAT_NEON, tcx.local_def_id_to_hir_id(did), feature_span, diff --git a/compiler/rustc_const_eval/src/const_eval/error.rs b/compiler/rustc_const_eval/src/const_eval/error.rs index 7efef74e70aa3..6694a6e8ae403 100644 --- a/compiler/rustc_const_eval/src/const_eval/error.rs +++ b/compiler/rustc_const_eval/src/const_eval/error.rs @@ -256,5 +256,5 @@ pub(super) fn lint<'tcx, L>( { let (span, frames) = get_span_and_frames(tcx, &machine.stack); - tcx.emit_diag_node_span_lint(lint, machine.best_lint_scope(*tcx), span, decorator(frames)); + tcx.emit_node_span_lint(lint, machine.best_lint_scope(*tcx), span, decorator(frames)); } diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 3da9f2e2cdcdf..c2b3ea19c3f48 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -718,7 +718,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> { .level .is_error(); let span = ecx.cur_span(); - ecx.tcx.emit_diag_node_span_lint( + ecx.tcx.emit_node_span_lint( rustc_session::lint::builtin::LONG_RUNNING_CONST_EVAL, hir_id, span, diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index a6a1b95ce4c1a..2068fc0ab978c 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -1256,7 +1256,7 @@ fn check_impl_items_against_trait<'tcx>( } if self_is_guaranteed_unsize_self && tcx.generics_require_sized_self(ty_trait_item.def_id) { - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( rustc_lint_defs::builtin::DEAD_CODE, tcx.local_def_id_to_hir_id(ty_impl_item.def_id.expect_local()), tcx.def_span(ty_impl_item.def_id), diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs index 0944edd86ef19..31104411ab55b 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs @@ -345,7 +345,7 @@ fn report_mismatched_rpitit_signature<'tcx>( with_no_trimmed_paths!(with_types_for_signature!(format!("{return_ty}"))); let span = unmatched_bound.unwrap_or(span); - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( if is_internal { REFINING_IMPL_TRAIT_INTERNAL } else { REFINING_IMPL_TRAIT_REACHABLE }, tcx.local_def_id_to_hir_id(impl_m_def_id.expect_local()), span, @@ -442,7 +442,7 @@ fn report_mismatched_rpitit_captures<'tcx>( .sort_by_cached_key(|arg| !matches!(arg.kind(), ty::GenericArgKind::Lifetime(_))); let suggestion = format!("use<{}>", trait_captured_args.iter().join(", ")); - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( if is_internal { REFINING_IMPL_TRAIT_INTERNAL } else { REFINING_IMPL_TRAIT_REACHABLE }, tcx.local_def_id_to_hir_id(impl_opaque_def_id), use_bound_span, diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 5a4d1794623f1..426331b33bd90 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -797,7 +797,7 @@ fn lint_item_shadowing_supertrait_item<'tcx>(tcx: TyCtxt<'tcx>, trait_item_def_i errors::SupertraitItemShadowee::Several { traits: traits.into(), spans: spans.into() } }; - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( SHADOWING_SUPERTRAIT_ITEMS, tcx.local_def_id_to_hir_id(trait_item_def_id), tcx.def_span(trait_item_def_id), @@ -2458,7 +2458,7 @@ fn lint_redundant_lifetimes<'tcx>( && outlives_env.free_region_map().sub_free_regions(tcx, victim, candidate) { shadowed.insert(victim); - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( rustc_lint_defs::builtin::REDUNDANT_LIFETIMES, tcx.local_def_id_to_hir_id(def_id.expect_local()), tcx.def_span(def_id), diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index b5e40058e7533..f1e138dbcb97a 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -497,13 +497,13 @@ fn lint_uncovered_ty_params<'tcx>( let name = tcx.item_ident(param_def_id); match local_ty { - Some(local_type) => tcx.emit_diag_node_span_lint( + Some(local_type) => tcx.emit_node_span_lint( UNCOVERED_PARAM_IN_PROJECTION, hir_id, span, errors::TyParamFirstLocalLint { span, note: (), param: name, local_type }, ), - None => tcx.emit_diag_node_span_lint( + None => tcx.emit_node_span_lint( UNCOVERED_PARAM_IN_PROJECTION, hir_id, span, 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 459d13e46e854..7b8e09943df71 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 @@ -291,7 +291,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { // FIXME(mgca): Ideally we would generalize the name of this lint to sth. like // `unused_associated_item_bindings` since this can now also trigger on *const* // projections / assoc *const* bindings. - tcx.emit_diag_node_span_lint( + tcx.emit_node_span_lint( UNUSED_ASSOCIATED_TYPE_BOUNDS, hir_id, span, diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index af529386eee2a..eaa87f1d4cbc6 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -687,7 +687,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { }; let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty); let cast_ty = fcx.resolve_vars_if_possible(self.cast_ty); - fcx.tcx.emit_diag_node_span_lint( + fcx.tcx.emit_node_span_lint( lint, self.expr.hir_id, self.span, @@ -1125,7 +1125,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { }; let lint = errors::LossyProvenancePtr2Int { expr_ty, cast_ty, sugg }; - fcx.tcx.emit_diag_node_span_lint( + fcx.tcx.emit_node_span_lint( lint::builtin::LOSSY_PROVENANCE_CASTS, self.expr.hir_id, self.span, @@ -1141,7 +1141,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty); let cast_ty = fcx.resolve_vars_if_possible(self.cast_ty); let lint = errors::LossyProvenanceInt2Ptr { expr_ty, cast_ty, sugg }; - fcx.tcx.emit_diag_node_span_lint( + fcx.tcx.emit_node_span_lint( lint::builtin::FUZZY_PROVENANCE_CASTS, self.expr.hir_id, self.span, diff --git a/compiler/rustc_hir_typeck/src/fallback.rs b/compiler/rustc_hir_typeck/src/fallback.rs index 79fdfd3563676..c10e7f3bfb8b9 100644 --- a/compiler/rustc_hir_typeck/src/fallback.rs +++ b/compiler/rustc_hir_typeck/src/fallback.rs @@ -238,7 +238,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { let sugg = self.try_to_suggest_annotations(&[root_vid], coercion_graph); for (hir_id, span, reason) in affected_unsafe_infer_vars { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( lint::builtin::NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE, hir_id, span, @@ -304,7 +304,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { { self.adjust_fulfillment_error_for_expr_obligation(never_error); let sugg = self.try_to_suggest_annotations(diverging_vids, coercions); - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( lint::builtin::DEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK, self.tcx.local_def_id_to_hir_id(self.body_id), self.tcx.def_span(self.body_id), diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 81523cdf633d5..1931222bba30e 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -1145,7 +1145,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }); return (Ty::new_error(self.tcx, guar), res); } else { - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( SELF_CONSTRUCTOR_FROM_OUTER_ITEM, hir_id, path_span, diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 6e5b05a8191fc..608bc7dffd9c0 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -717,7 +717,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { SupertraitItemShadowee::Several { traits: traits.into(), spans: spans.into() } }; - self.tcx.emit_diag_node_span_lint( + self.tcx.emit_node_span_lint( RESOLVING_TO_ITEMS_SHADOWING_SUPERTRAIT_ITEMS, segment.hir_id, segment.ident.span, diff --git a/compiler/rustc_lint/src/async_closures.rs b/compiler/rustc_lint/src/async_closures.rs index 0d3a954667f7b..0bc245c742b2e 100644 --- a/compiler/rustc_lint/src/async_closures.rs +++ b/compiler/rustc_lint/src/async_closures.rs @@ -1,5 +1,5 @@ use rustc_hir as hir; -use rustc_macros::{LintDiagnostic, Subdiagnostic}; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_session::{declare_lint, declare_lint_pass}; use rustc_span::Span; @@ -107,7 +107,7 @@ impl<'tcx> LateLintPass<'tcx> for AsyncClosureUsage { } } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("closure returning async block can be made into an async closure")] struct ClosureReturningAsyncBlock { #[label( diff --git a/compiler/rustc_lint/src/if_let_rescope.rs b/compiler/rustc_lint/src/if_let_rescope.rs index 7899d4690ea51..ba196ef301c0d 100644 --- a/compiler/rustc_lint/src/if_let_rescope.rs +++ b/compiler/rustc_lint/src/if_let_rescope.rs @@ -5,7 +5,7 @@ use hir::intravisit::{self, Visitor}; use rustc_ast::Recovered; use rustc_errors::{Applicability, Diag, EmissionGuarantee, Subdiagnostic, SuggestionStyle, msg}; use rustc_hir::{self as hir, HirIdSet}; -use rustc_macros::{LintDiagnostic, Subdiagnostic}; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::ty::adjustment::Adjust; use rustc_middle::ty::significant_drop_order::{ extract_component_with_significant_dtor, ty_dtor_span, @@ -302,7 +302,7 @@ impl<'tcx> LateLintPass<'tcx> for IfLetRescope { } } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("`if let` assigns a shorter lifetime since Edition 2024")] struct IfLetRescopeLint { #[subdiagnostic] diff --git a/compiler/rustc_lint/src/impl_trait_overcaptures.rs b/compiler/rustc_lint/src/impl_trait_overcaptures.rs index c7fa779447a49..3e18e918439ca 100644 --- a/compiler/rustc_lint/src/impl_trait_overcaptures.rs +++ b/compiler/rustc_lint/src/impl_trait_overcaptures.rs @@ -3,13 +3,13 @@ use std::cell::LazyCell; use rustc_data_structures::debug_assert_matches; use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; use rustc_data_structures::unord::UnordSet; -use rustc_errors::{LintDiagnostic, Subdiagnostic, msg}; +use rustc_errors::{Diagnostic, Subdiagnostic, msg}; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::infer::outlives::env::OutlivesEnvironment; -use rustc_macros::LintDiagnostic; +use rustc_macros::Diagnostic; use rustc_middle::middle::resolve_bound_vars::ResolvedArg; use rustc_middle::ty::relate::{ Relate, RelateResult, TypeRelation, relate_args_with_variances, structurally_relate_consts, @@ -433,11 +433,17 @@ struct ImplTraitOvercapturesLint<'tcx> { suggestion: Option, } -impl<'a> LintDiagnostic<'a, ()> for ImplTraitOvercapturesLint<'_> { - fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) { - diag.primary_message(msg!( - "`{$self_ty}` will capture more lifetimes than possibly intended in edition 2024" - )); +impl<'a> Diagnostic<'a, ()> for ImplTraitOvercapturesLint<'_> { + fn into_diag( + self, + dcx: rustc_errors::DiagCtxtHandle<'a>, + level: rustc_errors::Level, + ) -> rustc_errors::Diag<'a, ()> { + let mut diag = rustc_errors::Diag::new( + dcx, + level, + msg!("`{$self_ty}` will capture more lifetimes than possibly intended in edition 2024"), + ); diag.arg("self_ty", self.self_ty.to_string()) .arg("num_captured", self.num_captured) .span_note( @@ -451,12 +457,13 @@ impl<'a> LintDiagnostic<'a, ()> for ImplTraitOvercapturesLint<'_> { ) .note(msg!("all lifetimes in scope will be captured by `impl Trait`s in edition 2024")); if let Some(suggestion) = self.suggestion { - suggestion.add_to_diag(diag); + suggestion.add_to_diag(&mut diag); } + diag } } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("all possible in-scope parameters are already captured, so `use<...>` syntax is redundant")] struct ImplTraitRedundantCapturesLint { #[suggestion("remove the `use<...>` syntax", code = "", applicability = "machine-applicable")] diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 285a7b7f52935..4b7e102e239ec 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -4,13 +4,14 @@ use std::num::NonZero; use rustc_errors::codes::*; use rustc_errors::{ - Applicability, Diag, DiagArgValue, DiagMessage, DiagStyledString, ElidedLifetimeInPathSubdiag, - EmissionGuarantee, LintDiagnostic, MultiSpan, Subdiagnostic, SuggestionStyle, msg, + Applicability, Diag, DiagArgValue, DiagCtxtHandle, DiagMessage, DiagStyledString, Diagnostic, + ElidedLifetimeInPathSubdiag, EmissionGuarantee, Level, LintDiagnostic, MultiSpan, + Subdiagnostic, SuggestionStyle, msg, }; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::intravisit::VisitorExt; -use rustc_macros::{LintDiagnostic, Subdiagnostic}; +use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; use rustc_middle::ty::inhabitedness::InhabitedPredicate; use rustc_middle::ty::{Clause, PolyExistentialTraitRef, Ty, TyCtxt}; use rustc_session::Session; @@ -580,7 +581,7 @@ impl Subdiagnostic for BuiltinUnpermittedTypeInitSub { } } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] pub(crate) enum BuiltinClashingExtern<'a> { #[diag("`{$this}` redeclared with a different signature")] SameName { @@ -686,7 +687,7 @@ pub(crate) struct EnumIntrinsicsMemVariant<'a> { } // expect.rs -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("this lint expectation is unfulfilled")] pub(crate) struct Expectation { #[subdiagnostic] @@ -1341,7 +1342,7 @@ pub(crate) struct IgnoredUnlessCrateSpecified<'a> { } // dangling.rs -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("this creates a dangling pointer because temporary `{$ty}` is dropped at end of statement")] #[help("bind the `{$ty}` to a variable such that it outlives the pointer returned by `{$callee}`")] #[note("a dangling pointer is safe, but dereferencing one is undefined behavior")] @@ -1357,7 +1358,7 @@ pub(crate) struct DanglingPointersFromTemporaries<'tcx> { pub temporary_span: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("{$fn_kind} returns a dangling pointer to dropped local variable `{$local_var_name}`")] #[note("a dangling pointer is safe, but dereferencing one is undefined behavior")] #[note("for more information, see ")] @@ -1874,7 +1875,7 @@ impl<'a> LintDiagnostic<'a, ()> for DropGlue<'_> { } // transmute.rs -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("transmuting an integer to a pointer creates a pointer without provenance")] #[note("this is dangerous because dereferencing the resulting pointer is undefined behavior")] #[note( @@ -2324,7 +2325,7 @@ impl<'a> LintDiagnostic<'a, ()> for ImproperCTypes<'_> { } } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("passing type `{$ty}` to a function with \"gpu-kernel\" ABI may have unexpected behavior")] #[help("use primitive types and raw pointers to get reliable behavior")] pub(crate) struct ImproperGpuKernelArg<'a> { @@ -2564,13 +2565,18 @@ pub(crate) struct AsyncFnInTraitDiag { pub sugg: Option>, } -impl<'a> LintDiagnostic<'a, ()> for AsyncFnInTraitDiag { - fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { - diag.primary_message(msg!("use of `async fn` in public traits is discouraged as auto trait bounds cannot be specified")); - diag.note(msg!("you can suppress this lint if you plan to use the trait only in your own code, or do not care about auto traits like `Send` on the `Future`")); +impl<'a> Diagnostic<'a, ()> for AsyncFnInTraitDiag { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + let mut diag = Diag::new( + dcx, + level, + "use of `async fn` in public traits is discouraged as auto trait bounds cannot be specified", + ); + diag.note("you can suppress this lint if you plan to use the trait only in your own code, or do not care about auto traits like `Send` on the `Future`"); if let Some(sugg) = self.sugg { - diag.multipart_suggestion(msg!("you can alternatively desugar to a normal `fn` that returns `impl Future` and add any desired bounds such as `Send`, but these cannot be relaxed without a breaking API change"), sugg, Applicability::MaybeIncorrect); + diag.multipart_suggestion("you can alternatively desugar to a normal `fn` that returns `impl Future` and add any desired bounds such as `Send`, but these cannot be relaxed without a breaking API change", sugg, Applicability::MaybeIncorrect); } + diag } } @@ -3404,7 +3410,7 @@ pub(crate) struct ReservedMultihash { pub suggestion: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("direct cast of function item into an integer")] pub(crate) struct FunctionCastsAsIntegerDiag<'tcx> { #[subdiagnostic] diff --git a/compiler/rustc_lint/src/transmute.rs b/compiler/rustc_lint/src/transmute.rs index e4716c869c5f1..b55d209130b02 100644 --- a/compiler/rustc_lint/src/transmute.rs +++ b/compiler/rustc_lint/src/transmute.rs @@ -3,7 +3,7 @@ use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::LocalDefId; use rustc_hir::{self as hir}; -use rustc_macros::LintDiagnostic; +use rustc_macros::Diagnostic; use rustc_middle::ty::{self, Ty}; use rustc_session::{declare_lint, impl_lint_pass}; use rustc_span::sym; @@ -368,7 +368,7 @@ fn check_unnecessary_transmute<'tcx>( }); } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("pointers cannot be transmuted to integers during const eval")] #[note("at compile-time, pointers do not have an integer value")] #[note( diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 28ca6f9fcac20..08ccc4a0fca41 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -550,17 +550,6 @@ pub fn diag_lint_level<'a, D: Diagnostic<'a, ()> + 'a>( Level::Warn => rustc_errors::Level::Warning, Level::Deny | Level::Forbid => rustc_errors::Level::Error, }; - // Finally, run `decorate`. `decorate` can call `trimmed_path_str` (directly or indirectly), - // so we need to make sure when we do call `decorate` that the diagnostic is eventually - // emitted or we'll get a `must_produce_diag` ICE. - // - // When is a diagnostic *eventually* emitted? Well, that is determined by 2 factors: - // 1. If the corresponding `rustc_errors::Level` is beyond warning, i.e. `ForceWarning(_)` - // or `Error`, then the diagnostic will be emitted regardless of CLI options. - // 2. If the corresponding `rustc_errors::Level` is warning, then that can be affected by - // `-A warnings` or `--cap-lints=xxx` on the command line. In which case, the diagnostic - // will be emitted if `can_emit_warnings` is true. - let skip = err_level == rustc_errors::Level::Warning && !sess.dcx().can_emit_warnings(); let disable_suggestions = if let Some(ref span) = span // If this code originates in a foreign macro, aka something that this crate @@ -580,12 +569,35 @@ pub fn diag_lint_level<'a, D: Diagnostic<'a, ()> + 'a>( // allow individual lints to opt-out from being reported. let incompatible = future_incompatible.is_some_and(|f| f.reason.edition().is_none()); - if !incompatible && !lint.report_in_external_macro { + // In rustc, for the find_attr macro, we want to always emit this. + // This completely circumvents normal lint checking, which usually doesn't happen for macros from other crates. + // However, we kind of want that when using find_attr from another rustc crate. So we cheat a little. + let is_in_find_attr = sess.enable_internal_lints() + && span.as_ref().is_some_and(|span| { + span.primary_spans().iter().any(|s| { + s.source_callee().is_some_and(|i| { + matches!(i.kind, ExpnKind::Macro(_, name) if name.as_str() == "find_attr") + }) + }) + }); + + if !incompatible && !lint.report_in_external_macro && !is_in_find_attr { // Don't continue further, since we don't want to have // `diag_span_note_once` called for a diagnostic that isn't emitted. return; } } + // Finally, run `decorate`. `decorate` can call `trimmed_path_str` (directly or indirectly), + // so we need to make sure when we do call `decorate` that the diagnostic is eventually + // emitted or we'll get a `must_produce_diag` ICE. + // + // When is a diagnostic *eventually* emitted? Well, that is determined by 2 factors: + // 1. If the corresponding `rustc_errors::Level` is beyond warning, i.e. `ForceWarning(_)` + // or `Error`, then the diagnostic will be emitted regardless of CLI options. + // 2. If the corresponding `rustc_errors::Level` is warning, then that can be affected by + // `-A warnings` or `--cap-lints=xxx` on the command line. In which case, the diagnostic + // will be emitted if `can_emit_warnings` is true. + let skip = err_level == rustc_errors::Level::Warning && !sess.dcx().can_emit_warnings(); let mut err: Diag<'_, ()> = if !skip { decorate(sess.dcx(), err_level) diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index 4f0073b93ebad..ff6baabbb29a0 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -4,7 +4,7 @@ use std::num::NonZero; use rustc_ast::NodeId; -use rustc_errors::{Applicability, Diag, EmissionGuarantee, LintBuffer, msg}; +use rustc_errors::{Applicability, Diag, EmissionGuarantee, LintBuffer, LintDiagnostic, msg}; use rustc_feature::GateIssue; use rustc_hir::attrs::{DeprecatedSince, Deprecation}; use rustc_hir::def_id::{DefId, LocalDefId}; @@ -125,7 +125,19 @@ pub struct Deprecated { pub since_kind: DeprecatedSinceKind, } -impl<'a, G: EmissionGuarantee> rustc_errors::LintDiagnostic<'a, G> for Deprecated { +impl<'a, G: EmissionGuarantee> rustc_errors::Diagnostic<'a, G> for Deprecated { + fn into_diag( + self, + dcx: rustc_errors::DiagCtxtHandle<'a>, + level: rustc_errors::Level, + ) -> Diag<'a, G> { + let mut diag = Diag::new(dcx, level, ""); + self.decorate_lint(&mut diag); + diag + } +} + +impl<'a, G: EmissionGuarantee> LintDiagnostic<'a, G> for Deprecated { fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>) { diag.primary_message(match &self.since_kind { DeprecatedSinceKind::InEffect => msg!( diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 9eb41e57d4dce..d21f07a23e328 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2495,26 +2495,10 @@ impl<'tcx> TyCtxt<'tcx> { T::collect_and_apply(iter, |xs| self.mk_outlives(xs)) } - /// Emit a lint at `span` from a lint struct (some type that implements `LintDiagnostic`, - /// typically generated by `#[derive(LintDiagnostic)]`). - #[track_caller] - pub fn emit_node_span_lint( - self, - lint: &'static Lint, - hir_id: HirId, - span: impl Into, - decorator: impl for<'a> LintDiagnostic<'a, ()>, - ) { - let level = self.lint_level_at_node(lint, hir_id); - lint_level(self.sess, lint, level, Some(span.into()), |lint| { - decorator.decorate_lint(lint); - }) - } - /// Emit a lint at `span` from a lint struct (some type that implements `Diagnostic`, /// typically generated by `#[derive(Diagnostic)]`). #[track_caller] - pub fn emit_diag_node_span_lint( + pub fn emit_node_span_lint( self, lint: &'static Lint, hir_id: HirId, diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index 5a93c7cbdc7a9..fead221b9a0ca 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -3,13 +3,13 @@ use rustc_errors::{ Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan, Subdiagnostic, msg, }; -use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::ty::{self, Ty}; use rustc_pattern_analysis::errors::Uncovered; use rustc_pattern_analysis::rustc::RustcPatCtxt; use rustc_span::{Ident, Span, Symbol}; -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("call to deprecated safe function `{$function}` is unsafe and requires unsafe block")] pub(crate) struct CallToDeprecatedSafeFnRequiresUnsafe { #[label("call to unsafe function")] @@ -35,7 +35,7 @@ pub(crate) struct CallToDeprecatedSafeFnRequiresUnsafeSub { pub(crate) right: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("call to unsafe function `{$function}` is unsafe and requires unsafe block", code = E0133)] #[note("consult the function's documentation for information on how to avoid undefined behavior")] pub(crate) struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe { @@ -46,7 +46,7 @@ pub(crate) struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe { pub(crate) unsafe_not_inherited_note: Option, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("call to unsafe function is unsafe and requires unsafe block", code = E0133)] #[note("consult the function's documentation for information on how to avoid undefined behavior")] pub(crate) struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless { @@ -56,7 +56,7 @@ pub(crate) struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless { pub(crate) unsafe_not_inherited_note: Option, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("use of inline assembly is unsafe and requires unsafe block", code = E0133)] #[note("inline assembly is entirely unchecked and can cause undefined behavior")] pub(crate) struct UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe { @@ -66,7 +66,7 @@ pub(crate) struct UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe { pub(crate) unsafe_not_inherited_note: Option, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("initializing type with `rustc_layout_scalar_valid_range` attr is unsafe and requires unsafe block", code = E0133)] #[note( "initializing a layout restricted type's field with a value outside the valid range is undefined behavior" @@ -78,7 +78,7 @@ pub(crate) struct UnsafeOpInUnsafeFnInitializingTypeWithRequiresUnsafe { pub(crate) unsafe_not_inherited_note: Option, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("initializing type with an unsafe field is unsafe and requires unsafe block", code = E0133)] #[note("unsafe fields may carry library invariants")] pub(crate) struct UnsafeOpInUnsafeFnInitializingTypeWithUnsafeFieldRequiresUnsafe { @@ -88,7 +88,7 @@ pub(crate) struct UnsafeOpInUnsafeFnInitializingTypeWithUnsafeFieldRequiresUnsaf pub(crate) unsafe_not_inherited_note: Option, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("use of mutable static is unsafe and requires unsafe block", code = E0133)] #[note( "mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior" @@ -100,7 +100,7 @@ pub(crate) struct UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe { pub(crate) unsafe_not_inherited_note: Option, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("use of extern static is unsafe and requires unsafe block", code = E0133)] #[note( "extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior" @@ -112,7 +112,7 @@ pub(crate) struct UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe { pub(crate) unsafe_not_inherited_note: Option, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("use of unsafe field is unsafe and requires unsafe block", code = E0133)] #[note("unsafe fields may carry library invariants")] pub(crate) struct UnsafeOpInUnsafeFnUseOfUnsafeFieldRequiresUnsafe { @@ -122,7 +122,7 @@ pub(crate) struct UnsafeOpInUnsafeFnUseOfUnsafeFieldRequiresUnsafe { pub(crate) unsafe_not_inherited_note: Option, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("dereference of raw pointer is unsafe and requires unsafe block", code = E0133)] #[note( "raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior" @@ -134,7 +134,7 @@ pub(crate) struct UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe { pub(crate) unsafe_not_inherited_note: Option, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("access to union field is unsafe and requires unsafe block", code = E0133)] #[note( "the field may not be properly initialized: using uninitialized data will cause undefined behavior" @@ -146,7 +146,7 @@ pub(crate) struct UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe { pub(crate) unsafe_not_inherited_note: Option, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag( "mutation of layout constrained field is unsafe and requires unsafe block", code = E0133 @@ -159,7 +159,7 @@ pub(crate) struct UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsa pub(crate) unsafe_not_inherited_note: Option, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag( "borrow of layout constrained field with interior mutability is unsafe and requires unsafe block", code = E0133, @@ -171,7 +171,7 @@ pub(crate) struct UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe pub(crate) unsafe_not_inherited_note: Option, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag( "unsafe binder cast is unsafe and requires unsafe block information that may be required to uphold safety guarantees of a type", code = E0133, @@ -183,7 +183,7 @@ pub(crate) struct UnsafeOpInUnsafeFnUnsafeBinderCastRequiresUnsafe { pub(crate) unsafe_not_inherited_note: Option, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("call to function `{$function}` with `#[target_feature]` is unsafe and requires unsafe block", code = E0133)] #[help( "in order for the call to be safe, the context requires the following additional target {$missing_target_features_count -> @@ -631,7 +631,7 @@ impl Subdiagnostic for UnsafeNotInheritedLintNote { } } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("unnecessary `unsafe` block")] pub(crate) struct UnusedUnsafe { #[label("unnecessary `unsafe` block")] @@ -755,7 +755,7 @@ pub(crate) struct NonConstPath { pub(crate) span: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("unreachable pattern")] pub(crate) struct UnreachablePattern<'tcx> { #[label("no value can reach this")] @@ -809,7 +809,7 @@ pub(crate) struct WantedConstant { pub(crate) const_path: String, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("unreachable {$descr}")] pub(crate) struct UnreachableDueToUninhabited<'desc, 'tcx> { pub descr: &'desc str, @@ -874,7 +874,7 @@ pub(crate) struct UpperRangeBoundCannotBeMin { pub(crate) span: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("pattern binding `{$name}` is named the same as one of the variants of the type `{$ty_path}`", code = E0170)] pub(crate) struct BindingsWithVariantName { #[suggestion( @@ -887,7 +887,7 @@ pub(crate) struct BindingsWithVariantName { pub(crate) name: Ident, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag( "irrefutable `if let` {$count -> [one] pattern @@ -905,7 +905,7 @@ pub(crate) struct IrrefutableLetPatternsIfLet { pub(crate) count: usize, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag( "irrefutable `if let` guard {$count -> [one] pattern @@ -923,7 +923,7 @@ pub(crate) struct IrrefutableLetPatternsIfLetGuard { pub(crate) count: usize, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag( "irrefutable `let...else` {$count -> [one] pattern @@ -941,7 +941,7 @@ pub(crate) struct IrrefutableLetPatternsLetElse { pub(crate) count: usize, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag( "irrefutable `while let` {$count -> [one] pattern diff --git a/compiler/rustc_mir_transform/src/errors.rs b/compiler/rustc_mir_transform/src/errors.rs index 7421a55f2a79b..34720fc2f2958 100644 --- a/compiler/rustc_mir_transform/src/errors.rs +++ b/compiler/rustc_mir_transform/src/errors.rs @@ -1,6 +1,8 @@ use rustc_errors::codes::*; -use rustc_errors::{Applicability, Diag, EmissionGuarantee, LintDiagnostic, Subdiagnostic, msg}; -use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; +use rustc_errors::{ + Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, Subdiagnostic, msg, +}; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::mir::AssertKind; use rustc_middle::query::Key; use rustc_middle::ty::TyCtxt; @@ -48,7 +50,7 @@ pub(crate) fn emit_inline_always_target_feature_diagnostic<'a, 'tcx>( ); } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("function cannot return without recursing")] #[help("a `loop` may express intention better if this is on purpose")] pub(crate) struct UnconditionalRecursion { @@ -70,7 +72,7 @@ pub(crate) struct InvalidForceInline { pub reason: &'static str, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] pub(crate) enum ConstMutate { #[diag("attempting to modify a `const` item")] #[note( @@ -129,21 +131,26 @@ pub(crate) enum AssertLintKind { UnconditionalPanic, } -impl<'a, P: std::fmt::Debug> LintDiagnostic<'a, ()> for AssertLint

{ - fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { - diag.primary_message(match self.lint_kind { - AssertLintKind::ArithmeticOverflow => { - msg!("this arithmetic operation will overflow") - } - AssertLintKind::UnconditionalPanic => { - msg!("this operation will panic at runtime") - } - }); +impl<'a, P: std::fmt::Debug> Diagnostic<'a, ()> for AssertLint

{ + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + let mut diag = Diag::new( + dcx, + level, + match self.lint_kind { + AssertLintKind::ArithmeticOverflow => { + msg!("this arithmetic operation will overflow") + } + AssertLintKind::UnconditionalPanic => { + msg!("this operation will panic at runtime") + } + }, + ); let label = self.assert_kind.diagnostic_message(); self.assert_kind.add_args(&mut |name, value| { diag.arg(name, value); }); diag.span_label(self.span, label); + diag } } @@ -156,14 +163,14 @@ impl AssertLintKind { } } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("call to inline assembly that may unwind")] pub(crate) struct AsmUnwindCall { #[label("call to inline assembly that may unwind")] pub span: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag( "call to {$foreign -> [true] foreign function @@ -181,7 +188,7 @@ pub(crate) struct FfiUnwindCall { pub foreign: bool, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("taking a reference to a function item does not give a function pointer")] pub(crate) struct FnItemRef { #[suggestion( @@ -194,14 +201,14 @@ pub(crate) struct FnItemRef { pub ident: Ident, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("value captured by `{$name}` is never read")] #[help("did you mean to capture by reference instead?")] pub(crate) struct UnusedCaptureMaybeCaptureRef { pub name: Symbol, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("variable `{$name}` is assigned to, but never used")] #[note("consider using `_{$name}` instead")] pub(crate) struct UnusedVarAssignedOnly { @@ -210,7 +217,7 @@ pub(crate) struct UnusedVarAssignedOnly { pub typo: Option, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("value assigned to `{$name}` is never read")] pub(crate) struct UnusedAssign { pub name: Symbol, @@ -237,14 +244,14 @@ pub(crate) struct UnusedAssignSuggestion { pub rhs_borrow_span: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("value passed to `{$name}` is never read")] #[help("maybe it is overwritten before being read?")] pub(crate) struct UnusedAssignPassed { pub name: Symbol, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("unused variable: `{$name}`")] pub(crate) struct UnusedVariable { pub name: Symbol, @@ -331,11 +338,13 @@ pub(crate) struct MustNotSupend<'a, 'tcx> { } // Needed for def_path_str -impl<'a> LintDiagnostic<'a, ()> for MustNotSupend<'_, '_> { - fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) { - diag.primary_message(msg!( - "{$pre}`{$def_path}`{$post} held across a suspend point, but should not be" - )); +impl<'a> Diagnostic<'a, ()> for MustNotSupend<'_, '_> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + let mut diag = Diag::new( + dcx, + level, + msg!("{$pre}`{$def_path}`{$post} held across a suspend point, but should not be"), + ); diag.span_label(self.yield_sp, msg!("the value is held across this suspend point")); if let Some(reason) = self.reason { diag.subdiagnostic(reason); @@ -344,6 +353,7 @@ impl<'a> LintDiagnostic<'a, ()> for MustNotSupend<'_, '_> { diag.arg("pre", self.pre); diag.arg("def_path", self.tcx.def_path_str(self.def_id)); diag.arg("post", self.post); + diag } } diff --git a/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs b/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs index 2f733f54b26c9..667a702e40565 100644 --- a/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs +++ b/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs @@ -10,7 +10,7 @@ use rustc_hir::CRATE_HIR_ID; use rustc_hir::def_id::LocalDefId; use rustc_index::bit_set::MixedBitSet; use rustc_index::{IndexSlice, IndexVec}; -use rustc_macros::{LintDiagnostic, Subdiagnostic}; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::bug; use rustc_middle::mir::{ self, BasicBlock, Body, ClearCrossCrate, Local, Location, MirDumper, Place, StatementKind, @@ -498,7 +498,7 @@ fn assign_observables_names( names } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("relative drop order changing in Rust 2024")] struct TailExprDropOrderLint<'a> { #[subdiagnostic] diff --git a/compiler/rustc_monomorphize/src/errors.rs b/compiler/rustc_monomorphize/src/errors.rs index 62a8743873bdb..27705a9837ad3 100644 --- a/compiler/rustc_monomorphize/src/errors.rs +++ b/compiler/rustc_monomorphize/src/errors.rs @@ -1,4 +1,4 @@ -use rustc_macros::{Diagnostic, LintDiagnostic}; +use rustc_macros::Diagnostic; use rustc_middle::ty::{Instance, Ty}; use rustc_span::{Span, Symbol}; @@ -24,7 +24,7 @@ pub(crate) struct NoOptimizedMir { pub instance: String, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("moving {$size} bytes")] #[note( "the current maximum size is {$limit}, but it can be customized with the move_size_limit attribute: `#![move_size_limit = \"...\"]`" diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index b3dc48ea62f7f..d3a39909077b0 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -33,7 +33,7 @@ use rustc_hir::{ Item, ItemKind, MethodKind, Node, ParamName, PartialConstStability, Safety, Stability, StabilityLevel, Target, TraitItem, find_attr, }; -use rustc_macros::LintDiagnostic; +use rustc_macros::Diagnostic; use rustc_middle::hir::nested_filter; use rustc_middle::middle::resolve_bound_vars::ObjectLifetimeDefault; use rustc_middle::query::Providers; @@ -57,18 +57,18 @@ use tracing::debug; use crate::errors; -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("`#[diagnostic::on_unimplemented]` can only be applied to trait definitions")] struct DiagnosticOnUnimplementedOnlyForTraits; -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("`#[diagnostic::on_const]` can only be applied to trait impls")] struct DiagnosticOnConstOnlyForTraitImpls { #[label("not a trait impl")] item_span: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("`#[diagnostic::on_const]` can only be applied to non-const trait impls")] struct DiagnosticOnConstOnlyForNonConstTraitImpls { #[label("this is a const trait impl")] @@ -711,7 +711,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { UNUSED_ATTRIBUTES, hir_id, attr_span, - errors::InlineIgnoredForExported {}, + errors::InlineIgnoredForExported, ); } } diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 4bb8b06f129cc..b9ada150d0301 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -8,14 +8,14 @@ use rustc_errors::{ }; use rustc_hir::Target; use rustc_hir::attrs::{MirDialect, MirPhase}; -use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::ty::{MainDefinition, Ty}; use rustc_span::{DUMMY_SP, Ident, Span, Symbol}; use crate::check_attr::ProcMacroKind; use crate::lang_items::Duplicate; -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("`#[diagnostic::do_not_recommend]` can only be placed on trait implementations")] pub(crate) struct IncorrectDoNotRecommendLocation; @@ -45,7 +45,7 @@ pub(crate) struct ConstContinueAttr { pub node_span: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("`{$no_mangle_attr}` attribute may not be used in combination with `{$export_name_attr}`")] pub(crate) struct MixedExportNameAndNoMangle { #[label("`{$no_mangle_attr}` is ignored")] @@ -62,7 +62,7 @@ pub(crate) struct MixedExportNameAndNoMangle { pub export_name_attr: &'static str, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("crate-level attribute should be an inner attribute")] pub(crate) struct OuterCrateLevelAttr { #[subdiagnostic] @@ -76,7 +76,7 @@ pub(crate) struct OuterCrateLevelAttrSuggestion { pub bang_position: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("crate-level attribute should be in the root module")] pub(crate) struct InnerCrateLevelAttr; @@ -152,7 +152,7 @@ pub(crate) struct DocInlineConflict { pub spans: MultiSpan, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("this attribute can only be applied to a `use` item")] #[note( "read for more information" @@ -164,7 +164,7 @@ pub(crate) struct DocInlineOnlyUse { pub item_span: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("this attribute can only be applied to an `extern crate` item")] #[note( "read for more information" @@ -176,7 +176,7 @@ pub(crate) struct DocMaskedOnlyExternCrate { pub item_span: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("this attribute cannot be applied to an `extern crate self` item")] pub(crate) struct DocMaskedNotExternCrateSelf { #[label("not applicable on `extern crate self` items")] @@ -192,7 +192,7 @@ pub(crate) struct BothFfiConstAndPure { pub attr_span: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("attribute should be applied to an `extern` block with non-Rust ABI")] #[warning( "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" @@ -253,7 +253,7 @@ pub(crate) struct InvalidReprAlignForTarget { pub size: u64, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("conflicting representation hints", code = E0566)] pub(crate) struct ReprConflictingLint; @@ -302,7 +302,7 @@ pub(crate) struct RustcForceInlineCoro { pub span: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] pub(crate) enum MacroExport { #[diag("`#[macro_export]` has no effect on declarative macro definitions")] #[note("declarative macros follow the same exporting rules as regular items")] @@ -323,7 +323,7 @@ pub(crate) enum UnusedNote { LinkerMessagesBinaryCrateOnly, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("unused attribute")] pub(crate) struct Unused { #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")] @@ -347,7 +347,7 @@ pub(crate) struct InvalidMayDangle { pub attr_span: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("unused attribute")] pub(crate) struct UnusedDuplicate { #[suggestion("remove this attribute", code = "", applicability = "machine-applicable")] @@ -371,7 +371,7 @@ pub(crate) struct UnusedMultiple { pub name: Symbol, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("this `#[deprecated]` annotation has no effect")] pub(crate) struct DeprecatedAnnotationHasNoEffect { #[suggestion( @@ -803,7 +803,7 @@ pub(crate) struct IncorrectCrateType { pub span: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag( "useless assignment of {$is_field_assign -> [true] field @@ -815,12 +815,12 @@ pub(crate) struct UselessAssignment<'a> { pub ty: Ty<'a>, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("`#[inline]` is ignored on externally exported functions")] #[help( "externally exported functions are functions with `#[no_mangle]`, `#[export_name]`, or `#[linkage]`" )] -pub(crate) struct InlineIgnoredForExported {} +pub(crate) struct InlineIgnoredForExported; #[derive(Diagnostic)] #[diag("{$repr}")] @@ -1041,7 +1041,7 @@ pub(crate) struct ConstStableNotStable { pub const_span: Span, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] pub(crate) enum MultipleDeadCodes<'tcx> { #[diag( "{ $multiple -> @@ -1169,7 +1169,7 @@ pub(crate) struct ProcMacroBadSig { pub kind: ProcMacroKind, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag( "the feature `{$feature}` has been stable since {$since} and no longer requires an attribute to enable" )] @@ -1178,7 +1178,7 @@ pub(crate) struct UnnecessaryStableFeature { pub since: Symbol, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag( "the feature `{$feature}` has been partially stabilized since {$since} and is succeeded by the feature `{$implies}`" )] @@ -1200,7 +1200,7 @@ pub(crate) struct UnnecessaryPartialStableFeature { pub implies: Symbol, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("an `#[unstable]` annotation here has no effect")] #[note("see issue #55436 for more information")] pub(crate) struct IneffectiveUnstableImpl; @@ -1450,7 +1450,7 @@ pub(crate) struct FunctionNamesDuplicated { pub spans: Vec, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("there is no parameter `{$argument_name}` on trait `{$trait_name}`")] pub(crate) struct UnknownFormatParameterForOnUnimplementedAttr { pub argument_name: Symbol, diff --git a/compiler/rustc_pattern_analysis/src/errors.rs b/compiler/rustc_pattern_analysis/src/errors.rs index e7448613cc14e..b27e52f32bf27 100644 --- a/compiler/rustc_pattern_analysis/src/errors.rs +++ b/compiler/rustc_pattern_analysis/src/errors.rs @@ -46,7 +46,7 @@ impl Uncovered { } } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("multiple patterns overlap on their endpoints")] #[note("you likely meant to write mutually exclusive ranges")] pub struct OverlappingRangeEndpoints { @@ -64,7 +64,7 @@ pub struct Overlap { pub range: String, // a printed pattern } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("exclusive range missing `{$max}`")] pub struct ExclusiveRangeMissingMax { #[label("this range doesn't match `{$max}` because `..` is an exclusive range")] @@ -80,7 +80,7 @@ pub struct ExclusiveRangeMissingMax { pub max: String, // a printed pattern } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("multiple ranges are one apart")] pub struct ExclusiveRangeMissingGap { #[label("this range doesn't match `{$gap}` because `..` is an exclusive range")] @@ -119,7 +119,7 @@ impl Subdiagnostic for GappedRange { } } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("some variants are not matched explicitly")] #[help("ensure that all variants are matched explicitly by adding the suggested match arms")] #[note( diff --git a/compiler/rustc_privacy/src/errors.rs b/compiler/rustc_privacy/src/errors.rs index af4f0d61aa11e..afa91ddb3b012 100644 --- a/compiler/rustc_privacy/src/errors.rs +++ b/compiler/rustc_privacy/src/errors.rs @@ -1,6 +1,6 @@ use rustc_errors::codes::*; use rustc_errors::{DiagArgFromDisplay, MultiSpan}; -use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{Span, Symbol}; #[derive(Diagnostic)] @@ -87,7 +87,7 @@ pub(crate) struct ReportEffectiveVisibility { pub descr: String, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("{$kind} `{$descr}` from private dependency '{$krate}' in public interface")] pub(crate) struct FromPrivateDependencyInPublicInterface<'a> { pub kind: &'a str, @@ -95,7 +95,7 @@ pub(crate) struct FromPrivateDependencyInPublicInterface<'a> { pub krate: Symbol, } -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("{$kind} `{$descr}` is reachable but cannot be named")] pub(crate) struct UnnameableTypesLint<'a> { #[label( @@ -111,7 +111,7 @@ pub(crate) struct UnnameableTypesLint<'a> { // Used for `private_interfaces` and `private_bounds` lints. // They will replace private-in-public errors and compatibility lints in future. // See https://rust-lang.github.io/rfcs/2145-type-privacy.html for more details. -#[derive(LintDiagnostic)] +#[derive(Diagnostic)] #[diag("{$ty_kind} `{$ty_descr}` is more private than the item `{$item_descr}`")] pub(crate) struct PrivateInterfacesOrBoundsLint<'a> { #[label("{$item_kind} `{$item_descr}` is reachable at visibility `{$item_vis_descr}`")] diff --git a/tests/ui/drop/drop-order-comparisons.e2021.stderr b/tests/ui/drop/drop-order-comparisons.e2021.stderr index 40735650d182c..b1f0967103ab5 100644 --- a/tests/ui/drop/drop-order-comparisons.e2021.stderr +++ b/tests/ui/drop/drop-order-comparisons.e2021.stderr @@ -26,8 +26,6 @@ LL | | }, e.mark(3), e.ok(4)); | |__________________________this value will be stored in a temporary; let us call it `#1` | `#1` will be dropped later as of Edition 2024 | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: `#3` invokes this custom destructor --> $DIR/drop-order-comparisons.rs:503:1 | @@ -49,6 +47,8 @@ note: `#2` invokes this custom destructor LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages + = warning: this changes meaning in Rust 2024 + = note: for more information, see note: the lint level is defined here --> $DIR/drop-order-comparisons.rs:30:25 | @@ -74,8 +74,6 @@ LL | | }, e.mark(1), e.ok(4)); | |__________________________this value will be stored in a temporary; let us call it `#1` | `#1` will be dropped later as of Edition 2024 | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: `#2` invokes this custom destructor --> $DIR/drop-order-comparisons.rs:503:1 | @@ -87,6 +85,8 @@ note: `#1` invokes this custom destructor LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages + = warning: this changes meaning in Rust 2024 + = note: for more information, see warning: relative drop order changing in Rust 2024 --> $DIR/drop-order-comparisons.rs:102:19 @@ -106,8 +106,6 @@ LL | | }, e.mark(1), e.ok(4)); | |__________________________this value will be stored in a temporary; let us call it `#1` | `#1` will be dropped later as of Edition 2024 | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: `#2` invokes this custom destructor --> $DIR/drop-order-comparisons.rs:503:1 | @@ -119,6 +117,8 @@ note: `#1` invokes this custom destructor LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages + = warning: this changes meaning in Rust 2024 + = note: for more information, see warning: relative drop order changing in Rust 2024 --> $DIR/drop-order-comparisons.rs:223:24 @@ -138,8 +138,6 @@ LL | | }, e.mark(2), e.ok(3)); | |__________________________this value will be stored in a temporary; let us call it `#1` | `#1` will be dropped later as of Edition 2024 | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: `#2` invokes this custom destructor --> $DIR/drop-order-comparisons.rs:503:1 | @@ -151,6 +149,8 @@ note: `#1` invokes this custom destructor LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages + = warning: this changes meaning in Rust 2024 + = note: for more information, see warning: relative drop order changing in Rust 2024 --> $DIR/drop-order-comparisons.rs:249:24 @@ -170,8 +170,6 @@ LL | | }, e.mark(2), e.ok(3)); | |__________________________this value will be stored in a temporary; let us call it `#1` | `#1` will be dropped later as of Edition 2024 | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: `#2` invokes this custom destructor --> $DIR/drop-order-comparisons.rs:503:1 | @@ -183,6 +181,8 @@ note: `#1` invokes this custom destructor LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages + = warning: this changes meaning in Rust 2024 + = note: for more information, see warning: `if let` assigns a shorter lifetime since Edition 2024 --> $DIR/drop-order-comparisons.rs:125:13 @@ -192,8 +192,6 @@ LL | _ = (if let Ok(_) = e.ok(4).as_ref() { | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:503:1 | @@ -204,6 +202,8 @@ help: the value is now dropped here in Edition 2024 | LL | }, e.mark(2), e.ok(3)); | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see = note: `#[warn(if_let_rescope)]` implied by `#[warn(rust_2024_compatibility)]` help: a `match` with a single arm can preserve the drop order up to Edition 2021 | @@ -222,8 +222,6 @@ LL | _ = (if let Ok(_) = e.err(4).as_ref() {} else { | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:503:1 | @@ -234,6 +232,8 @@ help: the value is now dropped here in Edition 2024 | LL | _ = (if let Ok(_) = e.err(4).as_ref() {} else { | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: a `match` with a single arm can preserve the drop order up to Edition 2021 | LL ~ _ = (match e.err(4).as_ref() { Ok(_) => {} _ => { @@ -251,8 +251,6 @@ LL | if let Ok(_) = e.err(4).as_ref() {} else { | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:503:1 | @@ -263,6 +261,8 @@ help: the value is now dropped here in Edition 2024 | LL | if let Ok(_) = e.err(4).as_ref() {} else { | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: a `match` with a single arm can preserve the drop order up to Edition 2021 | LL ~ match e.err(4).as_ref() { Ok(_) => {} _ => { @@ -280,8 +280,6 @@ LL | if let true = e.err(9).is_ok() {} else { | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:503:1 | @@ -292,6 +290,8 @@ help: the value is now dropped here in Edition 2024 | LL | if let true = e.err(9).is_ok() {} else { | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: a `match` with a single arm can preserve the drop order up to Edition 2021 | LL ~ match e.err(9).is_ok() { true => {} _ => { @@ -309,8 +309,6 @@ LL | if let Ok(_v) = e.err(8) {} else { | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:503:1 | @@ -321,6 +319,8 @@ help: the value is now dropped here in Edition 2024 | LL | if let Ok(_v) = e.err(8) {} else { | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: a `match` with a single arm can preserve the drop order up to Edition 2021 | LL ~ match e.err(8) { Ok(_v) => {} _ => { @@ -338,8 +338,6 @@ LL | if let Ok(_) = e.err(7) {} else { | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:503:1 | @@ -350,6 +348,8 @@ help: the value is now dropped here in Edition 2024 | LL | if let Ok(_) = e.err(7) {} else { | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: a `match` with a single arm can preserve the drop order up to Edition 2021 | LL ~ match e.err(7) { Ok(_) => {} _ => { @@ -367,8 +367,6 @@ LL | if let Ok(_) = e.err(6).as_ref() {} else { | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:503:1 | @@ -379,6 +377,8 @@ help: the value is now dropped here in Edition 2024 | LL | if let Ok(_) = e.err(6).as_ref() {} else { | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: a `match` with a single arm can preserve the drop order up to Edition 2021 | LL ~ match e.err(6).as_ref() { Ok(_) => {} _ => { @@ -396,8 +396,6 @@ LL | if let Ok(_v) = e.err(5) {} else { | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:503:1 | @@ -408,6 +406,8 @@ help: the value is now dropped here in Edition 2024 | LL | if let Ok(_v) = e.err(5) {} else { | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: a `match` with a single arm can preserve the drop order up to Edition 2021 | LL ~ match e.err(5) { Ok(_v) => {} _ => { @@ -425,8 +425,6 @@ LL | if let Ok(_) = e.err(4) {} else { | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:503:1 | @@ -437,6 +435,8 @@ help: the value is now dropped here in Edition 2024 | LL | if let Ok(_) = e.err(4) {} else { | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: a `match` with a single arm can preserve the drop order up to Edition 2021 | LL ~ match e.err(4) { Ok(_) => {} _ => { @@ -454,8 +454,6 @@ LL | if let Ok(_) = e.err(4).as_ref() {} else { | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/drop-order-comparisons.rs:503:1 | @@ -466,6 +464,8 @@ help: the value is now dropped here in Edition 2024 | LL | if let Ok(_) = e.err(4).as_ref() {} else { | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: a `match` with a single arm can preserve the drop order up to Edition 2021 | LL ~ match e.err(4).as_ref() { Ok(_) => {} _ => { diff --git a/tests/ui/drop/lint-if-let-rescope-gated.edition2021.stderr b/tests/ui/drop/lint-if-let-rescope-gated.edition2021.stderr index 5f04273d336d6..feca46c2bc2dc 100644 --- a/tests/ui/drop/lint-if-let-rescope-gated.edition2021.stderr +++ b/tests/ui/drop/lint-if-let-rescope-gated.edition2021.stderr @@ -6,8 +6,6 @@ LL | if let Some(_value) = Droppy.get() { | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope-gated.rs:14:1 | @@ -18,6 +16,8 @@ help: the value is now dropped here in Edition 2024 | LL | } else { | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see note: the lint level is defined here --> $DIR/lint-if-let-rescope-gated.rs:10:9 | diff --git a/tests/ui/drop/lint-if-let-rescope-with-macro.stderr b/tests/ui/drop/lint-if-let-rescope-with-macro.stderr index 63e30f1ab92e4..a13c84f0e527d 100644 --- a/tests/ui/drop/lint-if-let-rescope-with-macro.stderr +++ b/tests/ui/drop/lint-if-let-rescope-with-macro.stderr @@ -13,8 +13,6 @@ LL | | {} LL | | }; | |_____- in this macro invocation | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope-with-macro.rs:22:1 | @@ -33,6 +31,8 @@ LL | | {} LL | | {} LL | | }; | |_____- in this macro invocation + = warning: this changes meaning in Rust 2024 + = note: for more information, see note: the lint level is defined here --> $DIR/lint-if-let-rescope-with-macro.rs:7:9 | diff --git a/tests/ui/drop/lint-if-let-rescope.stderr b/tests/ui/drop/lint-if-let-rescope.stderr index 7cab7339fe1e5..ee2acb0d67597 100644 --- a/tests/ui/drop/lint-if-let-rescope.stderr +++ b/tests/ui/drop/lint-if-let-rescope.stderr @@ -6,8 +6,6 @@ LL | if let Some(_value) = droppy().get() { | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope.rs:11:1 | @@ -18,6 +16,8 @@ help: the value is now dropped here in Edition 2024 | LL | } else { | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see note: the lint level is defined here --> $DIR/lint-if-let-rescope.rs:3:9 | @@ -46,8 +46,6 @@ LL | if let Some(_value) = droppy().get() { LL | } else if let Some(_value) = droppy().get() { | -------- this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope.rs:11:1 | @@ -68,6 +66,8 @@ help: the value is now dropped here in Edition 2024 | LL | } | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: a `match` with a single arm can preserve the drop order up to Edition 2021 | LL ~ match droppy().get() { Some(_value) => { @@ -88,8 +88,6 @@ LL | } else if let Some(_value) = droppy().get() { | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope.rs:11:1 | @@ -100,6 +98,8 @@ help: the value is now dropped here in Edition 2024 | LL | } else if droppy().get().is_none() { | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: a `match` with a single arm can preserve the drop order up to Edition 2021 | LL ~ } else { match droppy().get() { Some(_value) => { @@ -119,8 +119,6 @@ LL | if let Some(1) = { if let Some(_value) = Droppy.get() { Some(1) } else | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope.rs:11:1 | @@ -131,6 +129,8 @@ help: the value is now dropped here in Edition 2024 | LL | if let Some(1) = { if let Some(_value) = Droppy.get() { Some(1) } else { None } } { | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: a `match` with a single arm can preserve the drop order up to Edition 2021 | LL - if let Some(1) = { if let Some(_value) = Droppy.get() { Some(1) } else { None } } { @@ -145,8 +145,6 @@ LL | if (if let Some(_value) = droppy().get() { true } else { false }) { | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope.rs:11:1 | @@ -157,6 +155,8 @@ help: the value is now dropped here in Edition 2024 | LL | if (if let Some(_value) = droppy().get() { true } else { false }) { | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: a `match` with a single arm can preserve the drop order up to Edition 2021 | LL - if (if let Some(_value) = droppy().get() { true } else { false }) { @@ -171,8 +171,6 @@ LL | } else if (((if let Some(_value) = droppy().get() { true } else { false | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope.rs:11:1 | @@ -183,6 +181,8 @@ help: the value is now dropped here in Edition 2024 | LL | } else if (((if let Some(_value) = droppy().get() { true } else { false }))) { | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: a `match` with a single arm can preserve the drop order up to Edition 2021 | LL - } else if (((if let Some(_value) = droppy().get() { true } else { false }))) { @@ -197,8 +197,6 @@ LL | while (if let Some(_value) = droppy().get() { false } else { true }) { | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: value invokes this custom destructor --> $DIR/lint-if-let-rescope.rs:11:1 | @@ -209,6 +207,8 @@ help: the value is now dropped here in Edition 2024 | LL | while (if let Some(_value) = droppy().get() { false } else { true }) { | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: a `match` with a single arm can preserve the drop order up to Edition 2021 | LL - while (if let Some(_value) = droppy().get() { false } else { true }) { @@ -223,13 +223,13 @@ LL | if let Some(_value) = Some((droppy(), ()).1) {} else {} | | | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion | - = warning: this changes meaning in Rust 2024 - = note: for more information, see help: the value is now dropped here in Edition 2024 --> $DIR/lint-if-let-rescope.rs:97:51 | LL | if let Some(_value) = Some((droppy(), ()).1) {} else {} | ^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: a `match` with a single arm can preserve the drop order up to Edition 2021 | LL - if let Some(_value) = Some((droppy(), ()).1) {} else {} diff --git a/tests/ui/drop/lint-tail-expr-drop-order.stderr b/tests/ui/drop/lint-tail-expr-drop-order.stderr index c69c58aa1ab77..d638d6bd7f029 100644 --- a/tests/ui/drop/lint-tail-expr-drop-order.stderr +++ b/tests/ui/drop/lint-tail-expr-drop-order.stderr @@ -16,8 +16,6 @@ LL | x.get() + LoudDropper.get() LL | } | - now the temporary value is dropped here, before the local variables in the block or statement | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: `#1` invokes this custom destructor --> $DIR/lint-tail-expr-drop-order.rs:10:1 | @@ -29,6 +27,8 @@ note: `x` invokes this custom destructor LL | impl Drop for LoudDropper { | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages + = warning: this changes meaning in Rust 2024 + = note: for more information, see note: the lint level is defined here --> $DIR/lint-tail-expr-drop-order.rs:6:9 | @@ -53,8 +53,6 @@ LL | x.get() + LoudDropper.get() LL | } | - now the temporary value is dropped here, before the local variables in the block or statement | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: `#1` invokes this custom destructor --> $DIR/lint-tail-expr-drop-order.rs:10:1 | @@ -66,6 +64,8 @@ note: `x` invokes this custom destructor LL | impl Drop for LoudDropper { | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages + = warning: this changes meaning in Rust 2024 + = note: for more information, see error: relative drop order changing in Rust 2024 --> $DIR/lint-tail-expr-drop-order.rs:92:7 @@ -85,8 +85,6 @@ LL | { LoudDropper.get() } LL | } | - now the temporary value is dropped here, before the local variables in the block or statement | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: `#1` invokes this custom destructor --> $DIR/lint-tail-expr-drop-order.rs:10:1 | @@ -98,6 +96,8 @@ note: `x` invokes this custom destructor LL | impl Drop for LoudDropper { | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages + = warning: this changes meaning in Rust 2024 + = note: for more information, see error: relative drop order changing in Rust 2024 --> $DIR/lint-tail-expr-drop-order.rs:145:5 @@ -117,14 +117,14 @@ LL | LoudDropper.get() LL | } | - now the temporary value is dropped here, before the local variables in the block or statement | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: `#1` invokes this custom destructor --> $DIR/lint-tail-expr-drop-order.rs:10:1 | LL | impl Drop for LoudDropper { | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages + = warning: this changes meaning in Rust 2024 + = note: for more information, see error: relative drop order changing in Rust 2024 --> $DIR/lint-tail-expr-drop-order.rs:162:14 @@ -144,9 +144,9 @@ LL | extract(&T::default()) LL | } | - now the temporary value is dropped here, before the local variables in the block or statement | + = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages = warning: this changes meaning in Rust 2024 = note: for more information, see - = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages error: relative drop order changing in Rust 2024 --> $DIR/lint-tail-expr-drop-order.rs:176:5 @@ -166,8 +166,6 @@ LL | LoudDropper.get() LL | } | - now the temporary value is dropped here, before the local variables in the block or statement | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: `#1` invokes this custom destructor --> $DIR/lint-tail-expr-drop-order.rs:10:1 | @@ -179,6 +177,8 @@ note: `x` invokes this custom destructor LL | impl Drop for LoudDropper { | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages + = warning: this changes meaning in Rust 2024 + = note: for more information, see error: relative drop order changing in Rust 2024 --> $DIR/lint-tail-expr-drop-order.rs:220:5 @@ -198,8 +198,6 @@ LL | LoudDropper3.get() LL | } | - now the temporary value is dropped here, before the local variables in the block or statement | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: `#1` invokes this custom destructor --> $DIR/lint-tail-expr-drop-order.rs:193:5 | @@ -211,6 +209,8 @@ note: `x` invokes this custom destructor LL | impl Drop for LoudDropper2 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages + = warning: this changes meaning in Rust 2024 + = note: for more information, see error: relative drop order changing in Rust 2024 --> $DIR/lint-tail-expr-drop-order.rs:233:13 @@ -230,8 +230,6 @@ LL | let _x = LoudDropper; LL | )); | - now the temporary value is dropped here, before the local variables in the block or statement | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: `#1` invokes this custom destructor --> $DIR/lint-tail-expr-drop-order.rs:10:1 | @@ -243,6 +241,8 @@ note: `_x` invokes this custom destructor LL | impl Drop for LoudDropper { | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages + = warning: this changes meaning in Rust 2024 + = note: for more information, see error: aborting due to 8 previous errors diff --git a/tests/ui/drop/tail_expr_drop_order-on-coroutine-unwind.stderr b/tests/ui/drop/tail_expr_drop_order-on-coroutine-unwind.stderr index 94977185ced82..f89d1d3c2ceb7 100644 --- a/tests/ui/drop/tail_expr_drop_order-on-coroutine-unwind.stderr +++ b/tests/ui/drop/tail_expr_drop_order-on-coroutine-unwind.stderr @@ -22,8 +22,6 @@ LL | } LL | } | - now the temporary value is dropped here, before the local variables in the block or statement | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: `#2` invokes this custom destructor --> $DIR/tail_expr_drop_order-on-coroutine-unwind.rs:9:1 | @@ -40,6 +38,8 @@ note: `e` invokes this custom destructor LL | impl std::ops::Drop for Drop { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages + = warning: this changes meaning in Rust 2024 + = note: for more information, see note: the lint level is defined here --> $DIR/tail_expr_drop_order-on-coroutine-unwind.rs:6:9 | diff --git a/tests/ui/impl-trait/precise-capturing/overcaptures-2024-machine-applicable.stderr b/tests/ui/impl-trait/precise-capturing/overcaptures-2024-machine-applicable.stderr index 980ddedc255bf..ff904de61d2c3 100644 --- a/tests/ui/impl-trait/precise-capturing/overcaptures-2024-machine-applicable.stderr +++ b/tests/ui/impl-trait/precise-capturing/overcaptures-2024-machine-applicable.stderr @@ -4,14 +4,14 @@ error: `impl Sized` will capture more lifetimes than possibly intended in editio LL | fn named<'a>(x: &'a i32) -> impl Sized { *x } | ^^^^^^^^^^ | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024-machine-applicable.rs:9:10 | LL | fn named<'a>(x: &'a i32) -> impl Sized { *x } | ^^ = note: all lifetimes in scope will be captured by `impl Trait`s in edition 2024 + = warning: this changes meaning in Rust 2024 + = note: for more information, see note: the lint level is defined here --> $DIR/overcaptures-2024-machine-applicable.rs:7:9 | diff --git a/tests/ui/impl-trait/precise-capturing/overcaptures-2024.stderr b/tests/ui/impl-trait/precise-capturing/overcaptures-2024.stderr index dc9f1c218d9f3..a3c84a89fb415 100644 --- a/tests/ui/impl-trait/precise-capturing/overcaptures-2024.stderr +++ b/tests/ui/impl-trait/precise-capturing/overcaptures-2024.stderr @@ -4,14 +4,14 @@ error: `impl Sized` will capture more lifetimes than possibly intended in editio LL | fn named<'a>(x: &'a i32) -> impl Sized { *x } | ^^^^^^^^^^ | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024.rs:7:10 | LL | fn named<'a>(x: &'a i32) -> impl Sized { *x } | ^^ = note: all lifetimes in scope will be captured by `impl Trait`s in edition 2024 + = warning: this changes meaning in Rust 2024 + = note: for more information, see note: the lint level is defined here --> $DIR/overcaptures-2024.rs:5:9 | @@ -28,14 +28,14 @@ error: `impl Sized` will capture more lifetimes than possibly intended in editio LL | fn implicit(x: &i32) -> impl Sized { *x } | ^^^^^^^^^^ | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024.rs:11:16 | LL | fn implicit(x: &i32) -> impl Sized { *x } | ^ = note: all lifetimes in scope will be captured by `impl Trait`s in edition 2024 + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: use the precise capturing `use<...>` syntax to make the captures explicit | LL | fn implicit(x: &i32) -> impl Sized + use<> { *x } @@ -47,14 +47,14 @@ error: `impl Sized + '_` will capture more lifetimes than possibly intended in e LL | fn hello(&self, x: &i32) -> impl Sized + '_ { self } | ^^^^^^^^^^^^^^^ | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024.rs:17:24 | LL | fn hello(&self, x: &i32) -> impl Sized + '_ { self } | ^ = note: all lifetimes in scope will be captured by `impl Trait`s in edition 2024 + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: use the precise capturing `use<...>` syntax to make the captures explicit | LL | fn hello(&self, x: &i32) -> impl Sized + '_ + use<'_> { self } @@ -66,14 +66,14 @@ error: `impl Sized` will capture more lifetimes than possibly intended in editio LL | fn hrtb() -> impl for<'a> Higher<'a, Output = impl Sized> {} | ^^^^^^^^^^ | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024.rs:29:23 | LL | fn hrtb() -> impl for<'a> Higher<'a, Output = impl Sized> {} | ^^ = note: all lifetimes in scope will be captured by `impl Trait`s in edition 2024 + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: use the precise capturing `use<...>` syntax to make the captures explicit | LL | fn hrtb() -> impl for<'a> Higher<'a, Output = impl Sized + use<>> {} @@ -85,8 +85,6 @@ error: `impl Sized` will capture more lifetimes than possibly intended in editio LL | fn apit(_: &impl Sized) -> impl Sized {} | ^^^^^^^^^^ | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024.rs:33:12 | @@ -98,6 +96,8 @@ note: you could use a `use<...>` bound to explicitly specify captures, but argum | LL | fn apit(_: &impl Sized) -> impl Sized {} | ^^^^^^^^^^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: use the precise capturing `use<...>` syntax to make the captures explicit | LL - fn apit(_: &impl Sized) -> impl Sized {} @@ -110,8 +110,6 @@ error: `impl Sized` will capture more lifetimes than possibly intended in editio LL | fn apit2(_: &impl Sized, _: U) -> impl Sized {} | ^^^^^^^^^^ | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024.rs:37:16 | @@ -123,6 +121,8 @@ note: you could use a `use<...>` bound to explicitly specify captures, but argum | LL | fn apit2(_: &impl Sized, _: U) -> impl Sized {} | ^^^^^^^^^^ + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: use the precise capturing `use<...>` syntax to make the captures explicit | LL - fn apit2(_: &impl Sized, _: U) -> impl Sized {} @@ -135,14 +135,14 @@ error: `impl Sized` will capture more lifetimes than possibly intended in editio LL | async fn async_fn<'a>(x: &'a ()) -> impl Sized {} | ^^^^^^^^^^ | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024.rs:41:19 | LL | async fn async_fn<'a>(x: &'a ()) -> impl Sized {} | ^^ = note: all lifetimes in scope will be captured by `impl Trait`s in edition 2024 + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: use the precise capturing `use<...>` syntax to make the captures explicit | LL | async fn async_fn<'a>(x: &'a ()) -> impl Sized + use<> {} @@ -154,14 +154,14 @@ error: `impl Clone` will capture more lifetimes than possibly intended in editio LL | pub fn parens(x: &i32) -> &impl Clone { x } | ^^^^^^^^^^ | - = warning: this changes meaning in Rust 2024 - = note: for more information, see note: specifically, this lifetime is in scope but not mentioned in the type's bounds --> $DIR/overcaptures-2024.rs:45:18 | LL | pub fn parens(x: &i32) -> &impl Clone { x } | ^ = note: all lifetimes in scope will be captured by `impl Trait`s in edition 2024 + = warning: this changes meaning in Rust 2024 + = note: for more information, see help: use the precise capturing `use<...>` syntax to make the captures explicit | LL | pub fn parens(x: &i32) -> &(impl Clone + use<>) { x } diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr index e16841b369db9..43cb9eb12e17a 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr @@ -79,7 +79,6 @@ error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and req LL | sse2(); | ^^^^^^ call to function with `#[target_feature]` | - = note: for more information, see = help: in order for the call to be safe, the context requires the following additional target feature: sse2 = note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]` note: an unsafe function restricts its caller, but its body is safe by default @@ -87,6 +86,7 @@ note: an unsafe function restricts its caller, but its body is safe by default | LL | unsafe fn needs_unsafe_block() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: for more information, see note: the lint level is defined here --> $DIR/safe-calls.rs:65:8 | diff --git a/tests/ui/rust-2024/unsafe-env.e2021.stderr b/tests/ui/rust-2024/unsafe-env.e2021.stderr index a73db9fd60c73..fc3279af43bb8 100644 --- a/tests/ui/rust-2024/unsafe-env.e2021.stderr +++ b/tests/ui/rust-2024/unsafe-env.e2021.stderr @@ -4,13 +4,13 @@ error[E0133]: call to unsafe function `unsafe_fn` is unsafe and requires unsafe LL | unsafe_fn(); | ^^^^^^^^^^^ call to unsafe function | - = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/unsafe-env.rs:8:1 | LL | unsafe fn unsafe_fn() { | ^^^^^^^^^^^^^^^^^^^^^ + = note: for more information, see note: the lint level is defined here --> $DIR/unsafe-env.rs:7:8 | diff --git a/tests/ui/rust-2024/unsafe-env.e2024.stderr b/tests/ui/rust-2024/unsafe-env.e2024.stderr index cb48ae231f274..0473e9a2c4ae2 100644 --- a/tests/ui/rust-2024/unsafe-env.e2024.stderr +++ b/tests/ui/rust-2024/unsafe-env.e2024.stderr @@ -4,13 +4,13 @@ error[E0133]: call to unsafe function `std::env::set_var` is unsafe and requires LL | env::set_var("FOO", "BAR"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | - = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/unsafe-env.rs:8:1 | LL | unsafe fn unsafe_fn() { | ^^^^^^^^^^^^^^^^^^^^^ + = note: for more information, see note: the lint level is defined here --> $DIR/unsafe-env.rs:7:8 | @@ -23,8 +23,8 @@ error[E0133]: call to unsafe function `std::env::remove_var` is unsafe and requi LL | env::remove_var("FOO"); | ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | - = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior + = note: for more information, see error[E0133]: call to unsafe function `unsafe_fn` is unsafe and requires unsafe block --> $DIR/unsafe-env.rs:14:9 @@ -32,8 +32,8 @@ error[E0133]: call to unsafe function `unsafe_fn` is unsafe and requires unsafe LL | unsafe_fn(); | ^^^^^^^^^^^ call to unsafe function | - = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior + = note: for more information, see error[E0133]: call to unsafe function `set_var` is unsafe and requires unsafe block --> $DIR/unsafe-env.rs:22:5 diff --git a/tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.stderr b/tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.stderr index b6804511ac235..01189f15c3fea 100644 --- a/tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.stderr +++ b/tests/ui/unsafe/edition-2024-unsafe_op_in_unsafe_fn.stderr @@ -4,13 +4,13 @@ warning[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe blo LL | unsf(); | ^^^^^^ call to unsafe function | - = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/edition-2024-unsafe_op_in_unsafe_fn.rs:8:1 | LL | unsafe fn foo() { | ^^^^^^^^^^^^^^^ + = note: for more information, see = note: `#[warn(unsafe_op_in_unsafe_fn)]` (part of `#[warn(rust_2024_compatibility)]`) on by default warning: 1 warning emitted diff --git a/tests/ui/unsafe/unsafe_op_in_unsafe_fn/edition_2024_default.stderr b/tests/ui/unsafe/unsafe_op_in_unsafe_fn/edition_2024_default.stderr index 35f9d3a4ebc4c..23cb42013633d 100644 --- a/tests/ui/unsafe/unsafe_op_in_unsafe_fn/edition_2024_default.stderr +++ b/tests/ui/unsafe/unsafe_op_in_unsafe_fn/edition_2024_default.stderr @@ -4,13 +4,13 @@ warning[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe blo LL | unsf(); | ^^^^^^ call to unsafe function | - = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/edition_2024_default.rs:11:1 | LL | unsafe fn foo() { | ^^^^^^^^^^^^^^^ + = note: for more information, see = note: `#[warn(unsafe_op_in_unsafe_fn)]` (part of `#[warn(rust_2024_compatibility)]`) on by default warning: 1 warning emitted diff --git a/tests/ui/unsafe/unsafe_op_in_unsafe_fn/in_2024_compatibility.stderr b/tests/ui/unsafe/unsafe_op_in_unsafe_fn/in_2024_compatibility.stderr index 0c4070068d0b2..d9d42695d5b31 100644 --- a/tests/ui/unsafe/unsafe_op_in_unsafe_fn/in_2024_compatibility.stderr +++ b/tests/ui/unsafe/unsafe_op_in_unsafe_fn/in_2024_compatibility.stderr @@ -4,13 +4,13 @@ error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block LL | unsf(); | ^^^^^^ call to unsafe function | - = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/in_2024_compatibility.rs:6:1 | LL | unsafe fn foo() { | ^^^^^^^^^^^^^^^ + = note: for more information, see note: the lint level is defined here --> $DIR/in_2024_compatibility.rs:1:9 | diff --git a/tests/ui/unsafe/unsafe_op_in_unsafe_fn/rfc-2585-unsafe_op_in_unsafe_fn.stderr b/tests/ui/unsafe/unsafe_op_in_unsafe_fn/rfc-2585-unsafe_op_in_unsafe_fn.stderr index 3e43840cf6cb3..5ba70b882f813 100644 --- a/tests/ui/unsafe/unsafe_op_in_unsafe_fn/rfc-2585-unsafe_op_in_unsafe_fn.stderr +++ b/tests/ui/unsafe/unsafe_op_in_unsafe_fn/rfc-2585-unsafe_op_in_unsafe_fn.stderr @@ -4,13 +4,13 @@ error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block LL | unsf(); | ^^^^^^ call to unsafe function | - = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:8:1 | LL | unsafe fn deny_level() { | ^^^^^^^^^^^^^^^^^^^^^^ + = note: for more information, see note: the lint level is defined here --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:1:9 | @@ -23,8 +23,8 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe block LL | *PTR; | ^^^^ dereference of raw pointer | - = note: for more information, see = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + = note: for more information, see error[E0133]: use of mutable static is unsafe and requires unsafe block --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:13:5 @@ -32,8 +32,8 @@ error[E0133]: use of mutable static is unsafe and requires unsafe block LL | VOID = (); | ^^^^ use of mutable static | - = note: for more information, see = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + = note: for more information, see error: unnecessary `unsafe` block --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:16:5 @@ -53,13 +53,13 @@ error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block LL | unsf(); | ^^^^^^ call to unsafe function | - = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:23:1 | LL | unsafe fn warning_level() { | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: for more information, see note: the lint level is defined here --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:22:8 | @@ -73,8 +73,8 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe block LL | *PTR; | ^^^^ dereference of raw pointer | - = note: for more information, see = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + = note: for more information, see error[E0133]: use of mutable static is unsafe and requires unsafe block --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:28:5 @@ -82,8 +82,8 @@ error[E0133]: use of mutable static is unsafe and requires unsafe block LL | VOID = (); | ^^^^ use of mutable static | - = note: for more information, see = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + = note: for more information, see error: unnecessary `unsafe` block --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:30:5 diff --git a/tests/ui/unsafe/unsafe_op_in_unsafe_fn/wrapping-unsafe-block-sugg.stderr b/tests/ui/unsafe/unsafe_op_in_unsafe_fn/wrapping-unsafe-block-sugg.stderr index f7dbf39e6f261..3308a0807db6f 100644 --- a/tests/ui/unsafe/unsafe_op_in_unsafe_fn/wrapping-unsafe-block-sugg.stderr +++ b/tests/ui/unsafe/unsafe_op_in_unsafe_fn/wrapping-unsafe-block-sugg.stderr @@ -4,13 +4,13 @@ error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block LL | unsf(); | ^^^^^^ call to unsafe function | - = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/wrapping-unsafe-block-sugg.rs:11:1 | LL | pub unsafe fn foo() { | ^^^^^^^^^^^^^^^^^^^ + = note: for more information, see note: the lint level is defined here --> $DIR/wrapping-unsafe-block-sugg.rs:4:9 | @@ -23,8 +23,8 @@ error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block LL | unsf(); | ^^^^^^ call to unsafe function | - = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior + = note: for more information, see error[E0133]: dereference of raw pointer is unsafe and requires unsafe block --> $DIR/wrapping-unsafe-block-sugg.rs:25:13 @@ -32,13 +32,13 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe block LL | let y = *x; | ^^ dereference of raw pointer | - = note: for more information, see = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/wrapping-unsafe-block-sugg.rs:23:1 | LL | pub unsafe fn bar(x: *const i32) -> i32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: for more information, see error[E0133]: dereference of raw pointer is unsafe and requires unsafe block --> $DIR/wrapping-unsafe-block-sugg.rs:29:9 @@ -46,8 +46,8 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe block LL | y + *x | ^^ dereference of raw pointer | - = note: for more information, see = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + = note: for more information, see error[E0133]: use of mutable static is unsafe and requires unsafe block --> $DIR/wrapping-unsafe-block-sugg.rs:38:13 @@ -55,13 +55,13 @@ error[E0133]: use of mutable static is unsafe and requires unsafe block LL | let y = BAZ; | ^^^ use of mutable static | - = note: for more information, see = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/wrapping-unsafe-block-sugg.rs:36:1 | LL | pub unsafe fn baz() -> i32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: for more information, see error[E0133]: use of mutable static is unsafe and requires unsafe block --> $DIR/wrapping-unsafe-block-sugg.rs:42:9 @@ -69,8 +69,8 @@ error[E0133]: use of mutable static is unsafe and requires unsafe block LL | y + BAZ | ^^^ use of mutable static | - = note: for more information, see = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + = note: for more information, see error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block --> $DIR/wrapping-unsafe-block-sugg.rs:48:36 @@ -81,13 +81,13 @@ LL | macro_rules! unsafe_macro { () => (unsf()) } LL | unsafe_macro!(); | --------------- in this macro invocation | - = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior note: an unsafe function restricts its caller, but its body is safe by default --> $DIR/wrapping-unsafe-block-sugg.rs:58:1 | LL | pub unsafe fn unsafe_in_macro() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: for more information, see = note: this error originates in the macro `unsafe_macro` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block @@ -99,8 +99,8 @@ LL | macro_rules! unsafe_macro { () => (unsf()) } LL | unsafe_macro!(); | --------------- in this macro invocation | - = note: for more information, see = note: consult the function's documentation for information on how to avoid undefined behavior + = note: for more information, see = note: this error originates in the macro `unsafe_macro` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 8 previous errors