add AnonConst as potential parent_item#71477
Conversation
src/test/ui/repeat_count.stderr
Outdated
There was a problem hiding this comment.
This help message was incorrect.
There was a problem hiding this comment.
|
It'd be nice if we changed |
|
Can implement it in a separate PR 👍 |
|
I don't think this is the right approach, |
|
This PR is needed for https://github.com/rust-lang/rust/blob/4b575996168edbc5b7ad46229f5ed3bfee35484c/src/test/ui/const-generics/type-dependent/const-arg-in-const-arg.rs #70 (#71154 uses it to get the correct typeck_tables)
rust/src/librustc_middle/hir/map/mod.rs Line 564 in bf45975 which currently results in wrong diagnostics in rust/src/librustc_typeck/check/demand.rs Lines 597 to 601 in 413a129 What do you want to use instead? |
|
You want to loop through the parents with If you want to be more efficient you could probably add an cc @ecstatic-morse @oli-obk @wesleywiser on |
|
I now use the following in #71154: pub fn enclosing_body_owner(&self, hir_id: HirId) -> HirId {
for (parent, _) in self.parent_iter(hir_id) {
if let Some(body) = self.maybe_body_owned_by(parent) {
return self.body_owner(body);
}
}
bug!("no `enclosing_body_owner` for hir_id `{}`", hir_id);
}This means that this PR now only fixes incorrect suggestions afaict. Don't fully understand when |
|
Closing this for now as this is not the correct approach. Will try and make a more general fix for |
Fix `is_const_context`, update `check_for_cast` A better version of rust-lang#71477 Adds `fn enclosing_body_owner` and uses it in `is_const_context`. `is_const_context` now uses the same mechanism as `mir_const_qualif` as it was previously incorrect. Renames `is_const_context` to `is_inside_const_context`. I also updated `check_for_cast` in the second commit, so r? @estebank (I removed one lvl of indentation, so it might be easier to review by hiding whitespace changes)
Fix `is_const_context`, update `check_for_cast` A better version of rust-lang#71477 Adds `fn enclosing_body_owner` and uses it in `is_const_context`. `is_const_context` now uses the same mechanism as `mir_const_qualif` as it was previously incorrect. Renames `is_const_context` to `is_inside_const_context`. I also updated `check_for_cast` in the second commit, so r? @estebank (I removed one lvl of indentation, so it might be easier to review by hiding whitespace changes)
This prevents some help messages in const contexts, due to
rust/src/librustc_typeck/check/demand.rs
Lines 597 to 601 in 413a129
considering that the check in
is_const_contextwas previously unreachable,this is actually a bugfix 😆
rust/src/librustc_middle/hir/map/mod.rs
Line 563 in 413a129
r? @eddyb cc @estebank