about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2021-04-05Fix bug where rustc_lint would not apply renamed tool lintsJoshua Nelson-3/+4
2021-04-05Auto merge of #83864 - Dylan-DPC:rollup-78an86n, r=Dylan-DPCbors-136/+209
Rollup of 7 pull requests Successful merges: - #80525 (wasm64 support) - #83019 (core: disable `ptr::swap_nonoverlapping_one`'s block optimization on SPIR-V.) - #83717 (rustdoc: Separate filter-empty-string out into its own function) - #83807 (Tests: Remove redundant `ignore-tidy-linelength` annotations) - #83815 (ptr::addr_of documentation improvements) - #83820 (Remove attribute `#[link_args]`) - #83841 (Allow clobbering unsupported registers in asm!) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-04-04Auto merge of #83530 - Mark-Simulacrum:bootstrap-bump, r=Mark-Simulacrumbors-2/+1
Bump bootstrap to 1.52 beta This includes the standard bump, but also a workaround for new cargo behavior around clearing out the doc directory when the rustdoc version changes.
2021-04-05Rollup merge of #83841 - Amanieu:asm_clobber_feature, r=nagisaDylan DPC-33/+76
Allow clobbering unsupported registers in asm! Previously registers could only be marked as clobbered if the target feature for that register was enabled. This restriction is now removed. cc #81092 r? ``@nagisa``
2021-04-05Rollup merge of #83820 - petrochenkov:nolinkargs, r=nagisaDylan DPC-86/+7
Remove attribute `#[link_args]` Closes https://github.com/rust-lang/rust/issues/29596 The attribute could always be replaced with `-C link-arg`, but cargo didn't provide a reasonable way to pass such flags to rustc. Now cargo supports `cargo:rustc-link-arg*` directives in build scripts (https://doc.rust-lang.org/cargo/reference/unstable.html#extra-link-arg), so this attribute can be removed.
2021-04-05Rollup merge of #80525 - devsnek:wasm64, r=nagisaDylan DPC-17/+126
wasm64 support There is still some upstream llvm work needed before this can land.
2021-04-04Auto merge of #82907 - petrochenkov:dercache, r=Aaron1011bors-73/+100
resolve/expand: Cache intermediate results of `#[derive]` expansion Expansion function for `#[derive]` (`rustc_builtin_macros::derive::Expander::expand`) may return an indeterminate result, and therefore can be called multiple times. Previously we parsed the `#[derive(Foo, Bar)]`'s input and tried to resolve `Foo` and `Bar` on every such call. Now we maintain a cache `Resolver::derive_data` and take all the necessary data from it if it was computed previously. So `Foo, Bar` is now parsed at most once, and `Foo` and `Bar` are successfully resolved at most once.
2021-04-04Bump cfgsMark Rousskov-2/+1
2021-04-04Rollup merge of #83521 - sexxi-goose:quick-diagnostic-fix, r=nikomatsakisDylan DPC-40/+81
2229: Fix diagnostic issue when using FakeReads in closures This PR fixes a diagnostic issue caused by https://github.com/rust-lang/rust/pull/82536. A temporary work around was used in this merged PR which involved feature gating the addition of FakeReads introduced as a result of pattern matching in closures. The fix involves adding an optional closure DefId to ForLet and ForMatchedPlace FakeReadCauses. This DefId will only be added if a closure pattern matches a Place starting with an Upvar. r? ```@nikomatsakis```
2021-04-04Rollup merge of #73945 - est31:unused_externs, r=Mark-SimulacrumDylan DPC-6/+112
Add an unstable --json=unused-externs flag to print unused externs This adds an unstable flag to print a list of the extern names not used by cargo. This PR will enable cargo to collect unused dependencies from all units and provide warnings. The companion PR to cargo is: https://github.com/rust-lang/cargo/pull/8437 The goal is eventual stabilization of this flag in rustc as well as in cargo. Discussion of this feature is mostly contained inside these threads: #57274 #72342 #72603 The feature builds upon the internal datastructures added by #72342 Externs are uniquely identified by name and the information is sufficient for cargo. If the mode is enabled, rustc will print json messages like: ``` {"unused_extern_names":["byteorder","openssl","webpki"]} ``` For a crate that got passed byteorder, openssl and webpki dependencies but needed none of them. ### Q: Why not pass -Wunused-crate-dependencies? A: See [ehuss's comment here](https://github.com/rust-lang/rust/issues/57274#issuecomment-624839355) TLDR: it's cleaner. Rust's warning system wasn't built to be filtered or edited by cargo. Even a basic implementation of the feature would have to change the "n warnings emitted" line that rustc prints at the end. Cargo ideally wants to synthesize its own warnings anyways. For example, it would be hard for rustc to emit warnings like "dependency foo is only used by dev targets", suggesting to make it a dev-dependency instead. ### Q: Make rustc emit used or unused externs? A: Emitting used externs has the advantage that it simplifies cargo's collection job. However, emitting unused externs creates less data to be communicated between rustc and cargo. Often you want to paste a cargo command obtained from `cargo build -vv` for doing something completely unrelated. The message is emitted always, even if no warning or error is emitted. At that point, even this tiny difference in "noise" matters. That's why I went with emitting unused externs. ### Q: One json msg per extern or a collective json msg? A: Same as above, the data format should be concise. Having 30 lines for the 30 crates a crate uses would be disturbing to readers. Also it helps the cargo implementation to know that there aren't more unused deps coming. ### Q: Why use names of externs instead of e.g. paths? A: Names are both sufficient as well as neccessary to uniquely identify a passed `--extern` arg. Names are sufficient because you *must* pass a name when passing an `--extern` arg. Passing a path is optional on the other hand so rustc might also figure out a crate's location from the file system. You can also put multiple paths for the same extern name, via e.g. `--extern hello=/usr/lib/hello.rmeta --extern hello=/usr/local/lib/hello.rmeta`, but rustc will only ever use one of those paths. Also, paths don't identify a dependency uniquely as it is possible to have multiple different extern names point to the same path. So paths are ill-suited for identification. ### Q: What about 2015 edition crates? A: They are fully supported. Even on the 2015 edition, an explicit `--extern` flag is is required to enable `extern crate foo;` to work (outside of sysroot crates, which this flag doesn't warn about anyways). So the lint would still fire on 2015 edition crates if you haven't included a dependency specified in Cargo.toml using `extern crate foo;` or similar. The lint won't fire if your sole use in the crate is through a `extern crate foo;` statement, but that's not its job. For detecting unused `extern crate foo` statements, there is the `unused_extern_crates` lint which can be enabled by `#![warn(unused_extern_crates)]` or similar. cc ```@jsgf``` ```@ehuss``` ```@petrochenkov``` ```@estebank```
2021-04-04wasm64Gus Caplan-17/+126
2021-04-04resolve: Stable order for derive helper attributesVadim Petrochenkov-6/+9
2021-04-04resolve/expand: Cache intermediate results of `#[derive]` expansionVadim Petrochenkov-73/+97
2021-04-04Auto merge of #83839 - ldm0:deref, r=petrochenkovbors-4/+4
Remove unneeded type resolving small optimization.
2021-04-04Allow clobbering unsupported registers in asm!Amanieu d'Antras-33/+76
Previously registers could only be marked as clobbered if the target feature for that register was enabled. This restriction is now removed.
2021-04-03Auto merge of #83811 - JohnTitor:rollup-hnw1xwz, r=JohnTitorbors-11/+14
Rollup of 7 pull requests Successful merges: - #82487 (Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAddrV6`) - #83756 (rustdoc: Rename internal uses of `spotlight`) - #83780 (Document "standard" conventions for error messages) - #83787 (Monomorphization doc fix) - #83803 (add fp-armv8 for ARM_ALLOWED_FEATURES) - #83804 (Remove nightly features in rustc_type_ir) - #83810 (Fix rustc_lint_defs documentation typo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-04-03Remove attribute `#[link_args]`Vadim Petrochenkov-86/+7
2021-04-04Optimize out unneeded type resolvingliudingming-2/+2
2021-04-04Move log's short part to firstliudingming-2/+2
2021-04-04Rollup merge of #83810 - benmezger:update-builtin-docs-typo, r=jonas-schievinkYuki Okushi-1/+1
Fix rustc_lint_defs documentation typo Found a typo while reading the documentation. This PR fixes it.
2021-04-04Rollup merge of #83804 - detrumi:build-type-ir-on-stable, r=petrochenkovYuki Okushi-6/+4
Remove nightly features in rustc_type_ir `rustc_type_ir` will be used as a type library by Chalk, which we want to be able to build on stable, so this PR removes the current nightly features used.
2021-04-04Rollup merge of #83803 - surechen:add_target_feature, r=petrochenkovYuki Okushi-0/+1
add fp-armv8 for ARM_ALLOWED_FEATURES For fixing err in https://github.com/rust-lang/stdarch/pull/1105.
2021-04-04Rollup merge of #83787 - digama0:patch-1, r=bjorn3Yuki Okushi-4/+8
Monomorphization doc fix Only public items are monomorphization roots. This can be confirmed by noting that this program compiles: ```rust fn foo<T>() { if true { foo::<Option<T>>() } } fn bar() { foo::<()>() } ``` See also the [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Why.20are.20non.20public.20items.20monomorphization.20roots.3F).
2021-04-03Fix rustc_lint_defs documentation typoBen Mezger-1/+1
2021-04-03Auto merge of #83682 - bjorn3:mmap_wrapper, r=cjgillotbors-48/+62
Add an Mmap wrapper to rustc_data_structures This wrapper implements StableAddress and falls back to directly reading the file on wasm32. Taken from #83640, which I will close due to the perf regression.
2021-04-03Add safety comment to StableAddress impl for Mmapbjorn3-0/+4
2021-04-03Add fixme comment to revert change once const_panic is stableWilco Kusee-0/+2
2021-04-03Remove nightly features in rustc_type_irWilco Kusee-6/+2
2021-04-03add fp-armv8 for ARM_ALLOWED_FEATURESsurechen-0/+1
2021-04-03Auto merge of #83774 - richkadel:zero-based-counters, r=tmandrybors-24/+105
Translate counters from Rust 1-based to LLVM 0-based counter ids A colleague contacted me and asked why Rust's counters start at 1, when Clangs appear to start at 0. There is a reason why Rust's internal counters start at 1 (see the docs), and I tried to keep them consistent when codegenned to LLVM's coverage mapping format. LLVM should be tolerant of missing counters, but as my colleague pointed out, `llvm-cov` will silently fail to generate a coverage report for a function based on LLVM's assumption that the counters are 0-based. See: https://github.com/llvm/llvm-project/blob/main/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp#L170 Apparently, if, for example, a function has no branches, it would have exactly 1 counter. `CounterValues.size()` would be 1, and (with the 1-based index), the counter ID would be 1. This would fail the check and abort reporting coverage for the function. It turns out that by correcting for this during coverage map generation, by subtracting 1 from the Rust Counter ID (both when generating the counter increment intrinsic call, and when adding counters to the map), some uncovered functions (including in tests) now appear covered! This corrects the coverage for a few tests! r? `@tmandry` FYI: `@wesleywiser`
2021-04-03Auto merge of #83599 - jyn514:unorderable, r=Aaron1011bors-2/+5
Avoid sorting by DefId for `necessary_variants()` Follow-up to https://github.com/rust-lang/rust/pull/83074. Originally I tried removing `impl Ord for DefId` but that hit *lots* of errors :sweat_smile: so I thought I would start with easy things. I am not sure whether this could actually cause invalid query results, but this is used from `MarkSymbolVisitor::visit_arm` so it's at least feasible. r? `@Aaron1011`
2021-04-02Translate counters from Rust 1-based to LLVM 0-based counter idsRich Kadel-24/+105
A colleague contacted me and asked why Rust's counters start at 1, when Clangs appear to start at 0. There is a reason why Rust's internal counters start at 1 (see the docs), and I tried to keep them consistent when codegenned to LLVM's coverage mapping format. LLVM should be tolerant of missing counters, but as my colleague pointed out, `llvm-cov` will silently fail to generate a coverage report for a function based on LLVM's assumption that the counters are 0-based. See: https://github.com/llvm/llvm-project/blob/main/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp#L170 Apparently, if, for example, a function has no branches, it would have exactly 1 counter. `CounterValues.size()` would be 1, and (with the 1-based index), the counter ID would be 1. This would fail the check and abort reporting coverage for the function. It turns out that by correcting for this during coverage map generation, by subtracting 1 from the Rust Counter ID (both when generating the counter increment intrinsic call, and when adding counters to the map), some uncovered functions (including in tests) now appear covered! This corrects the coverage for a few tests!
2021-04-02Auto merge of #81866 - nagisa:nagisa/sanitizer-support-target-prop, r=tmiaskobors-200/+214
Maintain supported sanitizers as a target property In an effort to remove a hard-coded allow-list for target-sanitizer support correspondence, this PR moves the configuration to the target options. Perhaps the one notable change made in this PR is this doc-comment: ```rust /// The sanitizers supported by this target /// /// Note that the support here is at a codegen level. If the machine code with sanitizer /// enabled can generated on this target, but the necessary supporting libraries are not /// distributed with the target, the sanitizer should still appear in this list for the target. ``` Previously the target would typically be added to the allow-list at the same time as the supporting runtime libraries are shipped for the target. However whether we ship the runtime libraries or not needn't be baked into the compiler; and if we don't users will receive a significantly more directed error about library not being found. Fixes #81802
2021-04-02Reduce size of statementsRoxane-14/+16
2021-04-02Fix diagnostic issue when using FakeReads in closuresRoxane-30/+69
2021-04-03rm target specific logic in link_sanitizer_runtimeSimonas Kazlauskas-22/+14
2021-04-03(De-)serialize the supported_sanitizersSimonas Kazlauskas-14/+59
2021-04-03Maintain supported sanitizers as a target propertySimonas Kazlauskas-63/+47
This commit adds an additional target property – `supported_sanitizers`, and replaces the hardcoded allowlists in argument parsing to use this new property. Fixes #81802
2021-04-03Move SanitizerSet to rustc_targetSimonas Kazlauskas-116/+109
2021-04-02Auto merge of #83790 - Dylan-DPC:rollup-p6ep8jo, r=Dylan-DPCbors-29/+84
Rollup of 7 pull requests Successful merges: - #83065 (Rework `std::sys::windows::alloc`) - #83478 (rustdoc: Add unstable option to only emit shared/crate-specific files) - #83629 (Fix double-drop in `Vec::from_iter(vec.into_iter())` specialization when items drop during panic) - #83673 (give full path of constraint in suggest_constraining_type_param) - #83755 (Simplify coverage tests) - #83757 (2229: Support migration via rustfix) - #83771 (Fix stack overflow detection on FreeBSD 11.1+) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-04-02Rollup merge of #83757 - sexxi-goose:migrations_out, r=nikomatsakisDylan DPC-28/+81
2229: Support migration via rustfix - Adds support of machine applicable suggestions for `disjoint_capture_drop_reorder`. - Doesn't migrate in the case of pre-existing bugs in user code r? ``@nikomatsakis``
2021-04-02Rollup merge of #83673 - hi-rustin:rustin-patch-suggestion, r=estebankDylan DPC-1/+3
give full path of constraint in suggest_constraining_type_param close https://github.com/rust-lang/rust/issues/83513
2021-04-02Auto merge of #76881 - hameerabbasi:issue-53325, r=oli-obkbors-0/+10
Add allocation information to undefined behaviour errors. So far I'm looking on information on whether the error messages are suitable. Fixes #53325.
2021-04-02fixMario Carneiro-1/+2
2021-04-02clarify wordingMario Carneiro-3/+6
2021-04-02Monomorphization doc fixMario Carneiro-2/+2
Only public items are monomorphization roots. This can be confirmed by noting that this program compiles: ```rust fn foo<T>() { if true { foo::<Option<T>>() } } fn bar() { foo::<()>() } ```
2021-04-02Auto merge of #83468 - hi-rustin:rustin-patch-lint, r=nikomatsakisbors-3/+78
add OR_PATTERNS_BACK_COMPAT lint close https://github.com/rust-lang/rust/issues/83318
2021-04-02Auto merge of #83781 - JohnTitor:rollup-1vm3dxo, r=JohnTitorbors-0/+6
Rollup of 5 pull requests Successful merges: - #83535 (Break when there is a mismatch in the type count) - #83721 (Add a button to copy the "use statement") - #83740 (Fix comment typo in once.rs) - #83745 (Add my new email address to .mailmap) - #83754 (Add test to ensure search tabs behaviour) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-04-02Rollup merge of #83535 - MidasLamb:mir-type-count-mismatch, r=nikomatsakisYuki Okushi-0/+6
Break when there is a mismatch in the type count When other errors are generated, there can be a mismatch between the amount of input types in MIR, and the amount in the function itself. Break from the comparative loop if this is the case to prevent out-of-bounds. Fixes #83499
2021-04-02Auto merge of #83207 - oli-obk:valtree2, r=lcnrbors-30/+158
normalize mir::Constant differently from ty::Const in preparation for valtrees Valtrees are unable to represent many kind of constant values (this is on purpose). For constants that are used at runtime, we do not need a valtree representation and can thus use a different form of evaluation. In order to make this explicit and less fragile, I added a `fold_constant` method to `TypeFolder` and implemented it for normalization. Normalization can now, when it wants to eagerly evaluate a constant, normalize `mir::Constant` directly into a `mir::ConstantKind::Val` instead of relying on the `ty::Const` evaluation. In the future we can get rid of the `ty::Const` in there entirely and add our own `Unevaluated` variant to `mir::ConstantKind`. This would allow us to remove the `promoted` field from `ty::ConstKind::Unevaluated`, as promoteds can never occur in the type system. cc `@rust-lang/wg-const-eval` r? `@lcnr`