Do not ICE on range patterns in function arguments

This commit is contained in:
LeSeulArtichaut 2021-02-09 00:20:44 +01:00
parent 793e88ad16
commit 089ee27dd0
2 changed files with 2 additions and 5 deletions

View File

@ -289,10 +289,7 @@ crate fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
);
return Symbol::intern("()");
}
PatKind::Range(..) => panic!(
"tried to get argument name from PatKind::Range, \
which is not allowed in function arguments"
),
PatKind::Range(..) => return kw::Underscore,
PatKind::Slice(ref begin, ref mid, ref end) => {
let begin = begin.iter().map(|p| name_from_pat(&**p).to_string());
let mid = mid.as_ref().map(|p| format!("..{}", name_from_pat(&**p))).into_iter();

View File

@ -1,5 +1,5 @@
#![crate_name = "foo"]
// @has foo/fn.f.html
// @has - '//*[@class="rust fn"]' 'pub fn f(0u8 ...255: u8)'
// @has - '//*[@class="rust fn"]' 'pub fn f(_: u8)'
pub fn f(0u8...255: u8) {}