Commit graph

3162 commits

Author SHA1 Message Date
bors d5b40bf469 Auto merge of #78343 - camelid:macros-qualify-panic, r=m-ou-se
Qualify `panic!` as `core::panic!` in non-built-in `core` macros

Fixes #78333.

-----

Otherwise code like this

    #![no_implicit_prelude]

    fn main() {
        ::std::todo!();
        ::std::unimplemented!();
    }

will fail to compile, which is unfortunate and presumably unintended.

This changes many invocations of `panic!` in a `macro_rules!` definition
to invocations of `$crate::panic!`, which makes the invocations hygienic.

Note that this does not make the built-in macro `assert!` hygienic.
2020-11-23 22:05:28 +00:00
Camelid d708b444e4 Qualify panic! as core::panic! in non-built-in core macros
Otherwise code like this

    #![no_implicit_prelude]

    fn main() {
        ::std::todo!();
        ::std::unimplemented!();
    }

will fail to compile, which is unfortunate and presumably unintended.

This changes many invocations of `panic!` in a `macro_rules!` definition
to invocations of `$crate::panic!`, which makes the invocations hygienic.

Note that this does not make the built-in macro `assert!` hygienic.
2020-11-23 11:28:25 -08:00
Lzu Tao 4b698f2069 Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00
Mara Bos 78faaef8de Remove the clippy::panic-params lint.
Rustc itself now warns for all cases that triggered this lint.
2020-11-19 18:34:40 +01:00
Camelid 4e4c4fb8aa Fix handling of panic calls
This should make Clippy more resilient and will unblock #78343.

This PR is made against rust-lang/rust to avoid the need for a subtree
sync at @flip1995's suggestion in rust-lang/rust-clippy#6310.
2020-11-17 12:16:15 -08:00
bors 0c7a48c5f0 Auto merge of #78809 - vn-ki:fix-issue-76064, r=oli-obk
add error_occured field to ConstQualifs,

fix #76064

I wasn't sure what `in_return_place` actually did and not sure why it returns `ConstQualifs` while it's sibling functions return `bool`. So I tried to make as minimal changes to the structure as possible. Please point out whether I have to refactor it or not.

r? `@oli-obk`
cc `@RalfJung`
2020-11-14 18:03:17 +00:00
Vishnunarayan K I 7987f39ad5 update clippy test ouput 2020-11-13 17:11:13 +05:30
Fabian Zaiser 5f310d9b83 Implement destructuring assignment for structs and slices
Co-authored-by: varkor <github@varkor.com>
2020-11-11 12:10:52 +00:00
flip1995 34244190d4 Merge commit 'b20d4c155d2fe3a8391f86dcf9a8c49e17188703' into clippyup 2020-11-05 14:29:48 +01:00
Eduardo Broto 50419118b4 Merge commit '645ef505da378b6f810b1567806d1bcc2856395f' into clippyup 2020-10-28 23:36:07 +01:00
Nathan Whitaker a1bb10e9b8 Remove lint from clippy 2020-10-26 18:19:48 -04:00
Eduardo Broto cdb555f4fc Merge commit 'bf1c6f9871f430e284b17aa44059e0d0395e28a6' into clippyup 2020-10-23 22:16:59 +02:00
varkor fcde7683fe Fix clippy tests 2020-10-22 13:23:14 +01:00
Dylan DPC d2feccc1ef Rollup merge of #77493 - hosseind88:ICEs_should_always_print_the_top_of_the_query_stack, r=oli-obk
ICEs should always print the top of the query stack

see #76920
2020-10-16 02:10:09 +02:00
hosseind88 ab0fc477b8 fix stderr file of clippy/custom_ice_message test 2020-10-14 18:19:26 +03:30
hosseind75 7f07577e6f add new line 2020-10-09 20:57:45 +03:30
hosseind75 49bc85e947 fix clippy custom_ice_message test 2020-10-09 20:57:45 +03:30
flip1995 fbf2430f02 Merge commit '2f6439ae6a6803d030cceb3ee14c9150e91b328b' into clippyup 2020-10-09 12:45:29 +02:00
Felix S. Klock II 5747c15961 Prevent forbid from being ignored if overriden at the same level.
That is, this changes `#[forbid(foo)] #[allow(foo)]` from allowing foo to
forbidding foo.
2020-10-04 13:14:01 -04:00
Michael Howell 840f7daaad Deprecate clippy lint 2020-10-02 11:34:14 -07:00
flip1995 d1f9cad102 Merge commit 'e636b88aa180e8cab9e28802aac90adbc984234d' into clippyup 2020-09-24 14:49:22 +02:00
Christiaan Dirkx ed43385cab Update Clippy testcases
Update the test `redundant_pattern_matching`: check if `is_some` and `is_none` are suggested within const contexts.
2020-09-20 23:59:34 +02:00
bors a334ae658b Auto merge of #76136 - CDirkx:const-result, r=dtolnay
Stabilize some Result methods as const

Stabilize the following methods of Result as const:
 - `is_ok`
 - `is_err`
 - `as_ref`

A test is also included, analogous to the test for `const_option`.

These methods are currently const under the unstable feature `const_result` (tracking issue: #67520).
I believe these methods to be eligible for stabilization because of the stabilization of #49146 (Allow if and match in constants) and the trivial implementations, see also: [PR#75463](https://github.com/rust-lang/rust/pull/75463) and [PR#76135](https://github.com/rust-lang/rust/pull/76135).

Note: these methods are the only methods currently under the `const_result` feature, thus this PR results in the removal of the feature.

Related: #76225
2020-09-20 13:07:11 +00:00
Christiaan Dirkx 10d272b2e2 Update Clippy testcases
Update the test `redundant_pattern_matching`: check if `is_ok` and `is_err` are suggested within const contexts.
Also removes the `redundant_pattern_matching_const_result` test, as it is no longer needed.
2020-09-20 03:32:36 +02:00
flip1995 a12828a80a Merge commit '5034d47f721ff4c3a3ff2aca9ef2ef3e1d067f9f' into clippyup 2020-09-10 17:47:07 +02:00
Aaron Hill f23670ed68 Adjust Clippy for CONST_ITEM_MUTATION lint
We no longer lint assignments to const item fields in the
`temporary_assignment` lint, since this is now covered by the
`CONST_ITEM_MUTATION` lint.

Additionally, we `#![allow(const_item_mutation)]` in the
`borrow_interior_mutable_const.rs` test. Clippy UI tests are run with
`-D warnings`, which seems to cause builtin lints to prevent Clippy
lints from running.
2020-09-08 17:59:56 -04:00
Sasha 246f1f8a8e Improve recovery on malformed format call
If a comma in a format call is replaced with a similar token, then we
emit an error and continue parsing, instead of stopping at this point.
2020-09-02 13:18:19 +02:00
flip1995 282c59820b Merge commit '3d0b0e66afdfaa519d8855b338b35b4605775945' into clippyup 2020-08-28 18:43:25 +02:00
Scott McMurray 48b4aeabf8 Unbreak the clippy test 2020-08-24 16:29:03 -07:00
David Wood f13d2bfd9b clippy: support QPath::LangItem
This commit updates clippy with the introduction of `QPath::LangItem` so
that it still compiles.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-17 13:55:05 +01:00
flip1995 027780ca2c Merge commit '09bd400243ed6f7059fedc0c1623aae3792521d6' into clippyup 2020-08-11 17:50:45 +02:00
Dylan DPC 9e73d33680 Rollup merge of #75098 - Ryan1729:clippy-pointer-cast-lint-experiment, r=oli-obk
Clippy pointer cast lint experiment

This PR is an experiment about exposing more parts of `rustc_typeck` for use in `clippy`. In particular, the code that checks where a cast is valid or not was exposed, which necessitated exposing [`FnCtxt`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_typeck/check/struct.FnCtxt.html), and figuring out how to create an instance of that type inside `clippy`.

This was prompted by [this clippy issue](https://github.com/rust-lang/rust-clippy/issues/2064).

r? @oli-obk
2020-08-11 01:56:30 +02:00
Ryan1729 873e5f5c19 add allow unused_unsafe and allow dead_code 2020-08-09 00:39:14 -06:00
Ryan1729 bc8d32d36b fix unary minus on usize and unused variable errors in .fixed file 2020-08-09 00:28:56 -06:00
Ryan1729 84db238fa1 add a test example of where transmutes_expressible_as_ptr_casts should not suggest anything 2020-08-09 00:15:56 -06:00
Ryan1729 a1ca12581a update stderr for transmutes_expressible_as_ptr_casts 2020-08-08 21:03:41 -06:00
bors a7fa264ae7 Auto merge of #74821 - oli-obk:const_eval_read_uninit_fast_path, r=wesleywiser
Check whether locals are too large instead of whether accesses into them are too large

Essentially this stops const prop from attempting to optimize

```rust
let mut x = [0_u8; 5000];
x[42] = 3;
```

I don't expect this to be a perf improvement without #73656 (which is also where the lack of this PR will be a perf regression).

r? @wesleywiser
2020-08-07 15:28:07 +00:00
Ryan1729 fe9ad57e98 copy over *.fixed file 2020-08-06 20:28:29 -06:00
Ryan Wiedemann 49c7e39d03 Apply suggestions from code review
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-08-06 07:57:31 -06:00
Ryan1729 b0c8c7af16 add newline to transmutes_expressible_as_ptr_casts.rs 2020-08-06 04:49:06 -06:00
Ryan1729 ded2d6c233 add extra error message to the expected stderr for transmutes_expressible_as_ptr_casts test 2020-08-06 04:24:25 -06:00
Ryan1729 94340d6e17 add documentation to functions that call do_check and add a test against lint ordering changing 2020-08-06 04:24:25 -06:00
Ryan1729 ccc4747f46 get the expected number of errors by acknowledging that other lints are covering the same ground 2020-08-06 04:24:25 -06:00
Ryan1729 de05212987 try putting the can_be_expressed_as_pointer_cast at the top and find that we still get an ICE 2020-08-06 04:24:24 -06:00
Ryan1729 46ef4e8651 write currently failing test for transmutes_expressible_as_ptr_casts
There are 5 errors, when there should be 7.
2020-08-06 04:24:24 -06:00
Ryan1729 5e84b8c2fb run cargo dev new_lint then move transmutes_expressible_as_ptr_casts into transmute module 2020-08-06 04:24:24 -06:00
liuzhenyu 24a6130da2 fix typos 2020-08-02 23:20:00 +08:00
Oliver Scherer 98f3c79385 Update clippy ui test.
The reason we do not trigger these lints anymore is that clippy sets the mir-opt-level to 0, and the recent changes subtly changed how the const propagator works.
2020-07-29 22:14:19 +02:00
flip1995 d164ab65f7 Merge commit 'da5a6fb1b65ec6581a67e942a3850f6bc15a552c' into clippyup 2020-07-26 21:07:07 +02:00
flip1995 6f25adbd5a Merge commit '2ca58e7dda4a9eb142599638c59dc04d15961175' into clippyup 2020-07-14 14:59:59 +02:00