about summary refs log tree commit diff
path: root/src/librustc/mir
AgeCommit message (Collapse)AuthorLines
2020-03-11miri: categorize errors into "unsupported" and "UB"Ralf Jung-213/+129
Also slightly refactor pointer bounds checks to avoid creating unnecessary temporary Errors
2020-03-11Deduplicate and clean up pretty printing logicOliver Scherer-8/+8
2020-03-10[Miri] Use a session variable instead of checking for an env var alwaysWesley Wiser-13/+20
In CTFE heavy code, checking the env var everytime is inefficient. We can do a lot better by using a `Session` variable instead.
2020-03-10rust-lang.github.io/rustc-dev-guide -> rustc-dev-guide.rust-lang.orgSantiago Pastorino-1/+1
2020-03-10Rename rustc guide to rustc dev guideSantiago Pastorino-2/+2
2020-03-10Rename rustc-guide to rustc-dev-guideSantiago Pastorino-1/+1
2020-03-10Rollup merge of #69714 - spastorino:place-ref-lifetime, r=oli-obkMazdak Farrokhzad-4/+4
Make PlaceRef take just one lifetime r? @eddyb
2020-03-09Rollup merge of #69762 - RalfJung:validity-errors, r=oli-obkMazdak Farrokhzad-4/+23
Ensure that validity only raises validity errors For now, only as a debug-assertion (similar to const-prop detecting errors that allocate). Now includes https://github.com/rust-lang/rust/pull/69646. [Relative diff](https://github.com/RalfJung/rust/compare/layout-visitor...RalfJung:validity-errors). r? @oli-obk
2020-03-08use static strings instead of tcxRalf Jung-5/+5
2020-03-08Fix typoRalf Jung-2/+2
Co-Authored-By: bjorn3 <bjorn3@users.noreply.github.com>
2020-03-08fix some cases of unexpected exceptions leaving validationRalf Jung-5/+8
2020-03-08move error allocation test to error.rsRalf Jung-1/+17
2020-03-08Rollup merge of #69326 - JOE1994:os_str_widestring, r=RalfJungMazdak Farrokhzad-0/+10
mir-interpret: add method to read wide strings from Memory Implemented *step2* from [instructions](https://github.com/rust-lang/miri/issues/707#issuecomment-561564057) laid out in rust-lang/miri#707. Added 2 new methods to struct `rustc_mir::interpret::InterpCx`. * `read_os_str_from_wide_str` (src/librustc_mir/interpret/operand.rs) * `write_os_str_to_wide_str` (src/librustc_mir/interpret/place.rs) - used existing logic implemented in [MIRI/src/eval.rs](https://github.com/rust-lang/miri/blob/94732aaf7bf79fd01a4a48d11155c6586b937514/src/eval.rs#L132-L141) These methods are intended to be used for environment variable emulation in Windows.
2020-03-07Rollup merge of #69787 - spastorino:use-local-directly-its-copy, r=oli-obkMazdak Farrokhzad-5/+5
mir::Local is Copy we can pass it by value in these cases r? @oli-obk
2020-03-07Rollup merge of #69773 - matthiaskrgr:typos, r=petrochenkovMazdak Farrokhzad-1/+1
fix various typos
2020-03-07Rollup merge of #69782 - matthiaskrgr:redundant_field_name_rep, r=cramertjMazdak Farrokhzad-1/+1
Don't redundantly repeat field names (clippy::redundant_field_names)
2020-03-07Rollup merge of #69656 - matthiaskrgr:iter_nth_zero, r=oli-obkMazdak Farrokhzad-1/+1
Use .next() instead of .nth(0) on iterators.
2020-03-06mir-interpret: add method Memory::read wide_stringJOE1994-0/+10
2020-03-06mir::Local is Copy we can pass it by value in these casesSantiago Pastorino-5/+5
2020-03-06Don't redundantly repeat field names (clippy::redundant_field_names)Matthias Krüger-1/+1
2020-03-06fix various typosMatthias Krüger-1/+1
2020-03-05Rollup merge of #69736 - matthiaskrgr:even_more_clippy, r=Dylan-DPCDylan DPC-1/+1
even more clippy cleanups * Don't pass &mut where immutable reference (&) is sufficient (clippy::unnecessary_mut_passed) * Use more efficient &&str to String conversion (clippy::inefficient_to_string) * Don't always eval arguments inside .expect(), use unwrap_or_else and closure. (clippy::expect_fun_call) * Use righthand '&' instead of lefthand "ref". (clippy::toplevel_ref_arg) * Use simple 'for i in x' loops instead of 'while let Some(i) = x.next()' loops on iterators. (clippy::while_let_on_iterator) * Const items have by default a static lifetime, there's no need to annotate it. (clippy::redundant_static_lifetimes) * Remove redundant patterns when matching ( x @ _ to x) (clippy::redundant_pattern)
2020-03-05Const items have by default a static lifetime, there's no need to annotate ↵Matthias Krüger-1/+1
it. (clippy::redundant_static_lifetimes)
2020-03-04PlaceRef<'a, 'tcx> -> PlaceRef<'tcx>Santiago Pastorino-4/+4
2020-03-04use integer assoc consts instead of methodsRalf Jung-9/+9
2020-03-04Auto merge of #69550 - RalfJung:scalar, r=oli-obkbors-28/+14
interpret engine: Scalar cleanup * Remove `to_ptr` * Make `to_bits` private r? @oli-obk
2020-03-03Use .next() instead of .nth(0) on iterators.Matthias Krüger-1/+1
2020-03-02Make PlaceRef lifetimes of Place::as_ref be both 'tcxSantiago Pastorino-1/+1
2020-03-03Simplify conditions like x + 1 <= y to x < yMatthias Krüger-1/+1
2020-02-29Rename `syntax` to `rustc_ast` in source codeVadim Petrochenkov-4/+4
2020-02-28move ZST assertion up, for better errorsRalf Jung-2/+2
2020-02-28remove ScalarMaybeUndef::to_bits and make Scalar::to_bits privateRalf Jung-9/+4
2020-02-28use is_empty() instead of len() == x to determine if structs are empty.Matthias Krüger-2/+2
2020-02-28remove check_raw after reducing it to one use onlyRalf Jung-8/+3
2020-02-28get rid of to_ptrRalf Jung-11/+3
2020-02-28add comment to check_dataRalf Jung-0/+4
2020-02-28Auto merge of #68505 - skinny121:canonicalize-const-eval-inputs, r=nikomatsakisbors-19/+17
Canonicalize inputs to const eval where needed Canonicalize inputs to const eval, so that they can contain inference variables. Which enables invoking const eval queries even if the current param env has inference variable within it, which can occur during trait selection. This is a reattempt of #67717, in a far less invasive way. Fixes #68477 r? @nikomatsakis cc @eddyb
2020-02-27don't use .into() to convert types into identical types.Matthias Krüger-3/+3
example: let s: String = format!("hello").into();
2020-02-27Auto merge of #68528 - ecstatic-morse:maybe-init-variants, r=oli-obkbors-0/+9
Mark other variants as uninitialized after switch on discriminant During drop elaboration, which builds the drop ladder that handles destruction during stack unwinding, we attempt to remove MIR `Drop` terminators that will never be reached in practice. This reduces the number of basic blocks that are passed to LLVM, which should improve performance. In #66753, a user pointed out that unreachable `Drop` terminators are common in functions like `Option::unwrap`, which move out of an `enum`. While discussing possible remedies for that issue, @eddyb suggested moving const-checking after drop elaboration. This would allow the former, which looks for `Drop` terminators and replicates a small amount of drop elaboration to determine whether a dropped local has been moved out, leverage the work done by the latter. However, it turns out that drop elaboration is not as precise as it could be when it comes to eliminating useless drop terminators. For example, let's look at the code for `unwrap_or`. ```rust fn unwrap_or<T>(opt: Option<T>, default: T) -> T { match opt { Some(inner) => inner, None => default, } } ``` `opt` never needs to be dropped, since it is either moved out of (if it is `Some`) or has no drop glue (if it is `None`), and `default` only needs to be dropped if `opt` is `Some`. This is not reflected in the MIR we currently pass to codegen. ![pasted_image](https://user-images.githubusercontent.com/29463364/73384403-109a0d80-4280-11ea-8500-0637b368f2dc.png) @eddyb also suggested the solution to this problem. When we switch on an enum discriminant, we should be marking all fields in other variants as definitely uninitialized. I implemented this on top of alongside a small optimization (split out into #68943) that suppresses drop terminators for enum variants with no fields (e.g. `Option::None`). This is the resulting MIR for `unwrap_or`. ![after](https://user-images.githubusercontent.com/29463364/73384823-e432c100-4280-11ea-84bd-d0bcc3b777b4.png) In concert with #68943, this change speeds up many [optimized and debug builds](https://perf.rust-lang.org/compare.html?start=d55f3e9f1da631c636b54a7c22c1caccbe4bf0db&end=0077a7aa11ebc2462851676f9f464d5221b17d6a). We need to carefully investigate whether I have introduced any miscompilations before merging this. Code that never drops anything would be very fast indeed until memory is exhausted.
2020-02-24don't explicitly compare against true or falseMatthias Krüger-1/+1
2020-02-22Auto merge of #69302 - jonas-schievink:yield-needs-storage, r=Zoxcbors-1/+1
Fix generator miscompilations Fixes https://github.com/rust-lang/rust/issues/69039 r? @Zoxc
2020-02-20lit_to_const: gracefully bubble up type errors.Mazdak Farrokhzad-0/+4
2020-02-20Erase regions before before performing const eval, to improve caching.Ben Lewis-19/+17
2020-02-19Reorder yield visitation order to match callJonas Schievink-1/+1
2020-02-19Use a constructor function per dep node instead of an enum and a single functionJohn Kåre Alsaker-1/+1
2020-02-18Rollup merge of #69200 - jonas-schievink:yield-print, r=eddyb,ZoxcDylan DPC-8/+8
Fix printing of `Yield` terminator Addresses the bug found in https://github.com/rust-lang/rust/issues/69039#issuecomment-586633495
2020-02-18Rollup merge of #69181 - skinny121:const-eval-return, r=oli-obkDylan DPC-2/+39
Change const eval to just return the value As discussed in https://github.com/rust-lang/rust/pull/68505#discussion_r370956535, the type of consts shouldn't be returned from const eval queries. r? @eddyb cc @nikomatsakis
2020-02-16suspend -> yieldJonas Schievink-3/+1
2020-02-16Fix printing of `Yield` terminatorJonas Schievink-8/+10
2020-02-16Code review changes.Ben Lewis-3/+8