Commit graph

8512 commits

Author SHA1 Message Date
bors fdc2f879f1 Auto merge of #75405 - flip1995:clippyup, r=Manishearth
Update Clippy

Biweekly Clippy update (2 days late, since I wanted to wait for https://github.com/rust-lang/rust/pull/75098)

r? @Manishearth
2020-08-12 00:34:19 +00:00
flip1995 027780ca2c Merge commit '09bd400243ed6f7059fedc0c1623aae3792521d6' into clippyup 2020-08-11 17:50:45 +02:00
Yuki Okushi 91aa55d891 Rollup merge of #75226 - pnadon:miri-undef-uninit, r=RalfJung
Miri: Renamed "undef" to "uninit"

Renamed remaining references to "undef" to "uninit" when referring to Miri.

Impacted directories are:

- `src/librustc_codegen_llvm/consts.rs`
- `src/librustc_middle/mir/interpret/`
- `src/librustc_middle/ty/print/pretty.rs`
- `src/librustc_mir/`
- `src/tools/clippy/clippy_lints/src/consts.rs`

Upon building Miri based on the new changes it was verified that no changes needed to be made with the Miri project.

Related issue #71193
2020-08-11 16:23:47 +09: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
Philippe Nadon 2d1515a2c5 Miri: Renamed "undef" to "uninit"
Renamed remaining references to "undef" to "uninit" when referring to Miri.

Impacted directories are:

- src/librustc_codegen_llvm/consts.rs
- src/librustc_middle/mir/interpret/
- src/librustc_middle/ty/print/pretty.rs
- src/librustc_mir/
- src/tools/clippy/clippy_lints/src/consts.rs

Upon building Miri based on the new changes it was verified that no changes needed to be made with the Miri project.

Related issue #71193
2020-08-08 07:53:47 -06:00
Nicholas Nethercote 01bba2c532 Eliminate the SessionGlobals from librustc_ast.
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This
means they are accessed via the `Session`, rather than via TLS. A few
`Attr` methods and `librustc_ast` functions are now methods of
`Session`.

All of this required passing a `Session` to lots of functions that didn't
already have one. Some of these functions also had arguments removed, because
those arguments could be accessed directly via the `Session` argument.

`contains_feature_attr()` was dead, and is removed.

Some functions were moved from `librustc_ast` elsewhere because they now need
to access `Session`, which isn't available in that crate.
- `entry_point_type()` --> `librustc_builtin_macros`
- `global_allocator_spans()` --> `librustc_metadata`
- `is_proc_macro_attr()` --> `Session`
2020-08-08 12:03:42 +10: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
Vadim Petrochenkov a285b58368 Add some comments for magic numbers + Add tests 2020-08-06 22:55:26 +03:00
Vadim Petrochenkov d642c3b6f8 Fix clippy 2020-08-06 22:13:11 +03: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 42f3d39a54 run clippy_dev fmt
This seemed to overdo it a bit, affecting multiple submodules, and changing a file I didn't touch, so I didn't commit those changes
2020-08-06 06:15:57 -06:00
Ryan1729 0d2a378547 run clippy_dev update_lints 2020-08-06 06:11:23 -06:00
Ryan1729 b0c8c7af16 add newline to transmutes_expressible_as_ptr_casts.rs 2020-08-06 04:49:06 -06:00
Ryan1729 8997c558d8 change filter to assert, and update comments 2020-08-06 04:24:25 -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 19f36bc2f3 add description to assert 2020-08-06 04:24:25 -06:00
Ryan1729 d38766ed96 address some review comments 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 34d3a0086c accidentally cause an ICE by putting the TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS handling after the match
The reason I did this in the first place was to try and figure out why I don't see my expected 7 error messages
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 069f851671 initial compiling version of TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS 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
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
liuzhenyu 24a6130da2 fix typos 2020-08-02 23:20:00 +08:00
Valentin Lazureanu aa3d9ca0e9 Rename HAIR to THIR (Typed HIR). 2020-07-31 22:15:12 +00: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
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
Manish Goregaokar b57ceb45b0 Rollup merge of #72920 - oli-obk:const_transmute, r=RalfJung
Stabilize `transmute` in constants and statics but not const fn

cc #53605 (leaving issue open so we can add `transmute` to `const fn` later)

Previous attempt: #64011

r? @RalfJung

cc @rust-lang/wg-const-eval
2020-07-11 08:53:06 -07:00
Oliver Scherer 1eb0053dcd Stabilize transmute in constants and statics but not const fn 2020-07-11 09:22:17 +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