about summary refs log tree commit diff
path: root/src/librustc_middle/query
AgeCommit message (Collapse)AuthorLines
2020-08-03Rollup merge of #75054 - cjgillot:rename-depkind, r=petrochenkovYuki Okushi-1/+1
Rename rustc_middle::cstore::DepKind to CrateDepKind It is ambiguous with DepGraph's own DepKind.
2020-08-02Rename rustc_middle::cstore::DepKind to DependencyKind.Camille GILLOT-1/+1
2020-07-22Normalize opaque types when converting `ParamEnv` to `Reveal::All`Aaron Hill-1/+11
Fixes #65918
2020-07-21Auto merge of #69749 - davidtwco:issue-46477-polymorphization, r=eddybbors-2/+9
Polymorphization This PR implements an analysis to detect when functions could remain polymorphic during code generation. Fixes #46477 r? @eddyb cc @rust-lang/wg-mir-opt @nikomatsakis @pnkfelix
2020-07-20Rollup merge of #74376 - lcnr:type-dependent-path-cleanup, r=eddybManish Goregaokar-1/+5
test caching opt_const_param_of on disc Followup to #74113, implements parts of #74360 Tried caching `opt_const_param_of` on disk and adding an early exit if `tcx.dep_kind(def_id) != DefKind::AnonConst`. Ended up causing a perf regression instead, so we just remove the FIXME and a short note to `opt_const_param_of`. r? @eddyb
2020-07-20index: introduce and use `FiniteBitSet`David Wood-1/+1
This commit introduces a `FiniteBitSet` type which replaces the manual bit manipulation which was being performed in polymorphization. Signed-off-by: David Wood <david@davidtw.co>
2020-07-20mir: `unused_generic_params` queryDavid Wood-0/+7
This commit implements the `unused_generic_params` query, an initial version of polymorphization which detects when an item does not use generic parameters and is being needlessly monomorphized as a result. Signed-off-by: David Wood <david@davidtw.co>
2020-07-20trait_sel: only test predicates w/ no substsDavid Wood-2/+2
This commit modifies the `substitute_normalize_and_test_predicates` query, renaming it to `impossible_predicates` and only checking predicates which do not require substs. By making this change, polymorphization doesn't have to explicitly support vtables. Signed-off-by: David Wood <david@davidtw.co>
2020-07-18add note to `opt_const_param_of`Bastian Kauschke-1/+5
2020-07-17Rename TypeckTables to TypeckResults.Valentin Lazureanu-7/+7
2020-07-15Auto merge of #74113 - lcnr:type-dependent-consts-2, r=eddybbors-23/+95
Support const args in type dependent paths (Take 2) once more, except it is sound this time :smiling_face_with_three_hearts: previously #71154 ----- ```rust #![feature(const_generics)] struct A; impl A { fn foo<const N: usize>(&self) -> usize { N } } struct B; impl B { fn foo<const N: usize>(&self) -> usize { 42 } } fn main() { let a = A; a.foo::<7>(); } ``` When calling `type_of` for generic const arguments, we now use the `TypeckTables` of the surrounding body to get the expected type. This alone causes cycle errors though, as we now have `typeck_tables_of(main)` -> `...` -> `type_of(main_ANON0 := 7)` -> `typeck_tables_of(main)` :zap: (see https://github.com/rust-lang/rust/issues/68400#issuecomment-611760290) To prevent this we must not call `type_of(const_arg)` during `typeck_tables_of`. This is achieved by calling `type_of(param_def_id)` instead. We have to somehow remember the `DefId` of the param through all of typeck, which is done using the struct `ty::WithOptConstParam<DefId>`, which replaces `DefId` where needed and contains an `Option<DefId>` to be able to store the const parameter in case it exists. Queries which are currently cached on disk are split into two variants: `query_name`(cached) and `query_name_(of|for)_const_arg`(not cached), with `query_name_of_const_arg` taking a pair `(did, param_did): (LocalDefId, DefId)`. For some queries a method `query_name_of_opt_const_arg` is added to `TyCtxt` which takes a `ty::WithOptConstParam` and either calls `query_name` or `query_name_of_const_arg` depending on the value of `const_param_did`. r? @eddyb @varkor
2020-07-15unsafety_check_result_for_const_argBastian Kauschke-1/+1
2020-07-15improve namingBastian Kauschke-7/+7
2020-07-15cleanupBastian Kauschke-4/+12
2020-07-15update promoted_mirBastian Kauschke-2/+2
2020-07-15update const arg queriesBastian Kauschke-18/+18
2020-07-15only call `typeck_tables_of_const_arg` for const argsBastian Kauschke-2/+2
2020-07-15const generics work!Bastian Kauschke-12/+37
2020-07-15continue mir pipelineBastian Kauschke-13/+14
2020-07-15optimized_mirBastian Kauschke-2/+4
2020-07-15typeck all the tablesBastian Kauschke-0/+8
2020-07-15const_eval_resolveBastian Kauschke-0/+9
2020-07-15introduce the query `opt_const_param_of`Bastian Kauschke-0/+19
2020-07-15Change `SymbolName::name` to a `&str`.Nicholas Nethercote-1/+1
This eliminates a bunch of `Symbol::intern()` and `Symbol::as_str()` calls, which is good, because they require locking the interner. Note that the unsafety in `from_cycle_error()` is identical to the unsafety on other adjacent impls.
2020-07-10Avoid "whitelist"Tamir Duberstein-2/+2
Other terms are more inclusive and precise.
2020-07-02Auto merge of #73954 - Manishearth:rollup-8qvh170, r=Manishearthbors-2/+4
Rollup of 10 pull requests Successful merges: - #73414 (Implement `slice_strip` feature) - #73564 (linker: Create GNU_EH_FRAME header by default when producing ELFs) - #73622 (Deny unsafe ops in unsafe fns in libcore) - #73684 (add spans to injected coverage counters, extract with CoverageData query) - #73812 (ast_pretty: Pass some token streams and trees by reference) - #73853 (Add newline to rustc MultiSpan docs) - #73883 (Compile rustdoc less often.) - #73885 (Fix wasm32 being broken due to a NodeJS version bump) - #73903 (Changes required for rustc/cargo to build for iOS targets) - #73938 (Optimise fast path of checked_ops with `unlikely`) Failed merges: r? @ghost
2020-06-30Switch crate_extern_paths to a query, and tweak wording.Eric Huss-0/+4
2020-06-29add spans to injected coverage countersRich Kadel-2/+4
added regions with counter expressions and counters. Added codegen_llvm/coverageinfo mod for upcoming coverage map Move coverage region collection to CodegenCx finalization Moved from `query coverageinfo` (renamed from `query coverage_data`), as discussed in the PR at: https://github.com/rust-lang/rust/pull/73684#issuecomment-649882503 Address merge conflict in MIR instrument_coverage test The MIR test output format changed for int types. moved debug messages out of block.rs This makes the block.rs calls to add coverage mapping data to the CodegenCx much more concise and readable. move coverage intrinsic handling into llvm impl I realized that having half of the coverage intrinsic handling in `rustc_codegen_ssa` and half in `rustc_codegen_llvm` meant that any non-llvm backend would be bound to the same decisions about how the coverage-related MIR terminators should be handled. To fix this, I moved the non-codegen portion of coverage intrinsic handling into its own trait, and implemented it in `rustc_codegen_llvm` alongside `codegen_intrinsic_call`. I also added the (required?) stubs for the new intrinsics to `IntrepretCx::emulate_intrinsic()`, to ensure calls to this function do not fail if called with these new but known intrinsics. address PR Feedback on 28 June 2020 2:48pm PDT
2020-06-27Rollup merge of #73796 - lcnr:LocalDefId, r=matthewjasperManish Goregaokar-13/+13
replace more `DefId`s with `LocalDefId` part of https://github.com/rust-lang/rust/issues/70853
2020-06-27use LocalDefId in module checkingBastian Kauschke-13/+13
2020-06-26Make `fn_arg_names` return `Ident` instead of symbolAaron Hill-1/+1
Also, implement this query for the local crate, not just foreign crates.
2020-06-23Rollup merge of #73488 - richkadel:llvm-coverage-map-gen, r=tmandryManish Goregaokar-0/+6
code coverage foundation for hash and num_counters This PR is the next iteration after PR #73011 (which is still waiting on bors to merge). @wesleywiser - PTAL r? @tmandry (FYI, I'm also working on injecting the coverage maps, in another branch, while waiting for these to merge.) Thanks!
2020-06-22moves coverage data computation from pass to queryRich Kadel-1/+1
2020-06-22Address remaining feedback itemsRich Kadel-1/+1
2020-06-22implemented query for coverage dataRich Kadel-0/+6
This commit adds a query that allows the CoverageData to be pulled from a call on tcx, avoiding the need to change the `codegen_intrinsic_call()` signature (no need to pass in the FunctionCx or any additional arguments. The commit does not change where/when the CoverageData is computed. It's still done in the `pass`, and saved in the MIR `Body`. See discussion (in progress) here: https://github.com/rust-lang/rust/pull/73488#discussion_r443825646
2020-06-22Revert "Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, ↵Aaron Hill-1/+1
r=nikomatsakis" This reverts commit 372cb9b69c76a042d0b9d4b48ff6084f64c84a2c, reversing changes made to 5c61a8dc34c3e2fc6d7f02cb288c350f0233f944.
2020-06-20Move bounds on associated types to the typeMatthew Jasper-0/+10
Given `trait X { type U; }` the bound `<Self as X>::U` now lives on the type, rather than the trait. This is feature gated on `feature(generic_associated_types)` for now until more testing can be done. The also enabled type-generic associated types since we no longer need "implies bounds".
2020-06-20Consider fewer predicates for projection candidatesMatthew Jasper-0/+7
We now require that projection candidates are applicable with the idenitity substs of the trait, rather than allowing predicates that are only applicable for certain substs.
2020-06-15typeck: Use `LocalDefId`s for the unused trait import setVadim Petrochenkov-1/+1
2020-06-15Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, r=nikomatsakisRalf Jung-1/+1
Explain move errors that occur due to method calls involving `self` When calling a method that takes `self` (e.g. `vec.into_iter()`), the method receiver is moved out of. If the method receiver is used again, a move error will be emitted:: ```rust fn main() { let a = vec![true]; a.into_iter(); a; } ``` emits ``` error[E0382]: use of moved value: `a` --> src/main.rs:4:5 | 2 | let a = vec![true]; | - move occurs because `a` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait 3 | a.into_iter(); | - value moved here 4 | a; | ^ value used here after move ``` However, the error message doesn't make it clear that the move is caused by the call to `into_iter`. This PR adds additional messages to move errors when the move is caused by using a value as the receiver of a `self` method:: ``` error[E0382]: use of moved value: `a` --> vec.rs:4:5 | 2 | let a = vec![true]; | - move occurs because `a` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait 3 | a.into_iter(); | ------------- value moved due to this method call 4 | a; | ^ value used here after move | note: this function takes `self`, which moves the receiver --> /home/aaron/repos/rust/src/libcore/iter/traits/collect.rs:239:5 | 239 | fn into_iter(self) -> Self::IntoIter; ``` TODO: - [x] Add special handling for `FnOnce/FnMut/Fn` - we probably don't want to point at the unstable trait methods - [x] Consider adding additional context for operations (e.g. `Shr::shr`) when the call was generated using the operator syntax (e.g. `a >> b`) - [x] Consider pointing to the method parent (impl or trait block) in addition to the method itself.
2020-06-15Rollup merge of #71824 - ecstatic-morse:const-check-post-drop-elab, r=oli-obkRalf Jung-0/+6
Check for live drops in constants after drop elaboration Resolves #66753. This PR splits the MIR "optimization" pass series in two and introduces a query–`mir_drops_elaborated_and_const_checked`–that holds the result of the `post_borrowck_cleanup` analyses and checks for live drops. This query is invoked in `rustc_interface` for all items requiring const-checking, which means we now do `post_borrowck_cleanup` for items even if they are unused in the crate. As a result, we are now more precise about when drops are live. This is because drop elaboration can e.g. eliminate drops of a local when all its fields are moved from. This does not mean we are doing value-based analysis on move paths, however; Storing a `Some(CustomDropImpl)` into a field of a local will still set the qualifs for that entire local. r? @oli-obk
2020-06-13Add MIR phase and query for drop elaborationDylan MacKenzie-0/+6
2020-06-12Helper method for whether type has structural equalityDylan MacKenzie-0/+11
This helper method works for all types, falling back to a query for `TyKind::Adt`s to determine whether the implement the `{Partial,}StructuralEq` traits.
2020-06-11Make `fn_arg_names` return `Ident` instead of symbolAaron Hill-1/+1
Also, implement this query for the local crate, not just foreign crates.
2020-06-09Auto merge of #72114 - anyska:vtable-rename, r=nikomatsakisbors-1/+1
Rename traits::Vtable to ImplSource. Originally suggested by @eddyb. r? @nikomatsakis
2020-06-07Use `LocalDefId` directly in `Resolver::export_map` and `module_exports` querymarmeladema-2/+2
This is to avoid the final conversion from `NodeId` to `HirId` during call to `Resolver::(clone|into)_outputs`.
2020-06-05Rename traits::Vtable to ImplSource.Ana-Maria Mihalache-1/+1
2020-05-31Add descriptions for all queriesMatthew Jasper-66/+168
2020-05-30more `LocalDefId`sBastian Kauschke-2/+8
2020-05-27Store `LocalDefId` directly in `rustc_resolve::Resolver` where possiblemarmeladema-2/+4
This commit also include the following changes: * Remove unused `hir::Map::as_local_node_id` method * Remove outdated comment about `hir::Map::local_def_id` method * Remove confusing `GlobMap` type alias * Use `LocalDefId` instead of `DefId` in `extern_crate_map` * Use `LocalDefId` instead of `DefId` in `maybe_unused_extern_crates` * Modify `extern_mod_stmt_cnum` query to accept a `LocalDefId` instead of a `DefId`