fix: Lower const params with a bad id by HKalbasi · Pull Request #14932 · rust-l...
source link: https://github.com/rust-lang/rust-analyzer/pull/14932
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Conversation
Member
cc #7434
This PR adds an InTypeConstId
which is a DefWithBodyId
and lower const generic parameters into bodies using it, and evaluate them with the mir interpreter. I think this is the last unimplemented const generic feature relative to rustc stable.
But there is a problem: The id used in the InTypeConstId
is the raw FileAstId
, which changes frequently. So these ids and their bodies will be invalidated very frequently, which is bad for incremental analysis.
Due this problem, I disabled lowering for local crates (in library crate the id is stable since files won't be changed). This might be overreacting (const generic expressions are usually small, maybe it would be better enabled with bad performance than disabled) but it makes motivation for doing it in the correct way, and it splits the potential panic and breakages that usually comes with const generic PRs in two steps.
Other than the id, I think (at least I hope) other parts are in the right direction.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK