Fix AnonConst ICE
Add test Apply suggestions Switch to match Apply cargofmt
This commit is contained in:
parent
84826fec95
commit
a0fb992433
3 changed files with 44 additions and 4 deletions
|
@ -172,7 +172,7 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<
|
|||
// We've encountered an `AnonConst` in some path, so we need to
|
||||
// figure out which generic parameter it corresponds to and return
|
||||
// the relevant type.
|
||||
let (arg_index, segment) = path
|
||||
let filtered = path
|
||||
.segments
|
||||
.iter()
|
||||
.filter_map(|seg| seg.args.map(|args| (args.args, seg)))
|
||||
|
@ -181,10 +181,17 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<
|
|||
.filter(|arg| arg.is_const())
|
||||
.position(|arg| arg.id() == hir_id)
|
||||
.map(|index| (index, seg))
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
bug!("no arg matching AnonConst in path");
|
||||
});
|
||||
let (arg_index, segment) = match filtered {
|
||||
None => {
|
||||
tcx.sess.delay_span_bug(
|
||||
tcx.def_span(def_id),
|
||||
"no arg matching AnonConst in path",
|
||||
);
|
||||
return None;
|
||||
}
|
||||
Some(inner) => inner,
|
||||
};
|
||||
|
||||
// Try to use the segment resolution if it is valid, otherwise we
|
||||
// default to the path resolution.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue