Commit graph

144 commits

Author SHA1 Message Date
bors 85e355ea9b Auto merge of #80919 - cjgillot:defkey-span, r=oli-obk
Generate metadata by iterating on DefId instead of traversing the HIR tree 1/N

Sample from #80347.
2021-01-24 06:51:17 +00:00
Camille GILLOT 97ee7c7e5a Allow to query the HIR crate node. 2021-01-23 13:58:09 +01:00
Esteban Küber 9e82329c8f Do not suggest using a break label when one is already present 2021-01-21 21:43:29 -08:00
Esteban Küber 8a13abba1d Tweak error for invalid break expr
Point at loop head on invalid `break expr`.
Suggest removing `expr` or using label if available.
2021-01-21 21:41:46 -08:00
Esteban Küber 060dba67b7 Add loop head span to hir 2021-01-21 21:41:46 -08:00
oli 5bac1c9229 Only inherit const stability for methods of impl const Trait blocks 2021-01-18 11:07:35 +00:00
bors d03fe84169 Auto merge of #79328 - c410-f3r:hir-if, r=matthewjasper
Reintroduce hir::ExprKind::If

Basically copied and paste #59288/https://github.com/rust-lang/rust-clippy/pull/4080 with some modifications.

The vast majority of tests were fixed and now there are only a few remaining. Since I am still unable to figure out the missing pieces, any help with the following list is welcome.

