Commit graph

3934 commits

Author SHA1 Message Date
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