profile
viewpoint

mikerite/ebook-clipper-webextension 1

A Firefox extension for creating eBooks from page clippings

mikerite/cargo 0

The Rust package manager

mikerite/dir-diff 0

Are the contents of two directories different?

mikerite/mirror-video-webextension 0

A web extension that adds a browser action to mirror video

mikerite/rust 0

A safe, concurrent, practical language.

mikerite/rust-clippy 0

A bunch of lints to catch common mistakes and improve your Rust code

mikerite/rust-playground 0

The Rust Playground

mikerite/rustfmt 0

Format Rust code

issue commentrust-lang/rust-clippy

New lint: map_unwrap_or_bool

I actually think map_or looks the best. I like that it's compact and the default is close to the mapping function. Let's see what others think.

I saw that lint, but even specifying -D clippy::pedantic I couldn't get it to trigger on my code example. I presumed it had an exception for booleans.

It works for me. Playground

jhwgh1968

comment created time in 2 days

pull request commentrust-lang/rust-clippy

Move away form blacklist terminology

It's got to be done without breaking peoples config/code. The warnings should be emitted if the old name is used with instructions for using the new name. Don't crash with an error. #3803 shows how this can be done.

mocsy

comment created time in 2 days

issue commentrust-lang/rust-clippy

New lint: map_unwrap_or_bool

This seems like it belongs in pedantic to me.

I prefer both to comparison with Some(true) which I see every now and then.

if https_proxy.map(|v| v.starts_with("https://")) == Some(true) {
     //...
}

Also Clippy will ask you to use map_or in the first example.

jhwgh1968

comment created time in 3 days

delete branch mikerite/rust-clippy

delete branch : fix-2277

delete time in a month

push eventmikerite/rust-clippy

flip1995

commit sha f7acea2683c6124854bfe20e7127e4dfba344d3e

Register redundant_field_names and non_expressive_names as early passes

view details

flip1995

commit sha 485229c4a3d6a2fbe40f5a6976a33144a27497c6

Fix fallout in redundant_field_names

view details

flip1995

commit sha efd3dcff97f67f376e354c047133ce9044c52991

Fix fallout in similar_names

view details

Eduardo Broto

commit sha bb37a0f948b02e6434dbe3ea615960052d37f784

Avoid triggering similar names on code from expansion

view details

Azhng

commit sha dfecaef91478e1b529962bad3c8dffe0a95f9450

typeck: adding type information to projection This commit modifies the Place as follow: * remove 'ty' from ProjectionKind * add type information into to Projection * replace 'ty' in Place with 'base_ty' * introduce 'ty()' in `Place` to return the final type of the `Place` * introduce `ty_before_projection()` in `Place` to return the type of a `Place` before i'th projection is applied Closes https://github.com/rust-lang/project-rfc-2229/issues/5

view details

Eduard-Mihai Burtescu

commit sha 590e07bbc2d2cba6377476c6b8442400327ff579

rustc_lint: avoid using TypeckTables::empty for LateContext.

view details

Eduard-Mihai Burtescu

commit sha 30c046ede47ea45a772d2656b0365a4807263bca

Use 'tcx for references to AccessLevels wherever possible.

view details

flip1995

commit sha a7c58e66d4b4f1434d62ead0eec57fda36dd238f

Merge remote-tracking branch 'upstream/master' into rustup

view details

bors

commit sha c493090a8a601baea39a592fdbe199bd64d6db22

Auto merge of #5763 - flip1995:rustup, r=Manishearth Rustup changelog: none

view details

ThibsG

commit sha 754bfb1dc89ed9a98b2f1b7d77b035e809b14031

Add configurable threshold for `type_repetition_in_bounds` lint

view details

ThibsG

commit sha d5a8f03a350e8a392f0aa1c05707b503f549e90b

Take generic args into account for bounded type

view details

ThibsG

commit sha 2d5930a3da7048d784489f28b44a769880b6ceff

Don't lint for predicates generated in macros

view details

Robert Sedlacek

commit sha c3c402783f1d12852982f9dc734cc4c07b9fce33

Added restriction lint: pattern-type-mismatch

view details

Robert Sedlacek

commit sha 55877d7b4a6a2c713412db7b30ef79b2a252956e

span_help_and_lint -> span_lint_and_help

view details

Robert Sedlacek

commit sha 346ee968bbe8925aa7961a3e2c99e7ef84c74623

Adjusted expected STDERR

view details

flip1995

commit sha 6447507ab150ebd1787ca6af385db49dfdf45978

Fix rebase fallout

view details

Robert Sedlacek

commit sha 92ecc53691f3edd67526dca423a2b4083d12a221

Catching up with rustc changes

view details

Robert Sedlacek

commit sha d617551a6a3830a5324898f2046b97aad8c6067a

Expanded lint documentation

view details

bors

commit sha fff8e7291381327f5106120b98d7f9585a493cad

Auto merge of #5761 - ThibsG:TypeRepetitionThreshold, r=flip1995 Improvements for `type_repetition_in_bounds` lint Some improvements for `type_repetition_in_bounds`: - add a configurable threshold to trigger the lint (#4380). The lint won't trigger anymore if there are more bounds (strictly) than `conf.max_trait_bounds` on this type. - take generic args into account over bounded type (#4323) - don't lint for predicates generated in macros (#4326) Fixes #4380, Fixes #4323, Fixes #4326, Closes #3764 changelog: Fix multiple FPs in `type_repetition_in_bounds` and add a configuration option Note: the #3764 has already been fixed but not closed

view details

Robert Sedlacek

commit sha aa4bee228f23b3e1a1d91ed3a4606af3c6b60895

LateContext has only one lifetime parameter now

view details

push time in a month

delete branch mikerite/rust-clippy

