From 4c5ee0c8d15c3351741515374d8580f881d2f1b1 Mon Sep 17 00:00:00 2001 From: Samuel Moelius Date: Fri, 20 Oct 2023 16:32:50 +0000 Subject: [PATCH] Account for API changes --- .../await_holding_span_guard/src/lib.rs | 59 ++++++++++--------- .../await_holding_span_guard/ui/main.stderr | 25 ++++---- .../general/crate_wide_allow/ui/main.stderr | 1 + .../general/env_cargo_path/ui/main.stderr | 1 + .../src/lib.rs | 6 +- .../ui/main.stderr | 1 + .../ui_late/interprocedural.stderr | 1 + .../ui_late/set_current_dir.stderr | 1 + .../ui_pre_expansion/main.stderr | 1 + .../wrong_serialize_struct_arg/ui/main.stderr | 1 + .../assert_eq_arg_misordering/ui/main.stderr | 1 + .../collapsible_unwrap/ui/main.stderr | 1 + .../const_path_join/ui/main.stderr | 1 + .../derive_opportunity/ui/main.stderr | 1 + .../ui_at_least_one_field/main.stderr | 1 + .../derive_opportunity/ui_ignore/main.stderr | 1 + .../restriction/env_literal/ui/main.stderr | 1 + .../inconsistent_qualification/ui/main.stderr | 1 + .../misleading_variable_name/ui/main.stderr | 1 + .../missing_doc_comment_openai/src/lib.rs | 10 ++-- .../missing_doc_comment_openai/ui/main.stderr | 1 + .../restriction/overscoped_allow/src/lib.rs | 2 +- .../overscoped_allow/ui_general/main.stderr | 1 + .../overscoped_allow/ui_test/main.stderr | 1 + .../ui/clone.stderr | 1 + .../question_mark_in_expression/ui/ls.stderr | 1 + .../ui/non-empty.stderr | 1 + .../ui/eta.stderr | 1 + .../ui/ref_aware.stderr | 1 + .../suboptimal_pattern/ui/main.stderr | 1 + .../ui_no_explicit_deref_check/main.stderr | 1 + .../restriction/try_io_result/ui/main.stderr | 1 + .../commented_code/ui/main.stderr | 1 + .../redundant_reference/ui/main.stderr | 1 + .../ui_no_lifetime_check/main.stderr | 1 + .../unnamed_constant/ui/main.stderr | 1 + .../unnamed_constant/ui_threshold/main.stderr | 1 + .../unnecessary_borrow_mut/ui/main.stderr | 1 + .../src/check_inherents.rs | 1 + .../src/lib.rs | 4 +- .../ui/general.fixed | 2 +- .../ui/general.rs | 6 +- .../ui/general.stderr | 9 +-- .../ui/unnecessary_to_owned.stderr | 1 + .../ui/vec.stderr | 1 + 45 files changed, 97 insertions(+), 62 deletions(-) diff --git a/examples/general/await_holding_span_guard/src/lib.rs b/examples/general/await_holding_span_guard/src/lib.rs index 9f3458681..40a3e7ae2 100644 --- a/examples/general/await_holding_span_guard/src/lib.rs +++ b/examples/general/await_holding_span_guard/src/lib.rs @@ -3,15 +3,14 @@ extern crate rustc_hir; extern crate rustc_middle; -extern crate rustc_span; -use clippy_utils::diagnostics::span_lint_and_note; +use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::match_def_path; use rustc_hir::def_id::DefId; -use rustc_hir::{AsyncGeneratorKind, Body, BodyId, GeneratorKind}; +use rustc_hir::{AsyncGeneratorKind, Body, GeneratorKind}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_middle::ty::{Adt, GeneratorInteriorTypeCause}; -use rustc_span::Span; +use rustc_middle::mir::GeneratorLayout; +use rustc_middle::ty::Adt; dylint_linting::declare_late_lint! { /// This lint is due to David Barsky (@davidbarsky). @@ -89,38 +88,44 @@ impl LateLintPass<'_> for AwaitHoldingSpanGuard { fn check_body(&mut self, cx: &LateContext<'_>, body: &'_ Body<'_>) { use AsyncGeneratorKind::{Block, Closure, Fn}; if let Some(GeneratorKind::Async(Block | Closure | Fn)) = body.generator_kind { - let body_id = BodyId { - hir_id: body.value.hir_id, - }; - let typeck_results = cx.tcx.typeck_body(body_id); - check_interior_types( - cx, - typeck_results - .generator_interior_types - .as_ref() - .skip_binder(), - body.value.span, - ); + let def_id = cx.tcx.hir().body_owner_def_id(body.id()); + if let Some(generator_layout) = cx.tcx.mir_generator_witnesses(def_id) { + check_interior_types(cx, generator_layout); + } } } } -fn check_interior_types( - cx: &LateContext<'_>, - ty_causes: &[GeneratorInteriorTypeCause<'_>], - span: Span, -) { - for ty_cause in ty_causes { +// smoelius: As part of the upgrade to nightly-2023-10-06, `check_interior_types` was updated based +// on: https://github.com/rust-lang/rust-clippy/commit/0a2d39de2e0b87361432ae695cc84ad74d09972a +fn check_interior_types(cx: &LateContext<'_>, generator: &GeneratorLayout<'_>) { + for (ty_index, ty_cause) in generator.field_tys.iter_enumerated() { if let Adt(adt, _) = ty_cause.ty.kind() { + let await_points = || { + generator + .variant_source_info + .iter_enumerated() + .filter_map(|(variant, source_info)| { + generator.variant_fields[variant] + .raw + .contains(&ty_index) + .then_some(source_info.span) + }) + .collect::>() + }; if is_tracing_span_guard(cx, adt.did()) { - span_lint_and_note( + span_lint_and_then( cx, AWAIT_HOLDING_SPAN_GUARD, - ty_cause.span, + ty_cause.source_info.span, "this Span guard is held across an 'await' point. Consider using the \ `.instrument()` combinator or the `.in_scope()` method instead", - ty_cause.scope_span.or(Some(span)), - "these are all the await points this ref is held through", + |diag| { + diag.span_note( + await_points(), + "these are all the await points this ref is held through", + ); + }, ); } } diff --git a/examples/general/await_holding_span_guard/ui/main.stderr b/examples/general/await_holding_span_guard/ui/main.stderr index f471cadc0..45d9b0f0d 100644 --- a/examples/general/await_holding_span_guard/ui/main.stderr +++ b/examples/general/await_holding_span_guard/ui/main.stderr @@ -5,13 +5,12 @@ LL | let _guard = span.enter(); | ^^^^^^ | note: these are all the await points this ref is held through - --> $DIR/main.rs:20:5 + --> $DIR/main.rs:21:11 | -LL | / let _guard = span.enter(); -LL | | bar().await; -LL | | } - | |_^ +LL | bar().await; + | ^^^^^ = note: `-D await-holding-span-guard` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(await_holding_span_guard)]` error: this Span guard is held across an 'await' point. Consider using the `.instrument()` combinator or the `.in_scope()` method instead --> $DIR/main.rs:27:9 @@ -20,12 +19,10 @@ LL | let _guard = span.entered(); | ^^^^^^ | note: these are all the await points this ref is held through - --> $DIR/main.rs:27:5 + --> $DIR/main.rs:28:11 | -LL | / let _guard = span.entered(); -LL | | bar().await; -LL | | } - | |_^ +LL | bar().await; + | ^^^^^ error: this Span guard is held across an 'await' point. Consider using the `.instrument()` combinator or the `.in_scope()` method instead --> $DIR/main.rs:35:13 @@ -34,12 +31,10 @@ LL | let _guard = span.enter(); | ^^^^^^ | note: these are all the await points this ref is held through - --> $DIR/main.rs:35:9 + --> $DIR/main.rs:36:15 | -LL | / let _guard = span.enter(); -LL | | bar().await -LL | | } - | |_____^ +LL | bar().await + | ^^^^^ error: aborting due to 3 previous errors diff --git a/examples/general/crate_wide_allow/ui/main.stderr b/examples/general/crate_wide_allow/ui/main.stderr index 5919845c4..e70cc8b40 100644 --- a/examples/general/crate_wide_allow/ui/main.stderr +++ b/examples/general/crate_wide_allow/ui/main.stderr @@ -6,6 +6,7 @@ LL | #![allow(clippy::assertions_on_constants)] | = help: pass `--allow clippy::assertions-on-constants` on the command line = note: `-D crate-wide-allow` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(crate_wide_allow)]` error: aborting due to previous error diff --git a/examples/general/env_cargo_path/ui/main.stderr b/examples/general/env_cargo_path/ui/main.stderr index 08d2a88a2..02595aa28 100644 --- a/examples/general/env_cargo_path/ui/main.stderr +++ b/examples/general/env_cargo_path/ui/main.stderr @@ -5,6 +5,7 @@ LL | let _ = env!("CARGO"); | ^^^^^^^^^^^^^ | = note: `-D env-cargo-path` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(env_cargo_path)]` error: this path might not exist in production --> $DIR/main.rs:3:13 diff --git a/examples/general/non_local_effect_before_error_return/src/lib.rs b/examples/general/non_local_effect_before_error_return/src/lib.rs index 57e2c5b50..f40473f6d 100644 --- a/examples/general/non_local_effect_before_error_return/src/lib.rs +++ b/examples/general/non_local_effect_before_error_return/src/lib.rs @@ -17,7 +17,7 @@ use rustc_index::bit_set::BitSet; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::{ mir::{ - pretty::write_mir_fn, BasicBlock, Body, Constant, Local, Location, Mutability, Operand, + pretty::write_mir_fn, BasicBlock, Body, ConstOperand, Local, Location, Mutability, Operand, Place, ProjectionElem, Rvalue, Statement, StatementKind, TerminatorKind, }, ty, @@ -264,7 +264,7 @@ fn collect_locals_and_constants<'tcx>( mir: &'tcx Body<'tcx>, path: &[BasicBlock], args: &[Operand<'tcx>], -) -> (BitSet, Vec<&'tcx Constant<'tcx>>) { +) -> (BitSet, Vec<&'tcx Box>>) { let mut locals_narrowly = BitSet::new_empty(mir.local_decls.len()); let mut locals_widely = BitSet::new_empty(mir.local_decls.len()); let mut constants = Vec::new(); @@ -374,7 +374,7 @@ fn is_mut_ref_arg<'tcx>(mir: &'tcx Body<'tcx>, local: Local) -> bool { (1..=mir.arg_count).contains(&local.into()) && is_mut_ref(mir.local_decls[local].ty) } -fn is_const_ref(constant: &Constant<'_>) -> bool { +fn is_const_ref(constant: &Box>) -> bool { constant.ty().is_ref() } diff --git a/examples/general/non_local_effect_before_error_return/ui/main.stderr b/examples/general/non_local_effect_before_error_return/ui/main.stderr index ce0b3cf6e..ad3d4f057 100644 --- a/examples/general/non_local_effect_before_error_return/ui/main.stderr +++ b/examples/general/non_local_effect_before_error_return/ui/main.stderr @@ -10,6 +10,7 @@ note: error is determined here LL | Err(VarError::NotPresent) | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `-D non-local-effect-before-error-return` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(non_local_effect_before_error_return)]` error: call with mutable reference before error return --> $DIR/main.rs:28:8 diff --git a/examples/general/non_thread_safe_call_in_test/ui_late/interprocedural.stderr b/examples/general/non_thread_safe_call_in_test/ui_late/interprocedural.stderr index 6c91afc73..d97b33ec3 100644 --- a/examples/general/non_thread_safe_call_in_test/ui_late/interprocedural.stderr +++ b/examples/general/non_thread_safe_call_in_test/ui_late/interprocedural.stderr @@ -10,6 +10,7 @@ note: the call is reachable from at least this test LL | fn foo() { | ^^^ = note: `-D non-thread-safe-call-in-test` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(non_thread_safe_call_in_test)]` error: aborting due to previous error diff --git a/examples/general/non_thread_safe_call_in_test/ui_late/set_current_dir.stderr b/examples/general/non_thread_safe_call_in_test/ui_late/set_current_dir.stderr index b1cd8f5f4..b5f92a478 100644 --- a/examples/general/non_thread_safe_call_in_test/ui_late/set_current_dir.stderr +++ b/examples/general/non_thread_safe_call_in_test/ui_late/set_current_dir.stderr @@ -10,6 +10,7 @@ note: the call is reachable from at least this test LL | fn env_set_current_dir() { | ^^^^^^^^^^^^^^^^^^^ = note: `-D non-thread-safe-call-in-test` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(non_thread_safe_call_in_test)]` error: aborting due to previous error diff --git a/examples/general/non_thread_safe_call_in_test/ui_pre_expansion/main.stderr b/examples/general/non_thread_safe_call_in_test/ui_pre_expansion/main.stderr index f7bac8d3a..3343cab56 100644 --- a/examples/general/non_thread_safe_call_in_test/ui_pre_expansion/main.stderr +++ b/examples/general/non_thread_safe_call_in_test/ui_pre_expansion/main.stderr @@ -7,6 +7,7 @@ LL | std::env::set_var("KEY", "VALUE"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D non-thread-safe-call-in-test-pre-expansion` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(non_thread_safe_call_in_test_pre_expansion)]` error: calling `std::env::set_var` in a test could affect the outcome of other tests --> $DIR/main.rs:26:9 diff --git a/examples/general/wrong_serialize_struct_arg/ui/main.stderr b/examples/general/wrong_serialize_struct_arg/ui/main.stderr index e09e4cbea..7e65a47a7 100644 --- a/examples/general/wrong_serialize_struct_arg/ui/main.stderr +++ b/examples/general/wrong_serialize_struct_arg/ui/main.stderr @@ -20,6 +20,7 @@ note: `serialize_field` call 3 of 3 LL | state.serialize_field("b", &self.b)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `-D wrong-serialize-struct-arg` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(wrong_serialize_struct_arg)]` error: `serialize_struct` call's `len` argument is 0, but number of `serialize_field` calls is 1 --> $DIR/main.rs:58:33 diff --git a/examples/restriction/assert_eq_arg_misordering/ui/main.stderr b/examples/restriction/assert_eq_arg_misordering/ui/main.stderr index e447ba157..749e6e549 100644 --- a/examples/restriction/assert_eq_arg_misordering/ui/main.stderr +++ b/examples/restriction/assert_eq_arg_misordering/ui/main.stderr @@ -5,6 +5,7 @@ LL | assert_eq!(x, 0); | ^^^^ help: prefer "expected, actual": `0, x` | = note: `-D assert-eq-arg-misordering` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(assert_eq_arg_misordering)]` error: arguments are "non-const, const", which looks like "actual, expected" --> $DIR/main.rs:14:9 diff --git a/examples/restriction/collapsible_unwrap/ui/main.stderr b/examples/restriction/collapsible_unwrap/ui/main.stderr index f461ef38d..0681f8c89 100644 --- a/examples/restriction/collapsible_unwrap/ui/main.stderr +++ b/examples/restriction/collapsible_unwrap/ui/main.stderr @@ -6,6 +6,7 @@ LL | | .try_exists() | |_____________________^ help: use: `.and_then(|path_buf| path_buf.try_exists())` | = note: `-D collapsible-unwrap` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(collapsible_unwrap)]` error: `unwrap` that could be combined with an `expect` --> $DIR/main.rs:17:9 diff --git a/examples/restriction/const_path_join/ui/main.stderr b/examples/restriction/const_path_join/ui/main.stderr index f00bd9386..382536a14 100644 --- a/examples/restriction/const_path_join/ui/main.stderr +++ b/examples/restriction/const_path_join/ui/main.stderr @@ -5,6 +5,7 @@ LL | let _ = std::path::Path::new("..").join("target"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `std::path::PathBuf::from("../target")` | = note: `-D const-path-join` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(const_path_join)]` error: path could be constructed from a string literal --> $DIR/main.rs:5:13 diff --git a/examples/restriction/derive_opportunity/ui/main.stderr b/examples/restriction/derive_opportunity/ui/main.stderr index d4bacaaa8..a309e0fb1 100644 --- a/examples/restriction/derive_opportunity/ui/main.stderr +++ b/examples/restriction/derive_opportunity/ui/main.stderr @@ -5,6 +5,7 @@ LL | struct Derived; | ^ | = note: `-D derive-opportunity` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(derive_opportunity)]` help: precede with | LL + #[derive(Clone, Copy, Hash)] diff --git a/examples/restriction/derive_opportunity/ui_at_least_one_field/main.stderr b/examples/restriction/derive_opportunity/ui_at_least_one_field/main.stderr index bdc191ad8..024c341bf 100644 --- a/examples/restriction/derive_opportunity/ui_at_least_one_field/main.stderr +++ b/examples/restriction/derive_opportunity/ui_at_least_one_field/main.stderr @@ -5,6 +5,7 @@ LL | struct SimpleStruct { | ^ | = note: `-D derive-opportunity` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(derive_opportunity)]` help: precede with | LL + #[derive(Default, serde_derive::Deserialize)] diff --git a/examples/restriction/derive_opportunity/ui_ignore/main.stderr b/examples/restriction/derive_opportunity/ui_ignore/main.stderr index b185ad9fc..62c26c5dc 100644 --- a/examples/restriction/derive_opportunity/ui_ignore/main.stderr +++ b/examples/restriction/derive_opportunity/ui_ignore/main.stderr @@ -5,6 +5,7 @@ LL | struct Derived; | ^ | = note: `-D derive-opportunity` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(derive_opportunity)]` help: precede with | LL + #[derive(Clone, Copy, Hash)] diff --git a/examples/restriction/env_literal/ui/main.stderr b/examples/restriction/env_literal/ui/main.stderr index 2f903b8a5..7e6eefbc6 100644 --- a/examples/restriction/env_literal/ui/main.stderr +++ b/examples/restriction/env_literal/ui/main.stderr @@ -6,6 +6,7 @@ LL | let _ = std::env::var("RUSTFLAGS"); | = help: define a constant `RUSTFLAGS` and use that instead = note: `-D env-literal` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(env_literal)]` error: referring to an environment variable with a string literal is error prone --> $DIR/main.rs:3:26 diff --git a/examples/restriction/inconsistent_qualification/ui/main.stderr b/examples/restriction/inconsistent_qualification/ui/main.stderr index 1461675cc..f875ff30c 100644 --- a/examples/restriction/inconsistent_qualification/ui/main.stderr +++ b/examples/restriction/inconsistent_qualification/ui/main.stderr @@ -10,6 +10,7 @@ note: items from `std::env` were imported here LL | use std::env::var; | ^^^^^^^^^^^^^^^^^^ = note: `-D inconsistent-qualification` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(inconsistent_qualification)]` error: inconsistent qualification --> $DIR/main.rs:13:24 diff --git a/examples/restriction/misleading_variable_name/ui/main.stderr b/examples/restriction/misleading_variable_name/ui/main.stderr index c34ea0056..12e8d7dcc 100644 --- a/examples/restriction/misleading_variable_name/ui/main.stderr +++ b/examples/restriction/misleading_variable_name/ui/main.stderr @@ -6,6 +6,7 @@ LL | let file = read_to_string(path)?; | = help: use a name that is not `dir_builder`, `dir_entry`, `file`, `file_times`, `file_type`, `metadata`, `open_options`, `permissions`, or `read_dir` = note: `-D misleading-variable-name` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(misleading_variable_name)]` error: `std::fs` exports a type `File`, which is not the type of `file` --> $DIR/main.rs:55:9 diff --git a/examples/restriction/missing_doc_comment_openai/src/lib.rs b/examples/restriction/missing_doc_comment_openai/src/lib.rs index 510dc8b34..c36fb9482 100644 --- a/examples/restriction/missing_doc_comment_openai/src/lib.rs +++ b/examples/restriction/missing_doc_comment_openai/src/lib.rs @@ -1,5 +1,4 @@ #![feature(rustc_private)] -#![feature(io_error_other)] #![feature(let_chains)] #![warn(unused_extern_crates)] @@ -12,7 +11,7 @@ use clippy_utils::{attrs::is_doc_hidden, diagnostics::span_lint_and_then, source use rustc_ast::AttrKind; use rustc_hir::{FnSig, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; -use rustc_span::{BytePos, Span}; +use rustc_span::{BytePos, SourceFileAndLine, Span}; use serde::Deserialize; use std::{ fmt::Write, @@ -370,14 +369,13 @@ fn earliest_attr_span(cx: &LateContext<'_>, item: &Item<'_>) -> Span { fn skip_preceding_line_comments(cx: &LateContext<'_>, mut span: Span) -> Span { while span.lo() >= BytePos(1) { - let source_file_and_line = cx + let SourceFileAndLine { sf, line } = cx .sess() .source_map() .lookup_line(span.lo() - BytePos(1)) .unwrap(); - let lo_prev = source_file_and_line - .sf - .lines(|lines| lines[source_file_and_line.line]); + let lo_prev_relative = sf.lines()[line]; + let lo_prev = sf.absolute_position(lo_prev_relative); let span_prev = span.with_lo(lo_prev); if snippet_opt(cx, span_prev).map_or(false, |snippet| snippet.starts_with("//")) { span = span_prev; diff --git a/examples/restriction/missing_doc_comment_openai/ui/main.stderr b/examples/restriction/missing_doc_comment_openai/ui/main.stderr index 310626952..a33954613 100644 --- a/examples/restriction/missing_doc_comment_openai/ui/main.stderr +++ b/examples/restriction/missing_doc_comment_openai/ui/main.stderr @@ -5,6 +5,7 @@ LL | pub fn foo() {} | ^^^^^^^^^^^^ | = note: `-D missing-doc-comment-openai` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(missing_doc_comment_openai)]` help: use the following suggestion from OpenAI | LL + /// A doc comment generated by OpenAI. diff --git a/examples/restriction/overscoped_allow/src/lib.rs b/examples/restriction/overscoped_allow/src/lib.rs index fff965527..84c795eba 100644 --- a/examples/restriction/overscoped_allow/src/lib.rs +++ b/examples/restriction/overscoped_allow/src/lib.rs @@ -354,7 +354,7 @@ fn include_trailing_semicolons(cx: &LateContext<'_>, mut span: Span) -> Span { let Ok(FileLines { file, .. }) = cx.sess().source_map().span_to_lines(span) else { return span; }; - while span.hi() < file.end_pos { + while span.hi() < file.end_position() { let next = span.with_hi(span.hi() + BytePos(1)); if !snippet_opt(cx, next).map_or(false, |snip| snip.ends_with(';')) { break; diff --git a/examples/restriction/overscoped_allow/ui_general/main.stderr b/examples/restriction/overscoped_allow/ui_general/main.stderr index 3a03bd2e9..a6e2d7cc4 100644 --- a/examples/restriction/overscoped_allow/ui_general/main.stderr +++ b/examples/restriction/overscoped_allow/ui_general/main.stderr @@ -10,6 +10,7 @@ help: `allow` could be moved here LL | pub struct ItemStruct; | ^ = note: `-D overscoped-allow` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(overscoped_allow)]` error: `allow` could be moved closer to diagnostic source --> $DIR/main.rs:10:9 diff --git a/examples/restriction/overscoped_allow/ui_test/main.stderr b/examples/restriction/overscoped_allow/ui_test/main.stderr index 900fa1651..b9c249ebd 100644 --- a/examples/restriction/overscoped_allow/ui_test/main.stderr +++ b/examples/restriction/overscoped_allow/ui_test/main.stderr @@ -12,6 +12,7 @@ LL | #[test] LL | fn panic() { | ^ = note: `-D overscoped-allow` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(overscoped_allow)]` = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/examples/restriction/question_mark_in_expression/ui/clone.stderr b/examples/restriction/question_mark_in_expression/ui/clone.stderr index d959cac26..7a7f0af86 100644 --- a/examples/restriction/question_mark_in_expression/ui/clone.stderr +++ b/examples/restriction/question_mark_in_expression/ui/clone.stderr @@ -6,6 +6,7 @@ LL | let _ = git2::Repository::clone(DYLINT_URL, tempfile::tempdir()?.path() | = help: consider breaking this up into multiple expressions = note: `-D question-mark-in-expression` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(question_mark_in_expression)]` error: aborting due to previous error diff --git a/examples/restriction/question_mark_in_expression/ui/ls.stderr b/examples/restriction/question_mark_in_expression/ui/ls.stderr index a84938305..4c2d8844e 100644 --- a/examples/restriction/question_mark_in_expression/ui/ls.stderr +++ b/examples/restriction/question_mark_in_expression/ui/ls.stderr @@ -6,6 +6,7 @@ LL | Ok(std::path::PathBuf::from(&std::env::var("PWD")?)) | = help: consider breaking this up into multiple expressions = note: `-D question-mark-in-expression` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(question_mark_in_expression)]` error: aborting due to previous error diff --git a/examples/restriction/question_mark_in_expression/ui/non-empty.stderr b/examples/restriction/question_mark_in_expression/ui/non-empty.stderr index 9083ba6a3..e2d30de8d 100644 --- a/examples/restriction/question_mark_in_expression/ui/non-empty.stderr +++ b/examples/restriction/question_mark_in_expression/ui/non-empty.stderr @@ -6,6 +6,7 @@ LL | if !std::fs::read_to_string("Cargo.toml")?.is_empty() { | = help: consider breaking this up into multiple expressions = note: `-D question-mark-in-expression` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(question_mark_in_expression)]` error: aborting due to previous error diff --git a/examples/restriction/ref_aware_redundant_closure_for_method_calls/ui/eta.stderr b/examples/restriction/ref_aware_redundant_closure_for_method_calls/ui/eta.stderr index fb3944ec8..db05d4781 100644 --- a/examples/restriction/ref_aware_redundant_closure_for_method_calls/ui/eta.stderr +++ b/examples/restriction/ref_aware_redundant_closure_for_method_calls/ui/eta.stderr @@ -5,6 +5,7 @@ LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.trait_foo_ref()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `.as_ref().map(TestTrait::trait_foo_ref)` | = note: `-D ref-aware-redundant-closure-for-method-calls` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(ref_aware_redundant_closure_for_method_calls)]` error: aborting due to previous error diff --git a/examples/restriction/ref_aware_redundant_closure_for_method_calls/ui/ref_aware.stderr b/examples/restriction/ref_aware_redundant_closure_for_method_calls/ui/ref_aware.stderr index 77f2055e6..6dbf58cbc 100644 --- a/examples/restriction/ref_aware_redundant_closure_for_method_calls/ui/ref_aware.stderr +++ b/examples/restriction/ref_aware_redundant_closure_for_method_calls/ui/ref_aware.stderr @@ -5,6 +5,7 @@ LL | .and_then(|mut entries| entries.next()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `.as_mut().and_then(std::iter::Iterator::next)` | = note: `-D ref-aware-redundant-closure-for-method-calls` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(ref_aware_redundant_closure_for_method_calls)]` error: redundant closure --> $DIR/ref_aware.rs:32:36 diff --git a/examples/restriction/suboptimal_pattern/ui/main.stderr b/examples/restriction/suboptimal_pattern/ui/main.stderr index 48919a268..efc889446 100644 --- a/examples/restriction/suboptimal_pattern/ui/main.stderr +++ b/examples/restriction/suboptimal_pattern/ui/main.stderr @@ -5,6 +5,7 @@ LL | let _ = ws.iter().map(|w| *w == "").collect::>(); | ^ help: use: `&w` | = note: `-D suboptimal-pattern` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(suboptimal_pattern)]` error: could destructure references --> $DIR/main.rs:28:28 diff --git a/examples/restriction/suboptimal_pattern/ui_no_explicit_deref_check/main.stderr b/examples/restriction/suboptimal_pattern/ui_no_explicit_deref_check/main.stderr index 1c1239fee..c58e782f6 100644 --- a/examples/restriction/suboptimal_pattern/ui_no_explicit_deref_check/main.stderr +++ b/examples/restriction/suboptimal_pattern/ui_no_explicit_deref_check/main.stderr @@ -5,6 +5,7 @@ LL | let _ = ws.iter().map(|w| *w == "").collect::>(); | ^ help: use: `&w` | = note: `-D suboptimal-pattern` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(suboptimal_pattern)]` error: could destructure references --> $DIR/main.rs:28:28 diff --git a/examples/restriction/try_io_result/ui/main.stderr b/examples/restriction/try_io_result/ui/main.stderr index 383c5b457..8fca4e903 100644 --- a/examples/restriction/try_io_result/ui/main.stderr +++ b/examples/restriction/try_io_result/ui/main.stderr @@ -6,6 +6,7 @@ LL | let _ = File::open("/dev/null")?; | = help: return a type that includes relevant context = note: `-D try-io-result` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(try_io_result)]` error: aborting due to previous error diff --git a/examples/supplementary/commented_code/ui/main.stderr b/examples/supplementary/commented_code/ui/main.stderr index 8c9c7c2c5..bcd5ecc3b 100644 --- a/examples/supplementary/commented_code/ui/main.stderr +++ b/examples/supplementary/commented_code/ui/main.stderr @@ -6,6 +6,7 @@ LL | // dbg!(x); | = help: uncomment or remove = note: `-D commented-code` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(commented_code)]` error: commented out code --> $DIR/main.rs:10:5 diff --git a/examples/supplementary/redundant_reference/ui/main.stderr b/examples/supplementary/redundant_reference/ui/main.stderr index 0cd2c05d3..46cd98622 100644 --- a/examples/supplementary/redundant_reference/ui/main.stderr +++ b/examples/supplementary/redundant_reference/ui/main.stderr @@ -11,6 +11,7 @@ LL | self.cx.tcx.hir() | ^^^^^^^ = help: consider storing a copy of `.cx.tcx` to eliminate the need for `'cx` = note: `-D redundant-reference` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(redundant_reference)]` error: aborting due to previous error diff --git a/examples/supplementary/redundant_reference/ui_no_lifetime_check/main.stderr b/examples/supplementary/redundant_reference/ui_no_lifetime_check/main.stderr index 0934862c6..43fe3f7ae 100644 --- a/examples/supplementary/redundant_reference/ui_no_lifetime_check/main.stderr +++ b/examples/supplementary/redundant_reference/ui_no_lifetime_check/main.stderr @@ -11,6 +11,7 @@ LL | self.bar.qux | ^^^^^^^^ = help: consider storing a copy of `.bar.qux` instead = note: `-D redundant-reference` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(redundant_reference)]` error: aborting due to previous error diff --git a/examples/supplementary/unnamed_constant/ui/main.stderr b/examples/supplementary/unnamed_constant/ui/main.stderr index 817aad189..f6f7a09a4 100644 --- a/examples/supplementary/unnamed_constant/ui/main.stderr +++ b/examples/supplementary/unnamed_constant/ui/main.stderr @@ -6,6 +6,7 @@ LL | x *= -1000; | = help: give the constant a name and use that instead = note: `-D unnamed-constant` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(unnamed_constant)]` error: unnamed constant --> $DIR/main.rs:5:10 diff --git a/examples/supplementary/unnamed_constant/ui_threshold/main.stderr b/examples/supplementary/unnamed_constant/ui_threshold/main.stderr index 104efea8a..9886e6b82 100644 --- a/examples/supplementary/unnamed_constant/ui_threshold/main.stderr +++ b/examples/supplementary/unnamed_constant/ui_threshold/main.stderr @@ -6,6 +6,7 @@ LL | x *= -1000; | = help: give the constant a name and use that instead = note: `-D unnamed-constant` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(unnamed_constant)]` error: unnamed constant --> $DIR/main.rs:5:10 diff --git a/examples/supplementary/unnecessary_borrow_mut/ui/main.stderr b/examples/supplementary/unnecessary_borrow_mut/ui/main.stderr index 0276eb47c..b3d5d3abb 100644 --- a/examples/supplementary/unnecessary_borrow_mut/ui/main.stderr +++ b/examples/supplementary/unnecessary_borrow_mut/ui/main.stderr @@ -5,6 +5,7 @@ LL | x = *cell.borrow_mut(); | ^^^^^^^^^^^^ help: use: `borrow()` | = note: `-D unnecessary-borrow-mut` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(unnecessary_borrow_mut)]` error: borrowed reference is used only immutably --> $DIR/main.rs:11:24 diff --git a/examples/supplementary/unnecessary_conversion_for_trait/src/check_inherents.rs b/examples/supplementary/unnecessary_conversion_for_trait/src/check_inherents.rs index bdf8386ef..45d2dbec4 100644 --- a/examples/supplementary/unnecessary_conversion_for_trait/src/check_inherents.rs +++ b/examples/supplementary/unnecessary_conversion_for_trait/src/check_inherents.rs @@ -78,6 +78,7 @@ pub fn check_inherents>(cx: &LateContext<'_>, inherent let def_id = def_path_res(cx, path) .into_iter() .find_map(|res| res.opt_def_id()) + .ok_or_else(|| format!("`def_path_res` failed for {path:?}")) .unwrap(); assert!( diff --git a/examples/supplementary/unnecessary_conversion_for_trait/src/lib.rs b/examples/supplementary/unnecessary_conversion_for_trait/src/lib.rs index cb949f6f7..7badfe0a6 100644 --- a/examples/supplementary/unnecessary_conversion_for_trait/src/lib.rs +++ b/examples/supplementary/unnecessary_conversion_for_trait/src/lib.rs @@ -110,13 +110,13 @@ const WATCHED_INHERENTS: &[&[&str]] = &[ &["core", "slice", "", "iter"], &["core", "slice", "", "iter_mut"], &["core", "str", "", "as_bytes"], - &["std", "ffi", "os_str", "OsStr", "as_os_str_bytes"], + &["std", "ffi", "os_str", "OsStr", "as_encoded_bytes"], &["std", "ffi", "os_str", "OsStr", "into_os_string"], &["std", "ffi", "os_str", "OsStr", "new"], &["std", "ffi", "os_str", "OsStr", "to_os_string"], &["std", "ffi", "os_str", "OsString", "as_os_str"], &["std", "ffi", "os_str", "OsString", "into_boxed_os_str"], - &["std", "ffi", "os_str", "OsString", "into_os_str_bytes"], + &["std", "ffi", "os_str", "OsString", "into_encoded_bytes"], &["std", "path", "Path", "as_os_str"], &["std", "path", "Path", "into_path_buf"], &["std", "path", "Path", "as_mut_os_str"], diff --git a/examples/supplementary/unnecessary_conversion_for_trait/ui/general.fixed b/examples/supplementary/unnecessary_conversion_for_trait/ui/general.fixed index bef9739d9..7604c0cac 100644 --- a/examples/supplementary/unnecessary_conversion_for_trait/ui/general.fixed +++ b/examples/supplementary/unnecessary_conversion_for_trait/ui/general.fixed @@ -1,7 +1,7 @@ // run-rustfix #![allow(unused_imports, unused_parens)] -#![feature(os_str_bytes)] +// #![feature(os_str_bytes)] use std::{ borrow::{Borrow, BorrowMut}, diff --git a/examples/supplementary/unnecessary_conversion_for_trait/ui/general.rs b/examples/supplementary/unnecessary_conversion_for_trait/ui/general.rs index bda5f8da9..701c1d5c2 100644 --- a/examples/supplementary/unnecessary_conversion_for_trait/ui/general.rs +++ b/examples/supplementary/unnecessary_conversion_for_trait/ui/general.rs @@ -1,7 +1,7 @@ // run-rustfix #![allow(unused_imports, unused_parens)] -#![feature(os_str_bytes)] +// #![feature(os_str_bytes)] use std::{ borrow::{Borrow, BorrowMut}, @@ -67,14 +67,14 @@ fn main() { let _ = std::fs::write("x", "".as_bytes()); - let _ = os_str_or_bytes(osstr.as_os_str_bytes()); + let _ = os_str_or_bytes(osstr.as_encoded_bytes()); let _ = is_empty_os(osstring.clone().into_boxed_os_str().into_os_string()); let _ = std::fs::write(OsStr::new("x"), ""); let _ = std::fs::write(osstr.to_os_string(), ""); let _ = std::fs::write(osstring.as_os_str(), ""); let _ = is_empty_os(osstring.clone().into_boxed_os_str()); - let _ = os_string_or_bytes(osstring.clone().into_os_str_bytes()); + let _ = os_string_or_bytes(osstring.clone().into_encoded_bytes()); let _ = std::fs::write(path.as_os_str(), ""); let _ = std::fs::write(PathBuf::from("x").as_mut_os_str(), ""); diff --git a/examples/supplementary/unnecessary_conversion_for_trait/ui/general.stderr b/examples/supplementary/unnecessary_conversion_for_trait/ui/general.stderr index 6b4e64040..76970e100 100644 --- a/examples/supplementary/unnecessary_conversion_for_trait/ui/general.stderr +++ b/examples/supplementary/unnecessary_conversion_for_trait/ui/general.stderr @@ -5,6 +5,7 @@ LL | let _ = std::fs::write("x", "".to_owned()); | ^^^^^^^^^^^ help: remove this | = note: `-D unnecessary-conversion-for-trait` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(unnecessary_conversion_for_trait)]` error: the receiver implements the required traits --> $DIR/general.rs:31:35 @@ -153,8 +154,8 @@ LL | let _ = std::fs::write("x", "".as_bytes()); error: the receiver implements the required traits --> $DIR/general.rs:70:34 | -LL | let _ = os_str_or_bytes(osstr.as_os_str_bytes()); - | ^^^^^^^^^^^^^^^^^^ help: remove this +LL | let _ = os_str_or_bytes(osstr.as_encoded_bytes()); + | ^^^^^^^^^^^^^^^^^^^ help: remove this error: the receiver implements the required traits --> $DIR/general.rs:71:41 @@ -189,8 +190,8 @@ LL | let _ = is_empty_os(osstring.clone().into_boxed_os_str()); error: the receiver implements the required traits --> $DIR/general.rs:77:48 | -LL | let _ = os_string_or_bytes(osstring.clone().into_os_str_bytes()); - | ^^^^^^^^^^^^^^^^^^^^ help: remove this +LL | let _ = os_string_or_bytes(osstring.clone().into_encoded_bytes()); + | ^^^^^^^^^^^^^^^^^^^^^ help: remove this error: the receiver implements the required traits --> $DIR/general.rs:79:32 diff --git a/examples/supplementary/unnecessary_conversion_for_trait/ui/unnecessary_to_owned.stderr b/examples/supplementary/unnecessary_conversion_for_trait/ui/unnecessary_to_owned.stderr index 7d2817c25..5a24feb77 100644 --- a/examples/supplementary/unnecessary_conversion_for_trait/ui/unnecessary_to_owned.stderr +++ b/examples/supplementary/unnecessary_conversion_for_trait/ui/unnecessary_to_owned.stderr @@ -5,6 +5,7 @@ LL | require_deref_c_str(c_str.to_owned()); | ^^^^^^^^^^^ help: remove this | = note: `-D unnecessary-conversion-for-trait` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(unnecessary_conversion_for_trait)]` error: the receiver implements the required traits --> $DIR/unnecessary_to_owned.rs:86:32 diff --git a/examples/supplementary/unnecessary_conversion_for_trait/ui/vec.stderr b/examples/supplementary/unnecessary_conversion_for_trait/ui/vec.stderr index 81733b60b..b0cf8f8ad 100644 --- a/examples/supplementary/unnecessary_conversion_for_trait/ui/vec.stderr +++ b/examples/supplementary/unnecessary_conversion_for_trait/ui/vec.stderr @@ -6,6 +6,7 @@ LL | let _ = std::fs::write("x", vec![0]); | = help: use the macro arguments directly = note: `-D unnecessary-conversion-for-trait` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(unnecessary_conversion_for_trait)]` error: aborting due to previous error