rust/src
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
..
bootstrap x.py test --test-args flag description enhancement 2020-10-23 20:06:37 +01:00
build_helper
ci Rollup merge of #78309 2020-10-24 11:17:02 +02:00
doc Rollup merge of #78320 - phil-opp:patch-5, r=GuillaumeGomez,alexcrichton 2020-10-25 18:43:45 +09:00
etc BTreeMap: improve gdb introspection of BTreeMap with ZST keys or values 2020-10-14 13:03:23 +02:00
librustdoc Always store Rustdoc theme when it's changed 2020-10-23 18:58:42 +02:00
llvm-project@655a1467c9 Update LLVM for LLD COFF TLS alignment fix. 2020-10-17 01:34:08 -07:00
test Rollup merge of #78326 - Aaron1011:fix/min-stmt-lints, r=petrochenkov 2020-10-25 18:43:49 +09:00
tools Rollup merge of #78326 - Aaron1011:fix/min-stmt-lints, r=petrochenkov 2020-10-25 18:43:49 +09:00
README.md
stage0.txt Rollup merge of #77877 - scottmcm:fewer-try-trait-method-references, r=shepmaster 2020-10-19 18:20:20 +02:00
version Bump version to 1.49.0 2020-10-02 08:39:40 -04:00

This directory contains the source code of the rust project, including:

  • The test suite
  • The bootstrapping build system
  • Various submodules for tools, like rustdoc, rls, etc.

For more information on how various parts of the compiler work, see the rustc dev guide.