about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2021-05-07Rollup merge of #84991 - alexcrichton:target-feature-remap, r=nagisaDylan DPC-0/+5
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-07Rollup merge of #84442 - jyn514:doc-cfg, r=petrochenkovDylan DPC-39/+53
Unify rustc and rustdoc parsing of `cfg()` This extracts a new `parse_cfg` function that's used between both. - Treat `#[doc(cfg(x), cfg(y))]` the same as `#[doc(cfg(x)] #[doc(cfg(y))]`. Previously it would be completely ignored. - Treat `#[doc(inline, cfg(x))]` the same as `#[doc(inline)] #[doc(cfg(x))]`. Previously, the cfg would be ignored. - Pass the cfg predicate through to rustc_expand to be validated Technically this is a breaking change, but doc_cfg is still nightly so I don't think it matters. Fixes https://github.com/rust-lang/rust/issues/84437. r? `````````@petrochenkov`````````
2021-05-07Auto merge of #84797 - richkadel:cover-unreachable-statements, r=tmandrybors-49/+54
Report coverage `0` of dead blocks Fixes: #84018 With `-Z instrument-coverage`, coverage reporting of dead blocks (for example, blocks dropped because a conditional branch is dropped, based on const evaluation) is now supported. If `instrument-coverage` is enabled, `simplify::remove_dead_blocks()` finds all dropped coverage `Statement`s and adds their `code_region`s as `Unreachable` coverage `Statement`s to the `START_BLOCK`, so they are still included in the coverage map. Check out the resulting changes in the test coverage reports in this PR (in [commit 1](https://github.com/rust-lang/rust/pull/84797/commits/0b0d293c7c46bdadf80e5304a667e34c53c0cf7e)). r? `@tmandry` cc: `@wesleywiser`
2021-05-07Rollup merge of #84990 - GuillaumeGomez:sort-rustdoc-gui-tests, ↵Yuki Okushi-1/+6
r=Mark-Simulacrum Sort rustdoc-gui tests The rustdoc-gui tests were randomly run. Not really a big issue but I prefer the tests to be sorted.
2021-05-07Rollup merge of #84972 - RalfJung:null-ptr-msg, r=oli-obkYuki Okushi-8/+8
CTFE inbounds-error-messages tweak * use CheckInAllocMsg::PointerArithmeticTest for ptr_offset error * nicer errors for some null pointer cases r? `@oli-obk`
2021-05-07Rollup merge of #84911 - Mark-Simulacrum:retry-clang, r=pietroalbiniYuki Okushi-2/+4
Retry clang+llvm download We've been seeing a pretty high rate of spurious network failures (e.g., openssl connection reset by peer). Not clear why, but let's add a retry. r? `@pietroalbini`
2021-05-07Rollup merge of #84897 - richkadel:cover-closure-macros, r=tmandryYuki Okushi-46/+168
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. r? `@tmandry` cc: `@wesleywiser`
2021-05-07Rollup merge of #84875 - richkadel:no-coverage-dont-check-unused, r=tmandryYuki Okushi-52/+54
Removes unneeded check of `#[no_coverage]` in mapgen There is an anticipated feature request to support a compiler flag that only adds coverage for specific files (or perhaps mods). As I thought about where that change would need to be supported, I realized that checking the attribute in mapgen (for unused functions) was unnecessary. The unused functions are only synthesized if they have MIR coverage, and functions with the `no_coverage` attribute will not have been instrumented with MIR coverage statements in the first place. New tests confirm this. Also, while adding tests, I updated resolved comments and FIXMEs in other tests, and expanded comments and tests on one remaining issue that is still not resolved. r? `@tmandry` cc: `@wesleywiser`
2021-05-07Rollup merge of #84815 - richkadel:coverage-docs-update-2021-05, r=tmandryYuki Okushi-324/+378
Update coverage docs and command line help r? `@tmandry` cc: `@wesleywiser`
2021-05-07Rollup merge of #84781 - jyn514:check-bootstrap, r=Mark-SimulacrumYuki Okushi-3/+3
Don't check bootstrap artifacts by default Bootstrap has to build successfully or this won't run, so all it checks are the tests, which are uncommon to change. Fixes https://github.com/rust-lang/rust/issues/76624.
2021-05-07Rollup merge of #84779 - jyn514:cargotest-args, r=Mark-SimulacrumYuki Okushi-1/+4
Add support for --test-args to cargotest This allows running a single test without having to wait for all tests to complete. Closes https://github.com/rust-lang/rust/issues/77260.
2021-05-07Rollup merge of #84953 - ↵Dylan DPC-31/+33
GuillaumeGomez:remove-unneeded-with_default_session_globals, r=jyn514 Remove unneeded call to with_default_session_globals in rustdoc highlight This was the origin of the `Span` bug in https://github.com/rust-lang/rust/pull/84176. cc `````@Aaron1011````` r? `````@jyn514`````
2021-05-07Rollup merge of #84896 - estebank:issue-84772, r=jackh726Dylan DPC-0/+94
Handle incorrect placement of parentheses in trait bounds more gracefully Fix #84772. CC ``````@jonhoo``````
2021-05-07Rollup merge of #84872 - bjorn3:cg_clif_tidy, r=Mark-SimulacrumDylan DPC-47/+136
Wire up tidy dependency checks for cg_clif Also contains a fix and improvement to tidy. Required for https://github.com/rust-lang/rust/pull/81746.
2021-05-07Rollup merge of #84871 - richkadel:no-coverage-unstable-only, r=nagisaDylan DPC-43/+10
Disallows `#![feature(no_coverage)]` on stable and beta (using standard crate-level gating) Fixes: #84836 Removes the function-level feature gating solution originally implemented, and solves the same problem using `allow_internal_unstable`, so normal crate-level feature gating mechanism can still be used (which disallows the feature on stable and beta). I tested this, building the compiler with and without `CFG_DISABLE_UNSTABLE_FEATURES=1` With unstable features disabled, I get the expected result as shown here: ```shell $ ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc src/test/run-make-fulldeps/coverage/no_cov_crate.rs error[E0554]: `#![feature]` may not be used on the dev release channel --> src/test/run-make-fulldeps/coverage/no_cov_crate.rs:2:1 | 2 | #![feature(no_coverage)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0554`. ``` r? ````@Mark-Simulacrum```` cc: ````@tmandry```` ````@wesleywiser````
2021-05-07Rollup merge of #84734 - tmandry:compiletest-needs-unwind, r=Mark-SimulacrumDylan DPC-8/+44
Add `needs-unwind` and beginning of support for testing `panic=abort` std to compiletest For the Fuchsia platform we build libstd with `panic=abort` and would like a way to run tests with that enabled. This adds low-level support for this directly to compiletest. In the future I'd like to add high-level support in rustbuild, e.g. having target-specific flags that allow configuring a panic strategy. (Side note: It would be nice if we could also build multiple configurations for the same target, but I'm getting ahead of myself.) This plus #84500 have everything that's needed to get ui tests passing on fuchsia targets. Part of #84766. Note that this change only includes the header on tests which need an unwinder to _build_, not those which need it to _run_. r? ````@Mark-Simulacrum````
2021-05-07Rollup merge of #84728 - camelid:sized-param-sugg-test, r=Mark-SimulacrumDylan DPC-0/+88
Add test for suggestion to borrow unsized function parameters Closes #82820. This is a regression test for #82820. This test case is included in more general tests, but I think the error regressed because there were a bunch of other diagnostic changes in the test that obscured this regression. Hopefully, having a test specific to the suggestion, and running rustfix for the test, will prevent this error from regressing in the future.
2021-05-07Rollup merge of #84500 - tmandry:compiletest-run-flag, r=Mark-SimulacrumDylan DPC-16/+93
Add --run flag to compiletest This controls whether run-* tests actually get run. r? ```@Mark-Simulacrum```
2021-05-06Removes unneeded check of `#[no_coverage]` in mapgenRich Kadel-89/+54
And adds tests to validate it still works. There is an anticipated feature request to support a compiler flag that only adds coverage for specific files (or perhaps mods). As I thought about where that change would need to be supported, I realized that checking the attribute in mapgen (for unused functions) was unnecessary. The unused functions are only synthesized if they have MIR coverage, and functions with the `no_coverage` attribute will not have been instrumented with MIR coverage statements in the first place. New tests confirm this. Also, while adding tests, I updated resolved comments and FIXMEs in other tests.
2021-05-06Renamed compiler-flags file to name of compiler-flag: instrument-coverageRich Kadel-344/+349
And redirect users from the old file name.
2021-05-06Update coverage docs and command line helpRich Kadel-75/+124
2021-05-06Add test for suggestion to borrow unsized function parametersCamelid-0/+88
This is a regression test for #82820. This test case is included in more general tests, but I think the error regressed because there were a bunch of other diagnostic changes in the test that obscured this regression. Hopefully, having a test specific to the suggestion, and running rustfix for the test, will prevent this error from regressing in the future.
2021-05-06Coverage instruments closure bodies in macros (not the macro body)Rich Kadel-46/+168
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-06Auto merge of #84559 - jackh726:issue-84398, r=nikomatsakisbors-0/+20
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-06rustc: Support Rust-specific features in -Ctarget-featureAlex Crichton-0/+5
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-06Sort rustdoc-gui testsGuillaume Gomez-1/+6
2021-05-06Rollup merge of #84950 - pietroalbini:revert-3478f83c0, r=Mark-SimulacrumDylan DPC-47/+8
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-06Rollup merge of #84945 - fee1-dead:E0583-better-message, r=petrochenkovDylan DPC-8/+8
E0583: Include secondary path in error message Fixes #84819.
2021-05-06Rollup merge of #84851 - lnicola:rust-analyzer-2021-05-03, r=jonas-schievinkDylan DPC-21/+15
:arrow_up: rust-analyzer
2021-05-06Rollup merge of #83507 - luqmana:native-link-modifiers, r=petrochenkovDylan DPC-2/+210
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-0632bit blessRalf Jung-1/+1
2021-05-06use CheckInAllocMsg::PointerArithmeticTest for ptr_offset errorRalf Jung-7/+7
2021-05-06Fix up/ignore failing ui tests on fuchsiaTyler Mandry-0/+4
2021-05-06Support multi target-rustcflags for -Zpanic-abort-testsTyler Mandry-5/+5
I just need this until rustbuild supports -Cpanic=abort std directly.
2021-05-06Add needs-unwind to testsTyler Mandry-1/+9
2021-05-06compiletest: Add --target-panic, needs-unwindTyler Mandry-2/+26
2021-05-06E0583: Include secondary path in error messageDeadbeef-8/+8
2021-05-05Implement RFC 2951: Native link modifiersLuqman Aden-2/+210
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-05alloc: Add unstable Cfg feature `no-global_oom_handling`John Ericson-0/+4
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-05Remote test for alloc `extern_crate` feature.John Ericson-30/+0
This functionality was removed in 45bf1ed1a1123122ded05ae2eedaf0f190e52726, but the test was left by mistake.
2021-05-05Auto merge of #84956 - RalfJung:rollup-m70mx2n, r=RalfJungbors-12/+77
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-05Update highlight testsGuillaume Gomez-11/+16
2021-05-05Rollup merge of #84913 - estebank:issue-84831, r=varkorRalf Jung-0/+35
Do not ICE on invalid const param When encountering a path that can't have generics, do not call `generics_of`. This would happen when writing something like `path::this_is_a_mod<const_val>`. Fix #84831.
2021-05-05Rollup merge of #84882 - joshtriplett:platform-support-formatting, r=Dylan-DPCRalf Jung-2/+2
platform-support: Center the contents of the `std` and `host` columns Minor formatting improvement.
2021-05-05Rollup merge of #84865 - petrochenkov:llthread, r=Mark-SimulacrumRalf Jung-8/+15
rustbuild: Pass a `threads` flag that works to windows-gnu lld MinGW driver for COFF LLD doesn't currently translate GNU-style `--threads=N` to native `/threads:N`, so we have to pass the option in its native form to avoid an error. Also pass the `threads` flag to lld-link (windows-msvc lld) as well.
2021-05-05Rollup merge of #84808 - estebank:issue-84769, r=petrochenkovRalf Jung-2/+25
Account for unsatisfied bounds in E0599 Fix #84769, follow up to #84499, #83667.
2021-05-05Remove unneeded call to with_default_session_globals in rustdoc highlightGuillaume Gomez-20/+17
2021-05-05Disallows `#![feature(no_coverage)]` on stable and betaRich Kadel-43/+10
using allow_internal_unstable (as recommended) Fixes: #84836 ```shell $ ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc src/test/run-make-fulldeps/coverage/no_cov_crate.rs error[E0554]: `#![feature]` may not be used on the dev release channel --> src/test/run-make-fulldeps/coverage/no_cov_crate.rs:2:1 | 2 | #![feature(no_coverage)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0554`. ```
2021-05-05Auto merge of #84200 - CDirkx:os, r=m-ou-sebors-1/+1
Move all `sys::ext` modules to `os` This PR moves all `sys::ext` modules to `os`, centralizing the location of all `os` code and simplifying the dependencies between `os` and `sys`. Because this also removes all uses `cfg_if!` on publicly exported items, where after #81969 there were still a few left, this should properly work around https://github.com/rust-analyzer/rust-analyzer/issues/6038. `@rustbot` label: +T-libs-impl
2021-05-05Revert PR 83866Pietro Albini-47/+8
That PR caused multiple test failures when Rust's channel is changed from nightly to anything else. The commit will have to be landed again after the test suite is fixed.