rust icon indicating copy to clipboard operation
rust copied to clipboard

Migrate `rustc_lint` lint diagnostics

Open Rejyr opened this issue 3 years ago • 8 comments

Part 2 of Migrate rustc_lint errors to SessionDiagnostic

r? @davidtwco

Rejyr avatar Aug 28 '22 23:08 Rejyr

@rustbot label: +A-diagnostics

Rejyr avatar Aug 28 '22 23:08 Rejyr

@davidtwco How would I untangle emit_ffi_unsafe_type_lint and FfiResult? Would I only modify emit_ffi_unsafe_type_lint, create separate LintDiagnostic types for each lint, or just leave it?

Rejyr avatar Sep 04 '22 12:09 Rejyr

The job x86_64-gnu-llvm-13 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling fluent-syntax v0.11.0
   Compiling tracing v0.1.35
   Compiling tracing-subscriber v0.3.3
   Compiling thorin-dwp v0.3.0
error: internal compiler error: no warnings or errors encountered even though `delayed_good_path_bugs` issued

error: internal compiler error: trimmed_def_paths constructed
  |
  = note: delayed at    0: <rustc_errors::Handler>::delay_good_path_bug::<&str>
             1: rustc_middle::ty::print::pretty::trimmed_def_paths
             2: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::ArenaCache<(), std::collections::hash::map::HashMap<rustc_span::def_id::DefId, rustc_span::symbol::Symbol, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>>>
             3: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::trimmed_def_paths, rustc_query_impl::plumbing::QueryCtxt>
             4: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::trimmed_def_paths
             5: <rustc_middle::ty::print::pretty::FmtPrinter as rustc_middle::ty::print::Printer>::print_def_path
             7: <rustc_middle::ty::context::TyCtxt>::def_path_str
             7: <rustc_middle::ty::context::TyCtxt>::def_path_str
             8: <rustc_lint::traits::DropTraitConstraints as rustc_lint::passes::LateLintPass>::check_item
             9: <rustc_lint::late::LateContextAndPass<rustc_lint::BuiltinCombinedModuleLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_item
            10: <rustc_lint::late::LateContextAndPass<rustc_lint::BuiltinCombinedModuleLateLintPass> as rustc_hir::intravisit::Visitor>::visit_stmt
            11: rustc_hir::intravisit::walk_expr::<rustc_lint::late::LateContextAndPass<rustc_lint::BuiltinCombinedModuleLateLintPass>>
            12: <rustc_lint::late::LateContextAndPass<rustc_lint::BuiltinCombinedModuleLateLintPass> as rustc_hir::intravisit::Visitor>::visit_expr
            13: <rustc_lint::late::LateContextAndPass<rustc_lint::BuiltinCombinedModuleLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_body
            14: <rustc_lint::late::LateContextAndPass<rustc_lint::BuiltinCombinedModuleLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_item
            15: rustc_hir::intravisit::walk_mod::<rustc_lint::late::LateContextAndPass<rustc_lint::BuiltinCombinedModuleLateLintPass>>
            16: rustc_lint::late::late_lint_mod::<rustc_lint::BuiltinCombinedModuleLateLintPass>
            18: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, ()>>
            19: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::lint_mod, rustc_query_impl::plumbing::QueryCtxt>
            20: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::lint_mod
            20: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::lint_mod
            21: <core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::par_for_each_in<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_for_each_module<rustc_lint::late::check_crate<rustc_lint::BuiltinCombinedLateLintPass, rustc_interface::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#1}::{closure#0}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}> as core::ops::function::FnOnce<()>>::call_once
            22: rustc_data_structures::sync::par_for_each_in::<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_for_each_module<rustc_lint::late::check_crate<rustc_lint::BuiltinCombinedLateLintPass, rustc_interface::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#1}::{closure#0}::{closure#0}>::{closure#0}>
            23: <rustc_session::session::Session>::time::<(), rustc_lint::late::check_crate<rustc_lint::BuiltinCombinedLateLintPass, rustc_interface::passes::analysis::{closure#5}::{closure#1}::{closure#2}::{closure#0}::{closure#0}>::{closure#1}::{closure#0}>
            24: <core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#5}::{closure#1}::{closure#2}> as core::ops::function::FnOnce<()>>::call_once
            25: std::panic::catch_unwind::<core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#5}::{closure#1}::{closure#2}>, ()>
            26: <core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#5}::{closure#1}> as core::ops::function::FnOnce<()>>::call_once
            27: std::panic::catch_unwind::<core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#5}::{closure#1}>, ()>
            28: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#5}>
            30: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorGuaranteed>>>
            31: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
            32: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
            33: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
            33: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
            34: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
            35: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
            36: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
            37: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
            38: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
            39: std::panicking::try::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, core::panic::unwind_safe::AssertUnwindSafe<<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#1}::{closure#0}>>
            40: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            41: std::sys::unix::thread::Thread::new::thread_start
            42: <unknown>
            43: <unknown>

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1499:13
stack backtrace:
   0:     0x7f5984e98ecd - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h7aceaaec384abd8d
   0:     0x7f5984e98ecd - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h7aceaaec384abd8d
   1:     0x7f5984efe9a8 - core::fmt::write::h1935094ec1b611e9
   2:     0x7f5984e89fe1 - std::io::Write::write_fmt::h924a08855ab35277
   3:     0x7f5984e9beee - std::panicking::default_hook::{{closure}}::hdcba8bc567463877
   4:     0x7f5984e9bbb7 - std::panicking::default_hook::h5e023012d652ad1c
   5:     0x7f598584ab04 - rustc_driver[491383e5761cfd5f]::DEFAULT_HOOK::{closure#0}::{closure#0}
   6:     0x7f5984e9c691 - std::panicking::rust_panic_with_hook::hc50598e1e398727d
   7:     0x7f59885cc163 - std[8a3c335779a4ef7b]::panicking::begin_panic::<rustc_errors[a9e596aa33e6456]::ExplicitBug>::{closure#0}
   8:     0x7f59885c91c6 - std[8a3c335779a4ef7b]::sys_common::backtrace::__rust_end_short_backtrace::<std[8a3c335779a4ef7b]::panicking::begin_panic<rustc_errors[a9e596aa33e6456]::ExplicitBug>::{closure#0}, !>
   9:     0x7f598580a9b6 - std[8a3c335779a4ef7b]::panicking::begin_panic::<rustc_errors[a9e596aa33e6456]::ExplicitBug>
  10:     0x7f59885bd666 - std[8a3c335779a4ef7b]::panic::panic_any::<rustc_errors[a9e596aa33e6456]::ExplicitBug>
  11:     0x7f59885c28ad - <rustc_errors[a9e596aa33e6456]::HandlerInner as core[c1e30f1bd259d119]::ops::drop::Drop>::drop
  12:     0x7f59858a6ae2 - core[c1e30f1bd259d119]::ptr::drop_in_place::<rustc_session[5e51afea9c8b884e]::parse::ParseSess>
  13:     0x7f59858aee15 - <alloc[45623a189840f9f9]::rc::Rc<rustc_session[5e51afea9c8b884e]::session::Session> as core[c1e30f1bd259d119]::ops::drop::Drop>::drop
  14:     0x7f598583b87c - core[c1e30f1bd259d119]::ptr::drop_in_place::<rustc_interface[62be15c45d0bd73b]::interface::Compiler>
  15:     0x7f5985839537 - rustc_span[8c7477ded0a91ee5]::with_source_map::<core[c1e30f1bd259d119]::result::Result<(), rustc_errors[a9e596aa33e6456]::ErrorGuaranteed>, rustc_interface[62be15c45d0bd73b]::interface::create_compiler_and_run<core[c1e30f1bd259d119]::result::Result<(), rustc_errors[a9e596aa33e6456]::ErrorGuaranteed>, rustc_driver[491383e5761cfd5f]::run_compiler::{closure#1}>::{closure#1}>
  16:     0x7f598584d98e - rustc_interface[62be15c45d0bd73b]::interface::create_compiler_and_run::<core[c1e30f1bd259d119]::result::Result<(), rustc_errors[a9e596aa33e6456]::ErrorGuaranteed>, rustc_driver[491383e5761cfd5f]::run_compiler::{closure#1}>
  17:     0x7f59858304f2 - <scoped_tls[5efd78fa53ce51fd]::ScopedKey<rustc_span[8c7477ded0a91ee5]::SessionGlobals>>::set::<rustc_interface[62be15c45d0bd73b]::interface::run_compiler<core[c1e30f1bd259d119]::result::Result<(), rustc_errors[a9e596aa33e6456]::ErrorGuaranteed>, rustc_driver[491383e5761cfd5f]::run_compiler::{closure#1}>::{closure#0}, core[c1e30f1bd259d119]::result::Result<(), rustc_errors[a9e596aa33e6456]::ErrorGuaranteed>>
  18:     0x7f59858ab0bf - std[8a3c335779a4ef7b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[62be15c45d0bd73b]::util::run_in_thread_pool_with_globals<rustc_interface[62be15c45d0bd73b]::interface::run_compiler<core[c1e30f1bd259d119]::result::Result<(), rustc_errors[a9e596aa33e6456]::ErrorGuaranteed>, rustc_driver[491383e5761cfd5f]::run_compiler::{closure#1}>::{closure#0}, core[c1e30f1bd259d119]::result::Result<(), rustc_errors[a9e596aa33e6456]::ErrorGuaranteed>>::{closure#0}, core[c1e30f1bd259d119]::result::Result<(), rustc_errors[a9e596aa33e6456]::ErrorGuaranteed>>
  19:     0x7f598583abde - std[8a3c335779a4ef7b]::panicking::try::<core[c1e30f1bd259d119]::result::Result<(), rustc_errors[a9e596aa33e6456]::ErrorGuaranteed>, core[c1e30f1bd259d119]::panic::unwind_safe::AssertUnwindSafe<<std[8a3c335779a4ef7b]::thread::Builder>::spawn_unchecked_<rustc_interface[62be15c45d0bd73b]::util::run_in_thread_pool_with_globals<rustc_interface[62be15c45d0bd73b]::interface::run_compiler<core[c1e30f1bd259d119]::result::Result<(), rustc_errors[a9e596aa33e6456]::ErrorGuaranteed>, rustc_driver[491383e5761cfd5f]::run_compiler::{closure#1}>::{closure#0}, core[c1e30f1bd259d119]::result::Result<(), rustc_errors[a9e596aa33e6456]::ErrorGuaranteed>>::{closure#0}, core[c1e30f1bd259d119]::result::Result<(), rustc_errors[a9e596aa33e6456]::ErrorGuaranteed>>::{closure#1}::{closure#0}>>
  20:     0x7f59858ac8d0 - <<std[8a3c335779a4ef7b]::thread::Builder>::spawn_unchecked_<rustc_interface[62be15c45d0bd73b]::util::run_in_thread_pool_with_globals<rustc_interface[62be15c45d0bd73b]::interface::run_compiler<core[c1e30f1bd259d119]::result::Result<(), rustc_errors[a9e596aa33e6456]::ErrorGuaranteed>, rustc_driver[491383e5761cfd5f]::run_compiler::{closure#1}>::{closure#0}, core[c1e30f1bd259d119]::result::Result<(), rustc_errors[a9e596aa33e6456]::ErrorGuaranteed>>::{closure#0}, core[c1e30f1bd259d119]::result::Result<(), rustc_errors[a9e596aa33e6456]::ErrorGuaranteed>>::{closure#1} as core[c1e30f1bd259d119]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  21:     0x7f5984ea8665 - std::sys::unix::thread::Thread::new::thread_start::h3a069647ae68a533
  22:     0x7f5984c47b43 - <unknown>
  23:     0x7f5984cd9a00 - <unknown>
  24:                0x0 - <unknown>
note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md


note: rustc 1.65.0-nightly (d6996aabb 2022-09-04) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -C debug-assertions=on -Z unstable-options -C symbol-mangling-version=v0 -Z unstable-options -Z macro-backtrace -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -C split-debuginfo=off -Z unstable-options -C prefer-dynamic -C llvm-args=-import-instr-limit=10 -Z binary-dep-depinfo -Z tls-model=initial-exec -Z force-unstable-if-unmarked
note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack

rust-log-analyzer avatar Sep 04 '22 14:09 rust-log-analyzer

@davidtwco How would I untangle emit_ffi_unsafe_type_lint and FfiResult? Would I only modify emit_ffi_unsafe_type_lint, create separate LintDiagnostic types for each lint, or just leave it?

I think emit_ffi_unsafe_type_lint/FfiResult might be okay as they are - this lint is using translated diagnostics already, it isn't in a type implementing SessionDiagnostic but that's probably okay for this case.

davidtwco avatar Sep 05 '22 12:09 davidtwco

@davidtwco How would I untangle emit_ffi_unsafe_type_lint and FfiResult? Would I only modify emit_ffi_unsafe_type_lint, create separate LintDiagnostic types for each lint, or just leave it?

@davidtwco Same thing for check_panic in non_fmt_panic.rs?

Rejyr avatar Sep 05 '22 18:09 Rejyr

@davidtwco How would I migrate usages of struct_lint and struct_lint_level in levels.rs?

Rejyr avatar Sep 05 '22 20:09 Rejyr

@davidtwco How would I migrate usages of struct_lint and struct_lint_level in levels.rs?

We have emit_spanned_lint and #[derive(LintDiagnostic)] - I think that covers what you need for struct_lint? struct_lint_level might require a new function which does something similar to emit_spanned_lint - probably just changing its decorate argument to be a impl DecorateLint?

@davidtwco Same thing for check_panic in non_fmt_panic.rs?

I think so, yeah.

davidtwco avatar Sep 06 '22 09:09 davidtwco

@davidtwco There's no emit_spanned_lint for LintLevelsBuilder, should I add one? For struct_lint_level, in levels.rs, it only uses LintLevelsBuilder.sess for the Session and LintLevelsBuilder.lint_level(..) or LintLevelsBuilder.provider.get_lint_level(..) for the Level and LintLevelSource, so should I add a method like emit_spanned_lint_level to LintLevelsBuilder?

Rejyr avatar Sep 18 '22 11:09 Rejyr

:umbrella: The latest upstream changes (presumably #101558) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Sep 21 '22 23:09 bors

@davidtwco There's no emit_spanned_lint for LintLevelsBuilder, should I add one? For struct_lint_level, in levels.rs, it only uses LintLevelsBuilder.sess for the Session and LintLevelsBuilder.lint_level(..) or LintLevelsBuilder.provider.get_lint_level(..) for the Level and LintLevelSource, so should I add a method like emit_spanned_lint_level to LintLevelsBuilder?

What diagnostic are you trying to migrate where this is necessary?

davidtwco avatar Sep 22 '22 13:09 davidtwco

@davidtwco There's no emit_spanned_lint for LintLevelsBuilder, should I add one? For struct_lint_level, in levels.rs, it only uses LintLevelsBuilder.sess for the Session and LintLevelsBuilder.lint_level(..) or LintLevelsBuilder.provider.get_lint_level(..) for the Level and LintLevelSource, so should I add a method like emit_spanned_lint_level to LintLevelsBuilder?

What diagnostic are you trying to migrate where this is necessary?

@davidtwco Mostly the diagnostics in levels.rs. All of them are either struct_lint (one instance) or struct_lint_level (6 instances). There's a usage of struct_lint in context.rs at line 1013, but it's in the implementation of LintContext for EarlyContext.

Rejyr avatar Sep 22 '22 22:09 Rejyr

@davidtwco Also, should I make a new PR for refactoring the diagnostic structs in errors.rs since I've gotten more accustomed to migrating them, or can I add them to this PR?

Rejyr avatar Sep 22 '22 23:09 Rejyr

@davidtwco Also, should I make a new PR for refactoring the diagnostic structs in errors.rs since I've gotten more accustomed to migrating them, or can I add them to this PR?

Feel free to include that in this pull request, but you can split it out if you want this to land first so it doesn't need rebasing as often.

davidtwco avatar Sep 23 '22 08:09 davidtwco

@davidtwco Mostly the diagnostics in levels.rs. All of them are either struct_lint (one instance) or struct_lint_level (6 instances). There's a usage of struct_lint in context.rs at line 1013, but it's in the implementation of LintContext for EarlyContext.

I think you should add similar methods as emit_spanned_lint to LintLevelsBuilder, yeah.

davidtwco avatar Sep 23 '22 08:09 davidtwco

:umbrella: The latest upstream changes (presumably #101986) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Oct 01 '22 14:10 bors

The job x86_64-gnu-llvm-13 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Successfully built 855708bd0243
Successfully tagged rust-ci:latest
Built container sha256:855708bd02433eea7797c9d8fcd1f2f899b9aac0df3b9b95121bb05b8432df7e
Uploading finished image to https://ci-caches.rust-lang.org/docker/3ba9d538a45014cf9c069a7f7b39b17975213bb4ad3cb92953bcf42e2feac7246274891423ce6ec10459580375996bc5323b9b2e1eaa3f9fe83d7d3a2f2335cf
upload failed: - to s3://rust-lang-ci-sccache2/docker/3ba9d538a45014cf9c069a7f7b39b17975213bb4ad3cb92953bcf42e2feac7246274891423ce6ec10459580375996bc5323b9b2e1eaa3f9fe83d7d3a2f2335cf Unable to locate credentials
[CI_JOB_NAME=x86_64-gnu-llvm-13]
---
diff of stderr:

2   --> $DIR/lint-tool-test.rs:9:23
3    |
4 LL | #![cfg_attr(foo, warn(test_lint))]
-    |                       ^^^^^^^^^ help: change it to: `clippy::test_lint`
6    |
7    = note: `#[warn(renamed_and_removed_lints)]` on by default
7    = note: `#[warn(renamed_and_removed_lints)]` on by default
+ help: lint name `test_lint` is deprecated and may not have an effect in the future.
+    |
+ LL | #![cfg_attr(foo, warn(clippy::test_lint))]
8 
8 
9 warning: lint name `clippy_group` is deprecated and may not have an effect in the future.

11    |
11    |
12 LL | #![deny(clippy_group)]
-    |         ^^^^^^^^^^^^ help: change it to: `clippy::group`
+    |
+    |
+ help: lint name `clippy_group` is deprecated and may not have an effect in the future.
+    |
+ LL | #![deny(clippy::group)]
14 
14 
15 warning: lint name `test_group` is deprecated and may not have an effect in the future.

17    |
17    |
18 LL | #[allow(test_group)]
-    |         ^^^^^^^^^^ help: change it to: `clippy::test_group`
+    |
+    |
+ help: lint name `test_group` is deprecated and may not have an effect in the future.
+    |
+ LL | #[allow(clippy::test_group)]
20 
21 warning: lint name `test_lint` is deprecated and may not have an effect in the future.
22   --> $DIR/lint-tool-test.rs:9:23


23    |
24 LL | #![cfg_attr(foo, warn(test_lint))]
-    |                       ^^^^^^^^^ help: change it to: `clippy::test_lint`
+    |
+    |
+ help: lint name `test_lint` is deprecated and may not have an effect in the future.
+    |
+ LL | #![cfg_attr(foo, warn(clippy::test_lint))]
26 
26 
27 warning: lint name `clippy_group` is deprecated and may not have an effect in the future.

29    |
29    |
30 LL | #![deny(clippy_group)]
-    |         ^^^^^^^^^^^^ help: change it to: `clippy::group`
+    |
+    |
+ help: lint name `clippy_group` is deprecated and may not have an effect in the future.
+    |
+ LL | #![deny(clippy::group)]
32 
32 
33 warning: lint name `test_group` is deprecated and may not have an effect in the future.

35    |
35    |
36 LL | #[allow(test_group)]
-    |         ^^^^^^^^^^ help: change it to: `clippy::test_group`
+    |
+    |
+ help: lint name `test_group` is deprecated and may not have an effect in the future.
+    |
+ LL | #[allow(clippy::test_group)]
38 
39 warning: unknown lint: `this_lint_does_not_exist`
40   --> $DIR/lint-tool-test.rs:36:8


56   --> $DIR/lint-tool-test.rs:9:23
57    |
58 LL | #![cfg_attr(foo, warn(test_lint))]
-    |                       ^^^^^^^^^ help: change it to: `clippy::test_lint`
+    |
+    |
+ help: lint name `test_lint` is deprecated and may not have an effect in the future.
+    |
+ LL | #![cfg_attr(foo, warn(clippy::test_lint))]
60 
60 
61 warning: lint name `clippy_group` is deprecated and may not have an effect in the future.

63    |
63    |
64 LL | #![deny(clippy_group)]
-    |         ^^^^^^^^^^^^ help: change it to: `clippy::group`
+    |
+    |
+ help: lint name `clippy_group` is deprecated and may not have an effect in the future.
+    |
+ LL | #![deny(clippy::group)]
66 
66 
67 error: item is named 'lintme'

89   --> $DIR/lint-tool-test.rs:31:9
90    |
90    |
91 LL | #[allow(test_group)]
-    |         ^^^^^^^^^^ help: change it to: `clippy::test_group`
+    |
+    |
+ help: lint name `test_group` is deprecated and may not have an effect in the future.
+    |
+ LL | #[allow(clippy::test_group)]
93 
94 warning: lint name `test_lint` is deprecated and may not have an effect in the future.
95   --> $DIR/lint-tool-test.rs:9:23


96    |
97 LL | #![cfg_attr(foo, warn(test_lint))]
-    |                       ^^^^^^^^^ help: change it to: `clippy::test_lint`
+    |
+    |
+ help: lint name `test_lint` is deprecated and may not have an effect in the future.
+    |
+ LL | #![cfg_attr(foo, warn(clippy::test_lint))]
99 
99 
100 warning: lint name `clippy_group` is deprecated and may not have an effect in the future.

102    |
102    |
103 LL | #![deny(clippy_group)]
-    |         ^^^^^^^^^^^^ help: change it to: `clippy::group`
+    |
+    |
+ help: lint name `clippy_group` is deprecated and may not have an effect in the future.
+    |
+ LL | #![deny(clippy::group)]
105 
105 
106 warning: lint name `test_group` is deprecated and may not have an effect in the future.

108    |
108    |
109 LL | #[allow(test_group)]
-    |         ^^^^^^^^^^ help: change it to: `clippy::test_group`
+    |
+    |
+ help: lint name `test_group` is deprecated and may not have an effect in the future.
+    |
+ LL | #[allow(clippy::test_group)]
111 
112 error: aborting due to 2 previous errors; 14 warnings emitted
113 

---
To only update this specific test, also pass `--test-args lint-tool-test.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui-fulldeps/lint-tool-test.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui-fulldeps/lint-tool-test" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--cfg" "foo" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui-fulldeps/lint-tool-test/auxiliary"
stdout: none
--- stderr -------------------------------
warning: lint name `test_lint` is deprecated and may not have an effect in the future.
   |
   |
LL | #![cfg_attr(foo, warn(test_lint))]
   |
   = note: `#[warn(renamed_and_removed_lints)]` on by default
help: lint name `test_lint` is deprecated and may not have an effect in the future.
   |
   |
LL | #![cfg_attr(foo, warn(clippy::test_lint))]


warning: lint name `clippy_group` is deprecated and may not have an effect in the future.
   |
   |
LL | #![deny(clippy_group)]
   |
   |
help: lint name `clippy_group` is deprecated and may not have an effect in the future.
   |
LL | #![deny(clippy::group)]


warning: lint name `test_group` is deprecated and may not have an effect in the future.
   |
   |
LL | #[allow(test_group)]
   |
   |
help: lint name `test_group` is deprecated and may not have an effect in the future.
   |
LL | #[allow(clippy::test_group)]

warning: lint name `test_lint` is deprecated and may not have an effect in the future.
  --> /checkout/src/test/ui-fulldeps/lint-tool-test.rs:9:23
   |
   |
LL | #![cfg_attr(foo, warn(test_lint))]
   |
help: lint name `test_lint` is deprecated and may not have an effect in the future.
   |
   |
LL | #![cfg_attr(foo, warn(clippy::test_lint))]


warning: lint name `clippy_group` is deprecated and may not have an effect in the future.
   |
   |
LL | #![deny(clippy_group)]
   |
   |
help: lint name `clippy_group` is deprecated and may not have an effect in the future.
   |
LL | #![deny(clippy::group)]


warning: lint name `test_group` is deprecated and may not have an effect in the future.
   |
   |
LL | #[allow(test_group)]
   |
   |
help: lint name `test_group` is deprecated and may not have an effect in the future.
   |
LL | #[allow(clippy::test_group)]

warning: unknown lint: `this_lint_does_not_exist`
  --> /checkout/src/test/ui-fulldeps/lint-tool-test.rs:36:8
   |
   |
LL | #[deny(this_lint_does_not_exist)] //~ WARNING unknown lint: `this_lint_does_not_exist`
   |
   = note: `#[warn(unknown_lints)]` on by default


warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
   |
   |
LL | #![plugin(lint_tool_test)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
   = note: `#[warn(deprecated)]` on by default

warning: lint name `test_lint` is deprecated and may not have an effect in the future.
  --> /checkout/src/test/ui-fulldeps/lint-tool-test.rs:9:23
  --> /checkout/src/test/ui-fulldeps/lint-tool-test.rs:9:23
   |
LL | #![cfg_attr(foo, warn(test_lint))]
   |
help: lint name `test_lint` is deprecated and may not have an effect in the future.
   |
   |
LL | #![cfg_attr(foo, warn(clippy::test_lint))]


warning: lint name `clippy_group` is deprecated and may not have an effect in the future.
   |
   |
LL | #![deny(clippy_group)]
   |
   |
help: lint name `clippy_group` is deprecated and may not have an effect in the future.
   |
LL | #![deny(clippy::group)]


error: item is named 'lintme'
   |
   |
LL | fn lintme() { } //~ ERROR item is named 'lintme'
   |
note: the lint level is defined here
  --> /checkout/src/test/ui-fulldeps/lint-tool-test.rs:14:9
   |
   |
LL | #![deny(clippy_group)]
   |         ^^^^^^^^^^^^
   = note: `#[deny(clippy::test_lint)]` implied by `#[deny(clippy::group)]`

error: item is named 'lintmetoo'
   |
   |
LL |     fn lintmetoo() { } //~ ERROR item is named 'lintmetoo'
   |
   |
   = note: `#[deny(clippy::test_group)]` implied by `#[deny(clippy::group)]`

warning: lint name `test_group` is deprecated and may not have an effect in the future.
   |
   |
LL | #[allow(test_group)]
   |
   |
help: lint name `test_group` is deprecated and may not have an effect in the future.
   |
LL | #[allow(clippy::test_group)]

warning: lint name `test_lint` is deprecated and may not have an effect in the future.
  --> /checkout/src/test/ui-fulldeps/lint-tool-test.rs:9:23
   |
   |
LL | #![cfg_attr(foo, warn(test_lint))]
   |
help: lint name `test_lint` is deprecated and may not have an effect in the future.
   |
   |
LL | #![cfg_attr(foo, warn(clippy::test_lint))]


warning: lint name `clippy_group` is deprecated and may not have an effect in the future.
   |
   |
LL | #![deny(clippy_group)]
   |
   |
help: lint name `clippy_group` is deprecated and may not have an effect in the future.
   |
LL | #![deny(clippy::group)]


warning: lint name `test_group` is deprecated and may not have an effect in the future.
   |
   |
LL | #[allow(test_group)]
   |
   |
help: lint name `test_group` is deprecated and may not have an effect in the future.
   |
LL | #[allow(clippy::test_group)]

error: aborting due to 2 previous errors; 14 warnings emitted
------------------------------------------

rust-log-analyzer avatar Oct 05 '22 04:10 rust-log-analyzer

:umbrella: The latest upstream changes (presumably #102975) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Oct 12 '22 21:10 bors

@rustbot label -T-infra -A-bootstrap -A-query-system

Rejyr avatar Oct 15 '22 16:10 Rejyr

:umbrella: The latest upstream changes (presumably #103398) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Oct 22 '22 16:10 bors

@davidtwco Is it fine to leave the other diagnostics in builtin.rs without Diagnostic structs? Also, the rustc::diagnostic_outside_of_impl and rustc::untranslatable_diagnostic don't seem to work since #101986.

Rejyr avatar Oct 23 '22 01:10 Rejyr

@rustbot label -A-query-system

Rejyr avatar Oct 23 '22 02:10 Rejyr

:umbrella: The latest upstream changes (presumably #103426) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Oct 23 '22 09:10 bors

Hi, I've seen you changed some diagnostic structs in your PR. After #103345, the way we refer to fluent messages changed. They are now in a flat namespace with the same identifier as in the fluent file. For example, parser::cool_thing is now parser_cool_thing and parser::suggestion just suggestion. You should rebase to the latest master and change your fluent message references as described above. Thanks!

Noratrieb avatar Oct 23 '22 11:10 Noratrieb

@rustbot label -A-query-system

Rejyr avatar Oct 23 '22 14:10 Rejyr

@rustbot label -A-query-system

Rejyr avatar Oct 23 '22 14:10 Rejyr

:umbrella: The latest upstream changes (presumably #103727) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Oct 29 '22 17:10 bors

@davidtwco Is it fine to leave the other diagnostics in builtin.rs without Diagnostic structs? Also, the rustc::diagnostic_outside_of_impl and rustc::untranslatable_diagnostic don't seem to work since #101986.

Apologies for the delay in responding. Which diagnostics are those? Could you link some? I'm curious about the lints - the tests we have for them still work, maybe just some of the trigger functions had the annotation removed?

davidtwco avatar Nov 02 '22 14:11 davidtwco

I'm curious about the lints - the tests we have for them still work, maybe just some of the trigger functions had the annotation removed?

@davidtwco The tests in diagnostics.rs only cover Diagnostic and the err functions, but not LintDiagnostic and the lint functions.

Right now, diagnostics.rs has

  • Diagnostic
  • Handler::struct_err
  • DiagnosticBuilder::note.

It's missing

  • LintDiagnostic
  • LintContext::{lookup_with_diagnostics,lookup,struct_span_lint,lint}
  • TyCtxt::{struct_span_lint_hir,struct_lint_node}
  • LintLevelsBuilder::struct_lint
  • struct_lint_level.

Essentially, all the functions changed to accept a msg: impl Into<DiagnosticMessage> or msg: DiagnosticMessage.

Since the lint functions were changed to accept a msg, there is no lint.build(msg) in the decorate, so rustc::untranslatable_diagnostic and rustc::diagnostic_outside_of_impl don't activate. Should those functions be linted against?

Rejyr avatar Nov 06 '22 16:11 Rejyr

The tests in diagnostics.rs only cover Diagnostic and the err functions, but not LintDiagnostic and the lint functions.

@Rejyr I think that's mostly okay though - it tests that the mechanism works, if it works for one function it should work for all the others. For internal lints, I don't think we need to be too exhaustive about calling every single function that we trigger the lint for, it would probably be quite difficult to do that. Are you saying that the regular diagnostic functions, annotated with #[rustc_lint_diagnostics] so that the lint should trigger, aren't triggering the lint when they're in a closure being given to struct_span_lint_hir? Or are there just some functions missing a #[rustc_lint_diagnostics] annotation?

davidtwco avatar Nov 07 '22 17:11 davidtwco

Are you saying that the regular diagnostic functions, annotated with #[rustc_lint_diagnostics] so that the lint should trigger, aren't triggering the lint when they're in a closure being given to struct_span_lint_hir? Or are there just some functions missing a #[rustc_lint_diagnostics] annotation?

@davidtwco Some functions are missing the #[rustc_lint_diagnostics] annotations.

  • LintContext::{lookup_with_diagnostics,lookup,struct_span_lint,lint}
  • TyCtxt::struct_lint_node
  • LintLevelsBuilder::struct_lint. I'll make a new PR for adding #[rustc_lint_diagnostics] to them.

Rejyr avatar Nov 07 '22 23:11 Rejyr