As part of this reorganization, some traits need to be moved from `rustc_smir::context::traits` to `stable_mir::unstable::internal_cx`. These traits are specifically designed for `InternalCx` to clarify the behavior of different functions that share the same name. This move is necessary to avoid orphan rule violations.
While `expr as T` can be removed as a statement if `expr` has no
side-effect, the `as T` part alone cannot be removed if the type of
`expr` would be ambiguous without the cast.
changelog: [`unnecessary_operation`]: do not remove casts if they are
useful to type the expression
Fixesrust-lang/rust-clippy#15173
tidy: use --bless for tidy spellcheck instead of spellcheck:fix
previous behavior was inconsistent with existing extra checks.
unsure if this needs a change tracker entry or a warning for people who try to use the old behavior.
unsure if we should call this `spellcheck:lint` for consistency.
making this consistent is a prerequisite for https://github.com/rust-lang/rust/pull/143398
cc `@nnethercote`
r? `@Kobzol`
use `is_multiple_of` and `div_ceil`
In tricky logic, these functions are much more informative than the manual implementations. They also catch subtle bugs:
- the manual `is_multiple_of` often does not handle division by zero
- manual `div_ceil` often does not consider overflow
The transformation is free for `is_multiple_of` if the divisor is compile-time known to be non-zero. For `div_ceil` there is a small cost to considering overflow. Here is some assembly https://godbolt.org/z/5zP8KaE1d.
mbe: Defer checks for `compile_error!` until reporting an unused macro rule
The current MBE parser checks rules at initial parse time to see if their RHS has `compile_error!` in it, and returns a list of rule indexes and LHS spans that don't map to `compile_error!`, for use in unused macro rule checking.
Instead, have the unused macro rule reporting ask the macro for the rule to report, and let the macro check at that time. That avoids checking rules unless they're unused.
In the process, refactor the data structure used to store macro rules, to group the LHS and RHS (and LHS span) of each rule together, and refactor the unused rule tracking to only track rule indexes.
This builds atop a couple of minor MBE refactors. I would suggest reviewing commit-by-commit.
The overall result is a further simplification of the macro code.
Turns out that things like `#[attr]return unsafe { func(); }` didn't
work because we weren't checking above attributes on statements, only on
blocks!
fixes https://github.com/rust-lang/rust-clippy/issues/13189
Useful for Rust-For-Linux
changelog:[`undocumented_unsafe_blocks`]: Make sure to propagate
`accept-comment-above-attributes` to **all** statements.
Port streaming commands in bootstrap to `BootstrapCommand` and remove `as_command_mut`
This PR adds streaming capabilities to BootstrapCommand and migrate existing command streaming scenario's used in bootstrap.
r? `@Kobzol`
Most macro tests use `macro` in the name, making it easy to find and run
tests relevant to macros. However, a few use `mbe` instead. Rename those
to say `macro`.
As I said in my on-vacation PR (a little bit late) I'm getting
reincorporated into the review queue. Something that I'd like to do is
implement the reviewer capacity system into Clippy, but seems that it's
not supported yet. https://github.com/rust-lang/triagebot/issues/2007
r? @ghost
changelog:none
Even when at curly braces, otherwise the parser can get stuck.
This has happened in the past in #18625, but it was just worked around instead of handling the root of the problem. Now this happened again in #20171. IMO we can't let `err_and_bump()` not bump, that's too confusing and invites errors. We can (as I did) workaround the worse recovery instead.
The MBE parser checks rules at initial parse time to see if their RHS
has `compile_error!` in it, and returns a list of rule indexes and LHS
spans that don't map to `compile_error!`, for use in unused macro rule
checking.
Instead, have the unused macro rule reporting ask the macro for the rule
to report, and let the macro check at that time. That avoids checking
rules unless they're unused.
In the process, refactor the data structure used to store macro rules,
to group the LHS and RHS (and LHS span) of each rule together, and
refactor the unused rule tracking to only track rule indexes.
This ends up being a net simplification, and reduction in code size.
The parser repeatedly invokes the `parse` function, constructing a
one-entry vector, and assuming that the return value will be a one-entry
vector. Add a helper for that case. This will simplify adding additional
callers, and put all the logic in one place to allow potential future
simplification of the one-TT case.
remove armv5te-unknown-linux-gnueabi target maintainer
Sadly my former employer doesn't want to maintain this any more and I have no personal interest in maintaining it.
Stop using `Key` trait unnecessarily
Few places where the `Key` trait was being used but not really for a useful reason. This fixes those usages.
Namely, `<Ty as Key>::default_span()` is `DUMMY_SP` anyways.
Canonicalize input ty/ct infer/placeholder in the root universe
We shouldn't care what universe the inputs are, since we only ever do the leak check on the universes instantiated after entering the canonical binder.