Commit graph

148836 commits

Author SHA1 Message Date
Ralf Jung
266e7afe13
Rollup merge of #85367 - GuillaumeGomez:fix-css-rule, r=jsha
Fix invalid input:disabled CSS selector

For some reason, we used "search-focus" instead of "search-input"...

r? ``@jsha``
2021-05-17 18:52:09 +02:00
Ralf Jung
8f9d1107b5
Rollup merge of #85355 - hi-rustin:rustin-patch-issue-85255, r=varkor
More tests for issue-85255

Add more test for `pub(crate)`.

r? ``@varkor``
2021-05-17 18:52:08 +02:00
Ralf Jung
8a1403af1e
Rollup merge of #85302 - r00ster91:patch-7, r=joshtriplett
Expand WASI abbreviation in docs

I was pretty sure this was related to something for WebAssembly but wasn't 100% sure so I checked but even on these top-level docs I couldn't find the abbreviation expanded. I'm normally used to Rust docs being detailed and explanatory and writing abbreviations like this out in full at least once so I thought it was worth the change. Feel free to close this if it's too much.
2021-05-17 18:52:04 +02:00
Ralf Jung
b93753ee21
Rollup merge of #85087 - hyd-dev:lots-of-abis, r=RalfJung
`eval_fn_call`: check the ABI of `body.source`

And stop checking `instance_ty.fn_sig(*self.tcx).abi()`, if the function is not an intrinsic.
Addresses https://github.com/rust-lang/miri/pull/1776#discussion_r615381169.
No idea how to test this without Miri...
2021-05-17 18:51:59 +02:00
bors
fa72878a61 Auto merge of #85352 - Xanewok:update-rls, r=Xanewok
Update RLS

Contains https://github.com/rust-lang/rls/pull/1736. With #82208 merged, this should now close https://github.com/rust-lang/rust/issues/85225. Tested locally with `./x.py test src/tools/rls` and seems to be working as expected.

I noticed the rustfmt merge didn't trigger toolstate upgrade (because we pruned most but not all of the related machinery?), so I'd rather get this rubber-stamped by someone more knowledgeable with infra/the merged changes in case I missed something and need to include something else here to unbreak the RLS toolstate.

r? `@Mark-Simulacrum`
2021-05-17 16:34:11 +00:00
ThibsG
2fb35ce4f0 Add generic args for comparison in use_self and useless_conversion lints 2021-05-17 17:27:16 +02:00
Arya Kumar
0dcde71224 Fix missing variable init in lint example 2021-05-17 15:00:15 +00:00
Mark Rousskov
c7c9336469 Avoid zero-length write_str in fmt::write 2021-05-17 09:30:58 -04:00
Mark Rousskov
80ac15f667 Optimize default ToString impl
This avoids a zero-length write_str call, which boils down to a zero-length
memmove and ultimately costs quite a few instructions on some workloads.

This is approximately a 0.33% instruction count win on diesel-check.
2021-05-17 09:29:02 -04:00
Jack Huey
83459081ba Remove legacy for trait object mangling test and replace crate hash 2021-05-17 09:24:19 -04:00
Takayuki Nakata
ebf065e517 Fix a manual_unwrap_or FP with deref coercion 2021-05-17 22:18:50 +09:00
hyd-dev
97bc0eefe7
Add a comment for check_abi() 2021-05-17 20:54:31 +08:00
Ralf Jung
cb5533cff2 remove some functions that were only used by Miri 2021-05-17 14:43:16 +02:00
bors
9964284fed Auto merge of #84571 - jedel1043:issue-49804-impl, r=petrochenkov
Parse unnamed fields of struct and union type

Added the `unnamed_fields` feature gate.

