Make empty_line_after_outer_attr an early lint
Fixes#5567
Unfortunately I couldn't find a way to reproduce the issue without syn/quote. Considering that most real-world macros use syn and/or quote, I think it's okay to pull them in anyway.
changelog: Fix false positive in [`empty_line_after_outer_attr`]
This commit attempts to improve reproducibility of builds on macOS by
exporting the `ZERO_AR_DATE=1` environment variable for all invocations
of the linker. While it looks like this env var is targeted at just the
`ar` command (which does actually read this) it appears that recent-ish
versions of the linker *also* read this environment variable. This
env var forces the linker to set a deterministic zero value for the
mtime in the N_OSO field of the object file.
Currently it's believe that older versions of the linker will simply
ignore this env var, while newer versions will read it and produce a
deterministic output for compilations with debuginfo.
Closes#47086Closes#66568
reversed_empty_ranges: add suggestion for &slice[N..N]
As discussed in the issue thread, the user accepted this solution. Let me know if this is what we want, or if changing the way we lint the N..N case is prefered.
changelog: reversed_empty_ranges: add suggestion for &slice[N..N]
Closes#5628
The previous code paniced if offset_bytes == i64::MIN. This commit:
- Properly computes the absoulte value to avoid this panic
- Adds a test for this edge case
Signed-off-by: Joe Richey <joerichey@google.com>
This will print a diagnostic for crates which are mentioned as `--extern`
arguments on the command line, but are never referenced from the source.
This diagnostic is controlled by `-Wunused-crate-dependencies` or
`#![warn(unused_crate_dependencies)]` and is "allow" by default.
There are cases where certain crates need to be linked in but are not
directly referenced - for example if they are providing symbols for C
linkage. In this case the warning can be suppressed with
`use needed_crate as _;`.
Thanks to @petrochenkov for simplified core.
Resolves issue #57274
Fix bug in shebang handling
Shebang handling was too agressive in stripping out the first line in cases where it is actually _not_ a shebang, but instead, valid rust (#70528). This is a second attempt at resolving this issue (the first attempt was reverted, for, among other reasons, causing an ICE in certain cases (#71372, #71471).
The behavior is now codified by a number of UI tests, but simply:
For the first line to be a shebang, the following must all be true:
1. The line must start with `#!`
2. The line must contain a non-whitespace character after `#!`
3. The next character in the file, ignoring comments & whitespace must not be `[`
I believe this is a strict superset of what we used to allow, so perhaps a crater run is unnecessary, but probably not a terrible idea.
Fixes#70528
As part of supporting RFC 2229, we will be capturing all the places that
are mentioned in a closure. Currently the upvar_list field gives access
to a FxIndexMap<HirId, Upvar> map. Eventually this will change, with the
upvar_list having a more general structure that expresses captured
paths, not just the mentioned upvars. We will make those changes in
subsequent PRs.
This commit modifies the name of the upvar_list map to closure_captures
in TypeckTables.
Co-authored-by: Dhruv Jauhar <dhruvjhr@gmail.com>
Co-authored-by: Aman Arora <me@aman-arora.com>
Perform MIR NRVO even if types don't match
This is the most straightforward way to resolve#72428, but it could cause problems in codegen since the type of `_0` may no longer match the return type of the body.
add regression tests for stalled_on const vars
closes#70180
Afaict this has been fixed sometime after #70213
`trait_ref_type_vars` correctly adds const infers and I did not find any remaining `FIXME`s which correspond to this issue.
7c59a81a5f/src/librustc_trait_selection/traits/fulfill.rs (L555-L557)
Added both examples from the issue as regression tests and renamed `trait_ref_type_vars` -> `trait_ref_infer_vars`.
r? @eddyb
ptr_arg: honor `allow` attribute on arguments
The `intravisit::Visitor` impl for `LateContextAndPass` only takes into account the attributes of a function parameter inside the `check_param` method. `ptr_arg` starts its heuristics at `check_item` / `check_impl_item` / `check_trait_item`, so the `allow` is not taken into account automatically.
changelog: ptr_arg: honor `allow` attribute on arguments
Fixes#5644