Fix minor error in `MaybeUninit::get_mut()` doc example
In the `MaybeUninit::get_mut()` example I wanted to assert that the slice was sorted and mistakenly used `.chunks(2)` rather than `.windows(2)` to assert it, as @ametisf pointed out in https://github.com/rust-lang/rust/pull/65948#issuecomment-589988183 .
This fixes it.
Relax str::get_unchecked precondition to permit empty slicing
Prior to this commit, `str` documented that `get_unchecked` had
the precondition that "`begin` must come before `end`". This would appear
to prohibit empty slices (i.e. begin == end).
In practice, get_unchecked is called often with empty slices. Let's relax
the precondition so as to allow them.
Updates links in various Compiler Error Index entries
Currently many of the links in the online https://doc.rust-lang.org/error-index.html are not clickable, and many of them don't resolve correctly as they point to older versions of rustbyexample and the reference.
parse: unify item parsing & filter illegal item kinds
This PR fully unifies item parsing into a single `fn parse_item_common` method which produces `Option<Item>`. The `Item` is then mapped into `ForeignItem` and `AssocItem` as necessary by transforming the `*Kind` and converting contextually bad variants into `None`, thereby filtering them away.
The PR does not yet unmerge the definition of `ForeignItemKind` from `AssocItemKind`. I've left that as future work as it didn't feel like this parser-focused PR would be the best one to deal with it. Changes to the AST data structures are instead kept to a reasonable minimum.
Based on https://github.com/rust-lang/rust/pull/69361.
Fixes https://github.com/rust-lang/rust/issues/48137.
RELNOTES: Now, `item` macro fragments can be interpolated into `impl`, `trait`, and `extern` contexts. See `src/test/ui/parser/issue-48137-macros-cannot-interpolate-impl-items.rs` for the relevant test.
r? @petrochenkov
cc @estebank
Split non macro portion of unused_doc_comment from macro part into two passes/lints
## Motivation
This change is motivated by the needs of the [spandoc library](https://github.com/yaahc/spandoc). The specific use case is that my macro is removing doc comments when an attribute is applied to a fn with doc comments, but I would like the lint to still appear when I forget to add the `#[spandoc]` attribute to a fn, so I don't want to have to silence the lint globally.
## Approach
This change splits the `unused _doc_comment` lint into two lints, `unused_macro_doc_comment` and `unused_doc_comment`. The non macro portion is moved into an `early_lint_pass` rather than a pre_expansion_pass. This allows proc macros to silence `unused_doc_comment` warnings by either adding an attribute to silence it or by removing the doc comment before the early_pass runs.
The `unused_macro_doc_comment` lint however will still be impossible for proc-macros to silence, but the only alternative that I can see is to remove this lint entirely, which I don't think is acceptable / is a decision I'm not comfortable making personally, so instead I opted to split the macro portion of the check into a separate lint so that it can be silenced globally with an attribute if necessary without needing to globally silence the `unused_doc_comment` lint as well, which is still desireable.
fixes https://github.com/rust-lang/rust/issues/67838
Formatting fixes
Now that I can actually run `python x.py test src/tools/tidy` locally
... my god it takes a long time to compile when you're on a cellular
connection.
Removing unnecessary whitespaces
Updates src/test/ui/json-short.stderr golden test file
Fixes test failure by updating the golden file for changes
in src/librustc_error_codes/error_codes/E0601.md
Update src/librustc_error_codes/error_codes/E0080.md
Co-Authored-By: varkor <github@varkor.com>
Update src/librustc_error_codes/error_codes/E0080.md
Co-Authored-By: varkor <github@varkor.com>
Update src/librustc_error_codes/error_codes/E0080.md
Co-Authored-By: varkor <github@varkor.com>
Update src/librustc_error_codes/error_codes/E0154.md
Co-Authored-By: varkor <github@varkor.com>
Update src/librustc_error_codes/error_codes/E0154.md
Co-Authored-By: varkor <github@varkor.com>
Update src/librustc_error_codes/error_codes/E0661.md
Co-Authored-By: varkor <github@varkor.com>
Update src/librustc_error_codes/error_codes/E0662.md
Co-Authored-By: varkor <github@varkor.com>
Update src/librustc_error_codes/error_codes/E0663.md
Co-Authored-By: varkor <github@varkor.com>
Update src/librustc_error_codes/error_codes/E0664.md
Co-Authored-By: varkor <github@varkor.com>
Update src/test/ui/json-short.stderr
Co-Authored-By: varkor <github@varkor.com>
Update src/librustc_error_codes/error_codes/E0260.md
Co-Authored-By: varkor <github@varkor.com>
Update src/librustc_error_codes/error_codes/E0154.md
Co-Authored-By: varkor <github@varkor.com>
Update src/librustc_error_codes/error_codes/E0260.md
Co-Authored-By: varkor <github@varkor.com>
Apply suggestions from code review
Co-Authored-By: varkor <github@varkor.com>
Fixing 1 character over 80 cascade
Do not ping the infrastructure team on toolstate changes
To my knowledge, there is essentially never any particular action that the infra team needs to take on these pings, and they are currently relatively annoying.
cc rust-lang/infra -- does anyone *want* these notifications?
parse: allow `type Foo: Ord` syntactically
This addresses:
> (Work still remains to fuse this with free type aliases, but this can be done later.)
in https://github.com/rust-lang/rust/pull/69194.
r? @petrochenkov
Do not ping the infrastructure team on toolstate changes
To my knowledge, there is essentially never any particular action that the infra team needs to take on these pings, and they are currently relatively annoying.
cc rust-lang/infra -- does anyone *want* these notifications?
Take advantage of the fact that `check_mod_attrs` marks attributes as
used and change their type to normal, so that any remaining uses will be
warned about by the unused attribute lint.
Prior to this commit, `str` documented that `get_unchecked` had
the precondition that "`begin` must come before `end`". This would appear
to prohibit empty slices (i.e. begin == end).
In practice, get_unchecked is called often with empty slices. Let's relax
the precondition so as to allow them.
Currently, it is only set correctly in the sanity checking implicit
default fallback code. Having a config file at all will for force
`no_std = false`.