This is a prototype of [RFC 2102](https://github.com/rust-lang/rust/issues/49804), so any suggestions are greatly appreciated.

r? `@petrochenkov`
2021-05-17 12:15:26 +00:00
Fabian Wolff
7b301985fa Two minor changes for readability and efficiency 2021-05-17 13:58:14 +02:00
Christiaan Dirkx
383642714a Simplify cfg(any(unix, target_os="redox")) to just cfg(unix) 2021-05-17 13:49:14 +02:00
Ralf Jung
5d71c67423 mir-opt bless for Size field being removed from Allocation 2021-05-17 13:30:25 +02:00
Ralf Jung
7962b5ae45 remove size field from Allocation 2021-05-17 13:30:16 +02:00
Pietro Albini
6bcfdd9913
backport 1.52.1 release notes 2021-05-17 12:03:49 +02:00
Laurențiu Nicola
f054ce3946 ⬆️ rust-analyzer 2021-05-17 09:56:57 +03:00
bors
acdf43f257 Auto merge of #7225 - InquisitivePenguin:unnessecary-async, r=llogiq
New lint: `unused_async`

changelog: Adds a lint, `unused_async`, which checks for async functions with no await statements

`unused_async` is a lint that reduces code smell and overhead by encouraging async functions to be refactored into synchronous functions.

Fixes #7176

### Examples

```rust
async fn get_random_number() -> i64 {
    4 // Chosen by fair dice roll. Guaranteed to be random.
}
```

Could be written as:

```rust
fn get_random_number() -> i64 {
    4 // Chosen by fair dice roll. Guaranteed to be random.
}
```

Something like this, however, should **not** be caught by clippy:
```rust
#[async_trait]
trait AsyncTrait {
    async fn foo();
}

struct Bar;

#[async_trait]
impl AsyncTrait for Bar {
    async fn foo() {
        println!("bar");
    }
}
```
2021-05-17 06:00:55 +00:00
bors
44e0747664 Auto merge of #7216 - ThibsG:OptionIfLetElse7006, r=llogiq
Stop linting `else if let` pattern in [`option_if_let_else`] lint

For readability concerns, it is counterproductive to lint `else if let` pattern.
Unfortunately the suggested code is much less readable.

Fixes: #7006

changelog: stop linting `else if let` pattern in [`option_if_let_else`] lint
2021-05-17 05:45:24 +00:00
bors
44ec846f4e Auto merge of #85353 - jonas-schievink:async-blocks-in-ctfe, r=oli-obk
Allow `async {}` expressions in const contexts

Gated behind a new `const_async_blocks` feature.
2021-05-17 04:53:30 +00:00
Jacob Hoffman-Andrews
253cbabc39 rustdoc: restore header sizes 2021-05-16 20:48:55 -07:00
jedel1043
64acb7d921 Allow formatting Anonymous{Struct, Union} declarations 2021-05-16 22:13:38 -05:00
Aaron Hill
500503b16c
Suppress spurious errors inside async fn
Fixes #73741
2021-05-16 22:26:57 -04:00
bors
c086676657 Auto merge of #85178 - cjgillot:local-crate, r=oli-obk
Remove CrateNum parameter for queries that only work on local crate

The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea.

Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2021-05-17 01:42:03 +00:00
bors
3396a383bb Auto merge of #85178 - cjgillot:local-crate, r=oli-obk
Remove CrateNum parameter for queries that only work on local crate

The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea.

Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2021-05-17 01:42:03 +00:00
bors
a55748ffe9 Auto merge of #84993 - eddyb:cg-ssa-on-demand-blocks, r=nagisa
rustc_codegen_ssa: only create backend `BasicBlock`s as-needed.

Instead of creating one backend (e.g. LLVM) block per MIR block ahead of time, and then deleting the ones that weren't visited, this PR moves to creating the blocks as they're needed (either reached via the RPO visit, or used as the target of a branch from a different block).

As deleting a block was the only `unsafe` builder method (generally we only *create* backend objects, not *remove* them), that's gone now and codegen is overall a bit safer.

The only change in output is the order of LLVM blocks (which AFAIK has no semantic meaning, other than the first block being the entry block). This happens because the blocks are now created due to control-flow edges, rather than MIR block order.

I'm making this a standalone PR because I keep getting wild perf results when I change *anything* in codegen, but if you want to read more about my plans in this area, see https://github.com/rust-lang/rust/pull/84771#issuecomment-830636256 (and https://github.com/rust-lang/rust/pull/84771#issue-628295651 - but that may be a bit outdated).

(You may notice some of the APIs in this PR, like `append_block`, don't help with the future plans - but I didn't want to include the necessary refactors that pass a build around everywhere, in this PR, so it's a small compromise)

r? `@nagisa` `@bjorn3`
2021-05-16 23:00:53 +00:00
Aaron Hill
8657bb251c
Always produce sub-obligations when using cached projection result 2021-05-16 17:18:17 -04:00
Eduard-Mihai Burtescu
0fcaf11455 rustc_codegen_ssa: append blocks to functions w/o creating a builder. 2021-05-17 00:04:09 +03:00
Eduard-Mihai Burtescu
402e9efc56 rustc_codegen_ssa: only create backend BasicBlocks as-needed. 2021-05-17 00:04:09 +03:00
bors
48dad265ab Auto merge of #7214 - xFrednet:7197-collecting-configuration, r=flip1995,camsteffen
Metadata collection monster searching for Clippy's configuration options

This PR teaches our lovely metadata collection monster which configurations are available inside Clippy. It then adds a new *Configuration* section to the lint documentation.

---

The implementation uses the `define_Conf!` macro to create a vector of metadata during compilation. This enables easy collection and parsing without the need of searching for the struct during a lint-pass (and it's quite elegant IMO). The information is then parsed into an intermediate struct called `ClippyConfiguration` which will be saved inside the `MetadataCollector` struct itself. It is currently only used to generate the *Configuration* section in the lint documentation, but I'm thinking about adding an overview of available configurations to the website. Saving them in this intermediate state without formatting them right away enables this in the future.

The new parsing will also allow us to have a documentation that spans over multiple lines in the future. For example, this will be valid when the old script has been removed:
```rust
/// Lint: BLACKLISTED_NAME.
/// The list of blacklisted names to lint about. NB: `bar` is not here since it has legitimate uses
(blacklisted_names: Vec<String> = ["foo", "baz", "quux"].iter().map(ToString::to_string).collect())
```

The deprecation reason is also currently being collected but not used any further and that's basically it.

---

See: #7172 for the full metadata collection to-do list or to suggest a new feature in connection to it 🙃

---

changelog: none

r? `@flip1995`
cc `@camsteffen` It would be great if you could also review this PR as you have recently worked on Clippy's `define_Conf!` macro.
2021-05-16 21:02:02 +00:00
bors
fe72845f7b Auto merge of #85312 - ehuss:macro_use-unused-attr, r=petrochenkov
Fix unused attributes on macro_rules.

The `unused_attributes` lint wasn't firing on attributes of `macro_rules` definitions. The consequence is that many attributes are silently ignored on `macro_rules`. The reason is that `unused_attributes` is a late-lint pass, and only has access to the HIR, which does not have macro_rules definitions.

My solution here is to change `non_exported_macro_attrs` to be `macro_attrs` (a list of all attributes used for `macro_rules`, instead of just those for `macro_export`), and then to check this list in the `unused_attributes` lint. There are a number of alternate approaches, but this seemed the most reliable and least invasive. I am open to completely different approaches, though.

One concern is that I don't fully understand the implications of extending `non_exported_macro_attrs` to include non-exported macros. That list was originally added in #62042 to handle stability attributes, so I suspect it was just an optimization since that was all that was needed. It was later extended to be included in SVH in #83901. #80641 also added a use to check for `invalid` attributes, which seems a little odd to me (it didn't validate non-exported macros, and seems highly specific).

Overall, there doesn't seem to be a clear story of when `unused_attributes` should be used versus an error like E0518. I considered alternatively using an "allow list" of built-in attributes that can be used on macro_rules (allow, warn, deny, forbid, cfg, cfg_attr, macro_export, deprecated, doc), but I feel like that could be a pain to maintain.

Some built-in attributes already present hard-errors when used with macro_rules. These are each hard-coded in various places:
- `derive`
- `test` and `bench`
- `proc_macro` and `proc_macro_derive`
- `inline`
- `global_allocator`

The primary motivation is that I sometimes see people use `#[macro_use]` in front of `macro_rules`, which indicates there is some confusion out there (evident that there was even a case of it in rustc).
2021-05-16 20:19:45 +00:00
Jonas Schievink
014e8d46f8 Add tracking issue 2021-05-16 21:57:40 +02:00
Jacob Hoffman-Andrews
6696a60f0f Add test for trait toggle location 2021-05-16 12:50:15 -07:00
bors
7dc9ff5c62 Auto merge of #85290 - Amanieu:asm_const_int, r=nagisa
Remove support for floating-point constants in asm!

Floating-point constants aren't very useful anyways and this simplifies
the code since the type check can now be done in typeck.

cc `@rust-lang/wg-inline-asm`

r? `@nagisa`
2021-05-16 17:52:52 +00:00
The8472
39e492a2be mark internal inplace_iteration traits as hidden 2021-05-16 19:36:21 +02:00
Giacomo Stevanato
363eacd8d3 Add regression test 2021-05-16 19:01:28 +02:00
bors
6bbee5c584 Auto merge of #7217 - xFrednet:7172-metadata-collection-cargo-alias, r=flip1995
Add `cargo collect-metadata` as an cargo alias for the metadata collection lint

This PR adds a new alias to run the metadata collection monster on `clippy_lints`. I'm currently using it to create the `metadata_collection.json` file and I plan to use it in the `deply.sh` script. Having it as a new alias enables us to simply use:

```sh
cargo collect-metadata
```

It sometimes requires running `cargo clean` before collecting the metadata due to caching. I'm still debating if I should include a cargo clean as part of the `run_metadata_collection_lint` test or not. Input on this would be greatly appreciated 🙃

That's it, just a small change that can be reviewed and merged in parallel to #7214.

---

See: #7172 for the full metadata collection to-do list or to suggest a new feature in connection to it.

---

changelog: none

r? `@flip1995` btw. feel free to pass these PRs one to other team members as well if you want.
2021-05-16 16:57:15 +00:00
Giacomo Stevanato
d8f5d5e9cb Consider edge cases in missing lifetime diagnostics 2021-05-16 18:33:32 +02:00
Fabian Wolff
4efa4a5273 Implement changes suggested by varkor 2021-05-16 18:22:34 +02:00
bors
f8e1e92380 Auto merge of #84549 - tmiasko:static-initializer, r=varkor
Reachable statics have reachable initializers

Static initializer can read other statics. Initializers are evaluated at
compile time, and so their content could become inlined into another
crate. Ensure that initializers of reachable statics are also reachable.

Previously, when an item incorrectly considered to be unreachable was
reached from another crate an attempt would be made to codegen it. The
attempt could fail with an ICE (in the case MIR wasn't available to do
so) in some circumstances the attempt could also succeed resulting in
a local codegen of non-local items, including static ones.

Fixes #84455.
2021-05-16 15:11:48 +00:00
jedel1043
8a1dd6918b Add test for restriction of anonymous types on validation 2021-05-16 09:53:17 -05:00
jedel1043
d4ad050ce5 Check and deny anonymous fields on ast_validation 2021-05-16 09:51:00 -05:00
jedel1043
059b68dd67 Implement Anonymous{Struct, Union} in the AST
Add unnamed_fields feature gate and gate unnamed fields on parsing
2021-05-16 09:49:16 -05:00
Fabian Wolff
48d07d1326 Suggest borrowing if a trait implementation is found for &/&mut <type> 2021-05-16 16:20:35 +02:00
Guillaume Gomez
0b1ee79b6c Fix invalid input:disabled CSS selector 2021-05-16 14:49:44 +02:00
bors
747a5d2a5d Auto merge of #85316 - eddyb:cg-ssa-on-demand-cleanuppad, r=nagisa
rustc_codegen_ssa: generate MSVC cleanup pads on demand, like GNU landing pads.

This unblocks #84993 in terms of codegen tests, as it brings the MSVC-style (`cleanup_pad`) EH (LLVM) block order in line with the GNU-style (`landing_pad`) EH (LLVM) block order, by having both of them be on-demand (instead of MSVC-style being eager and GNU-style lazy/on-demand).

It also unifies the two implementations a bit, similar to #84699, but in the opposite direction (as that attempt made both kinds of EH pads eagerly built).

~~Opening as draft because I haven't done enough Windows testing just yet, of both this PR, and of #84993 rebased on it.~~ (**EDIT**: seems to be working as expected)

r? `@nagisa`
2021-05-16 12:30:07 +00:00
bors
3f46b82d29 Auto merge of #85332 - RalfJung:ptr-in-str, r=oli-obk
CTFE validation: handle pointers in str

I also finally learned how I can match *some* NOTEs in a ui test without matching all of them, and applied that to some const tests in the 2nd commit where I added NOTE because I did not know what I was doing. I can separate this into its own PR if you prefer.

Fixes https://github.com/rust-lang/rust/issues/83182
r? `@oli-obk`
2021-05-16 09:49:12 +00:00