Commit graph

143156 commits

Author SHA1 Message Date
Rich Kadel
cb70221857 Coverage instruments closure bodies in macros (not the macro body)
Fixes: #84884

This solution might be considered a compromise, but I think it is the
better choice.

The results in the `closure.rs` test correctly resolve all test cases
broken as described in #84884.

One test pattern (in both `closure_macro.rs` and
`closure_macro_async.rs`) was also affected, and removes coverage
statistics for the lines inside the closure, because the closure
includes a macro. (The coverage remains at the callsite of the macro, so
we lose some detail, but there isn't a perfect choice with macros.

Often macro implementations are split across the macro and the callsite,
and there doesn't appear to be a single "right choice" for which body
should be covered. For the current implementation, we can't do both.

The callsite is most likely to be the preferred site for coverage.

I applied this fix to all `MacroKinds`, not just `Bang`.

I'm trying to resolve an issue of lost coverage in a
`MacroKind::Attr`-based, function-scoped macro. Instead of only
searching for a body_span that is "not a function-like macro" (that is,
MacroKind::Bang), I'm expanding this to all `MacroKind`s. Maybe I should
expand this to `ExpnKind::Desugaring` and `ExpnKind::AstPass` (or
subsets, depending on their sub-kinds) as well, but I'm not sure that's
a good idea.

I'd like to add a test of the `Attr` macro on functions, but I need time
to figure out how to constract a good, simple example without external
crate dependencies. For the moment, all tests still work as expected (no
change), this new commit shouldn't have a negative affect, and more
importantly, I believe it will have a positive effect. I will try to
confirm this.
2021-05-06 11:15:39 -07:00
bors
377d1a984c Auto merge of #84559 - jackh726:issue-84398, r=nikomatsakis
Deduplicate ParamCandidates with the same value except for bound vars

Fixes #84398

This is kind of a hack. I wonder if we can get other types of candidates that are the same except for bound vars. This won't be a problem with Chalk, since we don't really need to know that there are two different "candidates" if they both give the same final substitution.

r? `@nikomatsakis`
2021-05-06 17:42:32 +00:00
Mohsen Zohrevandi
2acd62d7c3 join_orders_after_tls_destructors: ensure thread 2 is launched before thread 1 enters TLS destructors 2021-05-06 09:36:26 -07:00
Alex Crichton
97658e58f0 rustc: Support Rust-specific features in -Ctarget-feature
Since the beginning of time the `-Ctarget-feature` flag on the command
line has largely been passed unmodified to LLVM. Afterwards, though, the
`#[target_feature]` attribute was stabilized and some of the names in
this attribute do not match the corresponding LLVM name. This is because
Rust doesn't always want to stabilize the exact feature name in LLVM for
the equivalent functionality in Rust. This creates a situation, however,
where in Rust you'd write:

    #[target_feature(enable = "pclmulqdq")]
    unsafe fn foo() {
        // ...
    }

but on the command line you would write:

    RUSTFLAGS="-Ctarget-feature=+pclmul" cargo build --release

This difference is somewhat odd to deal with if you're a newcomer and
the situation may be made worse with upcoming features like [WebAssembly
SIMD](https://github.com/rust-lang/rust/issues/74372) which may be more
prevalent.

This commit implements a mapping to translate requests via
`-Ctarget-feature` through the same name-mapping functionality that's
present for attributes in Rust going to LLVM. This means that
`+pclmulqdq` will work on x86 targets where as previously it did not.

I've attempted to keep this backwards-compatible where the compiler will
just opportunistically attempt to remap features found in
`-Ctarget-feature`, but if there's something it doesn't understand it
gets passed unmodified to LLVM just as it was before.
2021-05-06 08:52:03 -07:00
bors
d44f647ffc Auto merge of #84982 - Dylan-DPC:rollup-q4cbec2, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #83507 (Implement RFC 2951: Native link modifiers)
 - #84328 (Stablize {HashMap,BTreeMap}::into_{keys,values})
 - #84712 (Simplify chdir implementation and minimize unsafe block)
 - #84851 (⬆️ rust-analyzer)
 - #84923 (Only compute Obligation `cache_key` once  in `register_obligation_at`)
 - #84945 (E0583: Include secondary path in error message)
 - #84949 (Fix typo in `MaybeUninit::array_assume_init` safety comment)
 - #84950 (Revert PR 83866)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-06 15:19:39 +00:00
Guillaume Gomez
cdbfea5c6c Sort rustdoc-gui tests 2021-05-06 16:51:04 +02:00
lcnr
b9811418dd outdated comment 2021-05-06 16:27:59 +02:00
Jack Huey
c1ef0f3050
Pick candidate with fewer bound vars 2021-05-06 10:19:51 -04:00
lcnr
513c56a611 remove unused variant 2021-05-06 14:59:53 +02:00
Dylan DPC
ccc820e1f8
Rollup merge of #84950 - pietroalbini:revert-3478f83c0, r=Mark-Simulacrum
Revert PR 83866

https://github.com/rust-lang/rust/pull/83866 caused multiple test failures when Rust's channel is changed from nightly to anything else. The PR will have to be landed again after the test suite is fixed.

The two kinds of test failures were:

* Rustdoc tests failed because the links in the generated HTML didn't point at nightly anymore, see https://github.com/rust-lang/rust/pull/84909#issuecomment-832028701
* Rustdoc UI tests failed because the links included in error messages didn't point at nightly anymore, see https://github.com/rust-lang/rust/pull/84909#issuecomment-832517722

r? ``@Mark-Simulacrum``
cc ``@jyn514``
2021-05-06 13:31:01 +02:00
Dylan DPC
ccf0e3e068
Rollup merge of #84949 - sdroege:maybe-unint-typo, r=m-ou-se
Fix typo in `MaybeUninit::array_assume_init` safety comment

And also add backticks around `MaybeUninit`.
2021-05-06 13:31:00 +02:00
Dylan DPC
b07834b986
Rollup merge of #84945 - fee1-dead:E0583-better-message, r=petrochenkov
E0583: Include secondary path in error message

Fixes #84819.
2021-05-06 13:30:59 +02:00
Dylan DPC
b5f40df95c
Rollup merge of #84923 - estebank:as_cache_key-once, r=petrochenkov
Only compute Obligation `cache_key` once  in `register_obligation_at`
2021-05-06 13:30:58 +02:00
Dylan DPC
ae409558e7
Rollup merge of #84851 - lnicola:rust-analyzer-2021-05-03, r=jonas-schievink
⬆️ rust-analyzer
2021-05-06 13:30:56 +02:00
Dylan DPC
2ed0134cfa
Rollup merge of #84712 - joshtriplett:simplify-chdir, r=yaahc
Simplify chdir implementation and minimize unsafe block
2021-05-06 13:30:55 +02:00
Dylan DPC
6a6c644016
Rollup merge of #84328 - Folyd:stablize_map_into_keys_values, r=m-ou-se
Stablize {HashMap,BTreeMap}::into_{keys,values}

I would propose to stabilize `{HashMap,BTreeMap}::into_{keys,values}`( aka. `map_into_keys_values`).

Closes #75294.
2021-05-06 13:30:54 +02:00
Dylan DPC
5dcdeb81e1
Rollup merge of #83507 - luqmana:native-link-modifiers, r=petrochenkov
Implement RFC 2951: Native link modifiers

A first attempt at implementing https://github.com/rust-lang/rfcs/pull/2951 / https://github.com/rust-lang/compiler-team/issues/356.

Tracking Issue: https://github.com/rust-lang/rust/issues/81490

Introduces feature flags for the general syntax (`native_link_modifiers`) and each modifier (`native_link_modifiers_{as_needed,bundle,verbatim,whole_archive}`).

r? `@petrochenkov`
2021-05-06 13:30:51 +02:00
bors
109248a4eb Auto merge of #84965 - the8472:lazy-delayed-diagnostics, r=Mark-Simulacrum
lazify backtrace formatting for delayed diagnostics

Formatting backtraces causes debug info to be parsed, which is superfluous work if the delayed bugs get cleared later.

Lazifying them results in these speedups for the UI testsuite:

|       | debuginfo = 0 | debuginfo = 1 | debuginfo = 2 |
|-------|---------------|---------------|---------------|
| eager | 31.59s        | 37.55s        | 42.64s        |
| lazy  | 30.44s        | 30.86s        | 34.07s        |
2021-05-06 11:29:29 +00:00
flip1995
c24058bc59
Update Cargo.lock 2021-05-06 12:21:46 +02:00
flip1995
8e6ff8ffbd
Merge commit 'b71f3405606d49b9735606b479c3415a0ca9810f' into clippyup 2021-05-06 12:20:44 +02:00
Ralf Jung
bcf622b87d 32bit bless 2021-05-06 12:00:19 +02:00
bors
b71f340560 Auto merge of #7178 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2021-05-06 09:45:37 +00:00
flip1995
d481b38634
Bump Clippy version -> 0.1.54 2021-05-06 11:32:34 +02:00
flip1995
d52316d5a4
Bump nightly version -> 2021-05-06 2021-05-06 11:32:27 +02:00
flip1995
767cc7cd89
Merge remote-tracking branch 'upstream/master' into rustup 2021-05-06 11:32:03 +02:00
bors
796a6f00e1 Auto merge of #7177 - giraffate:add_a_missing_lint_to_msrv_config_doc, r=flip1995
Add a missing lint to MSRV config doc

A follow-up of https://github.com/rust-lang/rust-clippy/pull/6859.

changelog: Add a missing lint to MSRV config doc
2021-05-06 08:43:36 +00:00
Ralf Jung
abdba81d03 use CheckInAllocMsg::PointerArithmeticTest for ptr_offset error 2021-05-06 10:39:35 +02:00
bors
7191675ab1 Auto merge of #7166 - TaKO8Ki:refactor_misc_early_module, r=llogiq
Refactor: arrange lints in misc_early module

This PR arranges misc_early lints so that they can be accessed more easily.
Basically, I refactored them following the instruction described in #6680.

cc: `@Y-Nak,` `@flip1995,` `@magurotuna`

changelog: Move lints in misc_early module into their own modules.
2021-05-06 07:46:52 +00:00
bors
1d99508b52 Auto merge of #84468 - iladin:iladin/fix-84467, r=petrochenkov
Fix#84467 linker_args with --target=sparcv9-sun-solaris

Trying to cross-compile for sparcv9-sun-solaris
getting a error message for -zignore

Introduced when -z -ignore was seperated here
22d0ab0

No formatting done

Reproduce

``` bash
rustup target add sparcv9-sun-solaris
cargo new --bin hello && cd hello && cargo run --target=sparcv9-sun-solaris
```

config.toml

[target.sparcv9-sun-solaris]
linker = "gcc"
2021-05-06 07:02:06 +00:00
Takayuki Nakata
b8046fab23 Add a missing lint to MSRV config doc 2021-05-06 14:04:50 +09:00
bors
d620ae1070 Auto merge of #84266 - QuiltOS:statically-disallow-global-oom-handling, r=Mark-Simulacrum
alloc: Add unstable Cfg feature `no-global_oom_handling

For certain sorts of systems, programming, it's deemed essential that
all allocation failures be explicitly handled where they occur. For
example, see Linus Torvald's opinion in [1]. Merely not calling global
panic handlers, or always `try_reserving` first (for vectors), is not
deemed good enough, because the mere presence of the global OOM handlers
is burdens static analysis.

One option for these projects to use rust would just be to skip `alloc`,
rolling their own allocation abstractions.  But this would, in my
opinion be a real shame. `alloc` has a few `try_*` methods already, and
we could easily have more. Features like custom allocator support also
demonstrate and existing to support diverse use-cases with the same
abstractions.

A natural way to add such a feature flag would a Cargo feature, but
there are currently uncertainties around how std library crate's Cargo
features may or not be stable, so to avoid any risk of stabilizing by
mistake we are going with a more low-level "raw cfg" token, which
cannot be interacted with via Cargo alone.

Note also that since there is no notion of "default cfg tokens" outside
of Cargo features, we have to invert the condition from
`global_oom_handling` to to `not(no_global_oom_handling)`. This breaks
the monotonicity that would be important for a Cargo feature (i.e.
turning on more features should never break compatibility), but it
doesn't matter for raw cfg tokens which are not intended to be
"constraint solved" by Cargo or anything else.

To support this use-case we create a new feature, "global-oom-handling",
on by default, and put the global OOM handler infra and everything else
it that depends on it behind it. By default, nothing is changed, but
users concerned about global handling can make sure it is disabled, and
be confident that all OOM handling is local and explicit.

For this first iteration, non-flat collections are outright disabled.
`Vec` and `String` don't yet have `try_*` allocation methods, but are
kept anyways since they can be oom-safely created "from parts", and we
hope to add those `try_` methods in the future.

[1]: https://lore.kernel.org/lkml/CAHk-=wh_sNLoz84AUUzuqXEsYH35u=8HV3vK-jbRbJ_B-JjGrg@mail.gmail.com/
2021-05-06 04:41:20 +00:00
Tyler Mandry
947ad5838c Fix up/ignore failing ui tests on fuchsia 2021-05-06 02:49:34 +00:00
Tyler Mandry
1993e1a86d Support multi target-rustcflags for -Zpanic-abort-tests
I just need this until rustbuild supports -Cpanic=abort std directly.
2021-05-06 02:49:34 +00:00
Tyler Mandry
e1a8ecf771 Add needs-unwind to tests 2021-05-06 02:49:34 +00:00
Tyler Mandry
568d9c5547 compiletest: Add --target-panic, needs-unwind 2021-05-06 02:49:34 +00:00
Deadbeef
4617b03316
E0583: Include secondary path in error message 2021-05-06 09:40:05 +08:00
Luqman Aden
db555e1284 Implement RFC 2951: Native link modifiers
This commit implements both the native linking modifiers infrastructure
as well as an initial attempt at the individual modifiers from the RFC.
It also introduces a feature flag for the general syntax along with
individual feature flags for each modifier.
2021-05-05 16:04:25 -07:00
bors
9dd87051c7 Auto merge of #7175 - camsteffen:filter-map-none, r=Manishearth
Fix unnecessary_filter_map false positive

changelog: Fix an [`unnecessary_filter_map`] false positive

Fixes #6804
2021-05-05 22:57:05 +00:00
Cameron Steffen
d66d37303c Fix unnecessary_filter_map false positive 2021-05-05 16:44:00 -05:00
bors
93fe3562d0 Auto merge of #7174 - camsteffen:eval-order-async, r=flip1995
Fix eval_order_dependence async false positive

changelog: Fix [`eval_order_dependence`] false positive in async code

Fixes #6925
2021-05-05 21:18:05 +00:00
The8472
b98629bfbc lazify backtrace formatting for delayed diagnostics
This defers backtrace formatting to the point where we
actually want to flush delayed diagnostics. If they are discarded
before that point then we can avoid invoking the backtrace formatting
machinery which will parse debug info and symbol tables.

for debuginfo=2 this leads to a 20% walltime reduction of the UI testsuite
2021-05-05 22:57:48 +02:00
John Ericson
19be438cda alloc: Add unstable Cfg feature no-global_oom_handling
For certain sorts of systems, programming, it's deemed essential that
all allocation failures be explicitly handled where they occur. For
example, see Linus Torvald's opinion in [1]. Merely not calling global
panic handlers, or always `try_reserving` first (for vectors), is not
deemed good enough, because the mere presence of the global OOM handlers
is burdens static analysis.

One option for these projects to use rust would just be to skip `alloc`,
rolling their own allocation abstractions.  But this would, in my
opinion be a real shame. `alloc` has a few `try_*` methods already, and
we could easily have more. Features like custom allocator support also
demonstrate and existing to support diverse use-cases with the same
abstractions.

A natural way to add such a feature flag would a Cargo feature, but
there are currently uncertainties around how std library crate's Cargo
features may or not be stable, so to avoid any risk of stabilizing by
mistake we are going with a more low-level "raw cfg" token, which
cannot be interacted with via Cargo alone.

Note also that since there is no notion of "default cfg tokens" outside
of Cargo features, we have to invert the condition from
`global_oom_handling` to to `not(no_global_oom_handling)`. This breaks
the monotonicity that would be important for a Cargo feature (i.e.
turning on more features should never break compatibility), but it
doesn't matter for raw cfg tokens which are not intended to be
"constraint solved" by Cargo or anything else.

To support this use-case we create a new feature, "global-oom-handling",
on by default, and put the global OOM handler infra and everything else
it that depends on it behind it. By default, nothing is changed, but
users concerned about global handling can make sure it is disabled, and
be confident that all OOM handling is local and explicit.

For this first iteration, non-flat collections are outright disabled.
`Vec` and `String` don't yet have `try_*` allocation methods, but are
kept anyways since they can be oom-safely created "from parts", and we
hope to add those `try_` methods in the future.

[1]: https://lore.kernel.org/lkml/CAHk-=wh_sNLoz84AUUzuqXEsYH35u=8HV3vK-jbRbJ_B-JjGrg@mail.gmail.com/
2021-05-05 16:49:04 -04:00
John Ericson
3ec0baa8bc Remote test for alloc extern_crate feature.
This functionality was removed in
45bf1ed1a1, but the test was left by
mistake.
2021-05-05 16:49:04 -04:00
Cameron Steffen
7a7b8bd3e8 Fix eval_order_dependence async false positive 2021-05-05 15:08:44 -05:00
Cameron Steffen
2b38399920 Improve eval_order_dependence output 2021-05-05 15:03:14 -05:00
bors
bacf770f29 Auto merge of #84956 - RalfJung:rollup-m70mx2n, r=RalfJung
Rollup of 11 pull requests

Successful merges:

 - #83553 (Update `ptr` docs with regards to `ptr::addr_of!`)
 - #84183 (Update RELEASES.md for 1.52.0)
 - #84709 (Add doc alias for `chdir` to `std::env::set_current_dir`)
 - #84803 (Reduce duplication in `impl_dep_tracking_hash` macros)
 - #84808 (Account for unsatisfied bounds in E0599)
 - #84843 (use else if in std library )
 - #84865 (rustbuild: Pass a `threads` flag that works to windows-gnu lld)
 - #84878 (Clarify documentation for `[T]::contains`)
 - #84882 (platform-support: Center the contents of the `std` and `host` columns)
 - #84903 (Remove `rustc_middle::mir::interpret::CheckInAllocMsg::NullPointerTest`)
 - #84913 (Do not ICE on invalid const param)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-05 17:45:41 +00:00
bors
182a1853c3 Auto merge of #7170 - flip1995:revert_drop_order, r=llogiq
Fix stack overflow issue in `redundant_pattern_matching`

Fixes #7169

~~cc `@Jarcho` Since tomorrow is release day and we need to get this also fixed in beta, I'll just revert the PR instead of looking into the root issue. Your changes are good, so if you have an idea what could cause this stack overflow and know how to fix it, please open a PR that reverts this revert with a fix.~~

r? `@llogiq`

changelog: none (fixes stack overflow, but this was introduced in this release cycle)
2021-05-05 17:33:46 +00:00
bors
f35345df91 Auto merge of #6887 - xFrednet:4310-internal-metadata-extraction-lint, r=xFrednet
A metadata collection monster

This PR introduces a metadata collection lint as discussed in #4310. It currently collects:
* The lint ID
* The lint declaration file and location (for #1303)
* The lint group
* The documentation
* The applicability (if resolvable)
* If the suggestion is a multi-part-suggestion

This data has a slightly different structure than the current [lints.json](https://github.com/rust-lang/rust-clippy/blob/gh-pages/master/lints.json) and doesn't include depreciated lints yet. I plan to adapt the website to the new format and include depreciated lints in a follow-up PR :). The current collected json looks like this: [metadata_collection.json](https://gist.github.com/xFrednet/6b9e2c3f725f476ba88db9563f67e119)

The entire implementation is guarded behind the `metadata-collector-lint` feature and the `ENABLE_METADATA_COLLECTION` environment value to prevent default collection. You can test the implementation via:
```sh
$ ENABLE_METADATA_COLLECTION=1 cargo test --test dogfood --all-features
```

changelog: none

---

The size of this PR sadly also grew into a small monster, sorry! I definitely plan to improve on this! And it's totally okay if you take your time with this :)

r? `@phansch`
cc: `@flip1995`
2021-05-05 17:11:14 +00:00
xFrednet
e0eb29c936 Applying PR suggestions (mostly typos)
Co-authored-by: flip1995 <hello@philkrones.com>
Co-authored-by: phansch <dev@phansch.net>
2021-05-05 18:58:57 +02:00
xFrednet
62cafe2c02 Applying PR suggestions 2021-05-05 18:38:26 +02:00