From 5c3fcf2a990f9691c530e0e0761a6c14747cdcf7 Mon Sep 17 00:00:00 2001 From: J-ZhengLi Date: Fri, 1 Dec 2023 15:59:52 +0800 Subject: [PATCH] api adjusting & dogfood tests etc Signed-off-by: J-ZhengLi --- CHANGELOG.md | 3 ++- .../src/guidelines/extern_without_repr.rs | 2 +- .../src/guidelines/fallible_memory_allocation.rs | 12 +++++++++--- clippy_lints/src/guidelines/mod.rs | 6 +++--- .../guidelines/passing_string_to_c_functions.rs | 10 ++++++++-- clippy_lints/src/guidelines/ptr.rs | 11 +++++------ .../src/guidelines/return_stack_address.rs | 7 ++----- .../src/guidelines/unsafe_block_in_proc_macro.rs | 3 ++- clippy_lints/src/lib.rs | 1 - .../guidelines/blocking_op_in_async.stderr | 1 + .../guidelines/dangling_ptr_dereference.stderr | 1 + .../guidelines/fallible_memory_allocation.stderr | 1 + .../guidelines/mem_unsafe_functions.stderr | 1 + .../guidelines/non_reentrant_functions.stderr | 1 + tests/ui-toml/guidelines/ptr_double_free.stderr | 1 + .../guidelines/untrusted_lib_loading.stderr | 1 + .../toml_unknown_key/conf_unknown_key.stderr | 15 +++++++++++---- tests/ui/guidelines/blocking_op_in_async.stderr | 1 + .../ui/guidelines/dangling_ptr_dereference.stderr | 1 + tests/ui/guidelines/extern_without_repr.stderr | 1 + .../guidelines/fallible_memory_allocation.stderr | 1 + tests/ui/guidelines/implicit_abi.stderr | 1 + tests/ui/guidelines/infinite_loop.rs | 4 +--- tests/ui/guidelines/infinite_loop.stderr | 1 + tests/ui/guidelines/mem_unsafe_functions.rs | 6 ++---- tests/ui/guidelines/mem_unsafe_functions.stderr | 1 + .../ui/guidelines/non_reentrant_functions.stderr | 1 + tests/ui/guidelines/null_ptr_dereference.stderr | 1 + .../passing_string_to_c_functions.stderr | 1 + tests/ui/guidelines/ptr_double_free.stderr | 1 + tests/ui/guidelines/return_stack_address.stderr | 1 + .../guidelines/unsafe_block_in_proc_macro.stderr | 1 + tests/ui/guidelines/untrusted_lib_loading.stderr | 1 + tests/ui/rename.rs | 2 ++ 34 files changed, 69 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bb3306855b5..39bdfc4f5158 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5066,6 +5066,7 @@ Released 2018-09-13 [`linkedlist`]: https://rust-lang.github.io/rust-clippy/master/index.html#linkedlist [`little_endian_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#little_endian_bytes [`logic_bug`]: https://rust-lang.github.io/rust-clippy/master/index.html#logic_bug +[`loop_without_break_or_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#loop_without_break_or_return [`lossy_float_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#lossy_float_literal [`macro_use_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#macro_use_imports [`main_recursion`]: https://rust-lang.github.io/rust-clippy/master/index.html#main_recursion @@ -5130,8 +5131,8 @@ Released 2018-09-13 [`mem_replace_option_with_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_option_with_none [`mem_replace_with_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default [`mem_replace_with_uninit`]: https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_uninit -[`min_ident_chars`]: https://rust-lang.github.io/rust-clippy/master/index.html#min_ident_chars [`mem_unsafe_functions`]: https://rust-lang.github.io/rust-clippy/master/index.html#mem_unsafe_functions +[`min_ident_chars`]: https://rust-lang.github.io/rust-clippy/master/index.html#min_ident_chars [`min_max`]: https://rust-lang.github.io/rust-clippy/master/index.html#min_max [`misaligned_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#misaligned_transmute [`mismatched_target_os`]: https://rust-lang.github.io/rust-clippy/master/index.html#mismatched_target_os diff --git a/clippy_lints/src/guidelines/extern_without_repr.rs b/clippy_lints/src/guidelines/extern_without_repr.rs index 0d101e62eb87..03a4f2693ae8 100644 --- a/clippy_lints/src/guidelines/extern_without_repr.rs +++ b/clippy_lints/src/guidelines/extern_without_repr.rs @@ -21,7 +21,7 @@ pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) { abi: Abi::C { .. }, items, } => { - for f_item in items.iter() { + for f_item in *items { if let Some(Node::ForeignItem(f)) = cx.tcx.hir().find(f_item.id.hir_id()) { if let ForeignItemKind::Fn(decl, ..) = f.kind { lint_for_tys(cx, decl.inputs); diff --git a/clippy_lints/src/guidelines/fallible_memory_allocation.rs b/clippy_lints/src/guidelines/fallible_memory_allocation.rs index 6242921d481d..328708de1e70 100644 --- a/clippy_lints/src/guidelines/fallible_memory_allocation.rs +++ b/clippy_lints/src/guidelines/fallible_memory_allocation.rs @@ -3,8 +3,7 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_note}; use clippy_utils::source::snippet_opt; use rustc_hir::def::Res; use rustc_hir::def_id::DefId; -use rustc_hir::intravisit::Visitor; -use rustc_hir::intravisit::{walk_expr, walk_stmt}; +use rustc_hir::intravisit::{walk_expr, walk_stmt, Visitor}; use rustc_hir::{Expr, ExprKind, HirId, Local, Node, Path, PathSegment, QPath, Stmt, StmtKind}; use rustc_lint::LateContext; use rustc_span::symbol::Ident; @@ -84,7 +83,14 @@ pub(super) fn check_expr<'tcx>( let mut ptr_status = PtrStatus::Unverified; let mut maybe_size_param: Option<&Expr<'_>> = None; - if !cx.tcx.fn_sig(func_did).skip_binder().output().is_unsafe_ptr() { + if !cx + .tcx + .fn_sig(func_did) + .skip_binder() + .output() + .skip_binder() + .is_unsafe_ptr() + { ptr_status = PtrStatus::NotPtr; } diff --git a/clippy_lints/src/guidelines/mod.rs b/clippy_lints/src/guidelines/mod.rs index 93183e5b0f08..93e74ff533cc 100644 --- a/clippy_lints/src/guidelines/mod.rs +++ b/clippy_lints/src/guidelines/mod.rs @@ -11,8 +11,8 @@ use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::{def_path_def_ids, fn_def_id}; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; -use rustc_hir::def_id::DefIdSet; -use rustc_hir::hir_id::{HirId, HirIdSet}; +use rustc_hir::def_id::{DefIdSet, LocalDefId}; +use rustc_hir::hir_id::HirIdSet; use rustc_hir::intravisit; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; @@ -418,7 +418,7 @@ impl<'tcx> LateLintPass<'tcx> for LintGroup { _decl: &'tcx hir::FnDecl<'_>, body: &'tcx hir::Body<'_>, span: Span, - _def_id: HirId, + _def_id: LocalDefId, ) { if !matches!(kind, intravisit::FnKind::Closure) { blocking_op_in_async::check_fn(cx, kind, body, span, &self.blocking_fns.ids); diff --git a/clippy_lints/src/guidelines/passing_string_to_c_functions.rs b/clippy_lints/src/guidelines/passing_string_to_c_functions.rs index 8e322b1bab95..723f92902a7d 100644 --- a/clippy_lints/src/guidelines/passing_string_to_c_functions.rs +++ b/clippy_lints/src/guidelines/passing_string_to_c_functions.rs @@ -17,8 +17,14 @@ pub(super) fn check_expr<'tcx>( if cx.tcx.is_foreign_item(fn_did) { for param in params { let str_or_string: Option<&Expr<'_>> = for_each_expr(param, |e| { - let ExprKind::Path(QPath::Resolved(None, Path { res: Res::Local(..), .. })) = e.kind else { - return ControlFlow::Continue(()) + let ExprKind::Path(QPath::Resolved( + None, + Path { + res: Res::Local(..), .. + }, + )) = e.kind + else { + return ControlFlow::Continue(()); }; let ty = cx.typeck_results().node_type(e.hir_id); match ty.kind() { diff --git a/clippy_lints/src/guidelines/ptr.rs b/clippy_lints/src/guidelines/ptr.rs index c7626b5d7c07..1dba6c701559 100644 --- a/clippy_lints/src/guidelines/ptr.rs +++ b/clippy_lints/src/guidelines/ptr.rs @@ -15,10 +15,7 @@ use rustc_span::Span; use if_chain::if_chain; -use super::peel_casts; -use super::DANGLING_PTR_DEREFERENCE; -use super::NULL_PTR_DEREFERENCE; -use super::PTR_DOUBLE_FREE; +use super::{peel_casts, DANGLING_PTR_DEREFERENCE, NULL_PTR_DEREFERENCE, PTR_DOUBLE_FREE}; macro_rules! span_ptr_lint { ($cx:expr, $lint:ident, $span:expr, $note_span:expr) => {{ @@ -69,7 +66,9 @@ pub(super) fn check_call(cx: &LateContext<'_>, call_expr: &Expr<'_>, free_fns: & if !is_lint_allowed(cx, DANGLING_PTR_DEREFERENCE, call_expr.hir_id) || !is_lint_allowed(cx, PTR_DOUBLE_FREE, call_expr.hir_id) { - let Some(mut ptr_validator) = PtrValidator::from_call(cx, call_expr, free_fns) else { return }; + let Some(mut ptr_validator) = PtrValidator::from_call(cx, call_expr, free_fns) else { + return; + }; ptr_validator.visit(cx); @@ -228,7 +227,7 @@ impl<'a, 'tcx> PtrValidator<'a, 'tcx> { /// 3. Constant that can be resolved as null pointer. fn expr_is_creating_null_ptr(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { match expr.kind { - ExprKind::Path(_) if matches!(constant(cx, cx.typeck_results(), expr), Some((Constant::RawPtr(0), _))) => true, + ExprKind::Path(_) if matches!(constant(cx, cx.typeck_results(), expr), Some(Constant::RawPtr(0))) => true, ExprKind::Cast(inner_expr, cast_ty) if is_integer_literal(peel_casts(inner_expr), 0) && matches!(cast_ty.kind, TyKind::Ptr(_)) => { diff --git a/clippy_lints/src/guidelines/return_stack_address.rs b/clippy_lints/src/guidelines/return_stack_address.rs index ba795e0af5d3..e32afce3d244 100644 --- a/clippy_lints/src/guidelines/return_stack_address.rs +++ b/clippy_lints/src/guidelines/return_stack_address.rs @@ -9,8 +9,7 @@ use rustc_lint::LateContext; use rustc_span::symbol::sym; use rustc_span::Span; -use super::peel_casts; -use super::RETURN_STACK_ADDRESS; +use super::{peel_casts, RETURN_STACK_ADDRESS}; pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'tcx>, visited_blocks: &mut HirIdSet) { if visited_blocks.contains(&block.hir_id) { @@ -39,10 +38,8 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'tcx>, visi emit_lint(cx, ret.span, decl_span); } }, - // FIXME: The [`sym::as_mut_ptr`] wasn't available in this toolchain yet, - // change the str comparison to `callee.ident.name == sym::as_mut_ptr` later. ExprKind::MethodCall(methond_name, caller, ..) - if methond_name.ident.name == sym::as_ptr || methond_name.ident.as_str() == "as_mut_ptr" => + if methond_name.ident.name == sym::as_ptr || methond_name.ident.name == sym::as_mut_ptr => { let maybe_path = peel_method_calls(caller); if let Some(decl_span) = get_simple_local_ty_span(cx, maybe_path, &collector.local) { diff --git a/clippy_lints/src/guidelines/unsafe_block_in_proc_macro.rs b/clippy_lints/src/guidelines/unsafe_block_in_proc_macro.rs index 2dc8144f3426..8257a4efe211 100644 --- a/clippy_lints/src/guidelines/unsafe_block_in_proc_macro.rs +++ b/clippy_lints/src/guidelines/unsafe_block_in_proc_macro.rs @@ -5,7 +5,8 @@ use rustc_data_structures::fx::FxHashSet; use rustc_hir::{Expr, Item, ItemKind, OwnerNode}; use rustc_lint::LateContext; use rustc_span::hygiene::{ExpnKind, MacroKind}; -use rustc_span::{sym, symbol::Ident, Span}; +use rustc_span::symbol::Ident; +use rustc_span::{sym, Span}; // FIXME: Currently, this lint does not have a working ui test, // because it needs to be tested with `#[proc_macro]` attribute, diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index c5ba2c61ade7..f9b43e675b2e 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -1121,7 +1121,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: msrv(), )) }); - store.register_late_pass(|_| Box::new(extern_without_repr::ExternWithoutRepr)); let mem_unsafe_fns = conf.mem_unsafe_functions.clone(); let input_fns = conf.input_functions.clone(); let lib_loading_fns = conf.lib_loading_functions.clone(); diff --git a/tests/ui-toml/guidelines/blocking_op_in_async.stderr b/tests/ui-toml/guidelines/blocking_op_in_async.stderr index 8d40a3be5d07..5ee687287137 100644 --- a/tests/ui-toml/guidelines/blocking_op_in_async.stderr +++ b/tests/ui-toml/guidelines/blocking_op_in_async.stderr @@ -10,6 +10,7 @@ note: asyncness was determined here LL | pub async fn async_std_read() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `-D clippy::blocking-op-in-async` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::blocking_op_in_async)]` error: this call might blocks the thread in async context --> $DIR/blocking_op_in_async.rs:17:5 diff --git a/tests/ui-toml/guidelines/dangling_ptr_dereference.stderr b/tests/ui-toml/guidelines/dangling_ptr_dereference.stderr index 7d295dc759b4..d08a43b83d9d 100644 --- a/tests/ui-toml/guidelines/dangling_ptr_dereference.stderr +++ b/tests/ui-toml/guidelines/dangling_ptr_dereference.stderr @@ -10,6 +10,7 @@ note: the pointer was freed here LL | my_free(ptr); | ^^^^^^^^^^^^ = note: `-D clippy::dangling-ptr-dereference` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::dangling_ptr_dereference)]` error: dereferencing a raw pointer that was already freed --> $DIR/dangling_ptr_dereference.rs:14:26 diff --git a/tests/ui-toml/guidelines/fallible_memory_allocation.stderr b/tests/ui-toml/guidelines/fallible_memory_allocation.stderr index 423341e98c92..3f57d6ca237e 100644 --- a/tests/ui-toml/guidelines/fallible_memory_allocation.stderr +++ b/tests/ui-toml/guidelines/fallible_memory_allocation.stderr @@ -10,6 +10,7 @@ note: unverified size used here LL | let p = my_malloc(size); // lint | ^^^^ = note: `-D clippy::fallible-memory-allocation` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::fallible_memory_allocation)]` error: allocating memory without checking if the result pointer is null --> $DIR/fallible_memory_allocation.rs:38:13 diff --git a/tests/ui-toml/guidelines/mem_unsafe_functions.stderr b/tests/ui-toml/guidelines/mem_unsafe_functions.stderr index 9dbbb52ac476..e4e00fbc1d59 100644 --- a/tests/ui-toml/guidelines/mem_unsafe_functions.stderr +++ b/tests/ui-toml/guidelines/mem_unsafe_functions.stderr @@ -6,6 +6,7 @@ LL | not_safe(); | = help: consider using its safe version = note: `-D clippy::mem-unsafe-functions` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mem_unsafe_functions)]` error: use of potentially dangerous memory manipulation function --> $DIR/mem_unsafe_functions.rs:30:9 diff --git a/tests/ui-toml/guidelines/non_reentrant_functions.stderr b/tests/ui-toml/guidelines/non_reentrant_functions.stderr index a8e3e5586875..b1ca9acb6254 100644 --- a/tests/ui-toml/guidelines/non_reentrant_functions.stderr +++ b/tests/ui-toml/guidelines/non_reentrant_functions.stderr @@ -6,6 +6,7 @@ LL | let _ = libc::strtok(null_mut(), null()); // lint | = help: consider using its reentrant counterpart = note: `-D clippy::non-reentrant-functions` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::non_reentrant_functions)]` error: use of non-reentrant function --> $DIR/non_reentrant_functions.rs:33:9 diff --git a/tests/ui-toml/guidelines/ptr_double_free.stderr b/tests/ui-toml/guidelines/ptr_double_free.stderr index c7a3531a5a1e..f8eaa6380160 100644 --- a/tests/ui-toml/guidelines/ptr_double_free.stderr +++ b/tests/ui-toml/guidelines/ptr_double_free.stderr @@ -10,6 +10,7 @@ note: second free occurred here LL | my_free(ptr); // lint | ^^^^^^^^^^^^ = note: `-D clippy::ptr-double-free` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ptr_double_free)]` error: pointer was freed multiple times --> $DIR/ptr_double_free.rs:15:5 diff --git a/tests/ui-toml/guidelines/untrusted_lib_loading.stderr b/tests/ui-toml/guidelines/untrusted_lib_loading.stderr index 62e2236fdf4f..074193245ebb 100644 --- a/tests/ui-toml/guidelines/untrusted_lib_loading.stderr +++ b/tests/ui-toml/guidelines/untrusted_lib_loading.stderr @@ -10,6 +10,7 @@ note: untrusted IO function called here LL | let name_a = untrusted_io(); | ^^^^^^^^^^^^^^ = note: `-D clippy::untrusted-lib-loading` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::untrusted_lib_loading)]` error: loading dynamic library from untrusted source --> $DIR/untrusted_lib_loading.rs:36:18 diff --git a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr index d1f2ab97691d..7b8712687733 100644 --- a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr +++ b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr @@ -3,7 +3,6 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect absolute-paths-max-segments accept-comment-above-attributes accept-comment-above-statement - alloc-size-check-functions allow-dbg-in-tests allow-expect-in-tests allow-io-blocking-ops @@ -48,19 +47,19 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect max-struct-bools max-suggested-slice-pattern-length max-trait-bounds - min-ident-chars-threshold - missing-docs-in-crate-items mem-alloc-functions mem-free-functions mem-unsafe-functions + min-ident-chars-threshold + missing-docs-in-crate-items msrv non-reentrant-functions pass-by-value-size-limit semicolon-inside-block-ignore-singleline semicolon-outside-block-ignore-multiline single-char-binding-names-threshold - stack-size-threshold size-checking-function-keywords + stack-size-threshold standard-macro-braces suppress-restriction-lint-in-const third-party @@ -87,6 +86,7 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect accept-comment-above-statement allow-dbg-in-tests allow-expect-in-tests + allow-io-blocking-ops allow-mixed-uninlined-format-args allow-one-hash-in-raw-strings allow-print-in-tests @@ -118,7 +118,9 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect excessive-nesting-threshold future-size-threshold ignore-interior-mutability + input-functions large-error-threshold + lib-loading-functions literal-representation-threshold matches-for-let-else max-fn-params-bools @@ -126,13 +128,18 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect max-struct-bools max-suggested-slice-pattern-length max-trait-bounds + mem-alloc-functions + mem-free-functions + mem-unsafe-functions min-ident-chars-threshold missing-docs-in-crate-items msrv + non-reentrant-functions pass-by-value-size-limit semicolon-inside-block-ignore-singleline semicolon-outside-block-ignore-multiline single-char-binding-names-threshold + size-checking-function-keywords stack-size-threshold standard-macro-braces suppress-restriction-lint-in-const diff --git a/tests/ui/guidelines/blocking_op_in_async.stderr b/tests/ui/guidelines/blocking_op_in_async.stderr index 4dc2cc938785..351340c99ee4 100644 --- a/tests/ui/guidelines/blocking_op_in_async.stderr +++ b/tests/ui/guidelines/blocking_op_in_async.stderr @@ -10,6 +10,7 @@ note: asyncness was determined here LL | pub async fn async_std_sleep() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `-D clippy::blocking-op-in-async` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::blocking_op_in_async)]` error: this call might blocks the thread in async context --> $DIR/blocking_op_in_async.rs:39:9 diff --git a/tests/ui/guidelines/dangling_ptr_dereference.stderr b/tests/ui/guidelines/dangling_ptr_dereference.stderr index 4b5577d7b67c..2973881ebfce 100644 --- a/tests/ui/guidelines/dangling_ptr_dereference.stderr +++ b/tests/ui/guidelines/dangling_ptr_dereference.stderr @@ -10,6 +10,7 @@ note: the pointer was freed here LL | free(ptr); | ^^^^^^^^^ = note: `-D clippy::dangling-ptr-dereference` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::dangling_ptr_dereference)]` error: dereferencing a raw pointer that was already freed --> $DIR/dangling_ptr_dereference.rs:24:22 diff --git a/tests/ui/guidelines/extern_without_repr.stderr b/tests/ui/guidelines/extern_without_repr.stderr index 93b6db487417..abefa2938e27 100644 --- a/tests/ui/guidelines/extern_without_repr.stderr +++ b/tests/ui/guidelines/extern_without_repr.stderr @@ -10,6 +10,7 @@ note: type declared here LL | struct ReprSimd { | ^^^^^^^^^^^^^^^ = note: `-D clippy::extern-without-repr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::extern_without_repr)]` error: should use `#[repr(..)]` to specifing data layout when type is used in FFI --> $DIR/extern_without_repr.rs:63:45 diff --git a/tests/ui/guidelines/fallible_memory_allocation.stderr b/tests/ui/guidelines/fallible_memory_allocation.stderr index d1fb95776968..09e9496d0f75 100644 --- a/tests/ui/guidelines/fallible_memory_allocation.stderr +++ b/tests/ui/guidelines/fallible_memory_allocation.stderr @@ -10,6 +10,7 @@ note: unverified size used here LL | let p = malloc(size); // lint | ^^^^ = note: `-D clippy::fallible-memory-allocation` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::fallible_memory_allocation)]` error: allocating memory without checking if the result pointer is null --> $DIR/fallible_memory_allocation.rs:26:13 diff --git a/tests/ui/guidelines/implicit_abi.stderr b/tests/ui/guidelines/implicit_abi.stderr index a5aadaa6948a..ebc3e49048d5 100644 --- a/tests/ui/guidelines/implicit_abi.stderr +++ b/tests/ui/guidelines/implicit_abi.stderr @@ -5,6 +5,7 @@ LL | extern { | ^^^^^^ help: explicitly states ABI instead: `extern "C"` | = note: `-D clippy::implicit-abi` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::implicit_abi)]` error: missing ABI label on extern block --> $DIR/implicit_abi.rs:23:1 diff --git a/tests/ui/guidelines/infinite_loop.rs b/tests/ui/guidelines/infinite_loop.rs index 3171e4b77e44..8af748c906a3 100644 --- a/tests/ui/guidelines/infinite_loop.rs +++ b/tests/ui/guidelines/infinite_loop.rs @@ -186,9 +186,7 @@ fn match_pat() { } // don't lint loop { - let Ok(val) = result.map(|v| 10) else { - break - }; // don't lint + let Ok(val) = result.map(|v| 10) else { break }; // don't lint } } diff --git a/tests/ui/guidelines/infinite_loop.stderr b/tests/ui/guidelines/infinite_loop.stderr index 9569611259ad..53d152e72ebe 100644 --- a/tests/ui/guidelines/infinite_loop.stderr +++ b/tests/ui/guidelines/infinite_loop.stderr @@ -8,6 +8,7 @@ LL | | } // lint | = help: consider adding `break` or `return` statement in the loop block = note: `-D clippy::infinite-loop` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::infinite_loop)]` error: loop without break condition --> $DIR/infinite_loop.rs:42:5 diff --git a/tests/ui/guidelines/mem_unsafe_functions.rs b/tests/ui/guidelines/mem_unsafe_functions.rs index ced8c5640cba..cb6cfc8432e1 100644 --- a/tests/ui/guidelines/mem_unsafe_functions.rs +++ b/tests/ui/guidelines/mem_unsafe_functions.rs @@ -1,14 +1,12 @@ #![feature(c_size_t)] #![warn(clippy::mem_unsafe_functions)] -use core::ffi::c_size_t as size_t; -use core::ffi::{c_char, c_int, c_size_t, c_void}; +use core::ffi::{c_char, c_int, c_size_t as size_t, c_size_t, c_void}; use std::ptr::{null, null_mut}; // mock libc crate mod libc { - pub use core::ffi::c_size_t as size_t; - pub use core::ffi::{c_char, c_int, c_void}; + pub use core::ffi::{c_char, c_int, c_size_t as size_t, c_void}; extern "C" { pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; diff --git a/tests/ui/guidelines/mem_unsafe_functions.stderr b/tests/ui/guidelines/mem_unsafe_functions.stderr index 33e3b3124d10..eed6a7c3e0f2 100644 --- a/tests/ui/guidelines/mem_unsafe_functions.stderr +++ b/tests/ui/guidelines/mem_unsafe_functions.stderr @@ -6,6 +6,7 @@ LL | let _ = memcpy(dst, src, n); | = help: consider using its safe version = note: `-D clippy::mem-unsafe-functions` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::mem_unsafe_functions)]` error: use of potentially dangerous memory manipulation function --> $DIR/mem_unsafe_functions.rs:36:13 diff --git a/tests/ui/guidelines/non_reentrant_functions.stderr b/tests/ui/guidelines/non_reentrant_functions.stderr index 8644908fe8eb..34c33d64ff53 100644 --- a/tests/ui/guidelines/non_reentrant_functions.stderr +++ b/tests/ui/guidelines/non_reentrant_functions.stderr @@ -6,6 +6,7 @@ LL | let _ = libc::strtok(string, delim); // lint | = help: consider using its reentrant counterpart = note: `-D clippy::non-reentrant-functions` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::non_reentrant_functions)]` error: use of non-reentrant function --> $DIR/non_reentrant_functions.rs:38:21 diff --git a/tests/ui/guidelines/null_ptr_dereference.stderr b/tests/ui/guidelines/null_ptr_dereference.stderr index 25d91f9e9ebc..0b4b4694005f 100644 --- a/tests/ui/guidelines/null_ptr_dereference.stderr +++ b/tests/ui/guidelines/null_ptr_dereference.stderr @@ -10,6 +10,7 @@ note: first dereference occurred here LL | do_something((*a).inner); | ^^^^ = note: `-D clippy::null-ptr-dereference` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::null_ptr_dereference)]` error: dereferencing null pointer --> $DIR/null_ptr_dereference.rs:29:5 diff --git a/tests/ui/guidelines/passing_string_to_c_functions.stderr b/tests/ui/guidelines/passing_string_to_c_functions.stderr index 1874df178b90..38c00abb92a7 100644 --- a/tests/ui/guidelines/passing_string_to_c_functions.stderr +++ b/tests/ui/guidelines/passing_string_to_c_functions.stderr @@ -10,6 +10,7 @@ help: use `CString` or `CStr` instead LL | greet(name.as_ptr() as *const _); // lint | ^^^^ = note: `-D clippy::passing-string-to-c-functions` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::passing_string_to_c_functions)]` error: passing native strings to external functions --> $DIR/passing_string_to_c_functions.rs:26:9 diff --git a/tests/ui/guidelines/ptr_double_free.stderr b/tests/ui/guidelines/ptr_double_free.stderr index 63faa76d0461..2345b79c3d1d 100644 --- a/tests/ui/guidelines/ptr_double_free.stderr +++ b/tests/ui/guidelines/ptr_double_free.stderr @@ -10,6 +10,7 @@ note: second free occurred here LL | free(ptr); // lint | ^^^^^^^^^ = note: `-D clippy::ptr-double-free` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::ptr_double_free)]` error: pointer was freed multiple times --> $DIR/ptr_double_free.rs:32:5 diff --git a/tests/ui/guidelines/return_stack_address.stderr b/tests/ui/guidelines/return_stack_address.stderr index 24e8bfb0a834..e596e4424aef 100644 --- a/tests/ui/guidelines/return_stack_address.stderr +++ b/tests/ui/guidelines/return_stack_address.stderr @@ -10,6 +10,7 @@ note: local variable declared/assigned here LL | let val: i32 = 100; | ^^^^^^^^^^^^^^^^^^^ = note: `-D clippy::return-stack-address` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::return_stack_address)]` error: returning a pointer to stack address --> $DIR/return_stack_address.rs:43:9 diff --git a/tests/ui/guidelines/unsafe_block_in_proc_macro.stderr b/tests/ui/guidelines/unsafe_block_in_proc_macro.stderr index 072b521d2196..2a6eaddb87a1 100644 --- a/tests/ui/guidelines/unsafe_block_in_proc_macro.stderr +++ b/tests/ui/guidelines/unsafe_block_in_proc_macro.stderr @@ -11,6 +11,7 @@ LL | | }) = help: consider removing unsafe block from the above `quote!` call, and add unsafe block when calling the macro instead: `unsafe { unsafe_print_foo!{...} }` = note: `-D clippy::unsafe-block-in-proc-macro` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unsafe_block_in_proc_macro)]` error: function-like procedural macro `unsafe_print_bar_unformatted` could masking unsafe operations --> $DIR/unsafe_block_in_proc_macro.rs:27:5 diff --git a/tests/ui/guidelines/untrusted_lib_loading.stderr b/tests/ui/guidelines/untrusted_lib_loading.stderr index 17f98ee8fcc3..c6e94eeadbe8 100644 --- a/tests/ui/guidelines/untrusted_lib_loading.stderr +++ b/tests/ui/guidelines/untrusted_lib_loading.stderr @@ -10,6 +10,7 @@ note: untrusted IO function called here LL | f.read_to_string(&mut name_a).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `-D clippy::untrusted-lib-loading` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::untrusted_lib_loading)]` error: loading dynamic library from untrusted source --> $DIR/untrusted_lib_loading.rs:28:18 diff --git a/tests/ui/rename.rs b/tests/ui/rename.rs index 940e60068e7b..7493bc0055d3 100644 --- a/tests/ui/rename.rs +++ b/tests/ui/rename.rs @@ -51,6 +51,7 @@ #![allow(undropped_manually_drops)] #![allow(unknown_lints)] #![allow(unused_labels)] +#![allow(clippy::infinite_loop)] #![warn(clippy::almost_complete_letter_range)] #![warn(clippy::blacklisted_name)] #![warn(clippy::block_in_if_condition_expr)] @@ -107,5 +108,6 @@ #![warn(clippy::undropped_manually_drops)] #![warn(clippy::unknown_clippy_lints)] #![warn(clippy::unused_label)] +#![warn(clippy::loop_without_break_or_return)] fn main() {}