about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/query
AgeCommit message (Collapse)AuthorLines
2022-08-09Rollup merge of #96478 - WaffleLapkin:rustc_default_body_unstable, r=Aaron1011Dylan DPC-0/+5
Implement `#[rustc_default_body_unstable]` This PR implements a new stability attribute — `#[rustc_default_body_unstable]`. `#[rustc_default_body_unstable]` controls the stability of default bodies in traits. For example: ```rust pub trait Trait { #[rustc_default_body_unstable(feature = "feat", isssue = "none")] fn item() {} } ``` In order to implement `Trait` user needs to either - implement `item` (even though it has a default implementation) - enable `#![feature(feat)]` This is useful in conjunction with [`#[rustc_must_implement_one_of]`](https://github.com/rust-lang/rust/pull/92164), we may want to relax requirements for a trait, for example allowing implementing either of `PartialEq::{eq, ne}`, but do so in a safe way — making implementation of only `PartialEq::ne` unstable. r? `@Aaron1011` cc `@nrc` (iirc you were interested in this wrt `read_buf`), `@danielhenrymantilla` (you were interested in the related `#[rustc_must_implement_one_of]`) P.S. This is my first time working with stability attributes, so I'm not sure if I did everything right 😅
2022-08-07Don't document impossible to call default trait items on implsMichael Goulet-0/+8
2022-08-03Compute `object_lifetime_default` per parameter.Camille GILLOT-2/+3
2022-08-03Create a specific `ObjectLifetimeDefault` enum.Camille GILLOT-1/+1
2022-08-03Make object_lifetime_defaults a cross-crate query.Camille GILLOT-1/+1
2022-08-01Remove trait_of_item query.Camille GILLOT-8/+0
2022-07-30Use LocalDefId for closures moreCameron Steffen-2/+2
2022-07-26Implement `#[rustc_default_body_unstable]`Maybe Waffle-0/+5
This attribute allows to mark default body of a trait function as unstable. This means that implementing the trait without implementing the function will require enabling unstable feature. This is useful in conjunction with `#[rustc_must_implement_one_of]`, we may want to relax requirements for a trait, for example allowing implementing either of `PartialEq::{eq, ne}`, but do so in a safe way -- making implementation of only `PartialEq::ne` unstable.
2022-07-20passes: improved partial stabilization diagnosticDavid Wood-2/+6
Improves the diagnostic when a feature attribute is specified unnecessarily but the feature implies another (i.e. it was partially stabilized) to refer to the implied feature. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-14Use constant eval to do strict validity checks5225225-0/+8
2022-07-12Move abstract const to rustc_middle::tykadmin-2/+2
2022-07-06Create a forever red node and use it to force side effects.Camille GILLOT-6/+0
2022-07-06Make AST lowering a query.Camille GILLOT-1/+8
2022-07-06Allow to create definitions inside the query system.Camille GILLOT-0/+6
2022-07-06Auto merge of #98959 - cjgillot:late-bound-order, r=michaelwoeristerbors-1/+1
Return a FxIndexSet in is_late_bound query. This return value is iterated upon by borrowck, hence the need to preserve a deterministic iteration order. Fixes https://github.com/rust-lang/rust/issues/98890 Affects https://github.com/rust-lang/rust/issues/96655 I don't know if this supersedes https://github.com/rust-lang/rust/pull/98924 or fixes an unrelated bug. r? `@michaelwoerister` This may deserve a backport.
2022-07-05Return a FxIndexSet in is_late_bound query.Camille GILLOT-1/+1
This return value is iterated upon by borrowck, hence the need to preserve a deterministic iteration order.
2022-07-04fully move dropck to mirlcnr-1/+2
2022-07-02Auto merge of #97235 - nbdd0121:unwind, r=Amanieubors-2/+6
Fix FFI-unwind unsoundness with mixed panic mode UB maybe introduced when an FFI exception happens in a `C-unwind` foreign function and it propagates through a crate compiled with `-C panic=unwind` into a crate compiled with `-C panic=abort` (#96926). To prevent this unsoundness from happening, we will disallow a crate compiled with `-C panic=unwind` to be linked into `panic-abort` *if* it contains a call to `C-unwind` foreign function or function pointer. If no such call exists, then we continue to allow such mixed panic mode linking because it's sound (and stable). In fact we still need the ability to do mixed panic mode linking for std, because we only compile std once with `-C panic=unwind` and link it regardless panic strategy. For libraries that wish to remain compile-once-and-linkable-to-both-panic-runtimes, a `ffi_unwind_calls` lint is added (gated under `c_unwind` feature gate) to flag any FFI unwind calls that will cause the linkable panic runtime be restricted. In summary: ```rust #![warn(ffi_unwind_calls)] mod foo { #[no_mangle] pub extern "C-unwind" fn foo() {} } extern "C-unwind" { fn foo(); } fn main() { // Call to Rust function is fine regardless ABI. foo::foo(); // Call to foreign function, will cause the crate to be unlinkable to panic-abort if compiled with `-Cpanic=unwind`. unsafe { foo(); } //~^ WARNING call to foreign function with FFI-unwind ABI let ptr: extern "C-unwind" fn() = foo::foo; // Call to function pointer, will cause the crate to be unlinkable to panic-abort if compiled with `-Cpanic=unwind`. ptr(); //~^ WARNING call to function pointer with FFI-unwind ABI } ``` Fix #96926 `@rustbot` label: T-compiler F-c_unwind
2022-06-29Improve doc comment of destructure_constDominik Stolz-1/+2
2022-06-28Improve pretty printing of valtrees for referencesDominik Stolz-5/+2
2022-06-28Auto merge of #98222 - cjgillot:single-wf, r=michaelwoeristerbors-7/+5
Only keep a single query for well-formed checking There are currently 3 queries to perform wf checks on different item-likes. This complexity is not required. This PR replaces the query by: - one query per item; - one query to invoke it for a whole module. This allows to remove HIR `ParItemLikeVisitor`.
2022-06-27Auto merge of #98221 - cjgillot:single-coh, r=lcnrbors-3/+4
Perform coherence checking per impl. r? `@ghost`
2022-06-22Perform coherence checking per impl.Camille GILLOT-3/+4
2022-06-21Perform wf checking per module.Camille GILLOT-0/+4
2022-06-21Only keep a single well-formed query.Camille GILLOT-7/+1
2022-06-19Rollup merge of #98136 - fee1-dead-contrib:rename_impl_constness, r=oli-obkDylan DPC-3/+3
Rename `impl_constness` to `constness` The current code is a basis for `is_const_fn_raw`, and `impl_constness` is no longer a valid name, which is previously used for determining the constness of impls, and not items in general. r? `@oli-obk`
2022-06-15Rename `impl_constness` to `constness`Deadbeef-3/+3
The current code is a basis for `is_const_fn_raw`, and `impl_constness` is no longer a valid name, which is previously used for determining the constness of impls, and not items in general.
2022-06-14Separate `source_span` and `expn_that_defined` from `Definitions`.Camille GILLOT-3/+0
2022-06-14Separate Definitions and CrateStore from ResolverOutputs.Camille GILLOT-0/+1
2022-06-14address reviewb-naber-6/+6
2022-06-14implement valtrees as the type-system representation for constant valuesb-naber-11/+1
2022-06-08Rename `panic_strategy` query to `required_panic_strategy`Gary Guo-4/+1
2022-06-08Fix FFI-unwind unsoundness with mixed panic modeGary Guo-2/+9
2022-06-06Rollup merge of #97312 - cjgillot:no-path-in-scope, r=compiler-errorsDylan DPC-5/+0
Compute lifetimes in scope at diagnostic time The set of available lifetimes is currently computed during lifetime resolution on HIR. It is only used for one diagnostic. In this PR, HIR lifetime resolution just reports whether elided lifetimes are well-defined at the place of use. The diagnostic code is responsible for building a list of lifetime names if elision is not allowed. This will allow to remove lifetime resolution on HIR eventually.
2022-06-04Rollup merge of #97609 - Elliot-Roberts:unused-trait-refactor, r=cjgillotMatthias Krüger-2/+2
Iterate over `maybe_unused_trait_imports` when checking dead trait imports Closes #96873 r? `@cjgillot` Some questions, if you have time: - Is there a way to shorten the `rustc_data_structures::fx::FxIndexSet` path in the query declaration? I wasn't sure where to put a `use`. - Was returning by reference from the query the right choice here? - How would I go about evaluating the importance of the `is_dummy()` call in `check_crate`? I don't see failing tests when I comment it out. Should I just try to determine whether dummy spans can ever be put into `maybe_unused_trait_imports`? - Am I doing anything silly with the various ID types? - Is that `let-else` with `unreachable!()` bad? (i.e is there a better idiom? Would `panic!("<explanation>")` be better?) - If I want to evaluate the perf of using a `Vec` as mentioned in #96873, is the best way to use the CI or is it feasible locally? Thanks :)
2022-06-04Iterate over `maybe_unused_trait_imports` when checking dead trait importsElliot Roberts-2/+2
2022-06-04Completely remove LifetimeScopeForPath.Camille GILLOT-5/+0
2022-06-03Compute `is_late_bound` in a separate query.Camille GILLOT-1/+1
The computation is actually much simpler, and can be done by directly fetching the HIR for the `FnDecl` and its generics.
2022-05-28Auto merge of #97383 - dingxiangfei2009:restore-region-scope-tree-query, ↵bors-0/+6
r=dingxiangfei2009 Try to cache region_scope_tree as a query This PR will attempt to restore `region_scope_tree` as a query so that caching works again. It seems that `region_scope_tree` could be re-computed for nested items after all, which could explain the performance regression introduced by #95563. cc `@Mark-Simulacrum` `@pnkfelix` I will try to trigger a perf run here.
2022-05-25try to cache region_scope_tree as a queryDing Xiang Fei-0/+6
2022-05-24Remove the check_mod_intrinsics queryOli Scherer-4/+0
2022-05-22factor out the rvalue lifetime ruleDing Xiang Fei-6/+0
remove region_scope_tree from RegionCtxt Apply suggestions from code review Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-05-20Auto merge of #95418 - cjgillot:more-disk, r=davidtwcobors-2/+36
Cache more queries on disk One of the principles of incremental compilation is to allow saving results on disk to avoid recomputing them. This PR investigates persisting a lot of queries whose result are to be saved into metadata. Some of the queries are cheap reads from HIR, but we may also want to get rid of these reads for incremental lowering.
2022-05-18Auto merge of #97019 - b-naber:transition-to-valtrees-pt1, r=oli-obkbors-9/+26
Transition to valtrees pt1 Compartmentalising https://github.com/rust-lang/rust/pull/96591 as much as possible. r? `@oli-obk`
2022-05-17Auto merge of #97012 - oli-obk:🦀_intrinsics, r=davidtwcobors-0/+5
Add a query for checking whether a function is an intrinsic. work towards #93145 This will reduce churn when we add more ways to declare intrinsics r? `@scottmcm`
2022-05-16use GlobalId in eval_to_valtree query and introduce query for ↵b-naber-9/+26
valtree_to_const_val
2022-05-16Add a query for checking whether a function is an intrinsic.Oli Scherer-0/+5
2022-05-13Do not cache item_attrs.Camille GILLOT-1/+0
2022-05-13Cache more queries on disk.Camille GILLOT-2/+37
2022-05-12Auto merge of #95562 - lcnr:attr-no-encode, r=davidtwcobors-0/+3
don't encode only locally used attrs Part of https://github.com/rust-lang/compiler-team/issues/505. We now filter builtin attributes before encoding them in the crate metadata in case they should only be used in the local crate. To prevent accidental misuse `get_attrs` now requires the caller to state which attribute they are interested in. For places where that isn't trivially possible, I've added a method `fn get_attrs_unchecked` which I intend to remove in a followup PR. After this pull request landed, we can then slowly move all attributes to only be used in the local crate while being certain that we don't accidentally try to access them from extern crates. cc https://github.com/rust-lang/rust/pull/94963#issuecomment-1082924289