about summary refs log tree commit diff
path: root/compiler/rustc_mir/src
AgeCommit message (Collapse)AuthorLines
2021-08-12Avoid ICE caused by suggestionEsteban Küber-7/+12
When suggesting dereferencing something that can be iterable in a `for` loop, erase lifetimes and use a fresh `ty::ParamEnv` to avoid 'region constraints already solved' panic. Fix #87657.
2021-08-11Auto merge of #87587 - oli-obk:lazy_tait, r=spastorinobors-91/+75
Various refactorings of the TAIT infrastructure Before this PR we used to store the opaque type knowledge outside the `InferCtxt`, so it got recomputed on every opaque type instantiation. I also removed a feature gate check that makes no sense in the planned lazy TAIT resolution scheme Each commit passes all tests, so this PR is best reviewed commit by commit. r? `@spastorino`
2021-08-07Run RemoveZsts at mir-opt-level=1Erik Desjardins-3/+0
Effectively reverts commit 6960bc9696b05b15d8d89ece2fef14e6e62a43fc.
2021-08-07Auto merge of #87408 - kornelski:try_reserve_error, r=yaahcbors-0/+1
Hide allocator details from TryReserveError I think there's [no need for TryReserveError to carry detailed information](https://github.com/rust-lang/rust/issues/48043#issuecomment-825139280), but I wouldn't want that issue to delay stabilization of the `try_reserve` feature. So I'm proposing to stabilize `try_reserve` with a `TryReserveError` as an opaque structure, and if needed, expose error details later. This PR moves the `enum` to an unstable inner `TryReserveErrorKind` that lives under a separate feature flag. `TryReserveErrorKind` could possibly be left as an implementation detail forever, and the `TryReserveError` get methods such as `allocation_size() -> Option<usize>` or `layout() -> Option<Layout>` instead, or the details could be dropped completely to make try-reserve errors just a unit struct, and thus smaller and cheaper.
2021-08-06Store the `DefId` of the currently typechecked item in `InferCtxt`Oli Scherer-2/+1
This allows opaque type inference to check for defining uses without having to pass down that def id via function arguments to every method that could possibly cause an opaque type to be compared with a concrete type
2021-08-06Immediately register new opaque types in the global list.Oli Scherer-68/+58
Previously each opaque type instantiation would create new inference vars, even for the same opaque type/substs combination. Now there is a global map in InferCtxt that gets filled whenever we encounter an opaque type.
2021-08-06Remove Option only used as its Some variantOli Scherer-23/+18
2021-08-04Auto merge of #86155 - alexcrichton:abort-on-unwind, r=nikomatsakisbors-45/+150
rustc: Fill out remaining parts of C-unwind ABI This commit intends to fill out some of the remaining pieces of the C-unwind ABI. This has a number of other changes with it though to move this design space forward a bit. Notably contained within here is: * On `panic=unwind`, the `extern "C"` ABI is now considered as "may unwind". This fixes a longstanding soundness issue where if you `panic!()` in an `extern "C"` function defined in Rust that's actually UB because the LLVM representation for the function has the `nounwind` attribute, but then you unwind. * Whether or not a function unwinds now mainly considers the ABI of the function instead of first checking the panic strategy. This fixes a miscompile of `extern "C-unwind"` with `panic=abort` because that ABI can still unwind. * The aborting stub for non-unwinding ABIs with `panic=unwind` has been reimplemented. Previously this was done as a small tweak during MIR generation, but this has been moved to a separate and dedicated MIR pass. This new pass will, for appropriate functions and function calls, insert a `cleanup` landing pad for any function call that may unwind within a function that is itself not allowed to unwind. Note that this subtly changes some behavior from before where previously on an unwind which was caught-to-abort it would run active destructors in the function, and now it simply immediately aborts the process. * The `#[unwind]` attribute has been removed and all users in tests and such are now using `C-unwind` and `#![feature(c_unwind)]`. I think this is largely the last piece of the RFC to implement. Unfortunately I believe this is still not stabilizable as-is because activating the feature gate changes the behavior of the existing `extern "C"` ABI in a way that has no replacement. My thinking for how to enable this is that we add support for the `C-unwind` ABI on stable Rust first, and then after it hits stable we change the behavior of the `C` ABI. That way anyone straddling stable/beta/nightly can switch to `C-unwind` safely.
2021-08-04Rollup merge of #87720 - matthiaskrgr:clippy_into, r=jyn514Yuki Okushi-3/+3
don't use .into() to convert types to identical types (clippy::useless_conversion) Example: let _x: String = String::from("hello world").into();
2021-08-03make the hybrid variant the default polonius algorithmRémy Rakic-1/+1
2021-08-03update polonius-engine to 0.13Rémy Rakic-22/+23
and update fact generation to the new relation names
2021-08-03Auto merge of #87515 - crlf0710:trait_upcasting_part2, r=bjorn3bors-10/+64
Trait upcasting coercion (part2) This is the second part of trait upcasting coercion implementation. Currently this is blocked on #86264 . The third part might be implemented using unsafety checking r? `@bjorn3`
2021-08-03Use predefined helper instead of a new oneAlex Crichton-13/+2
2021-08-03Move abort_unwinding_calls earlierAlex Crichton-26/+54
2021-08-03rustc: Fill out remaining parts of C-unwind ABIAlex Crichton-45/+133
This commit intends to fill out some of the remaining pieces of the C-unwind ABI. This has a number of other changes with it though to move this design space forward a bit. Notably contained within here is: * On `panic=unwind`, the `extern "C"` ABI is now considered as "may unwind". This fixes a longstanding soundness issue where if you `panic!()` in an `extern "C"` function defined in Rust that's actually UB because the LLVM representation for the function has the `nounwind` attribute, but then you unwind. * Whether or not a function unwinds now mainly considers the ABI of the function instead of first checking the panic strategy. This fixes a miscompile of `extern "C-unwind"` with `panic=abort` because that ABI can still unwind. * The aborting stub for non-unwinding ABIs with `panic=unwind` has been reimplemented. Previously this was done as a small tweak during MIR generation, but this has been moved to a separate and dedicated MIR pass. This new pass will, for appropriate functions and function calls, insert a `cleanup` landing pad for any function call that may unwind within a function that is itself not allowed to unwind. Note that this subtly changes some behavior from before where previously on an unwind which was caught-to-abort it would run active destructors in the function, and now it simply immediately aborts the process. * The `#[unwind]` attribute has been removed and all users in tests and such are now using `C-unwind` and `#![feature(c_unwind)]`. I think this is largely the last piece of the RFC to implement. Unfortunately I believe this is still not stabilizable as-is because activating the feature gate changes the behavior of the existing `extern "C"` ABI in a way that has no replacement. My thinking for how to enable this is that we add support for the `C-unwind` ABI on stable Rust first, and then after it hits stable we change the behavior of the `C` ABI. That way anyone straddling stable/beta/nightly can switch to `C-unwind` safely.
2021-08-03don't use .into() to convert types to identical types ↵Matthias Krüger-3/+3
(clippy::useless_conversion) Example: let _x: String = String::from("hello world").into();
2021-08-02Auto merge of #87628 - estebank:unmet-explicit-lifetime-bound, r=oli-obkbors-1/+1
Point at unmet explicit lifetime obligation bound r? `@oli-obk` Split off of #85799.
2021-08-03Small refactorings for miri.Charles Lew-17/+16
2021-08-03Implement pointer casting.Charles Lew-5/+60
2021-08-02Auto merge of #87248 - RalfJung:ctfe-partial-overwrite, r=oli-obkbors-4/+11
CTFE: throw unsupported error when partially overwriting a pointer Currently, during CTFE, when a write to memory would overwrite parts of a pointer, we make the remaining parts of that pointer "uninitialized". This is probably not what users expect, so if this ever happens they will be quite confused about why some of the data just vanishes for seemingly no good reason. So I propose we change this to abort CTFE when that happens, to at last avoid silently doing the wrong thing. Cc https://github.com/rust-lang/rust/issues/87184 Our CTFE test suite still seems to pass. However, we should probably crater this, and I want to do some tests with Miri as well.
2021-08-02Auto merge of #87535 - lf-:authors, r=Mark-Simulacrumbors-1/+0
rfc3052 followup: Remove authors field from Cargo manifests Since RFC 3052 soft deprecated the authors field, hiding it from crates.io, docs.rs, and making Cargo not add it by default, and it is not generally up to date/useful information for contributors, we may as well remove it from crates in this repo.
2021-08-01clippy::perf fixesMatthias Krüger-2/+2
2021-08-01Auto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisabors-13/+13
more clippy::complexity fixes (also a couple of clippy::perf fixes)
2021-07-31Point at unmet explicit lifetime obligation boundEsteban Küber-1/+1
2021-07-31CTFE: throw unsupported error when partially overwriting a pointerRalf Jung-4/+11
2021-07-30Auto merge of #86754 - estebank:use-multispans-more, r=varkorbors-11/+12
Use `multipart_suggestions` more Built on top of #86532
2021-07-31Rollup merge of #87559 - estebank:consider-borrowing, r=oli-obkYuki Okushi-30/+39
Tweak borrowing suggestion in `for` loop
2021-07-30Use multispan suggestions more oftenEsteban Küber-11/+12
* Use more accurate span for `async move` suggestion * Use more accurate span for deref suggestion * Use `multipart_suggestion` more often
2021-07-30Tweak borrowing suggestion in `for` loopEsteban Küber-30/+39
2021-07-30Update compiler/rustc_mir/src/borrow_check/consumers.rsNiko Matsakis-0/+2
2021-07-30Auto merge of #87483 - oli-obk:tait_ice, r=lqdbors-0/+1
Mir borrowck does not generate lifetime variables for 'static lifetimes during opaque type resolution Fixes #87455 This situation was unreachable before #87287 as we used to just grab the resolved opaque type from typeck and replaced all regions with new inference vars. After #87287 we let the `InferCx` in mir borrowck figure out the opaque type all by itself (which it already did before, but it only used the result to sanity check with the typeck result).
2021-07-29rfc3052: Remove authors field from Cargo manifestsJade-1/+0
Since RFC 3052 soft deprecated the authors field anyway, hiding it from crates.io, docs.rs, and making Cargo not add it by default, and it is not generally up to date/useful information, we should remove it from crates in this repo.
2021-07-29Auto merge of #86998 - m-ou-se:const-panic-fmt-as-str, r=oli-obkbors-8/+41
Make const panic!("..") work in Rust 2021. During const eval, this replaces calls to core::panicking::panic_fmt and std::panicking::being_panic_fmt with a call to a new const fn: core::panicking::const_panic_fmt. That function uses fmt::Arguments::as_str() to get the str and calls panic_str with that instead. panic!() invocations with formatting arguments are still not accepted, as the creation of such a fmt::Arguments cannot be done in constant functions right now. r? `@RalfJung`
2021-07-29Rollup merge of #87527 - LeSeulArtichaut:no-mir-unsafeck, r=oli-obkYuki Okushi-4/+6
Don't run MIR unsafeck at all when using `-Zthir-unsafeck` I don't know how I missed this :D r? ``@oli-obk``
2021-07-28Improve comments about const panic handlingMara Bos-0/+5
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-07-28Check that const_panic_fmt is const too.Mara Bos-2/+9
2021-07-28Make const panic!("..") work in Rust 2021.Mara Bos-9/+30
During const eval, this replaces calls to core::panicking::panic_fmt and std::panicking::being_panic_fmt with a call to a new const fn: core::panicking::const_panic_fmt. That function uses fmt::Arguments::as_str() to get the str and calls panic_str with that instead. panic!() invocations with formatting arguments are still not accepted, as the creation of such a fmt::Arguments cannot be done in constant functions right now.
2021-07-28Rollup merge of #87453 - ibraheemdev:i-68697, r=wesleywiserYuki Okushi-2/+12
Suggest removing unnecessary &mut as help message Closes #68697
2021-07-27Don't run MIR unsafeck at all when using `-Zthir-unsafeck`LeSeulArtichaut-4/+6
2021-07-27Stabilize `const_fn_union`Jacob Pratt-28/+1
2021-07-27Stabilize `const_fn_transmute`Jacob Pratt-32/+0
2021-07-27Rollup merge of #87427 - RalfJung:no-mir-for, r=oli-obkYuki Okushi-15/+4
get rid of NoMirFor error variant The only place where we throw that error, it is very quickly caught again and turned into a different error. So raise that other error immediately.
2021-07-27Auto merge of #85305 - MarcusDunn:master, r=pnkfelixbors-1/+1
Stabilize bindings_after_at attempting to stabilze bindings_after_at [#65490](https://github.com/rust-lang/rust/issues/65490), im pretty new to the whole thing so any pointers are greatly appreciated.
2021-07-26Mir borrowck does not generate lifetime variables for 'static lifetimes ↵Oli Scherer-0/+1
during opaque type resolution
2021-07-26Rollup merge of #87458 - ibraheemdev:help-msg-block-borrow, r=oli-obkGuillaume Gomez-6/+4
Fix help message for modification to &T created by &{t} Previous: ```rust error[E0594]: cannot assign to `*x` which is behind a `&` reference --> src/main.rs:3:5 | 2 | let x: &usize = &mut{0}; | ------- help: consider changing this to be a mutable reference: `&mut mut{0}` 3 | *x = 1; | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written ```
2021-07-26Rollup merge of #87447 - RalfJung:not-null, r=oli-obkGuillaume Gomez-1/+5
Miri: santiy check that null pointer can never have an AllocId
2021-07-26Auto merge of #87424 - RalfJung:const-check, r=oli-obkbors-8/+8
rename const checking visitor module to check_consts::check This avoids naming ambiguities with "const validation" which is in `interpret/validity.rs` and checks *values*. r? `@oli-obk`
2021-07-25fmtibraheemdev-3/+3
2021-07-25fix help message for modification to &T created by &{t}ibraheemdev-9/+7
2021-07-25suggest removing unnecessary \&mut as help messageibraheemdev-2/+12