about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir/query.rs
AgeCommit message (Collapse)AuthorLines
2021-09-27Remove `DefId` from `ConstraintCategory::Predicate`Aaron Hill-1/+4
This shirnks the size of `ConstraintCategory`, hopefully fixing a performance regression.
2021-09-27Improve cause information for NLL higher-ranked errorsAaron Hill-0/+5
This PR has several interconnected pieces: 1. In some of the NLL region error code, we now pass around an `ObligationCause`, instead of just a plain `Span`. This gets forwarded into `fulfill_cx.register_predicate_obligation` during error reporting. 2. The general InferCtxt error reporting code is extended to handle `ObligationCauseCode::BindingObligation` 3. A new enum variant `ConstraintCategory::Predicate` is added. We try to avoid using this as the 'best blame constraint' - instead, we use it to enhance the `ObligationCause` of the `BlameConstraint` that we do end up choosing. As a result, several NLL error messages now contain the same "the lifetime requirement is introduced here" message as non-NLL errors. Having an `ObligationCause` available will likely prove useful for future improvements to NLL error messages.
2021-09-16Add `ConstraintCategory::Usage` for handling aggregate constructionAaron Hill-5/+3
In some cases, we emit borrowcheck diagnostics pointing at a particular field expression in a struct expression (e.g. `MyStruct { field: my_expr }`). However, this behavior currently relies on us choosing the `ConstraintCategory::Boring` with the 'correct' span. When adding additional variants to `ConstraintCategory`, (or changing existing usages away from `ConstraintCategory::Boring`), the current behavior can easily get broken, since a non-boring constraint will get chosen over a boring one. To make the diagnostic output less fragile, this commit adds a `ConstraintCategory::Usage` variant. We use this variant for the temporary assignments created for each field of an aggregate we are constructing. Using this new variant, we can emit a message mentioning "this usage", emphasizing the fact that the error message is related to the specific use site (in the struct expression). This is preparation for additional work on improving NLL error messages (see #57374)
2021-09-09nitsEllen-13/+0
2021-09-09rename mir -> thir around abstract constsEllen-4/+5
2021-09-07Rename rustc_mir to rustc_const_eval.Camille GILLOT-2/+2
2021-06-07Remove ResolvedOpaqueTy and just use Ty, SubstsRef is already thereSantiago Pastorino-1/+1
2021-06-07Make OpaqueTypeKey the key of opaque types mapSantiago Pastorino-1/+2
2021-06-07Change concrete opaque type to be a `VecMap`Santiago Pastorino-2/+2
2021-05-17Remove remnants of BorrowOfPackedFieldLeSeulArtichaut-6/+0
2021-05-02Change 'NULL' to 'null'Brent Kerby-1/+1
2021-04-25fix typographyRalf Jung-1/+1
2021-04-25unsafety checking: no longer care about is_min_const_fnRalf Jung-3/+1
Rejecting the forbidden unsafe ops is done by const checking, not by unsafety checking
2021-03-27make unaligned_refereces future-incompat lint warn-by-default, and remove ↵Ralf Jung-6/+0
the safe_packed_borrows lint that it replaces
2021-03-10Rollup merge of #79208 - LeSeulArtichaut:stable-unsafe_op_in_unsafe_fn, ↵Yuki Okushi-2/+0
r=nikomatsakis Stabilize `unsafe_op_in_unsafe_fn` lint This makes it possible to override the level of the `unsafe_op_in_unsafe_fn`, as proposed in https://github.com/rust-lang/rust/issues/71668#issuecomment-729770896. Tracking issue: #71668 r? ```@nikomatsakis``` cc ```@SimonSapin``` ```@RalfJung``` # Stabilization report This is a stabilization report for `#![feature(unsafe_block_in_unsafe_fn)]`. ## Summary Currently, the body of unsafe functions is an unsafe block, i.e. you can perform unsafe operations inside. The `unsafe_op_in_unsafe_fn` lint, stabilized here, can be used to change this behavior, so performing unsafe operations in unsafe functions requires an unsafe block. For now, the lint is allow-by-default, which means that this PR does not change anything without overriding the lint level. For more information, see [RFC 2585](https://github.com/rust-lang/rfcs/blob/master/text/2585-unsafe-block-in-unsafe-fn.md) ### Example ```rust // An `unsafe fn` for demonstration purposes. // Calling this is an unsafe operation. unsafe fn unsf() {} // #[allow(unsafe_op_in_unsafe_fn)] by default, // the behavior of `unsafe fn` is unchanged unsafe fn allowed() { // Here, no `unsafe` block is needed to // perform unsafe operations... unsf(); // ...and any `unsafe` block is considered // unused and is warned on by the compiler. unsafe { unsf(); } } #[warn(unsafe_op_in_unsafe_fn)] unsafe fn warned() { // Removing this `unsafe` block will // cause the compiler to emit a warning. // (Also, no "unused unsafe" warning will be emitted here.) unsafe { unsf(); } } #[deny(unsafe_op_in_unsafe_fn)] unsafe fn denied() { // Removing this `unsafe` block will // cause a compilation error. // (Also, no "unused unsafe" warning will be emitted here.) unsafe { unsf(); } } ```
2021-03-04Remove a dead code pathOli Scherer-12/+0
2021-02-18Stabilize `unsafe_op_in_unsafe_fn` lintLeSeulArtichaut-2/+0
2021-01-16Enforce that query results implement DebugAaron Hill-4/+4
2021-01-04Simplify the `optimize_mir` queryoli-1/+1
2021-01-04Differentiate between the availability of ctfe MIR and runtime MIRoli-1/+1
2021-01-04Keep an unoptimized duplicate of `const fn` aroundoli-0/+9
This allows CTFE to reliably detect UB, as otherwise optimizations may hide UB.
2020-11-20needs -> might needRalf Jung-1/+1
2020-11-20consider assignments of union field of ManuallyDrop type safeRalf Jung-3/+3
2020-11-12review commentsVishnunarayan K I-1/+1
2020-11-12add error_occured field to ConstQualifs, fix #76064Vishnunarayan K I-2/+3
2020-10-14Remove unused code from rustc_middleest31-12/+0
2020-10-05query_name_of_opt_const_arg -> query_name_opt_const_argBastian Kauschke-3/+3
2020-10-04cleanup WithOptConstParam queriesBastian Kauschke-1/+33
2020-08-30mv compiler to compiler/mark-0/+443