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 authored and Mark-Simulacrum committed Feb 13, 2021
1 parent 2d6c4b3 commit b016024
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
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,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
Original file line number Diff line number Diff line change
@@ -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 b016024

Please sign in to comment.