Commit Graph

4000 Commits

Author SHA1 Message Date
Vadim Petrochenkov
52a9c157d0 rustc_ast: (Nested)MetaItem::check_name -> has_name
For consistency with `Attribute::has_name` which doesn't mark the attribute as used either.

Replace all uses of `check_name` with `has_name` outside of rustc
2020-08-04 00:34:11 +03:00
Valentin Lazureanu
aa3d9ca0e9 Rename HAIR to THIR (Typed HIR). 2020-07-31 22:15:12 +00:00
Bastian Kauschke
133e1d6773 clippy 2020-07-27 21:17:28 +02:00
Bastian Kauschke
6ce37fab95 introduce PredicateAtom 2020-07-27 21:07:37 +02:00
Bastian Kauschke
88787083f4 this might be unqualified, but at least it's now quantified 2020-07-27 21:06:36 +02:00
Bastian Kauschke
dfa1af2059 clippy 2020-07-27 21:06:36 +02:00
flip1995
d164ab65f7 Merge commit 'da5a6fb1b65ec6581a67e942a3850f6bc15a552c' into clippyup 2020-07-26 21:07:07 +02:00
David Wood
b7c8b96e66 trait_sel: only test predicates w/ no substs
This commit modifies the `substitute_normalize_and_test_predicates`
query, renaming it to `impossible_predicates` and only checking
predicates which do not require substs. By making this change,
polymorphization doesn't have to explicitly support vtables.

Signed-off-by: David Wood <david@davidtw.co>
2020-07-20 11:23:26 +01:00
Valentin Lazureanu
5a20489c5c Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
Nicholas Nethercote
62db617e40 Avoid storing SymbolStr in a struct.
It's intended only for very temporary use.
2020-07-17 08:28:22 +10:00
Bastian Kauschke
bf3104ec24 WithOptConstParam::dummy -> WithOptConstParam::unknown 2020-07-15 13:06:47 +02:00
Bastian Kauschke
c5b9463d26 improve naming 2020-07-15 13:06:47 +02:00
Bastian Kauschke
29de25b8a2 const_eval_resolve 2020-07-15 12:58:32 +02:00
Nicholas Nethercote
f2f99be2ff Remove lots of Symbol::as_str() calls.
In various ways, such as changing functions to take a `Symbol` instead
of a `&str`.
2020-07-15 09:01:35 +10:00
flip1995
6f25adbd5a Merge commit '2ca58e7dda4a9eb142599638c59dc04d15961175' into clippyup 2020-07-14 14:59:59 +02:00
Tamir Duberstein
cf91c54cc6 Avoid "whitelist"
Other terms are more inclusive and precise.
2020-07-10 07:39:28 -04:00
bors
c41fcad908 Auto merge of #74117 - Manishearth:rollup-ds7z0kx, r=Manishearth
Rollup of 14 pull requests

Successful merges:

 - #70563 ([rustdoc] Page hash handling)
 - #73856 (Edit librustc_lexer top-level docs)
 - #73870 (typeck: adding type information to projection)
 - #73953 (Audit hidden/short code suggestions)
 - #73962 (libstd/net/tcp.rs: #![deny(unsafe_op_in_unsafe_fn)])
 - #73969 (mir: mark mir construction temporaries as internal)
 - #73974 (Move A|Rc::as_ptr from feature(weak_into_raw) to feature(rc_as_ptr))
 - #74067 (rustdoc: Restore underline text decoration on hover for FQN in header)
 - #74074 (Fix the return type of Windows' `OpenOptionsExt::security_qos_flags`.)
 - #74078 (Always resolve type@primitive as a primitive, not a module)
 - #74089 (Add rust-analyzer to the build manifest)
 - #74090 (Remove unused RUSTC_DEBUG_ASSERTIONS)
 - #74102 (Fix const prop ICE)
 - #74112 (Expand abbreviation in core::ffi description)

Failed merges:

