summary refs log tree commit diff
path: root/compiler/rustc_middle/src/query
AgeCommit message (Collapse)AuthorLines
2022-10-06Revert "Auto merge of #101620 - cjgillot:compute_lint_levels_by_def, r=oli-obk"Camille GILLOT-7/+3
This reverts commit 2cb9a65684dba47c52de8fa938febf97a73e70a9, reversing changes made to 750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c. (cherry picked from commit fc43df0333d5862a219f16d294ae38b14b9191d3)
2022-09-16Rollup merge of #101787 - compiler-errors:cache-rpitit, r=petrochenkovDylan DPC-1/+2
cache `collect_trait_impl_trait_tys` Micro-optimization for RPITITs
2022-09-14cache collect_trait_impl_trait_tysMichael Goulet-1/+2
2022-09-14Move some code and add comments.Camille GILLOT-1/+1
2022-09-14Compute `lint_levels` by definitionDeadbeef-3/+7
2022-09-14Auto merge of #101307 - jyn514:simplify-storage, r=cjgillotbors-56/+49
Simplify caching and storage for queries I highly recommend reviewing commit-by-commit; each individual commit is quite small but it can be hard to see looking at the overall diff that the behavior is the same. Each commit depends on the previous. r? `@cjgillot`
2022-09-13Rollup merge of #101765 - GuillaumeGomez:tyctxt-visibility-doc, r=jyn514Matthias Krüger-0/+10
Add documentation for TyCtxt::visibility We encountered this issue while working on https://github.com/rust-lang/rust/pull/98450. cc ``@lqd`` r? ``@cjgillot``
2022-09-13Auto merge of #101615 - compiler-errors:rpitit-perf, r=oli-obkbors-1/+1
Make `compare_predicate_entailment` no longer a query Make `compare_predicate_entailment` so it's no longer a query (again), and splits out the new logic (that equates the return types to infer RPITITs) into its own query. This means that this new query (now called `collect_trait_impl_trait_tys`) is no longer executed for non-RPITIT cases. This should improve perf (https://github.com/rust-lang/rust/pull/101224#issuecomment-1241682203), though in practice we see that these some crates remain from the primary regressions list on the original report... They are all <= 0.43% regression and seemingly only on the incr-full scenario for all of them. I am at a loss for what might be causing this regression other than what I fixed here, since we don't introduce much new non-RPITIT logic except for some `def_kind` query calls in some places, for example, like projection. Maybe that's it? ---- Originally this PR was opened to test enabling `cache_on_disk` (62164aaaa11) but that didn't turn out to be very useful (https://github.com/rust-lang/rust/pull/101615#issuecomment-1242403205), so that led me to just split the query (and rename the PR).
2022-09-13Add documentation for TyCtxt::visibilityGuillaume Gomez-0/+10
2022-09-10split compare_predicate_entailment and collect_trait_impl_trait_tys outMichael Goulet-1/+1
2022-09-09Don't use a custom disk loader for diagnostic_only_typeckJoshua Nelson-7/+0
This uses exactly the same types for query results as `typeck`, which doesn't have custom code. It's not clear to me why this code exists (it goes back even before queries used a proc macro), but it compiles fine without the custom loader. Remove it for simplicity.
2022-09-09Make the `storage` query modifier less generalJoshua Nelson-49/+49
In practice, it was only ever used with `ArenaCacheSelector`. Change it to a single boolean `arena_cache` rather than allowing queries to specify an arbitrary type.
2022-09-09rename `codegen_fulfill_obligation`lcnr-5/+2
2022-09-09Deeply check that method signatures match, and allow for nested RPITITsMichael Goulet-0/+7
2022-09-07rustc: Parameterize `ty::Visibility` over used IDVadim Petrochenkov-1/+1
It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.
2022-09-03Do not call object_lifetime_default on lifetime params.Camille GILLOT-5/+6
2022-08-31Fix a bunch of typoDezhi Wu-1/+1
This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-29Rollup merge of #99821 - cjgillot:ast-lifetimes-2, r=compiler-errorsDylan DPC-2/+3
Remove separate indexing of early-bound regions ~Based on https://github.com/rust-lang/rust/pull/99728.~ This PR copies some modifications from https://github.com/rust-lang/rust/pull/97839 around object lifetime defaults. These modifications allow to stop counting generic parameters during lifetime resolution, and rely on the indexing given by `rustc_typeck::collect`.
2022-08-26Implementation of import_name_typeDaniel Paoliello-0/+3
2022-08-25Auto merge of #100748 - SparrowLii:query_depth, r=cjgillotbors-0/+1
add `depth_limit` in `QueryVTable` to avoid entering a new tcx in `layout_of` Fixes #49735 Updates #48685 The `layout_of` query needs to check whether it overflows the depth limit, and the current implementation needs to create a new `ImplicitCtxt` inside `layout_of`. However, `start_query` will already create a new `ImplicitCtxt`, so we can check the depth limit in `start_query`. We can tell whether we need to check the depth limit simply by whether the return value of `to_debug_str` of the query is `layout_of`. But I think adding the `depth_limit` field in `QueryVTable` may be more elegant and more scalable.
2022-08-24add `depth_limit` in `QueryVTable`SparrowLii-0/+1
2022-08-23Use par_body_owners for livenessSeo Sanghyeon-2/+2
2022-08-22Auto merge of #100676 - lcnr:implied-bounds-yay, r=nikomatsakisbors-0/+8
implied bounds: explicitly state which types are assumed to be wf Adds a new query which maps each definition to the types which that definition assumes to be well formed. The intent is to make it easier to reason about implied bounds. This change should not influence the user-facing behavior of rustc. Notably, `borrowck` still only assumes that the function signature of associated functions is well formed while `wfcheck` assumes that the both the function signature and the impl trait ref is well formed. Not sure if that by itself can trigger UB or whether it's just annoying. As a next step, we can add `WellFormed` predicates to `predicates_of` of these items and can stop adding the wf bounds at each place which uses them. I also intend to move the computation from `assumed_wf_types` to `implied_bounds` into the `param_env` computation. This requires me to take a deeper look at `compare_predicate_entailment` which is currently somewhat weird wrt implied bounds so I am not touching this here. r? `@nikomatsakis`
2022-08-17implied_bounds: clarify our assumptionslcnr-0/+8
2022-08-16Do not report cycle error when inferring return type for suggestionMichael Goulet-0/+1
2022-08-09Rollup merge of #100221 - compiler-errors:impossible-trait-items, ↵Dylan DPC-0/+8
r=lcnr,notriddle,camelid Don't document impossible to call default trait items on impls Closes #100176 This only skips documenting _default_ trait items on impls, not ones that are written inside the impl block. This is a conservative approach, since I think we should document all items written in an impl block (I guess unless hidden or whatever), but the existence of this new query I added makes this easy to extend to other rustdoc cases.
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