Skip to content

Commit

Permalink
Do not ICE on range patterns in function arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
LeSeulArtichaut committed Feb 10, 2021
1 parent 793e88a commit 089ee27
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/librustdoc/clean/utils.rs
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/range-arg-pattern.rs
@@ -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) {}

0 comments on commit 089ee27

Please sign in to comment.