r? @ghost
2020-07-07 00:56:44 +00:00
Manish Goregaokar
245b006a2e Rollup merge of #73870 - sexxi-goose:projection-ty, r=nikomatsakis
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
2020-07-06 17:45:20 -07:00
bors
4705037374 Auto merge of #73978 - Mark-Simulacrum:shrink-paramenv, r=nnethercote
Shrink ParamEnv to 16 bytes

r? @nnethercote

x.py check passes but I haven't tried running perf or tests
2020-07-06 20:44:16 +00:00
Mark Rousskov
3503247c11 Shrink ParamEnv to 16 bytes 2020-07-05 09:51:42 -04:00
Eduard-Mihai Burtescu
30c046ede4 Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
Eduard-Mihai Burtescu
590e07bbc2 rustc_lint: avoid using TypeckTables::empty for LateContext. 2020-07-02 16:51:04 +03:00
Azhng
dfecaef914 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
2020-06-29 16:46:52 -04:00
bors
81810fa8f4 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
2020-06-26 10:11:43 +00:00
Manish Goregaokar
a671ea4d3f 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 🙂
2020-06-26 00:39:08 -07:00
Eduard-Mihai Burtescu
f5ce0e5fe9 rustc_lint: only query typeck_tables_of when a lint needs it. 2020-06-26 02:56:23 +03:00
Ayaz Hafiz
7c1b3aa0dd 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 🙂
2020-06-23 09:25:46 -07:00
flip1995
80bcbf521c Merge commit 'c2c07fa9d095931eb5684a42942a7b573a0c5238' into clippyup 2020-06-23 17:05:22 +02:00
Ralf Jung
b92602ba69 Make is_freeze and is_copy_modulo_regions take TyCtxtAt 2020-06-21 11:47:19 +02:00
Aman Arora
922ff8e485 Refactor hir::Place
For the following code
```rust
let c = || bar(foo.x, foo.x)
```

We generate two different `hir::Place`s for both `foo.x`.
Handling this adds overhead for analysis we need to do for RFC 2229.

We also want to store type information at each Projection to support
analysis as part of the RFC. This resembles what we have for
`mir::Place`