delete branch : fix-2277-2

delete time in a month

Pull request review commentrust-lang/rust-clippy

Stable sort primitive

+use crate::utils::{self, span_lint_and_sugg, sugg::Sugg};++use if_chain::if_chain;++use rustc_errors::Applicability;+use rustc_hir::{Expr, ExprKind};+use rustc_lint::{LateContext, LateLintPass};+use rustc_middle::ty::{self, Ty};+use rustc_session::{declare_lint_pass, declare_tool_lint};++declare_clippy_lint! {+    /// **What it does:**+    /// When sorting primitive values (integers, bools, chars, as well+    /// as arrays, slices, and tuples of such items), it is better to+    /// use an unstable sort than a stable sort.+    ///+    /// **Why is this bad?**+    /// Using a stable sort consumes more memory and cpu cycles. Because+    /// values which compare equal are identical, preserving their+    /// relative order (the guarantee that a stable sort provides) means+    /// nothing, while the extra costs still apply.+    ///+    /// **Known problems:**+    /// This lint only activates if the item being sorted is a `Vec`,+    /// and array, or a slice of primitive values. There may be other+    /// types which implemenet Deref to a slice of primitives, and calls+    /// to a sorting function on such types will not be detected.+    ///+    /// **Example:**+    ///+    /// ```rust+    /// let mut vec = vec![2, 1, 3];+    /// vec.sort();+    /// ```+    /// Use instead:+    /// ```rust+    /// let mut vec = vec![2, 1, 3];+    /// vec.sort_unstable();+    /// ```+    pub STABLE_SORT_PRIMITIVE,+    perf,+    "use of sort() when sort_unstable() is equivalent"+}++declare_lint_pass!(StableSortPrimitive => [STABLE_SORT_PRIMITIVE]);++/// The three "kinds" of sorts+enum SortingKind {+    Vanilla,+    /* The other kinds of lint are currently commented out because they+     * can map distinct values to equal ones. If the key function is+     * provably one-to-one, or if the Cmp function conserves equality,+     * then they could be linted on, but I don't know if we can check+     * for that. */++    /* ByKey,+     * ByCmp, */+}+impl SortingKind {+    /// The name of the stable version of this kind of sort+    fn stable_name(&self) -> &str {+        match self {+            SortingKind::Vanilla => "sort",+            /* SortingKind::ByKey => "sort_by_key",+             * SortingKind::ByCmp => "sort_by", */+        }+    }+    /// The name of the unstable version of this kind of sort+    fn unstable_name(&self) -> &str {+        match self {+            SortingKind::Vanilla => "sort_unstable",+            /* SortingKind::ByKey => "sort_unstable_by_key",+             * SortingKind::ByCmp => "sort_unstable_by", */+        }+    }+    /// Takes the name of a function call and returns the kind of sort+    /// that corresponds to that function name (or None if it isn't)+    fn from_stable_name(name: &str) -> Option<SortingKind> {+        match name {+            "sort" => Some(SortingKind::Vanilla),+            // "sort_by" => Some(SortingKind::ByCmp),+            // "sort_by_key" => Some(SortingKind::ByKey),+            _ => None,+        }+    }+}++/// A detected instance of this lint+struct LintDetection {+    slice_name: String,+    method: SortingKind,+    method_args: String,+}++/// Returns true iff the given type is a primitive which we should lint+/// on.+fn is_primitive_type(ty: Ty<'_>) -> bool {+    match ty.kind {+        ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) => true,+        ty::Array(inner_type, _) | ty::Slice(inner_type) => is_primitive_type(inner_type),+        ty::Tuple(inner_types) => inner_types.types().all(is_primitive_type),+        _ => false,+    }+}++/// Returns true iff the given expression is a slice of primitives or if+/// it is of some type that implements deref to such a slice+fn is_slice_of_primitives(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {+    let expr_type = cx.tables().expr_ty(expr);

Arrays and Vecs just use the Slice sort method via coercion. I think it should be enough to check if expr_ty_adjusted is Slice without checking for Arrays and Vecs explicitely.

JarredAllen

comment created time in a month

Pull request review commentrust-lang/rust-clippy

Stable sort primitive

+use crate::utils::{self, span_lint_and_sugg, sugg::Sugg};++use if_chain::if_chain;++use rustc_errors::Applicability;+use rustc_hir::{Expr, ExprKind};+use rustc_lint::{LateContext, LateLintPass};+use rustc_middle::ty::{self, Ty};+use rustc_session::{declare_lint_pass, declare_tool_lint};++declare_clippy_lint! {+    /// **What it does:**+    /// When sorting primitive values (integers, bools, chars, as well+    /// as arrays, slices, and tuples of such items), it is better to+    /// use an unstable sort than a stable sort.+    ///+    /// **Why is this bad?**+    /// Using a stable sort consumes more memory and cpu cycles. Because+    /// values which compare equal are identical, preserving their+    /// relative order (the guarantee that a stable sort provides) means+    /// nothing, while the extra costs still apply.+    ///+    /// **Known problems:**+    /// This lint only activates if the item being sorted is a `Vec`,+    /// and array, or a slice of primitive values. There may be other+    /// types which implemenet Deref to a slice of primitives, and calls+    /// to a sorting function on such types will not be detected.+    ///+    /// **Example:**+    ///+    /// ```rust+    /// let mut vec = vec![2, 1, 3];+    /// vec.sort();+    /// ```+    /// Use instead:+    /// ```rust+    /// let mut vec = vec![2, 1, 3];+    /// vec.sort_unstable();+    /// ```+    pub STABLE_SORT_PRIMITIVE,+    perf,+    "use of sort() when sort_unstable() is equivalent"+}++declare_lint_pass!(StableSortPrimitive => [STABLE_SORT_PRIMITIVE]);++/// The three "kinds" of sorts+enum SortingKind {+    Vanilla,+    /* The other kinds of lint are currently commented out because they+     * can map distinct values to equal ones. If the key function is+     * provably one-to-one, or if the Cmp function conserves equality,+     * then they could be linted on, but I don't know if we can check+     * for that. */++    /* ByKey,+     * ByCmp, */+}+impl SortingKind {+    /// The name of the stable version of this kind of sort+    fn stable_name(&self) -> &str {+        match self {+            SortingKind::Vanilla => "sort",+            /* SortingKind::ByKey => "sort_by_key",+             * SortingKind::ByCmp => "sort_by", */+        }+    }+    /// The name of the unstable version of this kind of sort+    fn unstable_name(&self) -> &str {+        match self {+            SortingKind::Vanilla => "sort_unstable",+            /* SortingKind::ByKey => "sort_unstable_by_key",+             * SortingKind::ByCmp => "sort_unstable_by", */+        }+    }+    /// Takes the name of a function call and returns the kind of sort+    /// that corresponds to that function name (or None if it isn't)+    fn from_stable_name(name: &str) -> Option<SortingKind> {+        match name {+            "sort" => Some(SortingKind::Vanilla),+            // "sort_by" => Some(SortingKind::ByCmp),+            // "sort_by_key" => Some(SortingKind::ByKey),+            _ => None,+        }+    }+}++/// A detected instance of this lint+struct LintDetection {+    slice_name: String,+    method: SortingKind,+    method_args: String,+}++/// Returns true iff the given type is a primitive which we should lint+/// on.+fn is_primitive_type(ty: Ty<'_>) -> bool {+    match ty.kind {+        ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) => true,+        ty::Array(inner_type, _) | ty::Slice(inner_type) => is_primitive_type(inner_type),+        ty::Tuple(inner_types) => inner_types.types().all(is_primitive_type),+        _ => false,+    }+}++/// Returns true iff the given expression is a slice of primitives or if+/// it is of some type that implements deref to such a slice+fn is_slice_of_primitives(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {+    let expr_type = cx.tables().expr_ty(expr);+    match expr_type.kind {+        ty::Slice(element_type) | ty::Array(element_type, _) => is_primitive_type(element_type),+        ty::Adt(_, substs_ref) => {+            if utils::match_type(cx, expr_type, &utils::paths::VEC) {+                // We could potentially check for other types which have the same sorting methods+                is_primitive_type(substs_ref.types().next().unwrap())+            } else {+                println!("is not a Vec");

:thinking:

JarredAllen

comment created time in a month

issue commentrust-lang/rust-clippy

Lint double negation `!count != 0`

I think I was mistaken about extending nonminimal_bool because I mistook !count != 0 for !(count != 0). I don't think any code in nonminimal_bool will help with this.

Maybe a better fit would be to add this to bit_mask module since there is a lot of bit comparison logic in there.

idubrov

comment created time in a month

pull request commentrust-lang/rust-clippy

redundant_closure_call - don't lint when used more than once

I think you might be able to handle shadowing by comparing the resolution of the paths by using qpath_res.

Check out how they do it in the loop lints: https://github.com/rust-lang/rust-clippy/blob/84cdce01cbd40bb41b8bcc7eb1cc0778acef6dce/clippy_lints/src/loops.rs#L1613-L1637

montrivo

comment created time in a month

PR opened rust-lang/rust-clippy

Add test for `needless_range_loop` issue

Closes #2277

This was fixed when we fixed #2542.

changelog: none

+10 -0

0 comment

1 changed file

pr created time in a month

create barnchmikerite/rust-clippy

branch : fix-2277-2

created branch time in a month

PR closed rust-lang/rust-clippy

Add test for `needless_range_loop` issue S-waiting-on-review

Closes #2277

This was fixed when we fixed #2542.

changelog: none

+10 -0

2 comments

1 changed file

mikerite

pr closed time in a month

pull request commentrust-lang/rust-clippy

Add test for `needless_range_loop` issue

Found a typo in my test. I'll send another pull request soon.

mikerite

comment created time in a month

PR opened rust-lang/rust-clippy

Add test for `needless_range_loop` issue

Closes #2277

This was fixed when we fixed #2542.

changelog: none

+10 -0

0 comment

1 changed file

pr created time in a month

create barnchmikerite/rust-clippy

branch : fix-2277

created branch time in a month

issue commentrust-lang/rust-clippy

Lint double negation `!count != 0`

This should probably be an enhancement to nonminimal_bool

idubrov

comment created time in a month

issue commentrust-lang/rust-clippy

Lint suggestion: Replace `.chars().enumerate()` with `.char_indices()` for `str` slices

These are only equivalent if the chars are all one byte each. Playground example

ansimita

comment created time in a month

delete branch mikerite/rust-clippy

delete branch : multiple_crate_versions_20200701

delete time in a month

push eventmikerite/rust-clippy

flip1995

commit sha 80bcbf521c7ff95e38a7567432b5519cc18e5b2a

Merge commit 'c2c07fa9d095931eb5684a42942a7b573a0c5238' into clippyup

view details

Ayaz Hafiz

commit sha 7c1b3aa0ddb81954a804455ca45fcf09fdb17dd8

Record span of `const` kw in GenericParamKind Context: this is needed to fix https://github.com/rust-lang/rustfmt/issues/4263, which currently records the span of a const generic param incorrectly because the location of the `const` kw is not known. I am not sure how to add tests for this; any guidance in how to do so would be appreciated :slightly_smiling_face:

view details

Eduardo Broto

commit sha 5987c7d4041ce5d72c8412d2ad73fe3b63308b51

cmp_owned: avoid FP when PartialEq is not implemented symmetrically

view details

Eduardo Broto

commit sha b498e1d71537a79e7aff5378da625aca8b4eef96

cmp_owned: reverse operands if necessary

view details

Tim Nielens

commit sha 6bf5434e19ce6d2a501589d1fcbc0d1748c531a6

copy_on_clone - add machine applicability

view details

bors

commit sha a14eab389f6e9f8bdaffbba184b20220041b036f

Auto merge of #5745 - montrivo:copy_on_clone, r=phansch clone_on_copy - add machine applicability Fix #4826. Change the applicability of the lint clone_on_copy. Split a test file and run rustfix on the clone_on_copy part. changelog: clone_on_copy - add machine applicability

view details

bors

commit sha 46d33043d5de0403a2a3dab9e7817041999bf9dd

Auto merge of #5701 - ebroto:4874_cmp_owned_fp, r=flip1995 cmp_owned: handle when PartialEq is not implemented symmetrically changelog: Handle asymmetrical implementations of PartialEq in [`cmp_owned`]. Fixes #4874

view details

Carol (Nichols || Goulding)

commit sha fa0f1d3e5353df04e3d2e68e65810ca1a231c220

Change a noun to a verb to make the sentence complete

view details

bors

commit sha 88fec89c16312de60ca7ab6d660b1ae8917b35f8

Auto merge of #5748 - carols10cents:tiny-docs-fix, r=flip1995 Change a noun to a verb to make the sentence complete changelog: Fixed some grammar in the documentation for `await_holding_lock`. Just a tiny little thing I found while using clippy <3

view details

Eduard-Mihai Burtescu

commit sha f5ce0e5fe960d09db01cf912c475cd1a52131120

rustc_lint: only query `typeck_tables_of` when a lint needs it.

view details

Manish Goregaokar

commit sha a671ea4d3f9d416d9520d2ea902cb9f48eb35898

Rollup merge of #73597 - ayazhafiz:i/const-span, r=ecstatic-morse Record span of `const` kw in GenericParamKind Context: this is needed for a fix of https://github.com/rust-lang/rustfmt/issues/4263, which currently records the span of a const generic param incorrectly because the location of the `const` kw is not known. I am not sure how to add tests for this; any guidance in how to do so would be appreciated :slightly_smiling_face:

view details

bors

commit sha 81810fa8f400b1d941b8bf14b2d085cf0a045ae1

Auto merge of #73756 - Manishearth:rollup-aehswb2, r=Manishearth Rollup of 13 pull requests Successful merges: - #72620 (Omit DW_AT_linkage_name when it is the same as DW_AT_name) - #72967 (Don't move cursor in search box when using arrows to navigate results) - #73102 (proc_macro: Stop flattening groups with dummy spans) - #73297 (Support configurable deny-warnings for all in-tree crates.) - #73507 (Cleanup MinGW LLVM linkage workaround) - #73588 (Fix handling of reserved registers for ARM inline asm) - #73597 (Record span of `const` kw in GenericParamKind) - #73629 (Make AssocOp Copy) - #73681 (Update Chalk to 0.14) - #73707 (Fix links in `SliceIndex` documentation) - #73719 (emitter: column width defaults to 140) - #73729 (disable collectionbenches for android) - #73748 (Add code block to code in documentation of `List::rebase_onto`) Failed merges: r? @ghost

view details

Dylan MacKenzie

commit sha 3c5ee3300f6c88f3d984d62ce704d17b7432f29c

Update tests

view details

flip1995

commit sha 1e861a2663fc970bc0530535020b4eb62fca257f

Merge remote-tracking branch 'upstream/master' into rustup2

view details

flip1995

commit sha ab649c920e18929c8f2b3399178bcfd1ecdcdd3e

Disable chrono integration test

view details

bors

commit sha ccf7cb3764728b26f5ccc0d7b3754f0c49319af3

Auto merge of #5751 - flip1995:rustup, r=Manishearth,flip1995 Rustup cc https://github.com/rust-lang/rust/pull/73743 r? @Manishearth changelog: none

view details

Eduardo Broto

commit sha 814349f9418b3d247e2e3cc952877e510f824fdd

Lint enabling the whole restriction group

view details

Eduardo Broto

commit sha c5d8f530e0625f14c5b4bedebdf0dc53064310c9

Move blanket_clippy_restriction_lints to "style"

view details

bors

commit sha d05d6abf89865bc701f6001bc20fe07506257e14

Auto merge of #5750 - ebroto:blanket_clippy_restriction_lints, r=Manishearth,flip1995,phansch,oli-obk Lint enabling the whole restriction group I've added it to the `correctness` category, but I may be missing some valid use cases. In that case it could be changed to `pedantic`. changelog: Add [`blanket_clippy_restriction_lints`] to check against enabling the whole restriction group.

view details

Eduardo Broto

commit sha bff6c435ef597071410af5d136916231f310c64c

Require `or_patterns` to suggest nesting them

view details

push time in a month

PR opened rust-lang/rust-clippy

Fix multiple_crate_versions error

Fix the versions of packages in the multiple_crate_versions ui test by checking in the Cargo.lock for the test package. ansi_term 0.11 depends on winapi ^0.3.4. This means means that the expected stderr for this test would have to be updated whenever winapi 0.3 is updated otherwise.

changelog: none

+109 -0

0 comment

1 changed file

pr created time in a month

create barnchmikerite/rust-clippy

branch : multiple_crate_versions_20200701

created branch time in a month

push eventmikerite/ebook-clipper-webextension

Michael Wright

commit sha 154c6d7520cd21341d8552448c5ed26e77781097

Update packages.js

view details

push time in 2 months

Pull request review commentrust-lang/rust-clippy

Lint enabling the whole restriction group

 declare_clippy_lint! {     "unknown_lints for scoped Clippy lints" } +declare_clippy_lint! {+    /// **What it does:** Checks for `warn`/`deny`/`forbid` attributes targeting the whole clippy::restriction category.+    ///+    /// **Why is this bad?** Restriction lints sometimes are in contrast with other lints or even go against idiomatic rust.+    /// These lints should only be enabled on a lint-by-lint basis and with careful consideration.+    ///+    /// **Known problems:** None.+    ///+    /// **Example:**+    /// Bad:+    /// ```rust+    /// #![deny(clippy::restriction)]+    /// ```+    ///+    /// Good:+    /// ```rust+    /// #![deny(clippy::as_conversions)]+    /// ```+    pub BLANKET_CLIPPY_RESTRICTION_LINTS,+    correctness,

Correctness lints are for "code that is just outright wrong or very very useless" so this fits IMO.

ebroto

comment created time in 2 months

issue commentrust-lang/rust-clippy

Some(_) is not equivalent to is_some()

Thinking a little more. It would have to be a temporary value that implements drop.

josh65536

comment created time in 2 months

issue commentrust-lang/rust-clippy

Some(_) is not equivalent to is_some()

The way I see this... if let Some(_) = func() keeps the clone around until the end of the block which the code gets to finish the drop. if let func.is_some() immediately drops the clone. Now the drop runs for the clone you just created but the cache lock hasn't been released yet. I'm not 100% sure to be honest....

According to the mutext docs "The exact behavior on locking a mutex in the thread which already holds the lock is left unspecified. However, this function will not return on the second call (it might panic or deadlock, for example)." If you're going to lock in a drop and make clones you need to be really careful.

In any case, maybe we can check if the type of func() implements drop and not lint in this case.

josh65536

comment created time in 2 months

delete branch mikerite/rust-clippy

delete branch : fix-5053-2

delete time in 2 months

delete branch mikerite/rust-clippy

delete branch : fix-cargo_metadata-0.9

delete time in 2 months

delete branch mikerite/rust-clippy

delete branch : fix-4958

delete time in 2 months

delete branch mikerite/rust-clippy

delete branch : loops-20200623-2

delete time in 2 months

push eventmikerite/rust-clippy

David Tolnay

commit sha 56f25e3e62dbdd8f84a9152bbfb73a35055363dd

Downgrade unnested_or_patterns to pedantic

view details

Matthias Krüger

commit sha 840786a93976d5885bfe6c7878cecc99e4a56432

clippy-driver: pass all args after "--rustc" to rustc.

view details

Matthias Krüger

commit sha 88ab10400b81338782c729e4193e47cd3ef1cab6

add test and remove debug print

view details

Matthias Krüger

commit sha f1d5cd5d13bbd59c21e70e2e728c3db9829cf816

add test for compiler output when compiling with rustc/clippy-driver

view details

Matthias Krüger

commit sha 7a62380fc8f8ca39bc49b8f67a4d4929911cb036

clippy-driver: fix test and add --rustc to --help output

view details

Eduardo Broto

commit sha b21ef2b365ef4f5c973327f3f6064b8be42d1dae

Fix ICE in consts::binop

view details

Bastian Kauschke

commit sha dee794f4503dda6a10891b49a7cb2f8bb92e001b

typo

view details

Iain Brandram-Adams

commit sha f663a21c8f51db58ff73e2e0d9852d03e8916a5e

Remove `bar` from blacklisted names

view details

Teddy_Wang

commit sha 40ee620e51c86c72e3c2b65df71f5f0a4a79797f

Added a lint for .map(|x| x)

view details

Iain Brandram-Adams

commit sha c020e45cd3c1f10d1271de8b47cea9e00b73f500

Update stderr to match, and reinforce comments

view details

Iain Brandram-Adams

commit sha 454ed47acf462c847956464ac3811546b733bd5b

Update comment in conf.rs

view details

Dániel Buga

commit sha 8a6f42a9707bbad1dad3f1511f793cd07c723bb7

Fix typo in wildcard_imports

view details

Ericko Samudera

commit sha 8c1ee063bb67b20ac17603d0f0025b48b958cc08

mem_replace_with_uninit: suggest std::ptr::read

view details

Eduardo Broto

commit sha a7743e9084f9ccd7c966f98a14fa667c694d66ab

redundant_pattern_matching: avoid non-const fn in const context

view details

sozysozbot

commit sha f3a40f5eb1cedebd374ebcd52341dfec60f3ea10

Fix typo extending it's lifetime -> extending its lifetime

view details

Ralf Jung

commit sha b92602ba692b03cc2f959f1927b4f909eb5e3fcc

Make is_freeze and is_copy_modulo_regions take TyCtxtAt

view details

Dylan DPC

commit sha 1d077f61091b3e73b047be3ec681a923b54f3bf0

Rollup merge of #73578 - RalfJung:ty-ctxt-at, r=jonas-schievink Make is_freeze and is_copy_modulo_regions take TyCtxtAt Make is_freeze and is_copy_modulo_regions take TyCtxtAt instead of separately taking TyCtxt and Span. This is consistent with is_sized.

view details

bors

commit sha c56c7e2d02920a8ec2dcb67c5f18d589af7ceb1c

Auto merge of #5695 - esamudera:lint_mem_uninitialized, r=phansch,oli-obk New lint: suggest `ptr::read` instead of `mem::replace(..., uninitialized())` resolves: #5575 changelog: improvements to `MEM_REPLACE_WITH_UNINIT`: - add a new test case in `tests/ui/repl_uninit.rs` to cover the case of replacing with `mem::MaybeUninit::uninit().assume_init()`. - modify the existing `MEM_REPLACE_WITH_UNINIT` when replacing with `mem::uninitialized` to suggest using `ptr::read` instead. - lint with `MEM_REPLACE_WITH_UNINIT` when replacing with `mem::MaybeUninit::uninit().assume_init()`

view details

Michael Wright

commit sha 52c486475774b7416e691323322ef1ea2db790de

Improve end of expression check in for loop lints The code should to check that the current expression _is_ the end expression; not that it's equal to it. The equality check seems very wasteful in terms of performance.

view details

Lzu Tao

commit sha 51c3b42ef33f14cb40aa440d2d432e4c70e028b0

Add more specific GitHub issue templates Apply suggestions from code review Co-authored-by: Philipp Krones <hello@philkrones.com>

view details

push time in 2 months

PR opened rust-lang/rust-clippy

Improve end of expression check in for loop lints

changelog: none

+1 -1

0 comment

1 changed file

pr created time in 2 months

create barnchmikerite/rust-clippy

branch : loops-20200623-2

created branch time in 2 months

delete branch mikerite/rust-clippy

delete branch : loops-20200623

delete time in 2 months

create barnchmikerite/rust-clippy

branch : loops-20200623

created branch time in 2 months

push eventmikerite/rust-clippy

Mark Rousskov

commit sha 318b8b6aabb2ef0fae0c0aafbba2c7ad97fb3a2a

Add hint for collect type

view details

Philipp Krones

commit sha d4092ace00d60634bcdc22135d82e05a53971263

Merge pull request #5584 from Mark-Simulacrum/beta-next Add hint for collect type

view details

Yuki Okushi

commit sha 9fd8e1088fe858b6a5da2b7e8baaeeacd26c6a31

Return early to avoid ICE

view details

Michael Wright

commit sha 6122612232976c1ac766a5d415265eb3eb30e72c

Increase cargo_metadata version to 0.9.1 `clippy_lints` makes use of `dep_kinds` on `NodeDep` but this was only added in versoin 0.9.1. Compiling with 0.9.0 will fail because of this.

view details

flip1995

commit sha 0ab823c509897ce2f516feb760fe1bf02cf77443

Rework suggestion generation of `unit_arg` lint

view details

flip1995

commit sha 380d941a045dc213ae28807d74fc32d1b1841e22

Adapt stderr and fixed files

view details

flip1995

commit sha a1a1a4b82a35b810570dbf7d2ee7f00896bee232

Use multiple span_suggestions instead of multipart_suggestion multipart suggestions aren't autofixable by rustfix yet

view details

flip1995

commit sha 0f69cafc2dd77d573e24870887a4a13cfe50515a

Rework suggestion generation and use multipart_suggestion again

view details

flip1995

commit sha f9c325f5b657e0c37ba2016a51cddbeab7f7693f

Suggest to remove the semicolon of the last stmt in a block

view details

flip1995

commit sha 4c9cefa12232aa0224b1680f51654fe10f5cf3b7

Move linting out in its own function

view details

flip1995

commit sha 6d15a149640e5647ce232690d54b540346fa1641

Update test files

view details

flip1995

commit sha a9cde3a804808e82402888a20878053404a8eded

Don't suggest to move empty blocks

view details

flip1995

commit sha 77dd0ea62aa6a2af70da4c5e05de064eee182a6c

Add tests for empty blocks

view details

bors

commit sha fcc3ed2cdc442b4d3b8f1cb2be5ef7686ff89b3c

Auto merge of #5669 - mikerite:fix-cargo_metadata-0.9, r=phansch Increase cargo_metadata version to 0.9.1 `clippy_lints` makes use of `dep_kinds` on `NodeDep` but this was only added in versoin 0.9.1. Compiling with 0.9.0 will fail because of this. changelog: none

view details

bors

commit sha 9fdcb13edb4026d1058c793a553f1798c044870c

Auto merge of #4455 - flip1995:unit_arg_appl, r=phansch Rework suggestion generation of `unit_arg` lint Found this bug while running `cargo fix --clippy` on quite a big codebase: This would replace something like: ```rust Some(fn_that_actually_does_something(&a, b)) ``` with ```rust Some(()) ``` which obviously suppresses side effects. Since pretty much every expression could have side effects, I think making this suggestion `MaybeIncorrect` is the best thing to do here. A correct suggestion would be: ```rust fn_that_actually_does_something(&a, b); Some(()) ``` Somehow the suggestion is not correctly applied to the arguments, when more than one argument is a unit value. I have to look into this a little more, though. changelog: Fixes suggestion of `unit_arg` lint, so that it suggests semantic equivalent code Fixes #4741

view details

Eduardo Broto

commit sha 14e9100543166e48acd0ea00233249d2cddf09c2

cargo-ui tests: check that <dir>/src exists before processing test

view details

JarredAllen

commit sha 7e843515d9525b6389c3fc1bcfa6ae046c1351dc

Created lint

view details

JarredAllen

commit sha 24847ea53e332853597aca2c7dfe48a9f3be1de8

Attempted start at sort_by_key_reverse lint

view details

JarredAllen

commit sha 8590ab4d46de4eb43e7ebd42cb2f13b0064573e6

More progress towards sort_by_key_reverse lint

view details

JarredAllen

commit sha 943cb94dce8fca6f3a3f7f011a2a2f9f0a665b97

Passes all tests now!

view details

push time in 2 months

pull request commentrust-lang/rust-clippy

should_impl_trait - ignore methods with lifetime params

Does this check handle elided lifetimes?

    pub fn next<'b>(&'b mut self) -> Option<&'b mut T> {
        unimplemented!();
    }

is equivalent to

    pub fn next(&mut self) -> Option<&mut T> {
        unimplemented!();
    }

but will the second form be linted.

Also, I think this check should only apply to the next method specifally. A method like

    fn eq<'a, 'b>(&'a self, other: &'b Self) -> bool { unimplemented!() }

can be moved to a PartialEq implementation regardless of lifetimes.

montrivo

comment created time in 2 months

pull request commentrust-lang/rust-clippy

Add unnecessary lazy evaluation lint

Does this get linted?

some_option.unwrap_or_else(|| Some(very_expensive_func()))
bugadani

comment created time in 2 months

issue commentrust-lang/rust-clippy

map_entry warning does not consider possible intervening code

There are cases. entry() mutably borrows the Hashmap so the suggestion is invalid if you're using the hashmap for something else in the block. See #4674.

jmafc

comment created time in 2 months

issue commentrust-lang/rust-clippy

ICE when running clippy on 'criner'

Here is a simple reproducer:

Byron

comment created time in 2 months

Pull request review commentrust-lang/rust-clippy

cmp_owned: avoid FP when PartialEq is not implemented symmetrically

+#![allow(clippy::redundant_clone)] // See #5700++#[derive(PartialEq)]+struct Foo;++struct Bar;++impl std::fmt::Display for Bar {+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+        write!(f, "bar")+    }+}++// NOTE: PartialEq<Bar> for T can't be implemented due to the orphan rules+impl<T> PartialEq<T> for Bar+where+    T: AsRef<str> + ?Sized,+{+    fn eq(&self, _: &T) -> bool {+        true+    }+}++// NOTE: PartialEq<Bar> for Foo is not implemented+impl PartialEq<Foo> for Bar {+    fn eq(&self, _: &Foo) -> bool {+        true+    }+}++impl ToOwned for Bar {+    type Owned = Foo;+    fn to_owned(&self) -> Foo {+        Foo+    }+}++impl std::borrow::Borrow<Bar> for Foo {+    fn borrow(&self) -> &Bar {+        static BAR: Bar = Bar;+        &BAR+    }+}++fn main() {+    let b = Bar {};+    if "Hi" == b.to_string() {}++    let f = Foo {};+    if f == b.to_owned() {}+}

What I mean is two structs where A,B where PartialEq<B> is implemented for A but Partial<A> is not implemented for B. Does a == b.to_owned() recommend a == b?

ebroto

comment created time in 2 months

Pull request review commentrust-lang/rust-clippy

cmp_owned: avoid FP when PartialEq is not implemented symmetrically

+#![allow(clippy::redundant_clone)] // See #5700++#[derive(PartialEq)]+struct Foo;++struct Bar;++impl std::fmt::Display for Bar {+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+        write!(f, "bar")+    }+}++// NOTE: PartialEq<Bar> for T can't be implemented due to the orphan rules+impl<T> PartialEq<T> for Bar+where+    T: AsRef<str> + ?Sized,+{+    fn eq(&self, _: &T) -> bool {+        true+    }+}++// NOTE: PartialEq<Bar> for Foo is not implemented+impl PartialEq<Foo> for Bar {+    fn eq(&self, _: &Foo) -> bool {+        true+    }+}++impl ToOwned for Bar {+    type Owned = Foo;+    fn to_owned(&self) -> Foo {+        Foo+    }+}++impl std::borrow::Borrow<Bar> for Foo {+    fn borrow(&self) -> &Bar {+        static BAR: Bar = Bar;+        &BAR+    }+}++fn main() {+    let b = Bar {};+    if "Hi" == b.to_string() {}++    let f = Foo {};+    if f == b.to_owned() {}+}

What if you implement ToOwned for Foo and then compare b == f.to_owned()? Will it still lint?

ebroto

comment created time in 2 months

Pull request review commentrust-lang/rust-clippy

cmp_owned: avoid FP when PartialEq is not implemented symmetrically

+#![allow(clippy::redundant_clone)] // See #5700++#[derive(PartialEq)]+struct Foo;++struct Bar;++impl std::fmt::Display for Bar {+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+        write!(f, "bar")+    }+}++// NOTE: PartialEq<Bar> for T can't be implemented due to the orphan rules+impl<T> PartialEq<T> for Bar+where+    T: AsRef<str> + ?Sized,+{+    fn eq(&self, _: &T) -> bool {+        true+    }+}++// NOTE: PartialEq<Bar> for Foo is not implemented+impl PartialEq<Foo> for Bar {+    fn eq(&self, _: &Foo) -> bool {+        true+    }+}++impl ToOwned for Bar {+    type Owned = Foo;+    fn to_owned(&self) -> Foo {+        Foo+    }+}++impl std::borrow::Borrow<Bar> for Foo {+    fn borrow(&self) -> &Bar {+        static BAR: Bar = Bar;+        &BAR+    }+}++fn main() {+    let b = Bar {};+    if "Hi" == b.to_string() {}++    let f = Foo {};+    if f == b.to_owned() {}

I believe it's possible to recommend if b == f {} instead, which would be better.

ebroto

comment created time in 2 months

issue commentrust-lang/rust-clippy

map_entry warning does not consider possible intervening code

What about...

if let Entry::Vacant(v) = seen.entry(url) {
    v.push(Href {url: url.clone(), title: row.get("title")});
    entry.insert(1);
}

Now you're only looking up the key once so it should be faster. Aside from looking nicer.

jmafc

comment created time in 2 months

pull request commentrust-lang/rust-clippy

Increase cargo_metadata version to 0.9.1

The latest version of cargo_metadata is 0.10.0. I don't know if there is any reason not to switch to that but I kept this change conservative.

mikerite

comment created time in 2 months

push eventmikerite/rust-clippy

Philipp Hansch

commit sha 4d1a11d354c77213a98f76b07933ebb26822d017

Deprecate util/dev in favor of cargo alias If you've been using `./util/dev` before, this now becomes `cargo dev`. The key part of this change is found in `.cargo/config`. This means one less shell script and a bit more cross-platform support for contributors.

view details

Philipp Hansch

commit sha 3036a2c30e870f589a6176f25682b41b9b8fb4f8

Move project_root function to clippy_dev/src/lib.rs This allows us to use the method in both `fmt.rs` and `lib.rs` in multiple places. The downside is that we panic inside the method now, instead of using the error handling in `fmt.rs`. We may want to centralize the error handling for clippy_dev at some point, though.

view details

Ludwig Stecher

commit sha f0dc98160be8367fd011438da90fcce1d19e5b38

Fix syntax highlighting of code fence The documentation for RESULT_EXPECT_USED includes this code: let res: Result<usize, ()> = Ok(1); res?; # Ok::<(), ()>(()) Because the code fence didn't start with `rust`, the code wasn't highlighted and the line starting with `#` was displayed on the website. This is now fixed.

view details

bors

commit sha bbef531518a3b4977a9c1f40808f950514b400fc

Auto merge of #5108 - JohnTitor:split-up-0130, r=flip1995 Split up `match` ui test Part of #2038 Also, this decreases the line length limit to 220. changelog: none

view details

Ludwig Stecher

commit sha 58da5ba6db0772f676022ce80621f4f06661a7ab

Fix code formatting for more lints

view details

flip1995

commit sha 1ef4509eb46056e52a8c54cb78df01ae60305a32

Update changelog

view details

Ludwig Stecher

commit sha 1f600f3f9a815efaf8c627d0a9af4eb836ffa7a2

Un-ignore most code blocks to render correctly on website, correct mistakes

view details

bors

commit sha 8e9089e454b04b8bad5ed6678050f1cc290a74b3

Auto merge of #5110 - Aloso:patch-1, r=flip1995 Fix syntax highlighting of code fences The documentation for RESULT_EXPECT_USED includes this code: let res: Result<usize, ()> = Ok(1); res?; # Ok::<(), ()>(()) Because the code fence didn't start with `rust`, the code wasn't highlighted and the line starting with `#` was displayed on the website. This is now fixed. EDIT: I noticed that highlighting for some other lints is broken as well. It only works if the code fence looks like this: ````markdown ```rust // .. ``` ```` However, many code blocks were ignored. I un-ignored most code blocks and made them compile by adding hidden code with `#`. While doing so, I found two mistakes: ```rust opt.map_or(None, |a| a + 1) // instead of opt.map_or(None, |a| Some(a + 1)) ``` and ```rust fn as_str(self) -> &str // instead of fn as_str(self) -> &'static str ``` changelog: none

view details

Philipp Hansch

commit sha 3f2532b904f2ed38e69073d12a07c6aa32672197

Replace one more copy-pasted clippy_project_root fn

view details

Phil Hansch

commit sha 8f457fa4c99c39ec5c2428922d6f7cc3fec84f59

Mark clippy_project_root as `must_use` Co-Authored-By: Philipp Krones <hello@philkrones.com>

view details

bors

commit sha ca2abaf3667771ed5d7ab602792d472b032ca445

Auto merge of #5109 - phansch:ciao_util_dev, r=flip1995 Deprecate util/dev in favor of cargo alias This means one less shell script and a bit more cross-platform support for contributors. If you've been using `./util/dev` before, this now becomes `cargo dev`. The key part of this change is found in `.cargo/config` where an alias for calling the `clippy_dev` binary is defined. changelog: none

view details

bors

commit sha b90101251f19760f0841daa4ad8b2978a50bafb8

Auto merge of #5111 - flip1995:changelog, r=phansch Update changelog [Rendered](https://github.com/flip1995/rust-clippy/blob/changelog/CHANGELOG.md) r? @phansch changelog: none

view details

flip1995

commit sha b31a3dff480ffad248fa5b2c66fbe9b9d6726314

Small refactor of mutable_debug_assertions

view details

flip1995

commit sha 9fbd7f478e59cca00011b6ac0ed89bada8823e2a

Don't trigger `debug_assert_with_mut_call` on `.await`

view details

flip1995

commit sha 006f07f090894f09910fe6f15e5a670a955f8166

Add test for `await` in `debug_assert!(..)`

view details

flip1995

commit sha 5ba4aa8ebab79ffff4cb621fa22a07d32ea41b1f

Move debug_assertions_with_mut_call to nursery

view details

bors

commit sha 5826a0472dbdda1aa306a03b370f4eb65e895f20

Auto merge of #5106 - flip1995:dbg_assert_mut_async, r=oli-obk Don't trigger [debug_assert_with_mut_call] on debug_assert!(_.await) Fixes #5105 cc #5112 changelog: Don't trigger [`debug_assert_with_mut_call`] on `debug_assert!(_.await)` and move it to nursery.

view details

Matthias Krüger

commit sha 187983e9919fd181fba69c1d8a71a68aa45ac77b

update test stderr

view details

bors

commit sha f3e2ccd54e785cc7120f30ad41cd8b28bb2bbcd0

Auto merge of #5116 - matthiaskrgr:rustup_29, r=flip1995 update test stderr changelog: none

view details

Yuki Okushi

commit sha 0f67a7ecb5822a0ec5bdb5ebad50091e20074247

Pin versions to trigger lint correctly

view details

push time in 2 months

PR opened rust-lang/rust-clippy

Increase cargo_metadata version to 0.9.1

clippy_lints makes use of dep_kinds on NodeDep but this was only added in versoin 0.9.1. Compiling with 0.9.0 will fail because of this.

+2 -2

0 comment

2 changed files

pr created time in 2 months

create barnchmikerite/rust-clippy

branch : fix-cargo_metadata-0.9

created branch time in 2 months

more