summary refs log tree commit diff
path: root/compiler/rustc_mir/src
AgeCommit message (Collapse)AuthorLines
2021-09-04Concrete regions can show up in mir borrowck if the originated from there.Oli Scherer-9/+1
We used to not encounter them here, because we took regions from typeck's opaque type resolution by renumbering them. We don't do that anymore.
2021-08-27Split critical edge targeting the start blockTomasz Miąsko-1/+3
2021-08-20Mir borrowck does not generate lifetime variables for 'static lifetimes ↵Oli Scherer-0/+1
during opaque type resolution.
2021-07-22Resolve nested inference variables.Oli Scherer-19/+7
I attempted that with the previous code, but I misunderstdood how `shallow_resolve` works.
2021-07-22Remove an unnecessary variableOli Scherer-2/+1
2021-07-22Make mir borrowck's use of opaque types independent of the typeck query's resultOli Scherer-87/+62
2021-07-21Rollup merge of #87311 - oli-obk:nll_suggestion_span, r=estebankGuillaume Gomez-4/+6
Get back the more precise suggestion spans of old regionck I noticed that when you turn on nll, the structured suggestion replaces a snippet instead of appending a snippet. It seems clearer to the user to only highlight the newly added characters instead of the entire `impl Trait` (and old regionck already does it this way). r? ``@estebank``
2021-07-21Rollup merge of #87273 - fee1-dead:impl-const-impl-bounds, r=oli-obkGuillaume Gomez-8/+11
Recognize bounds on impls as const bounds r? ```@oli-obk```
2021-07-20Get back the more precise suggestion spans of old regionckOli Scherer-4/+6
2021-07-20Auto merge of #87224 - RalfJung:miri-ptr-oob, r=oli-obkbors-4/+10
miri: better ptr-out-of-bounds errors For offsets larger than `isize::MAX`, display them as negative offsets. r? `@oli-obk`
2021-07-20Auto merge of #87141 - spastorino:remove_impl_trait_in_bindings, r=oli-obkbors-72/+13
Remove impl trait in bindings Closes #86729 r? `@oli-obk`
2021-07-19Iterate through impls only when permittedDeadbeef-8/+11
2021-07-18Move mir_def_id inside `eq_opaque_type_and_type`Santiago Pastorino-8/+5
2021-07-18Remove `sub_types_or_anon`Santiago Pastorino-30/+2
2021-07-18Add `sub_types` docsSantiago Pastorino-0/+1
2021-07-18Removing unhandled region constraint error that is only for ↵Santiago Pastorino-34/+5
impl_trait_in_bindings
2021-07-18miri: better ptr-out-of-bounds errorsRalf Jung-4/+10
2021-07-18Auto merge of #85686 - ptrojahn:loop_reinitialize, r=estebankbors-18/+74
Add help on reinitialization between move and access Fixes #83760
2021-07-17Auto merge of #87123 - RalfJung:miri-provenance-overhaul, r=oli-obkbors-700/+634
CTFE/Miri engine Pointer type overhaul This fixes the long-standing problem that we are using `Scalar` as a type to represent pointers that might be integer values (since they point to a ZST). The main problem is that with int-to-ptr casts, there are multiple ways to represent the same pointer as a `Scalar` and it is unclear if "normalization" (i.e., the cast) already happened or not. This leads to ugly methods like `force_mplace_ptr` and `force_op_ptr`. Another problem this solves is that in Miri, it would make a lot more sense to have the `Pointer::offset` field represent the full absolute address (instead of being relative to the `AllocId`). This means we can do ptr-to-int casts without access to any machine state, and it means that the overflow checks on pointer arithmetic are (finally!) accurate. To solve this, the `Pointer` type is made entirely parametric over the provenance, so that we can use `Pointer<AllocId>` inside `Scalar` but use `Pointer<Option<AllocId>>` when accessing memory (where `None` represents the case that we could not figure out an `AllocId`; in that case the `offset` is an absolute address). Moreover, the `Provenance` trait determines if a pointer with a given provenance can be cast to an integer by simply dropping the provenance. I hope this can be read commit-by-commit, but the first commit does the bulk of the work. It introduces some FIXMEs that are resolved later. Fixes https://github.com/rust-lang/miri/issues/841 Miri PR: https://github.com/rust-lang/miri/pull/1851 r? `@oli-obk`
2021-07-17Auto merge of #87195 - yaahc:move-assert_matches-again, r=oli-obkbors-1/+1
rename assert_matches module Fixes nightly breakage introduced in https://github.com/rust-lang/rust/pull/86947
2021-07-16Add initial implementation of HIR-based WF checking for diagnosticsAaron Hill-17/+19
During well-formed checking, we walk through all types 'nested' in generic arguments. For example, WF-checking `Option<MyStruct<u8>>` will cause us to check `MyStruct<u8>` and `u8`. However, this is done on a `rustc_middle::ty::Ty`, which has no span information. As a result, any errors that occur will have a very general span (e.g. the definintion of an associated item). This becomes a problem when macros are involved. In general, an associated type like `type MyType = Option<MyStruct<u8>>;` may have completely different spans for each nested type in the HIR. Using the span of the entire associated item might end up pointing to a macro invocation, even though a user-provided span is available in one of the nested types. This PR adds a framework for HIR-based well formed checking. This check is only run during error reporting, and is used to obtain a more precise span for an existing error. This is accomplished by individually checking each 'nested' type in the HIR for the type, allowing us to find the most-specific type (and span) that produces a given error. The majority of the changes are to the error-reporting code. However, some of the general trait code is modified to pass through more information. Since this has no soundness implications, I've implemented a minimal version to begin with, which can be extended over time. In particular, this only works for HIR items with a corresponding `DefId` (e.g. it will not work for WF-checking performed within function bodies).
2021-07-16avoid manual Debug impls by adding extra Provenance bounds to typesRalf Jung-149/+46
I wish the derive macro would support adding extra where clauses...
2021-07-16rename assert_matches moduleJane Lusby-1/+1
2021-07-16get rid of incorrect erase_for_fmtRalf Jung-56/+50
2021-07-15make check_ptr_access_align work on function pointer allocationsRalf Jung-6/+12
2021-07-15enable Miri to fix the bytes in an allocation (since ptr offsets have ↵Ralf Jung-53/+41
different meanings there)
2021-07-15adjustions and cleanup to make Miri build againRalf Jung-138/+118
2021-07-15Rollup merge of #86947 - m-ou-se:assert-matches-to-submodule, r=yaahcYuki Okushi-0/+1
Move assert_matches to an inner module Fixes #82913
2021-07-14remove unused error variantRalf Jung-8/+3
2021-07-14more precise message for the ptr access check on derefRalf Jung-8/+7
2021-07-14use NonZeroU64 for AllocId to restore old type sizesRalf Jung-7/+7
2021-07-14consistently treat None-tagged pointers as ints; get rid of some deprecated ↵Ralf Jung-40/+49
Scalar methods
2021-07-14CTFE/Miri engine Pointer type overhaul: make Scalar-to-Pointer conversion ↵Ralf Jung-518/+584
infallible This resolves all the problems we had around "normalizing" the representation of a Scalar in case it carries a Pointer value: we can just use Pointer if we want to have a value taht we are sure is already normalized.
2021-07-13Auto merge of #87044 - cjgillot:expnhash, r=petrochenkovbors-1/+2
Cache expansion hash globally ... instead of computing it multiple times. Split from #86676 r? `@petrochenkov`
2021-07-13Cache expansion hash.Camille GILLOT-1/+2
2021-07-13Auto merge of #86857 - fee1-dead:add-attr, r=oli-obkbors-8/+37
Add #[default_method_body_is_const] `@rustbot` label F-const_trait_impl
2021-07-12remove unnecessary deallocate_local hackRalf Jung-15/+8
2021-07-12remove remaining use of Pointer in Allocation APIRalf Jung-2/+2
2021-07-12Auto merge of #86815 - FabianWolff:issue-84210, r=varkorbors-4/+20
Improve error reporting for modifications behind `&` references I had a look at #84210 and noticed that #85823 has effectively already fixed #84210. However, the string matching in #85823 is _very_ crude and already breaks down when a variable name starts with `mut`. I have made this a bit more robust; further improvements could definitely be made but are complicated by the lack of information provided by an earlier pass: https://github.com/rust-lang/rust/blob/ce331ee6ee010438d1a58c7da8ced4f26d69a20e/compiler/rustc_mir_build/src/build/matches/mod.rs#L2103-L2107 I have also fixed a missing comma in the error message.
2021-07-10rustc_span: Revert addition of `proc_macro` field to `ExpnKind::Macro`Vadim Petrochenkov-5/+2
The flag has a vague meaning and is used for a single diagnostic change that is low benefit and appears only under `-Z macro_backtrace`.
2021-07-11Rollup merge of #87028 - aDotInTheVoid:patch-1, r=petrochenkovYuki Okushi-1/+1
Fix type: `'satic` -> `'static` Pointed out on discord: https://discord.com/channels/273534239310479360/490356824420122645/863434443170250793 ~~The fact that this compiles is probably a bug.~~ Nope it's `#![feature(in_band_lifetimes)]` (Thanks to [floppy](https://discord.com/channels/273534239310479360/490356824420122645/863437381671059486) ~~[The docs](https://doc.rust-lang.org/stable/nightly-rustc/rustc_mir/transform/inline/struct.Inliner.html#method.check_codegen_attributes) seem to indicate rust thinks this function is generic over the lifetime `'satic`~~ This is because of `in_band_lifetimes`
2021-07-10Fix typo: `satic` -> `static`Nixon Enraght-Moony-1/+1
2021-07-10Update testsDeadbeef-1/+1
2021-07-10Update CTFE to allow fns marked with the attrDeadbeef-6/+9
2021-07-10Permit calls to default const fns of impl constDeadbeef-7/+25
2021-07-10functions marked with attr are not constDeadbeef-3/+0
2021-07-10Skip check for calling functions in same traitDeadbeef-3/+11
2021-07-10Treat trait fns marked with the attr as constDeadbeef-1/+4
2021-07-10remove const_raw_ptr_to_usize_cast featureRalf Jung-40/+16
2021-07-09Rollup merge of #87000 - m-ou-se:const-panic-track-caller, r=oli-obkMara Bos-2/+11
Use #[track_caller] in const panic diagnostics. This change stops const panic diagnostics from reporting inside #[track_caller] functions by skipping over them.