This commit modifies the Place as follows:
- Rename to `PlaceWithHirId`, where there `hir_id` is that of the
expressioin.
- Move any other information that describes the access out to another
struct now called `Place`.
- Removed `Span`, it can be accessed using the [hir
API](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html#method.span)
- Modify `Projection` to be a strucutre of its own, that currently only
contains the `ProjectionKind`.

Adding type information to projections wil be completed as part of https://github.com/rust-lang/project-rfc-2229/issues/5

Closes https://github.com/rust-lang/project-rfc-2229/issues/3

Co-authored-by: Aman Arora <me@aman-arora.com>
Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
2020-06-18 18:59:38 -04:00
Ralf Jung
93696f45ff Rollup merge of #72938 - lzutao:stabilize_option_zip, r=dtolnay
Stabilize Option::zip

This PR stabilizes the following API:

```rust
impl<T> Option<T> {
    pub fn zip<U>(self, other: Option<U>) -> Option<(T, U)>;
}
```

This API has real world usage as seen in <https://grep.app/search?q=-%3E%20Option%3C%5C%28T%2C%5Cs%3FU%5C%29%3E&regexp=true&filter[lang][0]=Rust>.

The `zip_with` method is left unstably as this API is kinda niche
and it hasn't received much usage in Rust repositories on GitHub.

cc #70086
2020-06-15 12:01:03 +02:00
bors
9217ef2018 Auto merge of #72080 - matthewjasper:uniform-impl-trait, r=nikomatsakis
Clean up type alias impl trait implementation

- Removes special case for top-level impl trait
- Removes associated opaque types
- Forbid lifetime elision in let position impl trait. This is consistent with the behavior for inferred types.
- Handle lifetimes in type alias impl trait more uniformly with other parameters

cc #69323
cc #63063
Closes #57188
Closes #62988
Closes #69136
Closes #73061
2020-06-15 04:10:24 +00:00
Lzu Tao
994a839622 Stabilize Option::zip 2020-06-13 01:27:18 +00:00
Dylan DPC
7c15f30701 Rollup merge of #72906 - lzutao:migrate-numeric-assoc-consts, r=dtolnay
Migrate to numeric associated consts

The deprecation PR is #72885

cc #68490
cc rust-lang/rfcs#2700
2020-06-12 12:28:23 +02:00
Matthew Jasper
af9b09235c Remove ImplItemKind::OpaqueTy from clippy 2020-06-11 16:24:01 +01:00
Matthew Jasper
857ea16feb Remove associated opaque types
They're unused now.
2020-06-11 16:24:01 +01:00
Aaron Hill
e2e2a0fa83 Clippy fixes 2020-06-10 17:30:12 -04:00
Aaron Hill
6b3ee8f600 Update Clippy for MethodCall changes 2020-06-10 17:30:11 -04:00
Lzu Tao
c9bd35cac3 Migrate to numeric associated consts 2020-06-10 01:35:47 +00:00
Lzu Tao
8db24840f7 Merge commit 'ff0993c5e9162ddaea78e83d0f0161e68bd4ea73' into clippy 2020-06-09 14:36:01 +00:00
Ralf Jung
161474b7f7 Rollup merge of #72508 - ecstatic-morse:poly-self-ty, r=nikomatsakis
Make `PolyTraitRef::self_ty` return `Binder<Ty>`

This came up during review of #71618. The current implementation is the same as a call to `skip_binder` but harder to audit. Make it preserve binding levels and add a call to `skip_binder` at all use sites so they can be audited as part of #72507.
2020-06-06 21:57:38 +02:00
bors
b059c0a2e6 Auto merge of #72927 - petrochenkov:rustc, r=Mark-Simulacrum
Rename all remaining compiler crates to use the `rustc_foo` pattern

libarena -> librustc_arena
libfmt_macros -> librustc_parse_format
libgraphviz -> librustc_graphviz
libserialize -> librustc_serialize

Closes https://github.com/rust-lang/rust/issues/71177 in particular.
2020-06-06 09:00:51 +00:00
Mark Rousskov
0c470b3339 Bump to 1.46 2020-06-03 15:27:51 -04:00
Vadim Petrochenkov
bd3fc11416 Update fulldeps tests and clippy 2020-06-03 00:18:57 +03:00
Vadim Petrochenkov
2b79413491 Rename the crates in source code 2020-06-02 20:42:54 +03:00
Dylan MacKenzie
ea06c72fdd Call skip_binder or no_bound_vars before self_ty 2020-06-01 12:18:57 -07:00
Yuki Okushi
9fd8e1088f Return early to avoid ICE 2020-05-30 18:48:54 +09:00
flip1995
a0e9f9bd0d Merge commit '7ea7cd165ad6705603852771bf82cc2fd6560db5' into clippyup2 2020-05-28 15:45:24 +02:00
Bastian Kauschke
e820a03d1c iterate List by value 2020-05-23 12:24:19 +02:00
Dylan MacKenzie
b3a690f5a1 Use OnceCell instead of Once 2020-05-22 13:31:02 -07:00
Bastian Kauschke
091239ee60 introduce newtype'd Predicate<'tcx> 2020-05-20 15:44:34 +02:00
Bastian Kauschke
2722522fac rename Predicate to PredicateKind, introduce alias 2020-05-20 15:38:03 +02:00
Amanieu d'Antras
d25b25610b Handle InlineAsm in clippy 2020-05-18 14:41:33 +01:00
flip1995
f1d3086492 Merge commit 'e214ea82ad0a751563acf67e1cd9279cf302db3a' into clippyup 2020-05-17 17:36:26 +02:00
Ralf Jung
8bba1b7589 Rollup merge of #72047 - Julian-Wollersberger:literal_error_reporting_cleanup, r=petrochenkov
Literal error reporting cleanup

While doing some performance work, I noticed some code duplication in `librustc_parser/lexer/mod.rs`, so I cleaned it up.

This PR is probably best reviewed commit by commit.

I'm not sure what the API stability practices for `librustc_lexer` are. Four public methods in `unescape.rs` can be removed, but two are used by clippy, so I left them in for now.
I could open a PR for Rust-Analyzer when this one lands.

But how do I open a PR for clippy? (Git submodules are frustrating to work with)
2020-05-16 19:46:31 +02:00
Dylan DPC
b0490cc80d Rollup merge of #71948 - csmoe:issue-61076, r=oli-obk
Suggest to await future before ? operator

Closes https://github.com/rust-lang/rust/issues/71811
cc #61076
2020-05-16 02:37:21 +02:00
csmoe
0a86335cd4 implement type_implments_trait query 2020-05-15 15:37:11 +08:00
Julian Wollersberger
ff9a9ed37c Replace some usages of the old unescape_ functions in AST, clippy and tests. 2020-05-13 10:05:04 +02:00
flip1995
d13d8987b0 Merge commit '43a1777b89cf6791f9e20878b4e5e3ae907867a5' into clippyup 2020-05-11 20:23:47 +02:00
Camille GILLOT
31c84e5077 Fix clippy. 2020-05-08 13:57:01 +02:00
Dylan MacKenzie
41fe5c1ca7 Update clippy lint 2020-05-03 11:41:03 -07:00
Matthias Krüger
b7800e1ac3 mismatched_target_os: link to respective section in rust reference 2020-05-01 01:21:24 +02:00
CrazyRoka
20c069beec Fixed incorrect suggestion of clone_double_ref lint
- Added `<_>` to suggestion
- Changed help message
2020-04-29 22:40:57 +03:00
Matthias Krüger
bdc9528e7c rustup https://github.com/rust-lang/rust/pull/71292/ 2020-04-28 15:05:56 +02:00
Eduardo Broto
3a96f548d1 used_underscore_binding: do not lint on await desugaring 2020-04-27 21:20:08 +02:00
csmoe
305177d9cc rustup: rust-lang/rust#71628 2020-04-27 22:40:56 +08:00
bors
d13ffbe3fe Auto merge of #5522 - CrazyRoka:match_vec_item, r=phansch
New  lint `match_vec_item`

Added new lint to warn a match on index item which can panic. It's always better to use `get(..)` instead.
Closes #5500
changelog: New lint `match_on_vec_items`
2020-04-27 06:02:05 +00:00
Eduardo Broto
ce50e42ed6 Use the span of the attribute for the error message 2020-04-26 21:27:29 +02:00
Eduardo Broto
d24a106395 Apply suggestions from PR review
- Show just one error message with multiple suggestions in case of
  using multiple times an OS in target family position
- Only suggest #[cfg(unix)] when the OS is in the Unix family
- Test all the operating systems
2020-04-26 21:27:29 +02:00
Eduardo Broto
149f6d6046 Implement mismatched_target_os lint 2020-04-26 21:27:29 +02:00
CrazyRoka
b574941dcb Updated lint info in lib.rs 2020-04-26 18:11:21 +03:00
CrazyRoka
940c662654 Small lint update
- Changed lint category to `correctness`
- Moved main function to bottom in test file
- Added `FIXME` comment to `span_lint_and_sugg` to improve later
2020-04-26 18:00:51 +03:00
Philipp Hansch
eda73fe707
Fix cargo crash 2020-04-26 14:11:58 +02:00
Philipp Hansch
0a49935270
cargo dev fmt 2020-04-26 13:44:08 +02:00
Philipp Hansch
0480ff861a
More diagnostic items
In particular for:

* `VecDeque`
* `String`
* `Mutex`
* `HashMap`
* `HashSet`

cc https://github.com/rust-lang/rust/pull/71414 https://github.com/rust-lang/rust-clippy/issues/5393
2020-04-26 13:44:08 +02:00
Philipp Hansch
5b1622b324
rustup to https://github.com/rust-lang/rust/pull/70043 2020-04-26 10:12:14 +02:00
bors
07dd5fada9 Auto merge of #5511 - alex-700:fix-redundant-pattern-matching, r=flip1995
Fix redundant_pattern_matching lint

fixes #5504

changelog: Fix suggestion in `redundant_pattern_matching` for macros.
2020-04-25 21:41:56 +00:00
bors
44eb953adc Auto merge of #5525 - flip1995:issue_1654, r=phansch
Don't trigger while_let_on_iterator when the iterator is recreated every iteration

r? @phansch

Fixes #1654

changelog: Fix false positive in [`while_let_on_iterator`]
2020-04-25 21:29:03 +00:00
bors
a76bfd46c5 Auto merge of #5530 - ebroto:issue_5524, r=flip1995
map_clone: avoid suggesting `copied()` for &mut

changelog: map_clone: avoid suggesting `copied()` for &mut

Fixes #5524
2020-04-25 21:16:06 +00:00
Eduardo Broto
806d973adc map_clone: avoid suggesting copied() for &mut 2020-04-25 22:52:19 +02:00
Aleksei Latyshev
69fe6b4c98
fix redundant_pattern_matching lint
- now it gives correct suggestion in case of macros
- better tests
- remove a couple of non-relevant tests
2020-04-25 23:51:30 +03:00
Philipp Krones
a33d64a4c3
Rollup merge of #5505 - flip1995:avoid_running_lints, r=matthiaskrgr
Avoid running cargo+internal lints when not enabled

r? @matthiaskrgr

changelog: none
2020-04-25 21:06:27 +02:00
Philipp Krones
e1d13c34b0
Rollup merge of #5408 - dtolnay:matchbool, r=flip1995
Downgrade match_bool to pedantic

I don't quite buy the justification in https://rust-lang.github.io/rust-clippy/. The justification is:

> It makes the code less readable.

In the Rust codebases I've worked in, I have found people were comfortable using `match bool` (selectively) to make code more readable. For example, initializing struct fields is a place where the indentation of `match` can work better than the indentation of `if`:

```rust
let _ = Struct {
    v: {
        ...
    },
    w: match doing_w {
        true => ...,
        false => ...,
    },
    x: Nested {
        c: ...,
        b: ...,
        a: ...,
    },
    y: if doing_y {
        ...
    } else { // :(
        ...
    },
    z: ...,
};
```

Or sometimes people prefer something a bit less pithy than `if` when the meaning of the bool doesn't read off clearly from the condition:

```rust
if set.insert(...) {
    ... // ???
} else {
    ...
}

match set.insert(...) {
    // set.insert returns false if already present
    false => ...,
    true => ...,
}
```

Or `match` can be a better fit when the bool is playing the role more of a value than a branch condition:

```rust
impl ErrorCodes {
    pub fn from(b: bool) -> Self {
        match b {
            true => ErrorCodes::Yes,
            false => ErrorCodes::No,
        }
    }
}
```

And then there's plain old it's-1-line-shorter, which means we get 25% more content on a screen when stacking a sequence of conditions:

```rust
let old_noun = match old_binding.is_import() {
    true => "import",
    false => "definition",
};
let new_participle = match new_binding.is_import() {
    true => "imported",
    false => "defined",
};
```

Bottom line is I think this lint fits the bill better as a pedantic lint; I don't think linting on this by default is justified.

changelog: Remove match_bool from default set of enabled lints
2020-04-25 21:06:26 +02:00
flip1995
eadd9d24dc
Don't trigger while_let_on_iterator when the iterator is recreated every iteration 2020-04-25 20:51:02 +02:00
flip1995
fe25dbe549
Fix while_let_on_iterator suggestion and make it MachineApplicable 2020-04-25 20:00:00 +02:00
CrazyRoka
63b451ea25 Renamed lint to match_on_vec_items 2020-04-25 11:34:16 +03:00
CrazyRoka
b0115fb996 Removed unnecessary code, added support for vector references 2020-04-25 00:52:02 +03:00
CrazyRoka
96e2bc80f5 Added lint match_vec_item 2020-04-24 22:45:15 +03:00
Matthias Krüger
f9c1acbc45
rustup https://github.com/rust-lang/rust/pull/71215/ 2020-04-24 15:29:31 +02:00
David Tolnay
ef28361293
Downgrade match_bool to pedantic 2020-04-23 16:30:06 -07:00
lzutao
3f6f392730 predecessors_for will be removed soon
Co-Authored-By: ecstatic-morse <ecstaticmorse@gmail.com>
2020-04-23 09:09:09 +07:00
Lzu Tao
9ef9b7946f Rustup "Remove BodyAndCache" 2020-04-23 08:39:35 +07:00
flip1995
f31502f4bb
Only run (late) internal lints, when they are warn/deny/forbid 2020-04-22 20:51:58 +02:00
flip1995
14f596cb74
Only run cargo lints, when they are warn/deny/forbid 2020-04-22 20:32:37 +02:00
Andy Weiss
8b052d3142 span_lint_and_note now takes an Option<Span> for the note_span instead of just a span 2020-04-21 21:28:23 -07:00
Andy Weiss
d6e55e97ff Make lint also capture blocks and closures, adjust language to mention other mutex types 2020-04-21 21:07:43 -07:00
Andy Weiss
54e7f7e5f2 don't test the code in the lint docs 2020-04-21 21:07:43 -07:00
Andy Weiss
2dc8c083f5 Switch to matching against full paths instead of just the last element of the path 2020-04-21 21:07:43 -07:00
Andy Weiss
6c25c3c381 Lint for holding locks across await points
Fixes #4226

This introduces the lint await_holding_lock. For async functions, we iterate
over all types in generator_interior_types and look for types named MutexGuard,
RwLockReadGuard, or RwLockWriteGuard. If we find one then we emit a lint.
2020-04-21 21:07:43 -07:00
Matthias Krüger
7221db2dc3 fix crash on issue-69020-assoc-const-arith-overflow.rs
Fixes #5497
2020-04-20 23:01:34 +02:00
bors
6ce05bf849 Auto merge of #5332 - DevinR528:if-let-else-mutex, r=flip1995
If let else mutex

changelog: Adds lint to catch incorrect use of `Mutex::lock` in `if let` expressions with lock calls in any of the blocks.

closes: #5219
2020-04-20 20:21:33 +00:00
Devin R
489dd2e504 factor ifs into function, add differing mutex test 2020-04-20 15:08:44 -04:00
Eduardo Broto
b7f85e8706 Apply suggestions from PR review
* Move the lint to pedantic
* Import used types instead of prefixing with `hir::`
2020-04-20 20:05:15 +02:00
Devin R
d1b1a4c5eb update span_lint_and_help call to six args 2020-04-20 06:49:59 -04:00
Devin R
a9f1bb43ef test for mutex eq, add another test case 2020-04-20 06:30:01 -04:00
Devin R
ae820924c4 use if chain 2020-04-20 06:30:01 -04:00
Devin R
4cebe2bf84 cargo dev fmt 2020-04-20 06:30:01 -04:00
Devin R
7242fa5e41 fix map import to rustc_middle 2020-04-20 06:30:01 -04:00
Devin R
1ee04e4f55 fix internal clippy warnings 2020-04-20 06:30:01 -04:00
Devin R
930619b484 change visitor name to OppVisitor 2020-04-20 06:30:01 -04:00
Devin R
c6c77d9a42 use Visitor api to find Mutex::lock calls 2020-04-20 06:30:00 -04:00
Devin R
fca3537fa3 add note about update-all-refs script, revert redundant pat to master 2020-04-20 06:30:00 -04:00
Devin R
51c2325dd7 move closures to seperate fns, remove known problems 2020-04-20 06:30:00 -04:00
Devin R
40bbdffc89 use span_lint_and_help, cargo dev fmt 2020-04-20 06:30:00 -04:00
Devin R
139e2c6227 creating suggestion 2020-04-20 06:30:00 -04:00
Devin R
001a42e632 progress work on suggestion for auto fix 2020-04-20 06:29:59 -04:00
Eduardo Broto
00b4f2819f Implement unsafe_derive_deserialize lint 2020-04-19 23:26:17 +02:00
bors
6dcc8d5038 Auto merge of #5141 - xiongmao86:issue5095, r=flip1995
Fixes issue 5095

fixes #5095.

- [x] Followed [lint naming conventions][lint_naming]
- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Executed `cargo dev update_lints`
- [x] Added lint documentation
- [x] Run `cargo dev fmt`

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

changelog: (internal) warn about collapsible `span_lint_and_then` calls.
2020-04-19 19:19:54 +00:00
bors
2efc2d6366 Auto merge of #5491 - smklein:borrowed_box, r=flip1995
Fix issue #2907.

Update the "borrow box" lint to avoid recommending the following
conversion:

```
  // Old
  pub fn f(&mut Box<T>) {...}

  // New
  pub fn f(&mut T) {...}
```

Given a mutable reference to a box, functions may want to change
"which" object the Box is pointing at.

This change avoids recommending removing the "Box" parameter
for mutable references.

changelog: Don't trigger [`borrow_box`] lint on `&mut Box` references
2020-04-19 18:59:23 +00:00
Philipp Krones
98a244fc27
Formatting and naming 2020-04-19 20:40:25 +02:00
Philipp Krones
41115d994a
Formatting and naming 2020-04-19 20:38:07 +02:00
bors
e5fe56de7f Auto merge of #5489 - phansch:node-id-hir-id, r=flip1995
Cleanup: `node_id` -> `hir_id`

This removes some more `node_id` terminology from Clippy and replaces one occurrence of `as_local_node_id` with `as_local_hir_id`, which should be doing the same for that particular case.

changelog: none
2020-04-19 18:09:34 +00:00
bors
6ed2ae8685 Auto merge of #5488 - phansch:future-not-send-ret-ty, r=flip1995
Cleanup: future_not_send: use `utils::return_ty` function

changelog: none
2020-04-19 17:50:33 +00:00
Philipp Hansch
c3c00e5028
Cleanup: node_id -> hir_id 2020-04-19 17:04:14 +02:00
Sean Klein
0ef5dee3b8 Fix issue #2907.
Update the "borrow box" lint to avoid recommending the following
conversion:

```
  // Old
  pub fn f(&mut Box<T>) {...}

  // New
  pub fn f(&mut T) {...}
```

Given a mutable reference to a box, functions may want to change
"which" object the Box is pointing at.

This change avoids recommending removing the "Box" parameter
for mutable references.
2020-04-19 10:56:15 -04:00
Shotaro Yamada
554f47bb48 Don't trigger toplevel_ref_arg for for loops 2020-04-19 22:56:47 +09:00
Philipp Hansch
502a66de3d
Cleanup: future_not_send: use return_ty method 2020-04-19 14:00:03 +02:00
xiongmao86
d7f1a1ed2b Change note_span argument for span_lint_and_note. 2020-04-18 18:29:36 +08:00
xiongmao86
cf4e35339b Add an Option<Span> argument to span_lint_and_help. 2020-04-18 18:28:29 +08:00
xiongmao86
d03d3bd95b Fixes internal lint warning in code base. 2020-04-18 18:20:46 +08:00
xiongmao86
bdd32e7700 Implement collapsible_span_lint_calls lint. 2020-04-18 18:13:50 +08:00
pmk21
4d03b4d2f0 Added final lint and tests 2020-04-18 12:02:13 +05:30
pmk21
7c52e51d79 Added basic lint and tests 2020-04-18 11:39:54 +05:30
Aleksei Latyshev
092c4595fe
fix redundant_pattern_matching lint
- now it handles `while let` case
- better suggestions in `if let` case
2020-04-17 21:51:07 +03:00
bors
f1fb815603 Auto merge of #5423 - rkuhn:add_futures_not_send, r=flip1995
add lint futures_not_send

changelog: add lint futures_not_send

fixes #5379

~Remark: one thing that can (should?) still be improved is to directly include the error message from the `Send` check so that the programmer stays in the flow. Currently, getting the actual error message requires a restructuring of the code to make the `Send` constraint explicit.~
It now shows all unmet constraints for allowing the Future to be Send.
2020-04-17 16:04:14 +00:00
bors
52dacbc876 Auto merge of #5445 - logan-dev-oss:master, r=flip1995
Fixes issue #4892.

First contribution here 😊 ! Do not hesitate to correct me.

This PR is related to issue #4892 .

# Summary

```rust
-literal.method_call(args)
```
The main idea is to not trigger `clippy::precedence` when the method call is an odd function.

# Example

```rust
// should trigger lint
let _ = -1.0_f64.abs() //precedence of method call abs() and neg ('-') is ambiguous

// should not trigger lint
let _ = -1.0_f64.sin() // sin is an odd function => -sin(x) = sin(-x)
```

# Theory

Rust allows following literals:
- char
- string
- integers
- floats
- byte
- bool

Only integers/floats implements the relevant `std::ops::Neg`.
Following odd functions are implemented on i[8-128] and/or f[32-64]:
- `asin`
- `asinh`
- `atan`
- `atanh`
- `cbrt`
- `fract`
- `round`
- `signum`
- `sin`
- `sinh`
- `tan`
- `tanh `
- `to_degrees`
- `to_radians`

# Implementation

As suggested by `flip1995` in [comment](https://github.com/rust-lang/rust-clippy/issues/4892#issuecomment-568249683), this PR add a whitelist of odd functions and compare method call to the the whitelist before triggering lint.

changelog: Don't trigger [`clippy::precedence`] on odd functions.
2020-04-17 14:15:28 +00:00
Roland Kuhn
d2cbbff217 add lint futures_not_send 2020-04-17 13:54:05 +02:00
logan-dev-oss
66b855c30b Integrate more idiomatic rust changes. 2020-04-17 10:12:30 +02:00
logan-dev-oss
9c89cf00c0 Fix issue #4892. 2020-04-17 09:27:54 +02:00
bors
3ea8e5e856 Auto merge of #5482 - phansch:diag, r=matthiaskrgr
Cleanup: Rename 'db' variables to 'diag'

Did the same in rustc a while ago: https://github.com/rust-lang/rust/pull/65428

changelog: none
2020-04-17 07:24:13 +00:00
bors
82be9dc606 Auto merge of #5481 - sinkuu:no_as_ref, r=phansch
question_mark: don't add `as_ref()` for a call expression

If a call returns a `!Copy` value, it does so regardless of whether `as_ref()` is added. For example, `foo.into_option().as_ref()?` can be simplified to `foo.into_option()?`.

---

changelog: Improved `question_mark` lint suggestion so that it doesn't add redundant `as_ref()`
2020-04-17 06:19:47 +00:00
Philipp Hansch
eb7ad1c6cd
cargo dev fmt 2020-04-17 08:09:09 +02:00
Philipp Hansch
870ae36f85
Cleanup: Rename 'db' variable to 'diag' 2020-04-17 08:08:00 +02:00
Shotaro Yamada
f58bb5b234 question_mark: don't add as_ref() for a call expression 2020-04-17 13:09:02 +09:00
Shotaro Yamada
162cf261dc unit_arg suggestion may be incorrect 2020-04-17 10:26:58 +09:00
bors
adf7c505e6 Auto merge of #5476 - ThibsG:FixMatchesInExternalMacros, r=flip1995
Do not lint in macros for match lints

Don't lint in macros for match lints, more precisely in `check_pat` and `check_local` where it was not the case.

changelog: none

fixes: #5362
2020-04-16 20:51:56 +00:00
ThibsG
7fb94c2ac9 Do not lint in macros for match lints 2020-04-16 14:57:12 +02:00
Marcin Serwin
c20afbdfe0 Lint map_flatten if caller is an Option 2020-04-16 08:00:32 +02:00
Philipp Krones
19183a6af5
Rollup merge of #5468 - Toxyxer:zero-single-char-names, r=flip1995
Zero single char names

Fixes: #4086

changelog:
- Make the inequality strict
2020-04-15 20:12:31 +02:00
Philipp Krones
071a5904eb
Rollup merge of #5466 - phansch:large-enum-variant-output, r=flip1995
large_enum_variant: Report sizes of variants

This reports the sizes of the largest and second-largest variants.

Closes #5459

changelog: `large_enum_variant`: Report the sizes of the largest and second-largest variants.
2020-04-15 20:12:30 +02:00