rust/compiler
Yuki Okushi 0a26e4ba7e
Rollup merge of #78326 - Aaron1011:fix/min-stmt-lints, r=petrochenkov
Split out statement attributes changes from #78306

This is the same as PR https://github.com/rust-lang/rust/pull/78306, but `unused_doc_comments` is modified to explicitly ignore statement items (which preserves the current behavior).

This shouldn't have any user-visible effects, so it can be landed without lang team discussion.

---------
When the 'early' and 'late' visitors visit an attribute target, they
activate any lint attributes (e.g. `#[allow]`) that apply to it.
This can affect warnings emitted on sibiling attributes. For example,
the following code does not produce an `unused_attributes` for
`#[inline]`, since the sibiling `#[allow(unused_attributes)]` suppressed
the warning.

```rust
trait Foo {
    #[allow(unused_attributes)] #[inline] fn first();
    #[inline] #[allow(unused_attributes)] fn second();
}
```

However, we do not do this for statements - instead, the lint attributes
only become active when we visit the struct nested inside `StmtKind`
(e.g. `Item`).

Currently, this is difficult to observe due to another issue - the
`HasAttrs` impl for `StmtKind` ignores attributes for `StmtKind::Item`.
As a result, the `unused_doc_comments` lint will never see attributes on
item statements.

This commit makes two interrelated fixes to the handling of inert
(non-proc-macro) attributes on statements:

* The `HasAttr` impl for `StmtKind` now returns attributes for
  `StmtKind::Item`, treating it just like every other `StmtKind`
  variant. The only place relying on the old behavior was macro
  which has been updated to explicitly ignore attributes on item
  statements. This allows the `unused_doc_comments` lint to fire for
  item statements.
* The `early` and `late` lint visitors now activate lint attributes when
  invoking the callback for `Stmt`. This ensures that a lint
  attribute (e.g. `#[allow(unused_doc_comments)]`) can be applied to
  sibiling attributes on an item statement.

For now, the `unused_doc_comments` lint is explicitly disabled on item
statements, which preserves the current behavior. The exact locatiosn
where this lint should fire are being discussed in PR #78306
2020-10-25 18:43:49 +09:00
..
rustc
rustc_apfloat
rustc_arena
rustc_ast Rollup merge of #78326 - Aaron1011:fix/min-stmt-lints, r=petrochenkov 2020-10-25 18:43:49 +09:00
rustc_ast_lowering Auto merge of #77546 - lcnr:impl-trait-closure, r=eddyb 2020-10-25 07:03:58 +00:00
rustc_ast_passes
rustc_ast_pretty
rustc_attr switch allow_internal_unstable const fns to rustc_allow_const_fn_unstable 2020-10-21 20:54:20 +02:00
rustc_builtin_macros Unconditionally capture tokens for attributes. 2020-10-21 18:57:29 -04:00
rustc_codegen_llvm Upgrade to measureme 9.0.0 2020-10-24 22:39:42 -04:00
rustc_codegen_ssa Make codegen coverage_context optional, and check 2020-10-23 12:00:30 -07:00
rustc_data_structures Upgrade to measureme 9.0.0 2020-10-24 22:39:42 -04:00
rustc_driver
rustc_error_codes
rustc_errors
rustc_expand Rollup merge of #78326 - Aaron1011:fix/min-stmt-lints, r=petrochenkov 2020-10-25 18:43:49 +09:00
rustc_feature Rollup merge of #78208 - liketechnik:issue-69399, r=oli-obk 2020-10-25 18:43:40 +09:00
rustc_fs_util
rustc_graphviz
rustc_hir Rollup merge of #78326 - Aaron1011:fix/min-stmt-lints, r=petrochenkov 2020-10-25 18:43:49 +09:00
rustc_hir_pretty
rustc_incremental
rustc_index
rustc_infer Reduce diagram mess in 'match arms have incompatible types' error 2020-10-22 16:16:02 -07:00
rustc_interface Strip tokens before printing AST JSON 2020-10-21 19:44:33 -04:00
rustc_lexer
rustc_lint Fix inconsistencies in handling of inert attributes on statements 2020-10-24 11:55:48 -04:00
rustc_llvm
rustc_macros Retire rustc_dep_node_try_load_from_on_disk_cache. 2020-10-22 23:04:46 +02:00
rustc_metadata Compute proper module parent during resolution 2020-10-24 14:28:13 -04:00
rustc_middle Rollup merge of #78326 - Aaron1011:fix/min-stmt-lints, r=petrochenkov 2020-10-25 18:43:49 +09:00
rustc_mir Rollup merge of #78208 - liketechnik:issue-69399, r=oli-obk 2020-10-25 18:43:40 +09:00
rustc_mir_build Rollup merge of #78072 - Nadrieril:cleanup-constant-matching, r=varkor 2020-10-24 22:39:51 +02:00
rustc_parse Auto merge of #77255 - Aaron1011:feature/collect-attr-tokens, r=petrochenkov 2020-10-24 19:23:32 +00:00
rustc_parse_format
rustc_passes Rollup merge of #78208 - liketechnik:issue-69399, r=oli-obk 2020-10-25 18:43:40 +09:00
rustc_plugin_impl
rustc_privacy
rustc_query_system Remove unused ProfileCategory. 2020-10-22 22:35:32 +02:00
rustc_resolve Rollup merge of #77984 - Aaron1011:fix/macro-mod-weird-parent, r=petrochenkov 2020-10-25 18:43:37 +09:00
rustc_save_analysis fix save-analysis 2020-10-22 21:11:50 +02:00
rustc_serialize
rustc_session
rustc_span Rollup merge of #78208 - liketechnik:issue-69399, r=oli-obk 2020-10-25 18:43:40 +09:00
rustc_symbol_mangling Update to rustc-demangle 0.1.18 2020-10-21 21:11:11 +01:00
rustc_target Rollup merge of #77716 - francesca64:revert-ios-dynamic-linking, r=jonas-schievink 2020-10-24 14:11:59 +02:00
rustc_trait_selection Rollup merge of #78272 - lcnr:abstract-const-unused-node, r=oli-obk 2020-10-24 22:39:57 +02:00
rustc_traits
rustc_ty
rustc_typeck Auto merge of #77546 - lcnr:impl-trait-closure, r=eddyb 2020-10-25 07:03:58 +00:00