about summary refs log tree commit diff
path: root/compiler/rustc_mir/src
AgeCommit message (Collapse)AuthorLines
2021-04-24Auto merge of #84310 - RalfJung:const-fn-feature-flags, r=oli-obkbors-33/+22
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-24Fix coverage ICE because fn_sig can have a span that crosses file boundariesRich Kadel-1/+1
Fixes: #83792 MIR `InstrumentCoverage` assumed the `FnSig` span was contained within a single file, but this is not always the case. Some macro constructions can result in a span that starts in one `SourceFile` and ends in a different one. The `FnSig` span is included in coverage results as long as that span is in the same `SourceFile` and the same macro context, but by assuming the `FnSig` span's `hi()` and `lo()` were in the same file, I took this for granted, and checked only that the `FnSig` `hi()` was in the same `SourceFile` as the `body_span`. I actually drop the `hi()` though, and extend the `FnSig` span to the `body_span.lo()`, so I really should have simply checked that the `FnSig` span's `lo()` was in the `SourceFile` of the `body_span`.
2021-04-25Rollup merge of #83519 - oli-obk:assign_shrink_your_normal_code, r=pnkfelixYuki Okushi-15/+46
Implement a lint that highlights all moves larger than a configured limit Tracking issue: #83518 [MCP 420](https://github.com/rust-lang/compiler-team/issues/420) still ~blazing~ in progress r? ```@pnkfelix``` The main open issue I see with this minimal impl of the feature is that the lint is immediately "stable" (so it can be named on stable), even if it is never executed on stable. I don't think we have the concept of unstable lint names or hiding lint names without an active feature gate, so that would be a bigger change.
2021-04-22Fix ICE if original_span(fn_sig) returns a span not in body sourcefileRich Kadel-8/+4
Fixes: #84421
2021-04-20Auto merge of #84353 - estebank:as-ref-mir, r=davidtwcobors-3/+31
Suggest `.as_ref()` on borrow error involving `Option`/`Result` When encountering a E0382 borrow error involving an `Option` or `Result` provide a suggestion to use `.as_ref()` on the prior move location to avoid the move. Fix #84165.
2021-04-20TidyOli Scherer-3/+3
2021-04-20Add an attribute to be able to configure the limitOli Scherer-1/+6
2021-04-20Implement a lint that highlights all moves larger than 1000 bytesOli Scherer-13/+39
2021-04-20Auto merge of #84323 - richkadel:uncovered-functions, r=tmandrybors-3/+8
coverage of async function bodies should match non-async This fixes some missing coverage within async function bodies. Commit 1 demonstrates the problem in the fixed issue, and commit 2 corrects it. Fixes: #83985
2021-04-19Suggest `.as_ref()` on borrow error involving `Option`/`Result`Esteban Küber-3/+31
When encountering a E0382 borrow error involving an `Option` or `Result` provide a suggestion to use `.as_ref()` on the prior move location to avoid the move. Fix #84165.
2021-04-19compute fn_sig span from body call_site, and use body ctxt, not rootRich Kadel-4/+9
2021-04-19remove E0723 error codeRalf Jung-8/+6
2021-04-19fix few typosklensy-9/+9
2021-04-19add gate tests and pacify tidyRalf Jung-1/+1
2021-04-18Fixes the issue with uncovered source in async function bodiesRich Kadel-2/+2
The body_span was assumed to be in the Span root context, but this was not the case for async function bodies.
2021-04-18fix feature use in rustc libsRalf Jung-1/+0
2021-04-18separate feature flag for unsizing casts in const fnRalf Jung-22/+9
2021-04-18move 'trait bounds on const fn' to separate feature gateRalf Jung-3/+8
2021-04-12Compiler error messages: reduce assertiveness of message E0384James Addison-1/+1
This message is emitted as guidance by the compiler when a developer attempts to reassign a value to an immutable variable. Following the message will always currently work, but it may not always be the best course of action; following the 'consider ...' messaging pattern provides a hint to the developer that it could be wise to explore other alternatives.
2021-04-09Auto merge of #83870 - jackh726:binder-refactor-fix, r=nikomatsakisbors-3/+4
Don't concatenate binders across types Partially addresses #83737 There's actually two issues that I uncovered in #83737. The first is that we are concatenating bound vars across types, i.e. in ``` F: Fn(&()) -> &mut (dyn Future<Output = ()> + Unpin) ``` the bound vars on `Future` get set as `for<anon>` since those are the binders on `Fn(&()`. This is obviously wrong, since we should only concatenate directly nested trait refs. This is solved here by introducing a new `TraitRefBoundary` scope, that we put around the "syntactical" trait refs and basically don't allow concatenation across. Now, this alone *shouldn't* be a super terrible problem. At least not until you consider the other issue, which is a much more elusive and harder to design a "perfect" fix. A repro can be seen in: ``` use core::future::Future; async fn handle<F>(slf: &F) where F: Fn(&()) -> &mut (dyn for<'a> Future<Output = ()> + Unpin), { (slf)(&()).await; } ``` Notice the `for<'a>` around `Future`. Here, `'a` is unused, so the `for<'a>` Binder gets changed to a `for<>` Binder in the generator witness, but the "local decl" still has it. This has heavy intersections with region anonymization and erasing. Luckily, it's not *super* common to find this unique set of circumstances. It only became apparently because of the first issue mentioned here. However, this *is* still a problem, so I'm leaving #83737 open. r? `@nikomatsakis`
2021-04-08Rollup merge of #83980 - pierwill:fix-compiler-librustc-names, r=davidtwcoDylan DPC-1/+1
Fix outdated crate names in compiler docs Changes `librustc_X` to `rustc_X`, only in documentation comments. Plain code comments are left unchanged.
2021-04-08Fix outdated crate names in compiler docspierwill-1/+1
Changes `librustc_X` to `rustc_X`, only in documentation comments. Plain code comments are left unchanged. Also fix incorrect file paths.
2021-04-07Rollup merge of #83945 - SkiFire13:fix-83924, r=estebankDylan DPC-1/+18
Add suggestion to reborrow mutable references when they're moved in a for loop Address #83924
2021-04-07Rollup merge of #83916 - Amanieu:asm_anonconst, r=petrochenkovDylan DPC-76/+27
Use AnonConst for asm! constants This replaces the old system which used explicit promotion. See #83169 for more background. The syntax for `const` operands is still the same as before: `const <expr>`. Fixes #83169 Because the implementation is heavily based on inline consts, we suffer from the same issues: - We lose the ability to use expressions derived from generics. See the deleted tests in `src/test/ui/asm/const.rs`. - We are hitting the same ICEs as inline consts, for example #78174. It is unlikely that we will be able to stabilize this before inline consts are stabilized.
2021-04-06Add reborrow suggestion when mutable reference is moved in a for loopGiacomo Stevanato-1/+18
2021-04-06Use AnonConst for asm! constantsAmanieu d'Antras-76/+27
2021-04-05Don't concatenate binders across typesJack Huey-3/+4
2021-04-04Rollup merge of #83521 - sexxi-goose:quick-diagnostic-fix, r=nikomatsakisDylan DPC-10/+28
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 #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-02Reduce size of statementsRoxane-9/+9
2021-04-02Fix diagnostic issue when using FakeReads in closuresRoxane-3/+21
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 #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-8/+61
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`
2021-04-01Some more fine-grained forced inliningOli Scherer-0/+1
2021-03-31Cleanups and commentsJack Huey-3/+1
2021-03-31Add var to BoundRegion. Add query to get bound vars for applicable items.Jack Huey-15/+29
2021-03-31Track bound varsJack Huey-3/+6
2021-03-31Add tcx lifetime to BinderJack Huey-4/+4
2021-03-31Some rebinds and dummysJack Huey-4/+6
2021-03-31Forward some layouts to prevent recomputationOli Scherer-2/+2
2021-03-31Add a new normalization query just for mir constantsOli Scherer-2/+35
2021-03-31We should never see unevaluated type-level constants after monomorphization ↵Oli Scherer-1/+7
unless errors occurred
2021-03-31Make unevaluated DefId rendering deterministicOli Scherer-1/+15
2021-03-31Add allocation information to undefined behaviour errors.Hameer Abbasi-0/+10
2021-03-31Auto merge of #83666 - Amanieu:instrprof-order, r=tmandrybors-7/+1
Run LLVM coverage instrumentation passes before optimization passes This matches the behavior of Clang and allows us to remove several hacks which were needed to ensure functions weren't optimized away before reaching the instrumentation pass. Fixes #83429 cc `@richkadel` r? `@tmandry`