- [ ] **Unnecessary `typeck` exception**: [Cheated on this one to make CI green.](https://github.com/rust-lang/rust/pull/79328/files#diff-3faee9ba23fc54a12b7c43364ba81f8c5660045c7e1d7989a02a0cee1c5b2051)
- [x] **Incorrect span**: [Span should reference `then` and `else` separately.](https://github.com/rust-lang/rust/pull/79328/files#diff-cf2c46e82222ee4b1037a68fff8a1af3c4f1de7a6b3fd798aacbf3c0475abe3d)
- [x] **New note regarding `assert!`**: [Modified but not "wrong". Maybe can be a good thing?](https://github.com/rust-lang/rust/pull/79328/files#diff-9e0d7c89ed0224e2b62060c957177c27db43c30dfe3c2974cb6b5091cda9cfb5)
- [x] **Inverted report location**: [Modified but not "wrong". Locations were inverted.](https://github.com/rust-lang/rust/pull/79328/files#diff-f637ce7c1f68d523a165aa9651765df05e36c4d7d279194b1a6b28b48a323691)
- [x] **`src/test/ui/point-to-type-err-cause-on-impl-trait-return.rs` has weird errors**: [Not sure why this is happening.](https://github.com/rust-lang/rust/pull/79328/files#diff-c823c09660f5b112f95e97e8ff71f1797b6c7f37dbb3d16f8e98bbaea8072e95)
- [x] **Missing diagnostic**: [???](https://github.com/rust-lang/rust/pull/79328/files#diff-6b8ab09360d725ba4513933827f9796b42ff9522b0690f80b76de067143af2fc)
2021-01-14 14:41:58 +00:00
bors 150d1fee04 Auto merge of #79322 - jyn514:refactor-impl, r=estebank
Separate out a `hir::Impl` struct

This makes it possible to pass the `Impl` directly to functions, instead
of having to pass each of the many fields one at a time. It also
simplifies matches in many cases.

See `rustc_save_analysis::dump_visitor::process_impl` or `rustdoc::clean::clean_impl` for a good example of how this makes `impl`s easier to work with.

r? `@petrochenkov` maybe?
2021-01-13 01:40:41 +00:00
Joshua Nelson a8ff647deb Separate out a hir::Impl struct
This makes it possible to pass the `Impl` directly to functions, instead
of having to pass each of the many fields one at a time. It also
simplifies matches in many cases.
2021-01-12 20:32:33 -05:00
Camelid e2d3a25161 Fix small typo
transmutting -> transmuting
2021-01-10 21:24:32 -08:00
Caio f85fc264fe Reintroduce hir::ExprKind::If 2021-01-07 18:54:12 -03:00
Guillaume Gomez 7bc22e96d3 Don't use to_string on Symbol 2021-01-06 10:59:50 +01:00
Guillaume Gomez c4c010f534 Add an error in case the doc alias is the same as the item it's aliasing 2021-01-04 15:05:36 +01:00
Matthias Krüger 8a90626a46 reduce borrowing and (de)referencing around match patterns (clippy::match_ref_pats) 2021-01-02 20:09:17 +01:00
Rémy Rakic 1fc3c4c16d adjust const generics defaults FIXMEs to the new feature gate 2021-01-01 11:01:01 +01:00
Mara Bos 9e8edc8c22
Rollup merge of #80495 - jyn514:rename-empty, r=petrochenkov
Rename kw::Invalid -> kw::Empty

See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471
for context.

r? `@petrochenkov`
2020-12-30 20:56:58 +00:00
Joshua Nelson edeac1778c Rename kw::Invalid -> kw::Empty
See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471
for context.
2020-12-30 09:50:02 -05:00
Matthias Krüger d12a358673 use matches!() macro in more places 2020-12-24 13:35:12 +01:00
bors 3d9ada686f Auto merge of #79073 - davidtwco:issue-78957-const-param-attrs, r=lcnr
passes: prohibit invalid attrs on generic params

Fixes #78957.

This PR modifies the `check_attr` pass so that attribute placement on generic parameters is checked for validity.

r? `@lcnr`
2020-12-19 04:32:50 +00:00
Yuki Okushi 3d42c00f0b
Rollup merge of #79877 - bstrie:depinfut, r=oli-obk
Allow `since="TBD"` for rustc_deprecated

Closes #78381.

This PR only affects `#[rustc_deprecated]`, not `#[deprecated]`, so there is no effect on any stable language feature.

Likewise this PR only implements `since="TBD"`, it does not actually tag any library functions with it, so there is no effect on any stable API.

Overview of changes:

* `rustc_middle/stability.rs`:
    * change `deprecation_in_effect` function to return `false` when `since="TBD"`
    * tidy up the compiler output when a deprecated item has `since="TBD"`
* `rustc_passes/stability.rs`:
    * allow `since="TBD"` to pass the sanity check for stable_version < deprecated_version
    * refactor the "invalid stability version" and "invalid deprecation version" error into separate errors
* rustdoc: make `since="TBD"` message on a deprecated item's page match the command-line deprecation output
* tests:
    * test rustdoc output
    * test that the `deprecated_in_future` lint fires when `since="TBD"`
    * test the new "invalid deprecation version" error message
2020-12-17 11:43:57 +09:00
Yuki Okushi 1e1ba7c936
Rollup merge of #79051 - LeSeulArtichaut:if-let-guard, r=matthewjasper
Implement if-let match guards

Implements rust-lang/rfcs#2294 (tracking issue: #51114).

I probably should do a few more things before this can be merged:
- [x] Add tests (added basic tests, more advanced tests could be done in the future?)
- [x] Add lint for exhaustive if-let guard (comparable to normal if-let statements)
- [x] Fix clippy

However since this is a nightly feature maybe it's fine to land this and do those steps in follow-up PRs.

Thanks a lot `@matthewjasper` ❤️ for helping me with lowering to MIR! Would you be interested in reviewing this?
r? `@ghost` for now
2020-12-17 11:43:55 +09:00
bstrie 1e1ca28f39 Allow since="TBD" for rustc_deprecated 2020-12-16 13:21:24 -05:00
Tyler Mandry b867d13d34
Rollup merge of #79844 - tmiasko:rwu-table-mod, r=lcnr
Move RWUTable to a separate module
2020-12-09 13:38:34 -08:00
Tyler Mandry 9ced8dc0f5
Rollup merge of #79826 - LingMan:match_if, r=lcnr
Simplify visit_{foreign,trait}_item

Using an `if` seems like a better semantic fit and saves a few lines.

Noticed while looking at https://github.com/rust-lang/rust/pull/79752, but that's already merged.
r? `@lcnr,` cc `@cjgillot`

`@rustbot` modify labels +C-cleanup +T-compiler
2020-12-09 13:38:33 -08:00
Tyler Mandry 2cca5e11e0
Rollup merge of #79777 - tmiasko:remove-first-merge, r=lcnr
Remove `first_merge` from liveness debug logs
2020-12-09 13:38:20 -08:00
bors db85512bd8 Auto merge of #79767 - tmiasko:malformed-required-const, r=matthewjasper
Don't ICE on malformed `rustc_args_required_const` attribute
2020-12-09 06:31:49 +00:00
Tomasz Miąsko c7d7bc917d Move RWUTable to a separate module 2020-12-09 00:00:00 +00:00
Tomasz Miąsko d711c3006b Remove first_merge from liveness debug logs 2020-12-09 00:00:00 +00:00
bors 1700ca07c6 Auto merge of #79727 - tmiasko:8bit-rwu, r=lcnr
Compress RWU from at least 32 bits to 4 bits

The liveness uses a mixed representation of RWUs based on the
observation that most of them have invalid reader and invalid
writer. The packed variant uses 32 bits and unpacked 96 bits.
Unpacked data contains reader live node and writer live node.

Since live nodes are used only to determine their validity,
RWUs can always be stored in a packed form with four bits for
each: reader bit, writer bit, used bit, and one extra padding
bit to simplify packing and unpacking operations.
2020-12-08 20:58:20 +00:00
LingMan 7654b12112 Simplify visit_{foreign,trait}_item
Using an `if` seems like a better semantic fit and saves a few lines.
2020-12-08 15:56:15 +01:00
bors 5019791e2d Auto merge of #79752 - cjgillot:dead-alien, r=lcnr
Visit ForeignItems when marking dead code

Follow-up to #79318

r? `@lcnr`
2020-12-08 11:16:19 +00:00
Camille GILLOT 37853f925f Visit ForeignItems when marking dead code. 2020-12-08 08:07:55 +01:00
Tomasz Miąsko 8065dabd17 Validate naked functions definitions 2020-12-07 00:00:00 +00:00
Tomasz Miąsko 91fe548825 Retain assembly operands span when lowering AST to HIR 2020-12-06 20:48:08 +01:00
LeSeulArtichaut f3d4aa6afb Implement lowering of if-let guards to MIR 2020-12-06 13:42:24 +01:00
LeSeulArtichaut cfaaa21e2a Implement liveness passes for if-let guards 2020-12-06 11:48:08 +01:00
Tomasz Miąsko 50c6fd6dd5 Don't ICE on malformed rustc_args_required_const attribute 2020-12-06 00:00:00 +00:00
Tomasz Miąsko bc8317a12a Compress RWU from at least 32 bits to 4 bits
The liveness uses a mixed representation of RWUs based on the
observation that most of them have invalid reader and invalid
writer. The packed variant uses 32 bits and unpacked 96 bits.
Unpacked data contains reader live node and writer live node.

Since live nodes are used only to determine their validity,
RWUs can always be stored in a packed form with four bits for
each: reader bit, writer bit, used bit, and one extra padding
bit to simplify packing and unpacking operations.
2020-12-06 00:00:00 +00:00
Guillaume Gomez 8a35b93c4d Add rustc_lexer as dependency to rustc_passes 2020-12-02 10:42:50 +01:00
Guillaume Gomez dc10ccfe89 Add checks for #[doc(keyword = "...")] and move them into rustc_passes 2020-12-02 10:42:50 +01:00
Guillaume Gomez 5a228263b8 Clean up doc attributes check before adding more 2020-12-02 10:42:50 +01:00
Guillaume Gomez 63816da5ed Improve some attributes error spans 2020-12-01 16:26:51 +01:00
David Wood 75eb72cc9c
passes: prohibit attrs on generic params
This commit modifies the `check_attr` pass so that attribute placement
on generic parameters is checked for validity.

Signed-off-by: David Wood <david@davidtw.co>
2020-11-29 14:05:19 +00:00
Camille GILLOT 5bd197921a Do not visit ForeignItemRef for HIR indexing and validation.
Similarly to what is done for ImplItemRef and TraitItemRef.

Fixes #79487
2020-11-28 18:08:17 +01:00
Camille GILLOT 12a3024c57 Use visitor for its very purpose. 2020-11-26 21:32:29 +01:00
Camille GILLOT 60c3bbd844 Formatting. 2020-11-26 21:32:29 +01:00
Camille GILLOT 032f68d625 Remove ForeignMod struct. 2020-11-26 21:32:27 +01:00
Camille GILLOT 419a9186a4 Store ForeignItem in a side table. 2020-11-26 21:29:27 +01:00
Tomasz Miąsko 22d3431221 Validate use of parameters in naked functions
* Reject use of parameters inside naked function body.
* Reject use of patterns inside function parameters, to emphasize role
  of parameters a signature declaration (mirroring existing behaviour
  for function declarations) and avoid generating code introducing
  specified bindings.
2020-11-25 00:00:00 +00:00
Tomasz Miąsko 75e00e8cf4 Validate that #[naked] is applied to a function definition 2020-11-24 00:00:00 +00:00