Skip to content

Commit b016024

Browse files
LeSeulArtichautMark-Simulacrum
authored andcommitted
Do not ICE on range patterns in function arguments
1 parent 2d6c4b3 commit b016024

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

src/librustdoc/clean/utils.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,7 @@ crate fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
409409
);
410410
return Symbol::intern("()");
411411
}
412-
PatKind::Range(..) => panic!(
413-
"tried to get argument name from PatKind::Range, \
414-
which is not allowed in function arguments"
415-
),
412+
PatKind::Range(..) => return kw::Underscore,
416413
PatKind::Slice(ref begin, ref mid, ref end) => {
417414
let begin = begin.iter().map(|p| name_from_pat(&**p).to_string());
418415
let mid = mid.as_ref().map(|p| format!("..{}", name_from_pat(&**p))).into_iter();

src/test/rustdoc/range-arg-pattern.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "foo"]
22

33
// @has foo/fn.f.html
4-
// @has - '//*[@class="rust fn"]' 'pub fn f(0u8 ...255: u8)'
4+
// @has - '//*[@class="rust fn"]' 'pub fn f(_: u8)'
55
pub fn f(0u8...255: u8) {}

0 commit comments

Comments
 (0)