summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src
AgeCommit message (Collapse)AuthorLines
2021-06-04Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514Yuki Okushi-3/+0
Remove unused feature gates The first commit removes a usage of a feature gate, but I don't expect it to be controversial as the feature gate was only used to workaround a limitation of rust in the past. (closures never being `Clone`) The second commit uses `#[allow_internal_unstable]` to avoid leaking the `trusted_step` feature gate usage from inside the index newtype macro. It didn't work for the `min_specialization` feature gate though. The third commit removes (almost) all feature gates from the compiler that weren't used anyway.
2021-06-03Auto merge of #85952 - JohnTitor:rollup-r00gu9q, r=JohnTitorbors-19/+15
Rollup of 13 pull requests Successful merges: - #83362 (Stabilize `vecdeque_binary_search`) - #85706 (Turn off frame pointer elimination on all Apple platforms. ) - #85724 (Fix issue 85435 by restricting Fake Read precision) - #85852 (Clarify meaning of MachineApplicable suggestions.) - #85877 (Intra doc link-ify a reference to a function) - #85880 (convert assertion on rvalue::threadlocalref to delay bug) - #85896 (Add test for forward declared const param defaults) - #85897 (Update I-unsound label for triagebot) - #85900 (Use pattern matching instead of checking lengths explicitly) - #85911 (Avoid a clone of output_filenames.) - #85926 (Update cargo) - #85934 (Add `Ty::is_union` predicate) - #85935 (Validate type of locals used as indices) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-06-03Rollup merge of #85724 - sexxi-goose:rox-fix-issue-85435, r=nikomatsakisYuki Okushi-19/+15
Fix issue 85435 by restricting Fake Read precision This PR fixes the root bug of issue #85435 by restricting Fake Read precision in closures and removing the feature gate introduced in PR #85564. More info [here](https://github.com/rust-lang/rust/issues/85561#issuecomment-846223784) and [here](https://github.com/rust-lang/rust/issues/85561#issuecomment-847270533). Closes #85561 r? ``@nikomatsakis``
2021-06-03Auto merge of #84988 - alexcrichton:safe-target-feature-wasm, r=joshtriplettbors-7/+10
rustc: Allow safe #[target_feature] on wasm This commit updates the compiler's handling of the `#[target_feature]` attribute when applied to functions on WebAssembly-based targets. The compiler in general requires that any functions with `#[target_feature]` are marked as `unsafe` as well, but this commit relaxes the restriction for WebAssembly targets where the attribute can be applied to safe functions as well. The reason this is done is that the motivation for this feature of the compiler is not applicable for WebAssembly targets. In general the `#[target_feature]` attribute is used to enhance target CPU features enabled beyond the basic level for the rest of the compilation. If done improperly this means that your program could execute an instruction that the CPU you happen to be running on does not understand. This is considered undefined behavior where it is unknown what will happen (e.g. it's not a deterministic `SIGILL`). For WebAssembly, however, the target is different. It is not possible for a running WebAssembly program to execute an instruction that the engine does not understand. If this were the case then the program would not have validated in the first place and would not run at all. Even if this were allowed in some hypothetical future where engines have some form of runtime feature detection (which they do not right now) any implementation of such a feature would generate a trap if a module attempts to execute an instruction the module does not understand. This deterministic trap behavior would still not fall into the category of undefined behavior because the trap is deterministic. For these reasons the `#[target_feature]` attribute is now allowed on safe functions, but only for WebAssembly targets. This notably enables the wasm-SIMD intrinsics proposed for stabilization in #74372 to be marked as safe generally instead of today where they're all `unsafe` due to the historical implementation of `#[target_feature]` in the compiler.
2021-05-31Remove unused feature gatesbjorn3-3/+0
2021-05-30Auto merge of #83772 - jhpratt:revamp-step-trait, r=Mark-Simulacrumbors-0/+2
Make `Step` trait safe to implement This PR makes a few modifications to the `Step` trait that I believe better position it for stabilization in the short term. In particular, 1. `unsafe trait TrustedStep` is introduced, indicating that the implementation of `Step` for a given type upholds all stated invariants (which have remained unchanged). This is gated behind a new `trusted_step` feature, as stabilization is realistically blocked on min_specialization. 2. The `Step` trait is internally specialized on the `TrustedStep` trait, which avoids a serious performance regression. 3. `TrustedLen` is implemented for `T: TrustedStep` as the latter's invariants subsume the former's. 4. The `Step` trait is no longer `unsafe`, as the invariants must not be relied upon by unsafe code (unless the type implements `TrustedStep`). 5. `TrustedStep` is implemented for all types that implement `Step` in the standard library and compiler. 6. The `step_trait_ext` feature is merged into the `step_trait` feature. I was unable to find any reasoning for the features being split; the `_unchecked` methods need not necessarily be stabilized at the same time, but I think it is useful to have them under the same feature flag. All existing implementations of `Step` will be broken, as it is not possible to `unsafe impl` a safe trait. Given this trait only exists on nightly, I feel this breakage is acceptable. The blanket `impl<T: Step> TrustedLen for T` will likely cause some minor breakage, but this should be covered by the equivalent impl for `TrustedStep`. Hopefully these changes are sufficient to place `Step` in decent position for stabilization, which would allow user-defined types to be used with `a..b` syntax.
2021-05-28rustc: Allow safe #[target_feature] on wasmAlex Crichton-7/+10
This commit updates the compiler's handling of the `#[target_feature]` attribute when applied to functions on WebAssembly-based targets. The compiler in general requires that any functions with `#[target_feature]` are marked as `unsafe` as well, but this commit relaxes the restriction for WebAssembly targets where the attribute can be applied to safe functions as well. The reason this is done is that the motivation for this feature of the compiler is not applicable for WebAssembly targets. In general the `#[target_feature]` attribute is used to enhance target CPU features enabled beyond the basic level for the rest of the compilation. If done improperly this means that your program could execute an instruction that the CPU you happen to be running on does not understand. This is considered undefined behavior where it is unknown what will happen (e.g. it's not a deterministic `SIGILL`). For WebAssembly, however, the target is different. It is not possible for a running WebAssembly program to execute an instruction that the engine does not understand. If this were the case then the program would not have validated in the first place and would not run at all. Even if this were allowed in some hypothetical future where engines have some form of runtime feature detection (which they do not right now) any implementation of such a feature would generate a trap if a module attempts to execute an instruction the module does not understand. This deterministic trap behavior would still not fall into the category of undefined behavior because the trap is deterministic. For these reasons the `#[target_feature]` attribute is now allowed on safe functions, but only for WebAssembly targets. This notably enables the wasm-SIMD intrinsics proposed for stabilization in #74372 to be marked as safe generally instead of today where they're all `unsafe` due to the historical implementation of `#[target_feature]` in the compiler.
2021-05-27Remove feature gateRoxane-19/+15
2021-05-27Make closures inherit their parent's "safety context"LeSeulArtichaut-2/+30
2021-05-27Rollup merge of #85564 - ↵Dylan DPC-15/+20
pnkfelix:issue-85435-readd-capture-disjoint-fields-gate, r=nikomatsakis readd capture disjoint fields gate This readds a feature gate guard that was added in PR #83521. (Basically, there were unintended consequences to the code exposed by removing the feature gate guard.) The root bug still remains to be resolved, as discussed in issue #85561. This is just a band-aid suitable for a beta backport. Cc issue #85435 Note that the latter issue is unfixed until we backport this (or another fix) to 1.53 beta
2021-05-26Specialize implementationsJacob Pratt-0/+2
Implementations in stdlib are now optimized as they were before.
2021-05-25Fix `unused_unsafe` in THIR unsafeckLeSeulArtichaut-8/+13
2021-05-25Handle `unsafe_op_in_unsafe_fn` properly in THIR unsafeckLeSeulArtichaut-8/+12
2021-05-25Rollup merge of #85605 - ptrojahn:closure_struct, r=matthewjasperGuillaume Gomez-7/+4
Replace Local::new(1) with CAPTURE_STRUCT_LOCAL
2021-05-25Auto merge of #84985 - pietroalbini:bootstrap-1.54, r=Mark-Simulacrumbors-1/+0
Bump bootstrap compiler to beta 1.53.0 This PR bumps the bootstrap compiler to version 1.53.0 beta, as part of our usual release process (this was supposed to be Wednesday's step, but creating the beta release took longer than expected). The PR also includes the "Bootstrap: skip rustdoc fingerprint for building docs" commit, see the reasoning [on Zulip](https://zulip-archive.rust-lang.org/241545trelease/88450153betabootstrap.html). r? `@Mark-Simulacrum`
2021-05-25Auto merge of #85273 - LeSeulArtichaut:thir-query, r=nikomatsakisbors-858/+138
Make building THIR a stealable query This PR creates a stealable `thir_body` query so that we can build the THIR only once for THIR unsafeck and MIR build. Blocked on #83842. r? `@nikomatsakis`
2021-05-24remove cfg(bootstrap)Pietro Albini-1/+0
2021-05-24Make `thir_check_unsafety` itself responsible for checking gateLeSeulArtichaut-9/+12
2021-05-24Add comments about stealing THIR in `mir_build`LeSeulArtichaut-0/+4
2021-05-24Replace more "NULL" with "null"LeSeulArtichaut-1/+1
2021-05-23Replace Local::new(1) with CAPTURE_STRUCT_LOCALPaul Trojahn-7/+4
2021-05-23support creating mutable allocations from byte slicesRalf Jung-2/+2
2021-05-22Handle typeck errors properlyLeSeulArtichaut-0/+8
2021-05-22Make the THIR unsafeck use the `thir_body` queryLeSeulArtichaut-24/+23
2021-05-22Make THIR building a stealable queryLeSeulArtichaut-20/+22
2021-05-22Move THIR structure definitions to `rustc_middle`LeSeulArtichaut-825/+89
2021-05-21Revert portion of PR #83521 that injected issue #85435 (and thus exposed ↵Felix S. Klock II-15/+20
underlying issue #85561).
2021-05-21Check for use of mutable/extern statics in THIR unsafeckLeSeulArtichaut-6/+10
2021-05-21Check for ptr-to-int casts in const functions in THIR unsafeckLeSeulArtichaut-1/+17
2021-05-21Check for initialization of layout-restricted typesLeSeulArtichaut-1/+13
2021-05-20Check for calls to functions with `#[target_feature]` in THIR unsafeckLeSeulArtichaut-4/+27
2021-05-20Check for raw pointer dereference in THIR unsafeckLeSeulArtichaut-1/+5
2021-05-19Auto merge of #83842 - LeSeulArtichaut:thir-vec, r=nikomatsakisbors-709/+775
Store THIR in `IndexVec`s instead of an `Arena` This is a necessary step to store the THIR in a query: #85273. See [relevant discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/278509-project-thir-unsafeck/topic/THIR-dependent.20queries.20design). r? `@ghost` cc `@cjgillot` `@nikomatsakis`
2021-05-19Adapt the THIR visitor to the vec-stored THIRLeSeulArtichaut-95/+96
2021-05-19Store THIR in `IndexVec`s instead of an `Arena`LeSeulArtichaut-614/+679
2021-05-17Remove remnants of BorrowOfPackedFieldLeSeulArtichaut-37/+22
2021-05-14Check for inline assembly in THIR unsafeckSmitty-1/+3
2021-05-14Auto merge of #85233 - FabianWolff:issue-85227, r=petrochenkovbors-1/+10
Improve error message for non-exhaustive matches on non-exhaustive enums This pull request fixes #85227. For an enum marked with `#[non_exhaustive]` and not defined in the current crate, the error message for non-exhaustive matches now mentions the fact that the enum is marked as non-exhaustive: ``` error[E0004]: non-exhaustive patterns: `_` not covered --> main.rs:12:11 | 12 | match e { | ^ pattern `_` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms = note: the matched value is of type `E`, which is marked as non-exhaustive ```
2021-05-14Auto merge of #85195 - Mark-Simulacrum:variant-by-idx, r=petrochenkovbors-10/+7
Store VariantIdx to distinguish enum variants This saves ~24% of the instructions on the match-stress-enum benchmark, but I'm not 100% sure that this is OK - if we ever compare two constructors across enums (e.g., a Result and an Option), then this is obviously insufficient; I can experiment with continuing to store the DefId for comparison purposes in that case.
2021-05-12Improve error message for non-exhaustive matches on non-exhaustive enumsFabian Wolff-1/+10
2021-05-11Store VariantIdx to distinguish enum variantsMark Rousskov-10/+7
This saves ~24% of the instructions on the match-stress-enum benchmark.
2021-05-11Add helper for switching safety contextsLeSeulArtichaut-49/+72
2021-05-11Introduce the (WIP) THIR unsafety checkerLeSeulArtichaut-0/+322
2021-05-11[WIP] Create a `Visitor` for the THIRLeSeulArtichaut-0/+179
2021-04-24Auto merge of #84310 - RalfJung:const-fn-feature-flags, r=oli-obkbors-1/+0
further split up const_fn feature flag This continues the work on splitting up `const_fn` into separate feature flags: * `const_fn_trait_bound` for `const fn` with trait bounds * `const_fn_unsize` for unsizing coercions in `const fn` (looks like only `dyn` unsizing is still guarded here) I don't know if there are even any things left that `const_fn` guards... at least libcore and liballoc do not need it any more. `@oli-obk` are you currently able to do reviews?
2021-04-20Auto merge of #84295 - richkadel:continue-coverage, r=tmandrybors-0/+15
Add coverage to continue statements `continue` statements were missing coverage. This was particularly noticeable in a match pattern that contained only a `continue` statement, leaving the branch appear uncounted. This PR addresses the problem and adds tests to prove it. r? `@tmandry` cc: `@wesleywiser`
2021-04-19fix few typosklensy-2/+2
2021-04-18fix feature use in rustc libsRalf Jung-1/+0
2021-04-18Only generate dummy assign when instrumenting coverageRich Kadel-10/+15
And make the LocalDecl internal, to avoid needing to declare storage. (For multiple `continue` stateuemtns, it must also be mutable.)
2021-04-18Add coverage to continue statementsRich Kadel-0/+10
`continue` statements were missing coverage. This was particularly noticeable in a match pattern that contained only a `continue` statement, leaving the branch appear uncounted. This PR addresses the problem and adds tests to prove it.