about summary refs log tree commit diff
path: root/compiler/rustc_mir/src
AgeCommit message (Collapse)AuthorLines
2020-12-11don't convert types into identical types with .into() ↵Matthias Krüger-2/+2
(clippy::useless_conversion)
2020-12-11Move binder for dyn to each list itemJack Huey-1/+1
2020-12-11RustfmtJCTyblaidd-5/+1
2020-12-11Fix rustfmt failureJCTyblaidd-1/+1
2020-12-11Add post-initialization hook for static memory initialized using the ↵JCTyblaidd-1/+14
interpereter.
2020-12-11add missing constraintsTunahan Karlibas-6/+10
2020-12-11Auto merge of #79910 - RalfJung:abort-msg, r=oli-obkbors-1/+7
CTFE: tweak abort-on-uninhabited message Having an "aborted execution:" makes it more consistent with the `Abort` terminator saying "the program aborted execution". Right now, at least one of the two errors will look weird in Miri. r? `@oli-obk`
2020-12-11make redundant StorageLive UBRalf Jung-23/+16
2020-12-10Rollup merge of #79809 - Eric-Arellano:split-once, r=matkladTyler Mandry-28/+35
Dogfood `str_split_once()` Part of https://github.com/rust-lang/rust/issues/74773. Beyond increased clarity, this fixes some instances of a common confusion with how `splitn(2)` behaves: the first element will always be `Some()`, regardless of the delimiter, and even if the value is empty. Given this code: ```rust fn main() { let val = "..."; let mut iter = val.splitn(2, '='); println!("Input: {:?}, first: {:?}, second: {:?}", val, iter.next(), iter.next()); } ``` We get: ``` Input: "no_delimiter", first: Some("no_delimiter"), second: None Input: "k=v", first: Some("k"), second: Some("v") Input: "=", first: Some(""), second: Some("") ``` Using `str_split_once()` makes more clear what happens when the delimiter is not found.
2020-12-11Lower `discriminant_value` intrinsicTomasz Miąsko-0/+15
This allows const propagation to evaluate comparisons involving field-less enums using derived implementations of `PartialEq` (after inlining `eq`).
2020-12-11Remove unnecessary check and fix local_def_id parameterTunahan Karlibas-11/+4
2020-12-10CTFE: tweak abort-on-uninhabited messageRalf Jung-1/+7
2020-12-10Auto merge of #79621 - usbalbin:constier_maybe_uninit, r=RalfJungbors-3/+19
Constier maybe uninit I was playing around trying to make `[T; N]::zip()` in #79451 be `const fn`. One of the things I bumped into was `MaybeUninit::assume_init`. Is there any reason for the intrinsic `assert_inhabited<T>()` and therefore `MaybeUninit::assume_init` not being `const`? --- I have as best as I could tried to follow the instruction in [library/core/src/intrinsics.rs](https://github.com/rust-lang/rust/blob/master/library/core/src/intrinsics.rs#L11). I have no idea what I am doing but it seems to compile after some slight changes after the copy paste. Is this anywhere near how this should be done? Also any ideas for name of the feature gate? I guess `const_maybe_assume_init` is quite misleading since I have added some more methods. Should I add test? If so what should be tested?
2020-12-09update commentsChenguang Wang-5/+4
2020-12-09Use closure_min_captures in borrow checkerAman Arora-8/+14
- Use closure_min_captures to generate the Upvar structure that stores information for diagnostics and information about mutability of captures.
2020-12-09fix issue #78496Chenguang Wang-0/+28
2020-12-09Rollup merge of #79818 - richkadel:llvm-coverage-counters-2.1.0, r=tmandryTyler Mandry-27/+43
Fixes to Rust coverage Fixes: #79725 Some macros can create a situation where `fn_sig_span` and `body_span` map to different files. New documentation on coverage tests incorrectly assumed multiple test binaries could just be listed at the end of the `llvm-cov` command, but it turns out each binary needs a `--object` prefix. This PR fixes the bug and updates the documentation to correct that issue. It also fixes a few other minor issues in internal implementation comments, and adds documentation on getting coverage results for doc tests.
2020-12-09Rollup merge of #79732 - matthiaskrgr:cl12ppy, r=Dylan-DPCTyler Mandry-1/+1
minor stylistic clippy cleanups simplify if let Some(_) = x to if x.is_some() (clippy::redundant_pattern_matching) don't create owned values for comparison (clippy::cmp_owned) use .contains() or .any() instead of find(x).is_some() (clippy::search_is_some) don't wrap code block in Ok() (clipppy::unit_arg)
2020-12-09Extra assertions in eval_body_using_ecx to disallow queries forTunahan Karlibas-0/+7
functions that does allocations
2020-12-09Auto merge of #78679 - oli-obk:temp_lifetime, r=eddybbors-16/+6
Also generate `StorageDead` in constants r? `@eddyb` None of this special casing is actually necessary since we started promoting within constants and statics. We may want to keep some of it around out of perf reasons, but it's not required for user visible behaviour somewhat related: #68622
2020-12-09Also generate `StorageDead` in constantsoli-16/+6
2020-12-09Auto merge of #78363 - RalfJung:promotion, r=oli-obkbors-52/+6
remove this weird special case from promotion Promotion has a special case to ignore interior mutability under some specific circumstances. The purpose of this PR is to figure out what changes if we remove that. Since `Cell::new` and friends only get promoted inside `const`/`static` initializers these days, it actually is not easy to exploit this case: you need something like ```rust const TEST_INTERIOR_MUT: () = { // The "0." case is already ruled out by not permitting any interior mutability in `const`. let _val: &'static _ = &(Cell::new(1), 2).1; }; ``` I assume something like `&Some(&(Cell::new(1), 2).1)` would hit the nested case inside `validate_rvalue`... though I am not sure why that would not just trigger nested promotion, first promoting the inner reference and then the outer one? Fixes https://github.com/rust-lang/rust/issues/67534 (by simply rejecting that code^^) r? `@oli-obk` (but for now this is not meant to be merged!) Cc `@rust-lang/wg-const-eval`
2020-12-09remove a hack that seems to only benefit a few very special casesRalf Jung-52/+6
2020-12-09Remove memoization leftoversTunahan Karlibas-59/+4
closes #79667
2020-12-08Review feedbackEric Arellano-32/+36
* Use a match statement. * Clarify why we can't use `file_stem()`. * Error if the `:` is missing for Tidy error codes, rather than no-oping.
2020-12-08use .contains() or .any() instead of find(x).is_some() (clippy::search_is_some)Matthias Krüger-1/+1
2020-12-07Fixes to Rust coverageRich Kadel-27/+43
Fixes: #79725 Some macros can create a situation where `fn_sig_span` and `body_span` map to different files. New documentation on coverage tests incorrectly assumed multiple test binaries could just be listed at the end of the `llvm-cov` command, but it turns out each binary needs a `--object` prefix. This PR fixes the bug and updates the documentation to correct that issue. It also fixes a few other minor issues in internal implementation comments, and adds documentation on getting coverage results for doc tests.
2020-12-07Dogfood 'str_split_once() with `compiler/`Eric Arellano-23/+26
2020-12-07Add comment for assert_inhabited in ↵Albin Hedman-0/+2
compiler/rustc_mir/src/interpret/intrinsics.rs Co-authored-by: Ralf Jung <post@ralfj.de>
2020-12-07small `TypeVisitor` refactorBastian Kauschke-4/+5
2020-12-06[mir-opt] Allow debuginfo to be generated for a constant or a PlaceWesley Wiser-28/+143
Prior to this commit, debuginfo was always generated by mapping a name to a Place. This has the side-effect that `SimplifyLocals` cannot remove locals that are only used for debuginfo because their other uses have been const-propagated. To allow these locals to be removed, we now allow debuginfo to point to a constant value. The `ConstProp` pass detects when debuginfo points to a local with a known constant value and replaces it with the value. This allows the later `SimplifyLocals` pass to remove the local.
2020-12-06Fix comments related to abort()Albin Hedman-6/+8
2020-12-05Fix tests (hopefully)Albin Hedman-1/+1
2020-12-05abort() now takes a msg parameterAlbin Hedman-5/+9
2020-12-04Auto merge of #79686 - Dylan-DPC:rollup-leama5f, r=Dylan-DPCbors-21/+48
Rollup of 11 pull requests Successful merges: - #77686 (Render Markdown in search results) - #79541 (Doc keyword lint pass) - #79602 (Fix SGX CI) - #79611 (Use more std:: instead of core:: in docs for consistency) - #79623 (Pass around Symbols instead of Idents in doctree) - #79627 (Update cargo) - #79631 (disable a ptr equality test on Miri) - #79638 (Use `item_name` instead of pretty printing for resolving `Self` on intra-doc links) - #79646 (rustc_metadata: Remove some dead code) - #79664 (move interpret::MemoryKind::Heap to const eval) - #79678 (Fix some clippy lints) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2020-12-03Addressed feedback from 2020-12-01Rich Kadel-7/+11
Added one more test (two files) showing coverage of generics and unused functions across crates. Created and referenced new Issues, as requested. Added comments. Added a note about the possible effects of compiler options on LLVM coverage maps.
2020-12-03Combination of commitsRich Kadel-127/+117
Fixes multiple issue with counters, with simplification Includes a change to the implicit else span in ast_lowering, so coverage of the implicit else no longer spans the `then` block. Adds coverage for unused closures and async function bodies. Fixes: #78542 Adding unreachable regions for known MIR missing from coverage map Cleaned up PR commits, and removed link-dead-code requirement and tests Coverage no longer depends on Issue #76038 (`-C link-dead-code` is no longer needed or enforced, so MSVC can use the same tests as Linux and MacOS now) Restrict adding unreachable regions to covered files Improved the code that adds coverage for uncalled functions (with MIR but not-codegenned) to avoid generating coverage in files not already included in the files with covered functions. Resolved last known issue requiring --emit llvm-ir workaround Fixed bugs in how unreachable code spans were added.
2020-12-03Coverage tests for remaining TerminatorKinds and async, improve AssertRich Kadel-2/+6
Tested and validate results for panic unwind, panic abort, assert!() macro, TerminatorKind::Assert (for example, numeric overflow), and async/await. Implemented a previous documented idea to change Assert handling to be the same as FalseUnwind and Goto, so it doesn't get its own BasicCoverageBlock anymore. This changed a couple of coverage regions, but I validated those changes are not any worse than the prior results, and probably help assure some consistency (even if some people might disagree with how the code region is consistently computed). Fixed issue with async/await. AggregateKind::Generator needs to be handled like AggregateKind::Closure; coverage span for the outer async function should not "cover" the async body, which is actually executed in a separate "closure" MIR.
2020-12-03move interpret::MemoryKind::Heap to const evalVishnunarayan K I-21/+48
2020-12-03move intrinsic to CTFE, add FIXMEVishnunarayan K I-19/+20
2020-12-02Undo fn -> const fn for all intrinsics but assert_inhabitedAlbin Hedman-17/+1
2020-12-02rename MemoryKind::Heap to ConstHeap; bless testVishnunarayan K I-6/+12
2020-12-02add comment and bless some testsVishnunarayan K I-1/+5
2020-12-02Make some of MaybeUninit's methods constAlbin Hedman-0/+24
2020-12-01review comment and one more testVishnunarayan K I-7/+6
2020-12-01review commentsVishnunarayan K I-5/+11
2020-12-01add const_allocate intrisicVishnunarayan K I-3/+21
2020-12-01Added better error message for shared borrow treated as unique for purposes ↵PankajChaudhary5-3/+4
of lifetimes
2020-11-28Auto merge of #78296 - Aaron1011:fix/stmt-tokens, r=petrochenkovbors-1/+1
Properly handle attributes on statements We now collect tokens for the underlying node wrapped by `StmtKind` nstead of storing tokens directly in `Stmt`. `LazyTokenStream` now supports capturing a trailing semicolon after it is initially constructed. This allows us to avoid refactoring statement parsing to wrap the parsing of the semicolon in `parse_tokens`. Attributes on item statements (e.g. `fn foo() { #[bar] struct MyStruct; }`) are now treated as item attributes, not statement attributes, which is consistent with how we handle attributes on other kinds of statements. The feature-gating code is adjusted so that proc-macro attributes are still allowed on item statements on stable. Two built-in macros (`#[global_allocator]` and `#[test]`) needed to be adjusted to support being passed `Annotatable::Stmt`.
2020-11-26Fix new 'unnecessary trailing semicolon' warningsAaron Hill-1/+1