summary refs log tree commit diff
path: root/compiler/rustc_mir/src
AgeCommit message (Collapse)AuthorLines
2021-05-04Remove assert_matches feature attributes.Mara Bos-1/+0
2021-05-04Remove assert_matches usersMark Rousskov-11/+3
2021-04-30Auto merge of #84401 - crlf0710:impl_main_by_path, r=petrochenkovbors-2/+2
Implement RFC 1260 with feature_name `imported_main`. This is the second extraction part of #84062 plus additional adjustments. This (mostly) implements RFC 1260. However there's still one test case failure in the extern crate case. Maybe `LocalDefId` doesn't work here? I'm not sure. cc https://github.com/rust-lang/rust/issues/28937 r? `@petrochenkov`
2021-04-29Auto merge of #84556 - RalfJung:const-fn-trait-bound, r=oli-obkbors-11/+2
use correct feature flag for impl-block-level trait bounds on const fn I am not sure what that special hack was needed for, but it doesn't seem needed any more... This removes the last use of the `const_fn` feature flag -- Cc https://github.com/rust-lang/rust/issues/84510 r? `@oli-obk`
2021-04-29don't let const_fn feature flag affect impl-block-level trait boundsRalf Jung-11/+2
2021-04-29Implement RFC 1260 with feature_name `imported_main`.Charles Lew-2/+2
2021-04-28Remove extra word in `rustc_mir` docspierwill-1/+1
Changes "is includes" to "includes" in `rustc_mir::borrow_check::type_check::type_check`.
2021-04-28Auto merge of #84562 - richkadel:issue-83601, r=tmandrybors-0/+6
Adds feature-gated `#[no_coverage]` function attribute, to fix derived Eq `0` coverage issue #83601 Derived Eq no longer shows uncovered The Eq trait has a special hidden function. MIR `InstrumentCoverage` would add this function to the coverage map, but it is never called, so the `Eq` trait would always appear uncovered. Fixes: #83601 The fix required creating a new function attribute `no_coverage` to mark functions that should be ignored by `InstrumentCoverage` and the coverage `mapgen` (during codegen). Adding a `no_coverage` feature gate with tracking issue #84605. r? `@tmandry` cc: `@wesleywiser`
2021-04-28Auto merge of #83401 - fee1-dead:master, r=davidtwcobors-7/+10
Fix ICE of for-loop mut borrowck where no suggestions are available Fixes #83309.
2021-04-28Rollup merge of #84529 - richkadel:issue-84180, r=tmandryYuki Okushi-1/+11
Improve coverage spans for chained function calls Fixes: #84180 For chained function calls separated by the `?` try operator, the function call following the try operator produced a MIR `Call` span that matched the span of the first call. The `?` try operator started a new span, so the second call got no span. It turns out the MIR `Call` terminator has a `func` `Operand` for the `Constant` representing the function name, and the function name's Span can be used to reset the starting position of the span. r? `@tmandry` cc: `@wesleywiser`
2021-04-27Derived Eq no longer shows uncoveredRich Kadel-0/+6
The Eq trait has a special hidden function. MIR `InstrumentCoverage` would add this function to the coverage map, but it is never called, so the `Eq` trait would always appear uncovered. Fixes: #83601 The fix required creating a new function attribute `no_coverage` to mark functions that should be ignored by `InstrumentCoverage` and the coverage `mapgen` (during codegen). While testing, I also noticed two other issues: * spanview debug file output ICEd on a function with no body. The workaround for this is included in this PR. * `assert_*!()` macro coverage can appear covered if followed by another `assert_*!()` macro. Normally they appear uncovered. I submitted a new Issue #84561, and added a coverage test to demonstrate this issue.
2021-04-27Auto merge of #84532 - richkadel:issue-83792, r=tmandrybors-1/+1
Fix coverage ICE because fn_sig can have a span that crosses file bou… 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`. r? `@tmandry` cc: `@wesleywiser`
2021-04-25remove now-unused 'is_min_const_fn'Ralf Jung-49/+0
2021-04-25unsafety checking: no longer care about is_min_const_fnRalf Jung-50/+17
Rejecting the forbidden unsafe ops is done by const checking, not by unsafety checking
2021-04-24Improve spans for chained function callsRich Kadel-1/+11
Fixes: #84180 For chained function calls separated by the `?` try operator, the function call following the try operator produced a MIR `Call` span that matched the span of the first call. The `?` try operator started a new span, so the second call got no span. It turns out the MIR `Call` terminator has a `func` `Operand` for the `Constant` representing the function name, and the function name's Span can be used to reset the starting position of the span.
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::<()>() } ```