diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b58e25c6110..aac89ab91b60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4620,6 +4620,7 @@ Released 2018-09-13 +[`absolute_symbol_paths`]: https://rust-lang.github.io/rust-clippy/master/index.html#absolute_symbol_paths [`absurd_extreme_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons [`alloc_instead_of_core`]: https://rust-lang.github.io/rust-clippy/master/index.html#alloc_instead_of_core [`allow_attributes`]: https://rust-lang.github.io/rust-clippy/master/index.html#allow_attributes diff --git a/clippy_dev/src/lib.rs b/clippy_dev/src/lib.rs index 8aaa029f7760..041a99634859 100644 --- a/clippy_dev/src/lib.rs +++ b/clippy_dev/src/lib.rs @@ -52,7 +52,7 @@ pub fn clippy_project_root() -> PathBuf { for path in current_dir.ancestors() { let result = std::fs::read_to_string(path.join("Cargo.toml")); if let Err(err) = &result { - if err.kind() == std::io::ErrorKind::NotFound { + if err.kind() == io::ErrorKind::NotFound { continue; } } diff --git a/clippy_lints/src/absolute_symbol_paths.rs b/clippy_lints/src/absolute_symbol_paths.rs new file mode 100644 index 000000000000..7c1238870079 --- /dev/null +++ b/clippy_lints/src/absolute_symbol_paths.rs @@ -0,0 +1,88 @@ +use clippy_utils::diagnostics::span_lint; +use clippy_utils::is_from_proc_macro; +use rustc_hir::intravisit::{walk_qpath, Visitor}; +use rustc_hir::{HirId, QPath}; +use rustc_lint::{LateContext, LateLintPass}; +use rustc_middle::hir::nested_filter::OnlyBodies; +use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_span::Span; + +declare_clippy_lint! { + /// ### What it does + /// Checks for usage of symbols through absolute paths, like `std::env::current_dir`. + /// + /// ### Why is this bad? + /// Many codebases have their own style when it comes to symbol importing, but one that is + /// seldom used is using absolute paths *everywhere*. This is generally considered unidiomatic, + /// and you should add a `use` statement. + /// + /// Note: One exception to this is code from macro expansion - this does not lint such cases, as + /// using absolute paths is the proper way of referencing symbols in one. + /// + /// ### Example + /// ```rust + /// let x = std::f64::consts::PI; + /// ``` + /// Use any of the below instead, or anything else: + /// ```rust + /// # use std::f64; + /// # use std::f64::consts; + /// # use std::f64::consts::PI; + /// let x = f64::consts::PI; + /// let x = consts::PI; + /// let x = PI; + /// use std::f64::consts as f64_consts; + /// let x = f64_consts::PI; + /// ``` + #[clippy::version = "1.72.0"] + pub ABSOLUTE_SYMBOL_PATHS, + style, + "checks for usage of a symbol without a `use` statement" +} +declare_lint_pass!(AbsoluteSymbolPaths => [ABSOLUTE_SYMBOL_PATHS]); + +impl LateLintPass<'_> for AbsoluteSymbolPaths { + fn check_crate(&mut self, cx: &LateContext<'_>) { + cx.tcx.hir().visit_all_item_likes_in_crate(&mut V { cx }); + } +} + +struct V<'a, 'tcx> { + cx: &'a LateContext<'tcx>, +} + +impl<'a, 'tcx> Visitor<'tcx> for V<'a, 'tcx> { + type NestedFilter = OnlyBodies; + + fn nested_visit_map(&mut self) -> Self::Map { + self.cx.tcx.hir() + } + + fn visit_qpath(&mut self, qpath: &'tcx QPath<'tcx>, hir_id: HirId, span: Span) { + let Self { cx } = *self; + + if !span.from_expansion() + && let QPath::Resolved(_, path) = qpath + && let Some(def_id) = path.res.opt_def_id() + { + let def_path = cx.tcx.def_path_str(def_id); + let segments = def_path.split("::"); + + // FIXME: I only allowed 3 segment paths because there's tons of them in clippy :D + // To my humble reviewer: thoughts? + if path.segments.len() >= 4 // A 2 segment path seems okay, like `std::println!` + && segments.eq(path.segments.iter().map(|segment| segment.ident.name.as_str())) + && !is_from_proc_macro(cx, qpath) + { + span_lint( + cx, + ABSOLUTE_SYMBOL_PATHS, + span, + "consider referring to this symbol by adding a `use` statement for consistent formatting", + ); + } + } + + walk_qpath(self, qpath, hir_id); + } +} diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs index 9c1e1f6702df..8ea05a4b777b 100644 --- a/clippy_lints/src/declared_lints.rs +++ b/clippy_lints/src/declared_lints.rs @@ -37,6 +37,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::utils::internal_lints::produce_ice::PRODUCE_ICE_INFO, #[cfg(feature = "internal")] crate::utils::internal_lints::unnecessary_def_path::UNNECESSARY_DEF_PATH_INFO, + crate::absolute_symbol_paths::ABSOLUTE_SYMBOL_PATHS_INFO, crate::allow_attributes::ALLOW_ATTRIBUTES_INFO, crate::almost_complete_range::ALMOST_COMPLETE_RANGE_INFO, crate::approx_const::APPROX_CONSTANT_INFO, diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 3fb4e6c8fa51..e7fed16d2b90 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -10,7 +10,11 @@ #![feature(stmt_expr_attributes)] #![recursion_limit = "512"] #![cfg_attr(feature = "deny-warnings", deny(warnings))] -#![allow(clippy::missing_docs_in_private_items, clippy::must_use_candidate)] +#![allow( + clippy::absolute_symbol_paths, + clippy::missing_docs_in_private_items, + clippy::must_use_candidate +)] #![warn(trivial_casts, trivial_numeric_casts)] // warn on lints, that are included in `rust-lang/rust`s bootstrap #![warn(rust_2018_idioms, unused_lifetimes)] @@ -65,6 +69,7 @@ mod declared_lints; mod renamed_lints; // begin lints modules, do not remove this comment, it’s used in `update_lints` +mod absolute_symbol_paths; mod allow_attributes; mod almost_complete_range; mod approx_const; @@ -1063,6 +1068,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: def_id_to_usage: rustc_data_structures::fx::FxHashMap::default(), }) }); + store.register_late_pass(|_| Box::new(absolute_symbol_paths::AbsoluteSymbolPaths)); // add lints here, do not remove this comment, it's used in `new_lint` } diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 852f6736585b..0004a150d51b 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -15,6 +15,7 @@ use rustc_hir::{ PredicateOrigin, TraitFn, TraitItem, TraitItemKind, Ty, TyKind, WherePredicate, }; use rustc_lint::{LateContext, LateLintPass, LintContext}; +use rustc_middle::hir::map::Map; use rustc_middle::hir::nested_filter as middle_nested_filter; use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; @@ -620,7 +621,7 @@ impl<'cx, 'tcx, F> Visitor<'tcx> for LifetimeChecker<'cx, 'tcx, F> where F: NestedFilter<'tcx>, { - type Map = rustc_middle::hir::map::Map<'tcx>; + type Map = Map<'tcx>; type NestedFilter = F; // for lifetimes as parameters of generics diff --git a/clippy_lints/src/redundant_static_lifetimes.rs b/clippy_lints/src/redundant_static_lifetimes.rs index 038dfe8e4803..ed42a422b4b5 100644 --- a/clippy_lints/src/redundant_static_lifetimes.rs +++ b/clippy_lints/src/redundant_static_lifetimes.rs @@ -5,6 +5,7 @@ use rustc_ast::ast::{ConstItem, Item, ItemKind, StaticItem, Ty, TyKind}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_span::symbol::kw; declare_clippy_lint! { /// ### What it does @@ -64,7 +65,7 @@ impl RedundantStaticLifetimes { if let Some(lifetime) = *optional_lifetime { match borrow_type.ty.kind { TyKind::Path(..) | TyKind::Slice(..) | TyKind::Array(..) | TyKind::Tup(..) => { - if lifetime.ident.name == rustc_span::symbol::kw::StaticLifetime { + if lifetime.ident.name == kw::StaticLifetime { let snip = snippet(cx, borrow_type.ty.span, ""); let sugg = format!("&{}{snip}", borrow_type.mutbl.prefix_str()); span_lint_and_then( diff --git a/clippy_utils/src/check_proc_macro.rs b/clippy_utils/src/check_proc_macro.rs index c6d0b654f57b..4eedf75d9769 100644 --- a/clippy_utils/src/check_proc_macro.rs +++ b/clippy_utils/src/check_proc_macro.rs @@ -304,7 +304,7 @@ fn attr_search_pat(attr: &Attribute) -> (Pat, Pat) { }, AttrKind::DocComment(_kind @ CommentKind::Line, ..) => { if matches!(attr.style, AttrStyle::Outer) { - (Pat::Str("///"), Pat::Str("")) + (Pat::Str("///*"), Pat::Str("")) } else { (Pat::Str("//!"), Pat::Str("")) } @@ -354,7 +354,7 @@ pub trait WithSearchPat<'cx> { fn span(&self) -> Span; } macro_rules! impl_with_search_pat { - ($cx:ident: $ty:ident with $fn:ident $(($tcx:ident))?) => { + ($cx:ident: $ty:ident with $fn:ident $(($tcx:ident))? && $span_method:ident$($par:tt)?) => { impl<'cx> WithSearchPat<'cx> for $ty<'cx> { type Context = $cx<'cx>; #[allow(unused_variables)] @@ -363,18 +363,19 @@ macro_rules! impl_with_search_pat { $fn($($tcx,)? self) } fn span(&self) -> Span { - self.span + self.$span_method$($par)? } } }; } -impl_with_search_pat!(LateContext: Expr with expr_search_pat(tcx)); -impl_with_search_pat!(LateContext: Item with item_search_pat); -impl_with_search_pat!(LateContext: TraitItem with trait_item_search_pat); -impl_with_search_pat!(LateContext: ImplItem with impl_item_search_pat); -impl_with_search_pat!(LateContext: FieldDef with field_def_search_pat); -impl_with_search_pat!(LateContext: Variant with variant_search_pat); -impl_with_search_pat!(LateContext: Ty with ty_search_pat); +impl_with_search_pat!(LateContext: Expr with expr_search_pat(tcx) && span); +impl_with_search_pat!(LateContext: Item with item_search_pat && span); +impl_with_search_pat!(LateContext: TraitItem with trait_item_search_pat && span); +impl_with_search_pat!(LateContext: ImplItem with impl_item_search_pat && span); +impl_with_search_pat!(LateContext: FieldDef with field_def_search_pat && span); +impl_with_search_pat!(LateContext: Variant with variant_search_pat && span); +impl_with_search_pat!(LateContext: Ty with ty_search_pat && span); +impl_with_search_pat!(LateContext: QPath with qpath_search_pat && span()); impl<'cx> WithSearchPat<'cx> for (&FnKind<'cx>, &Body<'cx>, HirId, Span) { type Context = LateContext<'cx>; diff --git a/clippy_utils/src/mir/possible_origin.rs b/clippy_utils/src/mir/possible_origin.rs index 8e7513d740ab..da04266863f9 100644 --- a/clippy_utils/src/mir/possible_origin.rs +++ b/clippy_utils/src/mir/possible_origin.rs @@ -44,7 +44,7 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleOriginVisitor<'a, 'tcx> { let lhs = place.local; match rvalue { // Only consider `&mut`, which can modify origin place - mir::Rvalue::Ref(_, rustc_middle::mir::BorrowKind::Mut { .. }, borrowed) | + mir::Rvalue::Ref(_, mir::BorrowKind::Mut { .. }, borrowed) | // _2: &mut _; // _3 = move _2 mir::Rvalue::Use(mir::Operand::Move(borrowed)) | diff --git a/tests/ui-cargo/module_style/fail_mod/src/main.rs b/tests/ui-cargo/module_style/fail_mod/src/main.rs index 3e985d4e904c..0f92bb50a913 100644 --- a/tests/ui-cargo/module_style/fail_mod/src/main.rs +++ b/tests/ui-cargo/module_style/fail_mod/src/main.rs @@ -1,3 +1,4 @@ +#![allow(clippy::absolute_symbol_paths)] #![warn(clippy::self_named_module_files)] mod bad; diff --git a/tests/ui-internal/interning_defined_symbol.fixed b/tests/ui-internal/interning_defined_symbol.fixed index a1a10c0798e3..af3f1fa16711 100644 --- a/tests/ui-internal/interning_defined_symbol.fixed +++ b/tests/ui-internal/interning_defined_symbol.fixed @@ -1,6 +1,10 @@ //@run-rustfix #![deny(clippy::internal)] -#![allow(clippy::missing_clippy_version_attribute, clippy::let_unit_value)] +#![allow( + clippy::absolute_symbol_paths, + clippy::missing_clippy_version_attribute, + clippy::let_unit_value +)] #![feature(rustc_private)] extern crate rustc_span; diff --git a/tests/ui-internal/interning_defined_symbol.rs b/tests/ui-internal/interning_defined_symbol.rs index 32dbfe5dcac2..1ea908f423d0 100644 --- a/tests/ui-internal/interning_defined_symbol.rs +++ b/tests/ui-internal/interning_defined_symbol.rs @@ -1,6 +1,10 @@ //@run-rustfix #![deny(clippy::internal)] -#![allow(clippy::missing_clippy_version_attribute, clippy::let_unit_value)] +#![allow( + clippy::absolute_symbol_paths, + clippy::missing_clippy_version_attribute, + clippy::let_unit_value +)] #![feature(rustc_private)] extern crate rustc_span; diff --git a/tests/ui-internal/interning_defined_symbol.stderr b/tests/ui-internal/interning_defined_symbol.stderr index 4e99636e6839..663f6de85532 100644 --- a/tests/ui-internal/interning_defined_symbol.stderr +++ b/tests/ui-internal/interning_defined_symbol.stderr @@ -1,5 +1,5 @@ error: interning a defined symbol - --> $DIR/interning_defined_symbol.rs:18:13 + --> $DIR/interning_defined_symbol.rs:22:13 | LL | let _ = Symbol::intern("f32"); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::f32` @@ -12,19 +12,19 @@ LL | #![deny(clippy::internal)] = note: `#[deny(clippy::interning_defined_symbol)]` implied by `#[deny(clippy::internal)]` error: interning a defined symbol - --> $DIR/interning_defined_symbol.rs:21:13 + --> $DIR/interning_defined_symbol.rs:25:13 | LL | let _ = sym!(f32); | ^^^^^^^^^ help: try: `rustc_span::sym::f32` error: interning a defined symbol - --> $DIR/interning_defined_symbol.rs:24:13 + --> $DIR/interning_defined_symbol.rs:28:13 | LL | let _ = Symbol::intern("proc-macro"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::proc_dash_macro` error: interning a defined symbol - --> $DIR/interning_defined_symbol.rs:27:13 + --> $DIR/interning_defined_symbol.rs:31:13 | LL | let _ = Symbol::intern("self"); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::symbol::kw::SelfLower` diff --git a/tests/ui-internal/unnecessary_def_path.fixed b/tests/ui-internal/unnecessary_def_path.fixed index fce24412f843..25653a6e82dc 100644 --- a/tests/ui-internal/unnecessary_def_path.fixed +++ b/tests/ui-internal/unnecessary_def_path.fixed @@ -1,5 +1,6 @@ //@run-rustfix //@aux-build:paths.rs +#![allow(clippy::absolute_symbol_paths)] #![deny(clippy::internal)] #![feature(rustc_private)] diff --git a/tests/ui-internal/unnecessary_def_path.rs b/tests/ui-internal/unnecessary_def_path.rs index b10bc9e46e2d..3607b9b61478 100644 --- a/tests/ui-internal/unnecessary_def_path.rs +++ b/tests/ui-internal/unnecessary_def_path.rs @@ -1,5 +1,6 @@ //@run-rustfix //@aux-build:paths.rs +#![allow(clippy::absolute_symbol_paths)] #![deny(clippy::internal)] #![feature(rustc_private)] diff --git a/tests/ui-internal/unnecessary_def_path.stderr b/tests/ui-internal/unnecessary_def_path.stderr index 3ca29f099771..697fe0c7b568 100644 --- a/tests/ui-internal/unnecessary_def_path.stderr +++ b/tests/ui-internal/unnecessary_def_path.stderr @@ -1,72 +1,72 @@ error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:37:13 + --> $DIR/unnecessary_def_path.rs:38:13 | LL | let _ = match_type(cx, ty, &OPTION); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Option)` | note: the lint level is defined here - --> $DIR/unnecessary_def_path.rs:3:9 + --> $DIR/unnecessary_def_path.rs:4:9 | LL | #![deny(clippy::internal)] | ^^^^^^^^^^^^^^^^ = note: `#[deny(clippy::unnecessary_def_path)]` implied by `#[deny(clippy::internal)]` error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:38:13 + --> $DIR/unnecessary_def_path.rs:39:13 | LL | let _ = match_type(cx, ty, RESULT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)` error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:39:13 + --> $DIR/unnecessary_def_path.rs:40:13 | LL | let _ = match_type(cx, ty, &["core", "result", "Result"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)` error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:43:13 + --> $DIR/unnecessary_def_path.rs:44:13 | LL | let _ = clippy_utils::ty::match_type(cx, ty, rc_path); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Rc)` error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:45:13 + --> $DIR/unnecessary_def_path.rs:46:13 | LL | let _ = match_type(cx, ty, &paths::OPTION); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Option)` error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:46:13 + --> $DIR/unnecessary_def_path.rs:47:13 | LL | let _ = match_type(cx, ty, paths::RESULT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)` error: use of a def path to a `LangItem` - --> $DIR/unnecessary_def_path.rs:48:13 + --> $DIR/unnecessary_def_path.rs:49:13 | LL | let _ = match_type(cx, ty, &["alloc", "boxed", "Box"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_lang_item(cx, ty, LangItem::OwnedBox)` error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:49:13 + --> $DIR/unnecessary_def_path.rs:50:13 | LL | let _ = match_type(cx, ty, &["core", "mem", "maybe_uninit", "MaybeUninit", "uninit"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::maybe_uninit_uninit)` error: use of a def path to a `LangItem` - --> $DIR/unnecessary_def_path.rs:51:13 + --> $DIR/unnecessary_def_path.rs:52:13 | LL | let _ = match_def_path(cx, did, &["alloc", "boxed", "Box"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.lang_items().get(LangItem::OwnedBox) == Some(did)` error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:52:13 + --> $DIR/unnecessary_def_path.rs:53:13 | LL | let _ = match_def_path(cx, did, &["core", "option", "Option"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.is_diagnostic_item(sym::Option, did)` error: use of a def path to a `LangItem` - --> $DIR/unnecessary_def_path.rs:53:13 + --> $DIR/unnecessary_def_path.rs:54:13 | LL | let _ = match_def_path(cx, did, &["core", "option", "Option", "Some"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.lang_items().get(LangItem::OptionSome) == Some(did)` @@ -74,25 +74,25 @@ LL | let _ = match_def_path(cx, did, &["core", "option", "Option", "Some"]); = help: if this `DefId` came from a constructor expression or pattern then the parent `DefId` should be used instead error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:55:13 + --> $DIR/unnecessary_def_path.rs:56:13 | LL | let _ = match_trait_method(cx, expr, &["core", "convert", "AsRef"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_trait_method(cx, expr, sym::AsRef)` error: use of a def path to a diagnostic item - --> $DIR/unnecessary_def_path.rs:57:13 + --> $DIR/unnecessary_def_path.rs:58:13 | LL | let _ = is_expr_path_def_path(cx, expr, &["core", "option", "Option"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_path_diagnostic_item(cx, expr, sym::Option)` error: use of a def path to a `LangItem` - --> $DIR/unnecessary_def_path.rs:58:13 + --> $DIR/unnecessary_def_path.rs:59:13 | LL | let _ = is_expr_path_def_path(cx, expr, &["core", "iter", "traits", "Iterator", "next"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `path_res(cx, expr).opt_def_id().map_or(false, |id| cx.tcx.lang_items().get(LangItem::IteratorNext) == Some(id))` error: use of a def path to a `LangItem` - --> $DIR/unnecessary_def_path.rs:59:13 + --> $DIR/unnecessary_def_path.rs:60:13 | LL | let _ = is_expr_path_def_path(cx, expr, &["core", "option", "Option", "Some"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_res_lang_ctor(cx, path_res(cx, expr), LangItem::OptionSome)` diff --git a/tests/ui-internal/unnecessary_symbol_str.fixed b/tests/ui-internal/unnecessary_symbol_str.fixed index b802de1cbc65..989b50525d01 100644 --- a/tests/ui-internal/unnecessary_symbol_str.fixed +++ b/tests/ui-internal/unnecessary_symbol_str.fixed @@ -2,6 +2,7 @@ #![feature(rustc_private)] #![deny(clippy::internal)] #![allow( + clippy::absolute_symbol_paths, clippy::borrow_deref_ref, clippy::unnecessary_operation, unused_must_use, diff --git a/tests/ui-internal/unnecessary_symbol_str.rs b/tests/ui-internal/unnecessary_symbol_str.rs index c1bead5bdc98..f9af20c9b51d 100644 --- a/tests/ui-internal/unnecessary_symbol_str.rs +++ b/tests/ui-internal/unnecessary_symbol_str.rs @@ -2,6 +2,7 @@ #![feature(rustc_private)] #![deny(clippy::internal)] #![allow( + clippy::absolute_symbol_paths, clippy::borrow_deref_ref, clippy::unnecessary_operation, unused_must_use, diff --git a/tests/ui-internal/unnecessary_symbol_str.stderr b/tests/ui-internal/unnecessary_symbol_str.stderr index a1f507f331d2..4a3559c78aa8 100644 --- a/tests/ui-internal/unnecessary_symbol_str.stderr +++ b/tests/ui-internal/unnecessary_symbol_str.stderr @@ -1,5 +1,5 @@ error: unnecessary `Symbol` to string conversion - --> $DIR/unnecessary_symbol_str.rs:16:5 + --> $DIR/unnecessary_symbol_str.rs:17:5 | LL | Symbol::intern("foo").as_str() == "clippy"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Symbol::intern("foo") == rustc_span::sym::clippy` @@ -12,25 +12,25 @@ LL | #![deny(clippy::internal)] = note: `#[deny(clippy::unnecessary_symbol_str)]` implied by `#[deny(clippy::internal)]` error: unnecessary `Symbol` to string conversion - --> $DIR/unnecessary_symbol_str.rs:17:5 + --> $DIR/unnecessary_symbol_str.rs:18:5 | LL | Symbol::intern("foo").to_string() == "self"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Symbol::intern("foo") == rustc_span::symbol::kw::SelfLower` error: unnecessary `Symbol` to string conversion - --> $DIR/unnecessary_symbol_str.rs:18:5 + --> $DIR/unnecessary_symbol_str.rs:19:5 | LL | Symbol::intern("foo").to_ident_string() != "Self"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Symbol::intern("foo") != rustc_span::symbol::kw::SelfUpper` error: unnecessary `Symbol` to string conversion - --> $DIR/unnecessary_symbol_str.rs:19:5 + --> $DIR/unnecessary_symbol_str.rs:20:5 | LL | &*Ident::empty().as_str() == "clippy"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Ident::empty().name == rustc_span::sym::clippy` error: unnecessary `Symbol` to string conversion - --> $DIR/unnecessary_symbol_str.rs:20:5 + --> $DIR/unnecessary_symbol_str.rs:21:5 | LL | "clippy" == Ident::empty().to_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::clippy == Ident::empty().name` diff --git a/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs b/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs index 7f28efd676f2..b4be9e80d570 100644 --- a/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs +++ b/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs @@ -1,3 +1,4 @@ +#![allow(clippy::absolute_symbol_paths)] #![warn(clippy::disallowed_types)] extern crate quote; diff --git a/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr b/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr index e3ece799c7ce..9a5aa8546358 100644 --- a/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr +++ b/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr @@ -1,5 +1,5 @@ error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:7:1 + --> $DIR/conf_disallowed_types.rs:8:1 | LL | use std::sync::atomic::AtomicU32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,61 +7,61 @@ LL | use std::sync::atomic::AtomicU32; = note: `-D clippy::disallowed-types` implied by `-D warnings` error: `std::time::Instant` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:8:1 + --> $DIR/conf_disallowed_types.rs:9:1 | LL | use std::time::Instant as Sneaky; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `std::time::Instant` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:12:33 + --> $DIR/conf_disallowed_types.rs:13:33 | LL | fn bad_return_type() -> fn() -> Sneaky { | ^^^^^^ error: `std::time::Instant` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:16:28 + --> $DIR/conf_disallowed_types.rs:17:28 | LL | fn bad_arg_type(_: impl Fn(Sneaky) -> foo::atomic::AtomicU32) {} | ^^^^^^ error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:16:39 + --> $DIR/conf_disallowed_types.rs:17:39 | LL | fn bad_arg_type(_: impl Fn(Sneaky) -> foo::atomic::AtomicU32) {} | ^^^^^^^^^^^^^^^^^^^^^^ error: `std::io::Read` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:18:22 + --> $DIR/conf_disallowed_types.rs:19:22 | LL | fn trait_obj(_: &dyn std::io::Read) {} | ^^^^^^^^^^^^^ error: `usize` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:20:33 + --> $DIR/conf_disallowed_types.rs:21:33 | LL | fn full_and_single_path_prim(_: usize, _: bool) {} | ^^^^^ error: `bool` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:20:43 + --> $DIR/conf_disallowed_types.rs:21:43 | LL | fn full_and_single_path_prim(_: usize, _: bool) {} | ^^^^ error: `usize` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:22:28 + --> $DIR/conf_disallowed_types.rs:23:28 | LL | fn const_generics() {} | ^^^^^ error: `usize` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:24:24 + --> $DIR/conf_disallowed_types.rs:25:24 | LL | struct GenArg([u8; U]); | ^^^^^ error: `std::net::Ipv4Addr` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:28:10 + --> $DIR/conf_disallowed_types.rs:29:10 | LL | fn ip(_: std::net::Ipv4Addr) {} | ^^^^^^^^^^^^^^^^^^ @@ -69,61 +69,61 @@ LL | fn ip(_: std::net::Ipv4Addr) {} = note: no IPv4 allowed (from clippy.toml) error: `std::net::TcpListener` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:30:16 + --> $DIR/conf_disallowed_types.rs:31:16 | LL | fn listener(_: std::net::TcpListener) {} | ^^^^^^^^^^^^^^^^^^^^^ error: `std::collections::HashMap` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:34:48 + --> $DIR/conf_disallowed_types.rs:35:48 | LL | let _: std::collections::HashMap<(), ()> = std::collections::HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `std::collections::HashMap` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:34:12 + --> $DIR/conf_disallowed_types.rs:35:12 | LL | let _: std::collections::HashMap<(), ()> = std::collections::HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `std::time::Instant` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:35:13 + --> $DIR/conf_disallowed_types.rs:36:13 | LL | let _ = Sneaky::now(); | ^^^^^^ error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:36:13 + --> $DIR/conf_disallowed_types.rs:37:13 | LL | let _ = foo::atomic::AtomicU32::new(0); | ^^^^^^^^^^^^^^^^^^^^^^ error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:37:17 + --> $DIR/conf_disallowed_types.rs:38:17 | LL | static FOO: std::sync::atomic::AtomicU32 = foo::atomic::AtomicU32::new(1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:37:48 + --> $DIR/conf_disallowed_types.rs:38:48 | LL | static FOO: std::sync::atomic::AtomicU32 = foo::atomic::AtomicU32::new(1); | ^^^^^^^^^^^^^^^^^^^^^^ error: `syn::TypePath` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:38:43 + --> $DIR/conf_disallowed_types.rs:39:43 | LL | let _: std::collections::BTreeMap<(), syn::TypePath> = Default::default(); | ^^^^^^^^^^^^^ error: `syn::Ident` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:39:13 + --> $DIR/conf_disallowed_types.rs:40:13 | LL | let _ = syn::Ident::new("", todo!()); | ^^^^^^^^^^ error: `usize` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:41:12 + --> $DIR/conf_disallowed_types.rs:42:12 | LL | let _: usize = 64_usize; | ^^^^^ diff --git a/tests/ui/absolute_symbol_paths.rs b/tests/ui/absolute_symbol_paths.rs new file mode 100644 index 000000000000..1cb60fa96a8a --- /dev/null +++ b/tests/ui/absolute_symbol_paths.rs @@ -0,0 +1,73 @@ +//@aux-build:proc_macros.rs +#![allow(clippy::no_effect, unused)] +#![warn(clippy::absolute_symbol_paths)] +#![feature(decl_macro)] + +#[macro_use] +extern crate proc_macros; + +pub mod a { + pub mod b { + pub mod c { + pub struct C; + + impl C { + pub const ZERO: u32 = 0; + } + } + + pub struct B; + } + + pub struct A; +} + +fn main() { + f32::max(1.0, 2.0); + std::f32::MAX; + core::f32::MAX; + a::b::c::C; + a::A; + a::b::B; + a::b::c::C::ZERO; + fn b() -> a::b::B { + todo!() + } + // Does not lint + use a::b; + use a::b::c::C; + b::c::C; + fn a() -> a::A { + todo!() + } + use a::b::c; + + fn c() -> c::C { + todo!() + } + fn d() -> Result<(), ()> { + todo!() + } + external! { + a::b::c::C::ZERO; + } + with_span! { + span + a::b::c::C::ZERO; + } + macro_rules! local_crate { + () => { + a::b::c::C::ZERO; + }; + } + macro local_crate_2_0() { + a::b::c::C::ZERO; + } + local_crate!(); + local_crate_2_0!(); + // Macros are unfortunately tricky, as these are defined in `std::macros` but we have to access + // them from `std::println!`, both due to privacy and because they're not macros 2.0 + std::println!("a"); + let x = 1; + std::ptr::addr_of!(x); +} diff --git a/tests/ui/absolute_symbol_paths.stderr b/tests/ui/absolute_symbol_paths.stderr new file mode 100644 index 000000000000..e044120e8a49 --- /dev/null +++ b/tests/ui/absolute_symbol_paths.stderr @@ -0,0 +1,16 @@ +error: consider referring to this symbol by adding a `use` statement for consistent formatting + --> $DIR/absolute_symbol_paths.rs:29:5 + | +LL | a::b::c::C; + | ^^^^^^^^^^ + | + = note: `-D clippy::absolute-symbol-paths` implied by `-D warnings` + +error: consider referring to this symbol by adding a `use` statement for consistent formatting + --> $DIR/absolute_symbol_paths.rs:32:5 + | +LL | a::b::c::C::ZERO; + | ^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/cast_alignment.rs b/tests/ui/cast_alignment.rs index 95bb883df1bf..715e52af5a9c 100644 --- a/tests/ui/cast_alignment.rs +++ b/tests/ui/cast_alignment.rs @@ -2,6 +2,7 @@ #![feature(rustc_private)] #![feature(core_intrinsics)] +#![allow(clippy::absolute_symbol_paths)] extern crate libc; #[warn(clippy::cast_ptr_alignment)] diff --git a/tests/ui/cast_alignment.stderr b/tests/ui/cast_alignment.stderr index 5df2b5b1094b..b0a1f979c5e3 100644 --- a/tests/ui/cast_alignment.stderr +++ b/tests/ui/cast_alignment.stderr @@ -1,5 +1,5 @@ error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) (1 < 2 bytes) - --> $DIR/cast_alignment.rs:19:5 + --> $DIR/cast_alignment.rs:20:5 | LL | (&1u8 as *const u8) as *const u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,19 +7,19 @@ LL | (&1u8 as *const u8) as *const u16; = note: `-D clippy::cast-ptr-alignment` implied by `-D warnings` error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) (1 < 2 bytes) - --> $DIR/cast_alignment.rs:20:5 + --> $DIR/cast_alignment.rs:21:5 | LL | (&mut 1u8 as *mut u8) as *mut u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) (1 < 2 bytes) - --> $DIR/cast_alignment.rs:23:5 + --> $DIR/cast_alignment.rs:24:5 | LL | (&1u8 as *const u8).cast::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) (1 < 2 bytes) - --> $DIR/cast_alignment.rs:24:5 + --> $DIR/cast_alignment.rs:25:5 | LL | (&mut 1u8 as *mut u8).cast::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/default_trait_access.fixed b/tests/ui/default_trait_access.fixed index bf5dca976416..e0602bb5a70f 100644 --- a/tests/ui/default_trait_access.fixed +++ b/tests/ui/default_trait_access.fixed @@ -2,7 +2,7 @@ //@aux-build: proc_macros.rs #![deny(clippy::default_trait_access)] #![allow(dead_code, unused_imports)] -#![allow(clippy::uninlined_format_args)] +#![allow(clippy::absolute_symbol_paths, clippy::uninlined_format_args)] extern crate proc_macros; diff --git a/tests/ui/default_trait_access.rs b/tests/ui/default_trait_access.rs index 5e8e9ce85b1c..2d7b5e34a2f6 100644 --- a/tests/ui/default_trait_access.rs +++ b/tests/ui/default_trait_access.rs @@ -2,7 +2,7 @@ //@aux-build: proc_macros.rs #![deny(clippy::default_trait_access)] #![allow(dead_code, unused_imports)] -#![allow(clippy::uninlined_format_args)] +#![allow(clippy::absolute_symbol_paths, clippy::uninlined_format_args)] extern crate proc_macros; diff --git a/tests/ui/entry.fixed b/tests/ui/entry.fixed index 7e82390605cc..c675bee8b006 100644 --- a/tests/ui/entry.fixed +++ b/tests/ui/entry.fixed @@ -1,7 +1,12 @@ //@needs-asm-support //@run-rustfix -#![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)] +#![allow( + unused, + clippy::absolute_symbol_paths, + clippy::needless_pass_by_value, + clippy::collapsible_if +)] #![warn(clippy::map_entry)] use std::arch::asm; diff --git a/tests/ui/entry.rs b/tests/ui/entry.rs index 742c93225357..34e255c9299a 100644 --- a/tests/ui/entry.rs +++ b/tests/ui/entry.rs @@ -1,7 +1,12 @@ //@needs-asm-support //@run-rustfix -#![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)] +#![allow( + unused, + clippy::absolute_symbol_paths, + clippy::needless_pass_by_value, + clippy::collapsible_if +)] #![warn(clippy::map_entry)] use std::arch::asm; diff --git a/tests/ui/entry.stderr b/tests/ui/entry.stderr index 2c4c49d2522c..83d4c814c319 100644 --- a/tests/ui/entry.stderr +++ b/tests/ui/entry.stderr @@ -1,5 +1,5 @@ error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:25:5 + --> $DIR/entry.rs:30:5 | LL | / if !m.contains_key(&k) { LL | | m.insert(k, v); @@ -9,7 +9,7 @@ LL | | } = note: `-D clippy::map-entry` implied by `-D warnings` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:30:5 + --> $DIR/entry.rs:35:5 | LL | / if !m.contains_key(&k) { LL | | if true { @@ -32,7 +32,7 @@ LL + }); | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:39:5 + --> $DIR/entry.rs:44:5 | LL | / if !m.contains_key(&k) { LL | | if true { @@ -55,7 +55,7 @@ LL + }); | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:48:5 + --> $DIR/entry.rs:53:5 | LL | / if !m.contains_key(&k) { LL | | if true { @@ -79,7 +79,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:58:5 + --> $DIR/entry.rs:63:5 | LL | / if !m.contains_key(&k) { LL | | foo(); @@ -96,7 +96,7 @@ LL + }); | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:64:5 + --> $DIR/entry.rs:69:5 | LL | / if !m.contains_key(&k) { LL | | match 0 { @@ -122,7 +122,7 @@ LL + }); | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:76:5 + --> $DIR/entry.rs:81:5 | LL | / if !m.contains_key(&k) { LL | | match 0 { @@ -146,7 +146,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:86:5 + --> $DIR/entry.rs:91:5 | LL | / if !m.contains_key(&k) { LL | | foo(); @@ -187,7 +187,7 @@ LL + }); | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:120:5 + --> $DIR/entry.rs:125:5 | LL | / if !m.contains_key(&m!(k)) { LL | | m.insert(m!(k), m!(v)); @@ -195,7 +195,7 @@ LL | | } | |_____^ help: try this: `m.entry(m!(k)).or_insert_with(|| m!(v));` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:152:5 + --> $DIR/entry.rs:157:5 | LL | / if !m.contains_key(&k) { LL | | let x = (String::new(), String::new()); diff --git a/tests/ui/entry_btree.fixed b/tests/ui/entry_btree.fixed index 3baaacffd20d..238a0f1b61d9 100644 --- a/tests/ui/entry_btree.fixed +++ b/tests/ui/entry_btree.fixed @@ -1,7 +1,7 @@ //@run-rustfix #![warn(clippy::map_entry)] -#![allow(dead_code)] +#![allow(clippy::absolute_symbol_paths, dead_code)] use std::collections::BTreeMap; diff --git a/tests/ui/entry_btree.rs b/tests/ui/entry_btree.rs index 770e8e91da23..64eb7374728e 100644 --- a/tests/ui/entry_btree.rs +++ b/tests/ui/entry_btree.rs @@ -1,7 +1,7 @@ //@run-rustfix #![warn(clippy::map_entry)] -#![allow(dead_code)] +#![allow(clippy::absolute_symbol_paths, dead_code)] use std::collections::BTreeMap; diff --git a/tests/ui/entry_with_else.fixed b/tests/ui/entry_with_else.fixed index 71fe04fd6484..a798a7c066ea 100644 --- a/tests/ui/entry_with_else.fixed +++ b/tests/ui/entry_with_else.fixed @@ -1,6 +1,11 @@ //@run-rustfix -#![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)] +#![allow( + unused, + clippy::absolute_symbol_paths, + clippy::needless_pass_by_value, + clippy::collapsible_if +)] #![warn(clippy::map_entry)] use std::collections::{BTreeMap, HashMap}; diff --git a/tests/ui/entry_with_else.rs b/tests/ui/entry_with_else.rs index 80f74649a603..dd3cfe5dd942 100644 --- a/tests/ui/entry_with_else.rs +++ b/tests/ui/entry_with_else.rs @@ -1,6 +1,11 @@ //@run-rustfix -#![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)] +#![allow( + unused, + clippy::absolute_symbol_paths, + clippy::needless_pass_by_value, + clippy::collapsible_if +)] #![warn(clippy::map_entry)] use std::collections::{BTreeMap, HashMap}; diff --git a/tests/ui/entry_with_else.stderr b/tests/ui/entry_with_else.stderr index e0f6671b460e..b09138f969b4 100644 --- a/tests/ui/entry_with_else.stderr +++ b/tests/ui/entry_with_else.stderr @@ -1,5 +1,5 @@ error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:16:5 + --> $DIR/entry_with_else.rs:21:5 | LL | / if !m.contains_key(&k) { LL | | m.insert(k, v); @@ -22,7 +22,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:22:5 + --> $DIR/entry_with_else.rs:27:5 | LL | / if m.contains_key(&k) { LL | | m.insert(k, v); @@ -44,7 +44,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:28:5 + --> $DIR/entry_with_else.rs:33:5 | LL | / if !m.contains_key(&k) { LL | | m.insert(k, v); @@ -63,7 +63,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:34:5 + --> $DIR/entry_with_else.rs:39:5 | LL | / if !m.contains_key(&k) { LL | | foo(); @@ -82,7 +82,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:40:5 + --> $DIR/entry_with_else.rs:45:5 | LL | / if !m.contains_key(&k) { LL | | m.insert(k, v); @@ -104,7 +104,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:46:5 + --> $DIR/entry_with_else.rs:51:5 | LL | / if m.contains_key(&k) { LL | | if true { m.insert(k, v) } else { m.insert(k, v2) } @@ -127,7 +127,7 @@ LL ~ }; | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:52:5 + --> $DIR/entry_with_else.rs:57:5 | LL | / if m.contains_key(&k) { LL | | foo(); diff --git a/tests/ui/eta.fixed b/tests/ui/eta.fixed index bf44bcb564ec..315c3d4c4f9b 100644 --- a/tests/ui/eta.fixed +++ b/tests/ui/eta.fixed @@ -2,6 +2,7 @@ #![warn(clippy::redundant_closure, clippy::redundant_closure_for_method_calls)] #![allow(unused)] #![allow( + clippy::absolute_symbol_paths, clippy::needless_borrow, clippy::needless_pass_by_value, clippy::no_effect, diff --git a/tests/ui/eta.rs b/tests/ui/eta.rs index b2af4bf09537..5494d185f672 100644 --- a/tests/ui/eta.rs +++ b/tests/ui/eta.rs @@ -2,6 +2,7 @@ #![warn(clippy::redundant_closure, clippy::redundant_closure_for_method_calls)] #![allow(unused)] #![allow( + clippy::absolute_symbol_paths, clippy::needless_borrow, clippy::needless_pass_by_value, clippy::no_effect, diff --git a/tests/ui/eta.stderr b/tests/ui/eta.stderr index 0ac0b901df44..de0238861864 100644 --- a/tests/ui/eta.stderr +++ b/tests/ui/eta.stderr @@ -1,5 +1,5 @@ error: redundant closure - --> $DIR/eta.rs:29:27 + --> $DIR/eta.rs:30:27 | LL | let a = Some(1u8).map(|a| foo(a)); | ^^^^^^^^^^ help: replace the closure with the function itself: `foo` @@ -7,31 +7,31 @@ LL | let a = Some(1u8).map(|a| foo(a)); = note: `-D clippy::redundant-closure` implied by `-D warnings` error: redundant closure - --> $DIR/eta.rs:33:40 + --> $DIR/eta.rs:34:40 | LL | let _: Option> = true.then(|| vec![]); // special case vec! | ^^^^^^^^^ help: replace the closure with `Vec::new`: `std::vec::Vec::new` error: redundant closure - --> $DIR/eta.rs:34:35 + --> $DIR/eta.rs:35:35 | LL | let d = Some(1u8).map(|a| foo((|b| foo2(b))(a))); //is adjusted? | ^^^^^^^^^^^^^ help: replace the closure with the function itself: `foo2` error: redundant closure - --> $DIR/eta.rs:35:26 + --> $DIR/eta.rs:36:26 | LL | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted | ^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `below` error: redundant closure - --> $DIR/eta.rs:42:27 + --> $DIR/eta.rs:43:27 | LL | let e = Some(1u8).map(|a| generic(a)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `generic` error: redundant closure - --> $DIR/eta.rs:94:51 + --> $DIR/eta.rs:95:51 | LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo()); | ^^^^^^^^^^^ help: replace the closure with the method itself: `TestStruct::foo` @@ -39,121 +39,121 @@ LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo()); = note: `-D clippy::redundant-closure-for-method-calls` implied by `-D warnings` error: redundant closure - --> $DIR/eta.rs:95:51 + --> $DIR/eta.rs:96:51 | LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.trait_foo()); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `TestTrait::trait_foo` error: redundant closure - --> $DIR/eta.rs:97:42 + --> $DIR/eta.rs:98:42 | LL | let e = Some(&mut vec![1, 2, 3]).map(|v| v.clear()); | ^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::vec::Vec::clear` error: redundant closure - --> $DIR/eta.rs:101:29 + --> $DIR/eta.rs:102:29 | LL | let e = Some("str").map(|s| s.to_string()); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::string::ToString::to_string` error: redundant closure - --> $DIR/eta.rs:102:27 + --> $DIR/eta.rs:103:27 | LL | let e = Some('a').map(|s| s.to_uppercase()); | ^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `char::to_uppercase` error: redundant closure - --> $DIR/eta.rs:104:65 + --> $DIR/eta.rs:105:65 | LL | let e: std::vec::Vec = vec!['a', 'b', 'c'].iter().map(|c| c.to_ascii_uppercase()).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `char::to_ascii_uppercase` error: redundant closure - --> $DIR/eta.rs:167:22 + --> $DIR/eta.rs:168:22 | LL | requires_fn_once(|| x()); | ^^^^^^ help: replace the closure with the function itself: `x` error: redundant closure - --> $DIR/eta.rs:174:27 + --> $DIR/eta.rs:175:27 | LL | let a = Some(1u8).map(|a| foo_ptr(a)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `foo_ptr` error: redundant closure - --> $DIR/eta.rs:179:27 + --> $DIR/eta.rs:180:27 | LL | let a = Some(1u8).map(|a| closure(a)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `closure` error: redundant closure - --> $DIR/eta.rs:211:28 + --> $DIR/eta.rs:212:28 | LL | x.into_iter().for_each(|x| add_to_res(x)); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut add_to_res` error: redundant closure - --> $DIR/eta.rs:212:28 + --> $DIR/eta.rs:213:28 | LL | y.into_iter().for_each(|x| add_to_res(x)); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut add_to_res` error: redundant closure - --> $DIR/eta.rs:213:28 + --> $DIR/eta.rs:214:28 | LL | z.into_iter().for_each(|x| add_to_res(x)); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `add_to_res` error: redundant closure - --> $DIR/eta.rs:220:21 + --> $DIR/eta.rs:221:21 | LL | Some(1).map(|n| closure(n)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut closure` error: redundant closure - --> $DIR/eta.rs:224:21 + --> $DIR/eta.rs:225:21 | LL | Some(1).map(|n| in_loop(n)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `in_loop` error: redundant closure - --> $DIR/eta.rs:317:18 + --> $DIR/eta.rs:318:18 | LL | takes_fn_mut(|| f()); | ^^^^^^ help: replace the closure with the function itself: `&mut f` error: redundant closure - --> $DIR/eta.rs:320:19 + --> $DIR/eta.rs:321:19 | LL | takes_fn_once(|| f()); | ^^^^^^ help: replace the closure with the function itself: `&mut f` error: redundant closure - --> $DIR/eta.rs:324:26 + --> $DIR/eta.rs:325:26 | LL | move || takes_fn_mut(|| f_used_once()) | ^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut f_used_once` error: redundant closure - --> $DIR/eta.rs:336:19 + --> $DIR/eta.rs:337:19 | LL | array_opt.map(|a| a.as_slice()); | ^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `<[u8; 3]>::as_slice` error: redundant closure - --> $DIR/eta.rs:339:19 + --> $DIR/eta.rs:340:19 | LL | slice_opt.map(|s| s.len()); | ^^^^^^^^^^^ help: replace the closure with the method itself: `<[u8]>::len` error: redundant closure - --> $DIR/eta.rs:342:17 + --> $DIR/eta.rs:343:17 | LL | ptr_opt.map(|p| p.is_null()); | ^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `<*const usize>::is_null` error: redundant closure - --> $DIR/eta.rs:346:17 + --> $DIR/eta.rs:347:17 | LL | dyn_opt.map(|d| d.method_on_dyn()); | ^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `::method_on_dyn` diff --git a/tests/ui/floating_point_log.fixed b/tests/ui/floating_point_log.fixed index 6582c0a0f6c8..7f9bab6a38fa 100644 --- a/tests/ui/floating_point_log.fixed +++ b/tests/ui/floating_point_log.fixed @@ -1,5 +1,10 @@ //@run-rustfix -#![allow(dead_code, clippy::double_parens, clippy::unnecessary_cast)] +#![allow( + dead_code, + clippy::absolute_symbol_paths, + clippy::double_parens, + clippy::unnecessary_cast +)] #![warn(clippy::suboptimal_flops, clippy::imprecise_flops)] const TWO: f32 = 2.0; diff --git a/tests/ui/floating_point_log.rs b/tests/ui/floating_point_log.rs index 854d269fff59..3ab0f869acd8 100644 --- a/tests/ui/floating_point_log.rs +++ b/tests/ui/floating_point_log.rs @@ -1,5 +1,10 @@ //@run-rustfix -#![allow(dead_code, clippy::double_parens, clippy::unnecessary_cast)] +#![allow( + dead_code, + clippy::absolute_symbol_paths, + clippy::double_parens, + clippy::unnecessary_cast +)] #![warn(clippy::suboptimal_flops, clippy::imprecise_flops)] const TWO: f32 = 2.0; diff --git a/tests/ui/floating_point_log.stderr b/tests/ui/floating_point_log.stderr index 89800a13a6ec..e99af473999f 100644 --- a/tests/ui/floating_point_log.stderr +++ b/tests/ui/floating_point_log.stderr @@ -1,5 +1,5 @@ error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:10:13 + --> $DIR/floating_point_log.rs:15:13 | LL | let _ = x.log(2f32); | ^^^^^^^^^^^ help: consider using: `x.log2()` @@ -7,55 +7,55 @@ LL | let _ = x.log(2f32); = note: `-D clippy::suboptimal-flops` implied by `-D warnings` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:11:13 + --> $DIR/floating_point_log.rs:16:13 | LL | let _ = x.log(10f32); | ^^^^^^^^^^^^ help: consider using: `x.log10()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:12:13 + --> $DIR/floating_point_log.rs:17:13 | LL | let _ = x.log(std::f32::consts::E); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.ln()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:13:13 + --> $DIR/floating_point_log.rs:18:13 | LL | let _ = x.log(TWO); | ^^^^^^^^^^ help: consider using: `x.log2()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:14:13 + --> $DIR/floating_point_log.rs:19:13 | LL | let _ = x.log(E); | ^^^^^^^^ help: consider using: `x.ln()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:15:13 + --> $DIR/floating_point_log.rs:20:13 | LL | let _ = (x as f32).log(2f32); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).log2()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:18:13 + --> $DIR/floating_point_log.rs:23:13 | LL | let _ = x.log(2f64); | ^^^^^^^^^^^ help: consider using: `x.log2()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:19:13 + --> $DIR/floating_point_log.rs:24:13 | LL | let _ = x.log(10f64); | ^^^^^^^^^^^^ help: consider using: `x.log10()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:20:13 + --> $DIR/floating_point_log.rs:25:13 | LL | let _ = x.log(std::f64::consts::E); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.ln()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:25:13 + --> $DIR/floating_point_log.rs:30:13 | LL | let _ = (1f32 + 2.).ln(); | ^^^^^^^^^^^^^^^^ help: consider using: `2.0f32.ln_1p()` @@ -63,115 +63,115 @@ LL | let _ = (1f32 + 2.).ln(); = note: `-D clippy::imprecise-flops` implied by `-D warnings` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:26:13 + --> $DIR/floating_point_log.rs:31:13 | LL | let _ = (1f32 + 2.0).ln(); | ^^^^^^^^^^^^^^^^^ help: consider using: `2.0f32.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:27:13 + --> $DIR/floating_point_log.rs:32:13 | LL | let _ = (1.0 + x).ln(); | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:28:13 + --> $DIR/floating_point_log.rs:33:13 | LL | let _ = (1.0 + x / 2.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:29:13 + --> $DIR/floating_point_log.rs:34:13 | LL | let _ = (1.0 + x.powi(3)).ln(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:30:13 + --> $DIR/floating_point_log.rs:35:13 | LL | let _ = (1.0 + x.powi(3) / 2.0).ln(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x.powi(3) / 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:31:13 + --> $DIR/floating_point_log.rs:36:13 | LL | let _ = (1.0 + (std::f32::consts::E - 1.0)).ln(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(std::f32::consts::E - 1.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:32:13 + --> $DIR/floating_point_log.rs:37:13 | LL | let _ = (x + 1.0).ln(); | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:33:13 + --> $DIR/floating_point_log.rs:38:13 | LL | let _ = (x.powi(3) + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:34:13 + --> $DIR/floating_point_log.rs:39:13 | LL | let _ = (x + 2.0 + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x + 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:35:13 + --> $DIR/floating_point_log.rs:40:13 | LL | let _ = (x / 2.0 + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:43:13 + --> $DIR/floating_point_log.rs:48:13 | LL | let _ = (1f64 + 2.).ln(); | ^^^^^^^^^^^^^^^^ help: consider using: `2.0f64.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:44:13 + --> $DIR/floating_point_log.rs:49:13 | LL | let _ = (1f64 + 2.0).ln(); | ^^^^^^^^^^^^^^^^^ help: consider using: `2.0f64.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:45:13 + --> $DIR/floating_point_log.rs:50:13 | LL | let _ = (1.0 + x).ln(); | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:46:13 + --> $DIR/floating_point_log.rs:51:13 | LL | let _ = (1.0 + x / 2.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:47:13 + --> $DIR/floating_point_log.rs:52:13 | LL | let _ = (1.0 + x.powi(3)).ln(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:48:13 + --> $DIR/floating_point_log.rs:53:13 | LL | let _ = (x + 1.0).ln(); | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:49:13 + --> $DIR/floating_point_log.rs:54:13 | LL | let _ = (x.powi(3) + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:50:13 + --> $DIR/floating_point_log.rs:55:13 | LL | let _ = (x + 2.0 + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x + 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:51:13 + --> $DIR/floating_point_log.rs:56:13 | LL | let _ = (x / 2.0 + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()` diff --git a/tests/ui/floating_point_powf.fixed b/tests/ui/floating_point_powf.fixed index 1e660b140c58..ac43776c98c8 100644 --- a/tests/ui/floating_point_powf.fixed +++ b/tests/ui/floating_point_powf.fixed @@ -1,6 +1,6 @@ //@run-rustfix #![warn(clippy::suboptimal_flops, clippy::imprecise_flops)] -#![allow(clippy::unnecessary_cast)] +#![allow(clippy::absolute_symbol_paths, clippy::unnecessary_cast)] fn main() { let x = 3f32; diff --git a/tests/ui/floating_point_powf.rs b/tests/ui/floating_point_powf.rs index 71c2f5292053..aeb6c3839190 100644 --- a/tests/ui/floating_point_powf.rs +++ b/tests/ui/floating_point_powf.rs @@ -1,6 +1,6 @@ //@run-rustfix #![warn(clippy::suboptimal_flops, clippy::imprecise_flops)] -#![allow(clippy::unnecessary_cast)] +#![allow(clippy::absolute_symbol_paths, clippy::unnecessary_cast)] fn main() { let x = 3f32; diff --git a/tests/ui/floating_point_rad.fixed b/tests/ui/floating_point_rad.fixed index af2364527128..c74dd86543c8 100644 --- a/tests/ui/floating_point_rad.fixed +++ b/tests/ui/floating_point_rad.fixed @@ -1,5 +1,6 @@ //@run-rustfix #![feature(const_fn_floating_point_arithmetic)] +#![allow(clippy::absolute_symbol_paths)] #![warn(clippy::suboptimal_flops)] /// Allow suboptimal_flops in constant context diff --git a/tests/ui/floating_point_rad.rs b/tests/ui/floating_point_rad.rs index d7612c56a3e4..bbca45be0d52 100644 --- a/tests/ui/floating_point_rad.rs +++ b/tests/ui/floating_point_rad.rs @@ -1,5 +1,6 @@ //@run-rustfix #![feature(const_fn_floating_point_arithmetic)] +#![allow(clippy::absolute_symbol_paths)] #![warn(clippy::suboptimal_flops)] /// Allow suboptimal_flops in constant context diff --git a/tests/ui/floating_point_rad.stderr b/tests/ui/floating_point_rad.stderr index 979442f2c24a..bf0b43a1aff5 100644 --- a/tests/ui/floating_point_rad.stderr +++ b/tests/ui/floating_point_rad.stderr @@ -1,5 +1,5 @@ error: conversion to radians can be done more accurately - --> $DIR/floating_point_rad.rs:12:13 + --> $DIR/floating_point_rad.rs:13:13 | LL | let _ = degrees as f64 * std::f64::consts::PI / 180.0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(degrees as f64).to_radians()` @@ -7,43 +7,43 @@ LL | let _ = degrees as f64 * std::f64::consts::PI / 180.0; = note: `-D clippy::suboptimal-flops` implied by `-D warnings` error: conversion to degrees can be done more accurately - --> $DIR/floating_point_rad.rs:13:13 + --> $DIR/floating_point_rad.rs:14:13 | LL | let _ = degrees as f64 * 180.0 / std::f64::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(degrees as f64).to_degrees()` error: conversion to degrees can be done more accurately - --> $DIR/floating_point_rad.rs:18:13 + --> $DIR/floating_point_rad.rs:19:13 | LL | let _ = x * 180f32 / std::f32::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.to_degrees()` error: conversion to degrees can be done more accurately - --> $DIR/floating_point_rad.rs:19:13 + --> $DIR/floating_point_rad.rs:20:13 | LL | let _ = 90. * 180f64 / std::f64::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.0_f64.to_degrees()` error: conversion to degrees can be done more accurately - --> $DIR/floating_point_rad.rs:20:13 + --> $DIR/floating_point_rad.rs:21:13 | LL | let _ = 90.5 * 180f64 / std::f64::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.5_f64.to_degrees()` error: conversion to radians can be done more accurately - --> $DIR/floating_point_rad.rs:21:13 + --> $DIR/floating_point_rad.rs:22:13 | LL | let _ = x * std::f32::consts::PI / 180f32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.to_radians()` error: conversion to radians can be done more accurately - --> $DIR/floating_point_rad.rs:22:13 + --> $DIR/floating_point_rad.rs:23:13 | LL | let _ = 90. * std::f32::consts::PI / 180f32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.0_f64.to_radians()` error: conversion to radians can be done more accurately - --> $DIR/floating_point_rad.rs:23:13 + --> $DIR/floating_point_rad.rs:24:13 | LL | let _ = 90.5 * std::f32::consts::PI / 180f32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.5_f64.to_radians()` diff --git a/tests/ui/needless_borrow.fixed b/tests/ui/needless_borrow.fixed index 80cdb4e472d4..bc02d9e7d4e3 100644 --- a/tests/ui/needless_borrow.fixed +++ b/tests/ui/needless_borrow.fixed @@ -2,6 +2,7 @@ #![feature(lint_reasons)] #![allow( unused, + clippy::absolute_symbol_paths, clippy::uninlined_format_args, clippy::unnecessary_mut_passed, clippy::unnecessary_to_owned, diff --git a/tests/ui/needless_borrow.rs b/tests/ui/needless_borrow.rs index 99f735127eb8..16c3639556b6 100644 --- a/tests/ui/needless_borrow.rs +++ b/tests/ui/needless_borrow.rs @@ -2,6 +2,7 @@ #![feature(lint_reasons)] #![allow( unused, + clippy::absolute_symbol_paths, clippy::uninlined_format_args, clippy::unnecessary_mut_passed, clippy::unnecessary_to_owned, diff --git a/tests/ui/needless_borrow.stderr b/tests/ui/needless_borrow.stderr index f85b4fb46a65..2409e5a1daeb 100644 --- a/tests/ui/needless_borrow.stderr +++ b/tests/ui/needless_borrow.stderr @@ -1,5 +1,5 @@ error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:16:15 + --> $DIR/needless_borrow.rs:17:15 | LL | let _ = x(&&a); // warn | ^^^ help: change this to: `&a` @@ -7,211 +7,211 @@ LL | let _ = x(&&a); // warn = note: `-D clippy::needless-borrow` implied by `-D warnings` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:20:13 + --> $DIR/needless_borrow.rs:21:13 | LL | mut_ref(&mut &mut b); // warn | ^^^^^^^^^^^ help: change this to: `&mut b` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:32:13 + --> $DIR/needless_borrow.rs:33:13 | LL | &&a | ^^^ help: change this to: `&a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:34:15 + --> $DIR/needless_borrow.rs:35:15 | LL | 46 => &&a, | ^^^ help: change this to: `&a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:40:27 + --> $DIR/needless_borrow.rs:41:27 | LL | break &ref_a; | ^^^^^^ help: change this to: `ref_a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:47:15 + --> $DIR/needless_borrow.rs:48:15 | LL | let _ = x(&&&a); | ^^^^ help: change this to: `&a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:48:15 + --> $DIR/needless_borrow.rs:49:15 | LL | let _ = x(&mut &&a); | ^^^^^^^^ help: change this to: `&a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:49:15 + --> $DIR/needless_borrow.rs:50:15 | LL | let _ = x(&&&mut b); | ^^^^^^^^ help: change this to: `&mut b` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:50:15 + --> $DIR/needless_borrow.rs:51:15 | LL | let _ = x(&&ref_a); | ^^^^^^^ help: change this to: `ref_a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:53:11 + --> $DIR/needless_borrow.rs:54:11 | LL | x(&b); | ^^ help: change this to: `b` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:60:13 + --> $DIR/needless_borrow.rs:61:13 | LL | mut_ref(&mut x); | ^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:61:13 + --> $DIR/needless_borrow.rs:62:13 | LL | mut_ref(&mut &mut x); | ^^^^^^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:62:23 + --> $DIR/needless_borrow.rs:63:23 | LL | let y: &mut i32 = &mut x; | ^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:63:23 + --> $DIR/needless_borrow.rs:64:23 | LL | let y: &mut i32 = &mut &mut x; | ^^^^^^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:72:14 + --> $DIR/needless_borrow.rs:73:14 | LL | 0 => &mut x, | ^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:78:14 + --> $DIR/needless_borrow.rs:79:14 | LL | 0 => &mut x, | ^^^^^^ help: change this to: `x` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:90:13 + --> $DIR/needless_borrow.rs:91:13 | LL | let _ = (&x).0; | ^^^^ help: change this to: `x` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:92:22 + --> $DIR/needless_borrow.rs:93:22 | LL | let _ = unsafe { (&*x).0 }; | ^^^^^ help: change this to: `(*x)` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:102:5 + --> $DIR/needless_borrow.rs:103:5 | LL | (&&()).foo(); | ^^^^^^ help: change this to: `(&())` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:111:5 + --> $DIR/needless_borrow.rs:112:5 | LL | (&&5).foo(); | ^^^^^ help: change this to: `(&5)` error: the borrowed expression implements the required traits - --> $DIR/needless_borrow.rs:136:51 + --> $DIR/needless_borrow.rs:137:51 | LL | let _ = std::process::Command::new("ls").args(&["-a", "-l"]).status().unwrap(); | ^^^^^^^^^^^^^ help: change this to: `["-a", "-l"]` error: the borrowed expression implements the required traits - --> $DIR/needless_borrow.rs:137:44 + --> $DIR/needless_borrow.rs:138:44 | LL | let _ = std::path::Path::new(".").join(&&"."); | ^^^^^ help: change this to: `"."` error: the borrowed expression implements the required traits - --> $DIR/needless_borrow.rs:138:23 + --> $DIR/needless_borrow.rs:139:23 | LL | deref_target_is_x(&X); | ^^ help: change this to: `X` error: the borrowed expression implements the required traits - --> $DIR/needless_borrow.rs:139:26 + --> $DIR/needless_borrow.rs:140:26 | LL | multiple_constraints(&[[""]]); | ^^^^^^^ help: change this to: `[[""]]` error: the borrowed expression implements the required traits - --> $DIR/needless_borrow.rs:140:45 + --> $DIR/needless_borrow.rs:141:45 | LL | multiple_constraints_normalizes_to_same(&X, X); | ^^ help: change this to: `X` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:141:32 + --> $DIR/needless_borrow.rs:142:32 | LL | let _ = Some("").unwrap_or(&""); | ^^^ help: change this to: `""` error: the borrowed expression implements the required traits - --> $DIR/needless_borrow.rs:142:33 + --> $DIR/needless_borrow.rs:143:33 | LL | let _ = std::fs::write("x", &"".to_string()); | ^^^^^^^^^^^^^^^ help: change this to: `"".to_string()` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:191:13 + --> $DIR/needless_borrow.rs:192:13 | LL | (&self.f)() | ^^^^^^^^^ help: change this to: `(self.f)` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:200:13 + --> $DIR/needless_borrow.rs:201:13 | LL | (&mut self.f)() | ^^^^^^^^^^^^^ help: change this to: `(self.f)` error: the borrowed expression implements the required traits - --> $DIR/needless_borrow.rs:284:20 + --> $DIR/needless_borrow.rs:285:20 | LL | takes_iter(&mut x) | ^^^^^^ help: change this to: `x` error: the borrowed expression implements the required traits - --> $DIR/needless_borrow.rs:298:55 + --> $DIR/needless_borrow.rs:299:55 | LL | let _ = std::process::Command::new("ls").args(&["-a", "-l"]).status().unwrap(); | ^^^^^^^^^^^^^ help: change this to: `["-a", "-l"]` error: the borrowed expression implements the required traits - --> $DIR/needless_borrow.rs:336:37 + --> $DIR/needless_borrow.rs:337:37 | LL | let _ = std::fs::write("x", &arg); | ^^^^ help: change this to: `arg` error: the borrowed expression implements the required traits - --> $DIR/needless_borrow.rs:337:37 + --> $DIR/needless_borrow.rs:338:37 | LL | let _ = std::fs::write("x", &loc); | ^^^^ help: change this to: `loc` error: the borrowed expression implements the required traits - --> $DIR/needless_borrow.rs:355:15 + --> $DIR/needless_borrow.rs:356:15 | LL | debug(&x); | ^^ help: change this to: `x` error: the borrowed expression implements the required traits - --> $DIR/needless_borrow.rs:364:15 + --> $DIR/needless_borrow.rs:365:15 | LL | use_x(&x); | ^^ help: change this to: `x` error: the borrowed expression implements the required traits - --> $DIR/needless_borrow.rs:458:13 + --> $DIR/needless_borrow.rs:459:13 | LL | foo(&a); | ^^ help: change this to: `a` diff --git a/tests/ui/option_as_ref_deref.fixed b/tests/ui/option_as_ref_deref.fixed index 4d1a6a1ab98d..b87d4c155e07 100644 --- a/tests/ui/option_as_ref_deref.fixed +++ b/tests/ui/option_as_ref_deref.fixed @@ -1,6 +1,6 @@ //@run-rustfix -#![allow(unused, clippy::redundant_clone, clippy::useless_vec)] +#![allow(unused, clippy::absolute_symbol_paths, clippy::redundant_clone, clippy::useless_vec)] #![warn(clippy::option_as_ref_deref)] use std::ffi::{CString, OsString}; diff --git a/tests/ui/option_as_ref_deref.rs b/tests/ui/option_as_ref_deref.rs index 66d5a1250360..dba31f7f3509 100644 --- a/tests/ui/option_as_ref_deref.rs +++ b/tests/ui/option_as_ref_deref.rs @@ -1,6 +1,6 @@ //@run-rustfix -#![allow(unused, clippy::redundant_clone, clippy::useless_vec)] +#![allow(unused, clippy::absolute_symbol_paths, clippy::redundant_clone, clippy::useless_vec)] #![warn(clippy::option_as_ref_deref)] use std::ffi::{CString, OsString}; diff --git a/tests/ui/unnecessary_cast.fixed b/tests/ui/unnecessary_cast.fixed index 8efd44baf59f..ff69eb923306 100644 --- a/tests/ui/unnecessary_cast.fixed +++ b/tests/ui/unnecessary_cast.fixed @@ -2,6 +2,7 @@ //@aux-build:extern_fake_libc.rs #![warn(clippy::unnecessary_cast)] #![allow( + clippy::absolute_symbol_paths, clippy::borrow_as_ptr, clippy::no_effect, clippy::nonstandard_macro_braces, diff --git a/tests/ui/unnecessary_cast.rs b/tests/ui/unnecessary_cast.rs index c7723ef51f99..0d35246681f7 100644 --- a/tests/ui/unnecessary_cast.rs +++ b/tests/ui/unnecessary_cast.rs @@ -2,6 +2,7 @@ //@aux-build:extern_fake_libc.rs #![warn(clippy::unnecessary_cast)] #![allow( + clippy::absolute_symbol_paths, clippy::borrow_as_ptr, clippy::no_effect, clippy::nonstandard_macro_braces, diff --git a/tests/ui/unnecessary_cast.stderr b/tests/ui/unnecessary_cast.stderr index f0443556fb4d..9f83bd734bb6 100644 --- a/tests/ui/unnecessary_cast.stderr +++ b/tests/ui/unnecessary_cast.stderr @@ -1,5 +1,5 @@ error: casting raw pointers to the same type and constness is unnecessary (`*const T` -> `*const T`) - --> $DIR/unnecessary_cast.rs:19:5 + --> $DIR/unnecessary_cast.rs:20:5 | LL | ptr as *const T | ^^^^^^^^^^^^^^^ help: try: `ptr` @@ -7,223 +7,223 @@ LL | ptr as *const T = note: `-D clippy::unnecessary-cast` implied by `-D warnings` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:44:5 + --> $DIR/unnecessary_cast.rs:45:5 | LL | 1i32 as i32; | ^^^^^^^^^^^ help: try: `1_i32` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:45:5 + --> $DIR/unnecessary_cast.rs:46:5 | LL | 1f32 as f32; | ^^^^^^^^^^^ help: try: `1_f32` error: casting to the same type is unnecessary (`bool` -> `bool`) - --> $DIR/unnecessary_cast.rs:46:5 + --> $DIR/unnecessary_cast.rs:47:5 | LL | false as bool; | ^^^^^^^^^^^^^ help: try: `false` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:49:5 + --> $DIR/unnecessary_cast.rs:50:5 | LL | -1_i32 as i32; | ^^^^^^^^^^^^^ help: try: `-1_i32` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:50:5 + --> $DIR/unnecessary_cast.rs:51:5 | LL | - 1_i32 as i32; | ^^^^^^^^^^^^^^ help: try: `- 1_i32` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:51:5 + --> $DIR/unnecessary_cast.rs:52:5 | LL | -1f32 as f32; | ^^^^^^^^^^^^ help: try: `-1_f32` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:52:5 + --> $DIR/unnecessary_cast.rs:53:5 | LL | 1_i32 as i32; | ^^^^^^^^^^^^ help: try: `1_i32` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:53:5 + --> $DIR/unnecessary_cast.rs:54:5 | LL | 1_f32 as f32; | ^^^^^^^^^^^^ help: try: `1_f32` error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`) - --> $DIR/unnecessary_cast.rs:55:22 + --> $DIR/unnecessary_cast.rs:56:22 | LL | let _: *mut u8 = [1u8, 2].as_ptr() as *const u8 as *mut u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_ptr()` error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`) - --> $DIR/unnecessary_cast.rs:57:5 + --> $DIR/unnecessary_cast.rs:58:5 | LL | [1u8, 2].as_ptr() as *const u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_ptr()` error: casting raw pointers to the same type and constness is unnecessary (`*mut u8` -> `*mut u8`) - --> $DIR/unnecessary_cast.rs:59:5 + --> $DIR/unnecessary_cast.rs:60:5 | LL | [1u8, 2].as_mut_ptr() as *mut u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_mut_ptr()` error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`) - --> $DIR/unnecessary_cast.rs:70:5 + --> $DIR/unnecessary_cast.rs:71:5 | LL | owo::([1u32].as_ptr()) as *const u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `owo::([1u32].as_ptr())` error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`) - --> $DIR/unnecessary_cast.rs:71:5 + --> $DIR/unnecessary_cast.rs:72:5 | LL | uwu::([1u32].as_ptr()) as *const u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `uwu::([1u32].as_ptr())` error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`) - --> $DIR/unnecessary_cast.rs:73:5 + --> $DIR/unnecessary_cast.rs:74:5 | LL | uwu::([1u32].as_ptr()) as *const u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `uwu::([1u32].as_ptr())` error: casting integer literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:139:9 + --> $DIR/unnecessary_cast.rs:140:9 | LL | 100 as f32; | ^^^^^^^^^^ help: try: `100_f32` error: casting integer literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:140:9 + --> $DIR/unnecessary_cast.rs:141:9 | LL | 100 as f64; | ^^^^^^^^^^ help: try: `100_f64` error: casting integer literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:141:9 + --> $DIR/unnecessary_cast.rs:142:9 | LL | 100_i32 as f64; | ^^^^^^^^^^^^^^ help: try: `100_f64` error: casting integer literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:142:17 + --> $DIR/unnecessary_cast.rs:143:17 | LL | let _ = -100 as f32; | ^^^^^^^^^^^ help: try: `-100_f32` error: casting integer literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:143:17 + --> $DIR/unnecessary_cast.rs:144:17 | LL | let _ = -100 as f64; | ^^^^^^^^^^^ help: try: `-100_f64` error: casting integer literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:144:17 + --> $DIR/unnecessary_cast.rs:145:17 | LL | let _ = -100_i32 as f64; | ^^^^^^^^^^^^^^^ help: try: `-100_f64` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:145:9 + --> $DIR/unnecessary_cast.rs:146:9 | LL | 100. as f32; | ^^^^^^^^^^^ help: try: `100_f32` error: casting float literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:146:9 + --> $DIR/unnecessary_cast.rs:147:9 | LL | 100. as f64; | ^^^^^^^^^^^ help: try: `100_f64` error: casting integer literal to `u32` is unnecessary - --> $DIR/unnecessary_cast.rs:158:9 + --> $DIR/unnecessary_cast.rs:159:9 | LL | 1 as u32; | ^^^^^^^^ help: try: `1_u32` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:159:9 + --> $DIR/unnecessary_cast.rs:160:9 | LL | 0x10 as i32; | ^^^^^^^^^^^ help: try: `0x10_i32` error: casting integer literal to `usize` is unnecessary - --> $DIR/unnecessary_cast.rs:160:9 + --> $DIR/unnecessary_cast.rs:161:9 | LL | 0b10 as usize; | ^^^^^^^^^^^^^ help: try: `0b10_usize` error: casting integer literal to `u16` is unnecessary - --> $DIR/unnecessary_cast.rs:161:9 + --> $DIR/unnecessary_cast.rs:162:9 | LL | 0o73 as u16; | ^^^^^^^^^^^ help: try: `0o73_u16` error: casting integer literal to `u32` is unnecessary - --> $DIR/unnecessary_cast.rs:162:9 + --> $DIR/unnecessary_cast.rs:163:9 | LL | 1_000_000_000 as u32; | ^^^^^^^^^^^^^^^^^^^^ help: try: `1_000_000_000_u32` error: casting float literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:164:9 + --> $DIR/unnecessary_cast.rs:165:9 | LL | 1.0 as f64; | ^^^^^^^^^^ help: try: `1.0_f64` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:165:9 + --> $DIR/unnecessary_cast.rs:166:9 | LL | 0.5 as f32; | ^^^^^^^^^^ help: try: `0.5_f32` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:169:17 + --> $DIR/unnecessary_cast.rs:170:17 | LL | let _ = -1 as i32; | ^^^^^^^^^ help: try: `-1_i32` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:170:17 + --> $DIR/unnecessary_cast.rs:171:17 | LL | let _ = -1.0 as f32; | ^^^^^^^^^^^ help: try: `-1.0_f32` error: casting to the same type is unnecessary (`i32` -> `i32`) - --> $DIR/unnecessary_cast.rs:176:18 + --> $DIR/unnecessary_cast.rs:177:18 | LL | let _ = &(x as i32); | ^^^^^^^^^^ help: try: `{ x }` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:182:22 + --> $DIR/unnecessary_cast.rs:183:22 | LL | let _: i32 = -(1) as i32; | ^^^^^^^^^^^ help: try: `-1_i32` error: casting integer literal to `i64` is unnecessary - --> $DIR/unnecessary_cast.rs:184:22 + --> $DIR/unnecessary_cast.rs:185:22 | LL | let _: i64 = -(1) as i64; | ^^^^^^^^^^^ help: try: `-1_i64` error: casting float literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:191:22 + --> $DIR/unnecessary_cast.rs:192:22 | LL | let _: f64 = (-8.0 as f64).exp(); | ^^^^^^^^^^^^^ help: try: `(-8.0_f64)` error: casting float literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:193:23 + --> $DIR/unnecessary_cast.rs:194:23 | LL | let _: f64 = -(8.0 as f64).exp(); // should suggest `-8.0_f64.exp()` here not to change code behavior | ^^^^^^^^^^^^ help: try: `8.0_f64` error: casting to the same type is unnecessary (`f32` -> `f32`) - --> $DIR/unnecessary_cast.rs:201:20 + --> $DIR/unnecessary_cast.rs:202:20 | LL | let _num = foo() as f32; | ^^^^^^^^^^^^ help: try: `foo()` diff --git a/tests/workspace_test/module_style/pass_mod_with_dep_in_subdir/src/main.rs b/tests/workspace_test/module_style/pass_mod_with_dep_in_subdir/src/main.rs index 5cb4795e9451..4a1bfa87629f 100644 --- a/tests/workspace_test/module_style/pass_mod_with_dep_in_subdir/src/main.rs +++ b/tests/workspace_test/module_style/pass_mod_with_dep_in_subdir/src/main.rs @@ -1,4 +1,5 @@ #![deny(clippy::self_named_module_files)] +#![allow(clippy::absolute_symbol_paths)] mod bad; mod more; diff --git a/tests/workspace_test/module_style/pass_no_mod_with_dep_in_subdir/dep_with_mod/src/lib.rs b/tests/workspace_test/module_style/pass_no_mod_with_dep_in_subdir/dep_with_mod/src/lib.rs index 4647424f2c2f..9d18f2eb97ae 100644 --- a/tests/workspace_test/module_style/pass_no_mod_with_dep_in_subdir/dep_with_mod/src/lib.rs +++ b/tests/workspace_test/module_style/pass_no_mod_with_dep_in_subdir/dep_with_mod/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::absolute_symbol_paths)] + pub mod with_mod; pub fn foo() { diff --git a/tests/workspace_test/module_style/pass_no_mod_with_dep_in_subdir/src/main.rs b/tests/workspace_test/module_style/pass_no_mod_with_dep_in_subdir/src/main.rs index 42eb99cd7a3e..05d64803b813 100644 --- a/tests/workspace_test/module_style/pass_no_mod_with_dep_in_subdir/src/main.rs +++ b/tests/workspace_test/module_style/pass_no_mod_with_dep_in_subdir/src/main.rs @@ -1,4 +1,5 @@ #![deny(clippy::mod_module_files)] +#![allow(clippy::absolute_symbol_paths)] mod good; pub use dep_with_mod::with_mod::Thing;