Skip to content

Commit 452c745

Browse files
committed
Add a comment warning against using associated type defaults <3
1 parent 7e79c57 commit 452c745

File tree

1 file changed

+8
-0
lines changed
  • compiler/rustc_middle/src/query

1 file changed

+8
-0
lines changed

compiler/rustc_middle/src/query/keys.rs

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ use rustc_span::{Span, DUMMY_SP};
1515
/// The `Key` trait controls what types can legally be used as the key
1616
/// for a query.
1717
pub trait Key: Sized {
18+
// N.B. Most of the keys down below have `type CacheSelector = DefaultCacheSelector<Self>;`,
19+
// it would be reasonable to use associated type defaults, to remove the duplication...
20+
//
21+
// ...But r-a doesn't support them yet and using a default here causes r-a to not infer
22+
// return types of queries which is very annoying. Thus, until r-a support associated
23+
// type defaults, plese restrain from using them here <3
24+
//
25+
// r-a issue: <https://github.com/rust-lang/rust-analyzer/issues/13693>
1826
type CacheSelector;
1927

2028
/// Given an instance of this key, what crate is it referring to?

0 commit comments

Comments
 (0)