about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/query/keys.rs
AgeCommit message (Collapse)AuthorLines
2024-04-11Auto merge of #122213 - estebank:issue-50195, r=oli-obk,estebankbors-0/+13
Provide suggestion to dereference closure tail if appropriate When encoutnering a case like ```rust use std::collections::HashMap; fn main() { let vs = vec![0, 0, 1, 1, 3, 4, 5, 6, 3, 3, 3]; let mut counts = HashMap::new(); for num in vs { let count = counts.entry(num).or_insert(0); *count += 1; } let _ = counts.iter().max_by_key(|(_, v)| v); ``` produce the following suggestion ``` error: lifetime may not live long enough --> $DIR/return-value-lifetime-error.rs:13:47 | LL | let _ = counts.iter().max_by_key(|(_, v)| v); | ------- ^ returning this value requires that `'1` must outlive `'2` | | | | | return type of closure is &'2 &i32 | has type `&'1 (&i32, &i32)` | help: dereference the return value | LL | let _ = counts.iter().max_by_key(|(_, v)| **v); | ++ ``` Fix #50195.
2024-04-05Provide suggestion to dereference closure tail if appropriateEsteban Küber-0/+13
When encoutnering a case like ```rust //@ run-rustfix use std::collections::HashMap; fn main() { let vs = vec![0, 0, 1, 1, 3, 4, 5, 6, 3, 3, 3]; let mut counts = HashMap::new(); for num in vs { let count = counts.entry(num).or_insert(0); *count += 1; } let _ = counts.iter().max_by_key(|(_, v)| v); ``` produce the following suggestion ``` error: lifetime may not live long enough --> $DIR/return-value-lifetime-error.rs:13:47 | LL | let _ = counts.iter().max_by_key(|(_, v)| v); | ------- ^ returning this value requires that `'1` must outlive `'2` | | | | | return type of closure is &'2 &i32 | has type `&'1 (&i32, &i32)` | help: dereference the return value | LL | let _ = counts.iter().max_by_key(|(_, v)| **v); | ++ ``` Fix #50195.
2024-04-04cache type info for ParamEnvLukas Markeffsky-1/+1
2024-03-26Remove `CacheSelector` trait now that we can use GATsOli Scherer-55/+54
2024-03-22Add `tag_for_variant` queryJack Wrenn-0/+9
This query allows for sharing code between `rustc_const_eval` and `rustc_transmutability`. Also moves `DummyMachine` to `rustc_const_eval`.
2024-01-15Cache local DefId-keyed queries without hashingMark Rousskov-1/+2
Foreign maps are used to cache external DefIds, typically backed by metadata decoding. In the future we might skip caching `V` there (since loading from metadata usually is already cheap enough), but for now this cuts down on the impact to memory usage and time to None-init a bunch of memory. Foreign data is usually much sparser, since we're not usually loading *all* entries from the foreign crate(s).
2024-01-08Don't check for recursion in generator witness fieldsMichael Goulet-4/+9
2023-10-02remove another unused Key implRalf Jung-9/+0
2023-10-02remove Key impls for types that involve an AllocIdRalf Jung-24/+0
2023-09-21rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::ConstRalf Jung-1/+1
2023-09-19move ConstValue into mirRalf Jung-3/+2
this way we have mir::ConstValue and ty::ValTree as reasonably parallel
2023-08-14Use `{Local}ModDefId` in many queriesNilstrieb-1/+36
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-5/+5
2023-07-06get rid of a bit more calls to poly_selectMichael Goulet-2/+2
2023-07-05Specialize `try_destructure_mir_constant` for its sole userOli Scherer-0/+9
2023-06-26Migrate predicates_of and caller_bounds to ClauseMichael Goulet-1/+1
2023-04-20Remove WithOptconstParam.Camille GILLOT-9/+1
2023-04-12Rollup merge of #110153 - DaniPopes:compiler-typos, r=NilstriebMatthias Krüger-1/+1
Fix typos in compiler I ran [`typos -w compiler`](https://github.com/crate-ci/typos) to fix typos in the `compiler` directory. Refs #110150
2023-04-11Split super_predicates_that_define_assoc_type query from super_predicates_ofMichael Goulet-1/+1
2023-04-10Fix typos in compilerDaniPopes-1/+1
2023-03-28Move `mir::Field` → `abi::FieldIdx`Scott McMurray-1/+2
The first PR for https://github.com/rust-lang/compiler-team/issues/606 This is just the move-and-rename, because it's plenty big-and-bitrotty already. Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
2023-03-21LocalCrate keyMichael Goulet-2/+6
2023-03-21AsLocalKey traitMichael Goulet-304/+43
2023-03-21Use LocalDefId in ItemCtxtMichael Goulet-3/+3
2023-03-21Use local key in providersMichael Goulet-109/+202
2023-03-14Use `unused_generic_params` from crate metadataMichael Goulet-2/+2
2023-02-27Unify all validity check intrinsicsNilstrieb-2/+2
Also merges the inhabitedness check into the query to further unify the code paths.
2023-02-23Unify validity checks into a single queryNilstrieb-1/+23
Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one.
2023-02-11Create a single value cache for the () query keyJohn Kåre Alsaker-2/+2
2022-12-16Add a comment warning against using associated type defaults <3Maybe Waffle-0/+8
2022-12-09Help rust-analyzer normalize query return typesMaybe Waffle-1/+97
2022-11-01Use Key impl to select cache.Camille GILLOT-1/+10
2022-11-01Move keys module.Camille GILLOT-0/+585