Skip to content

Commit 089ee27

Browse files
Do not ICE on range patterns in function arguments
1 parent 793e88a commit 089ee27

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
@@ -289,10 +289,7 @@ crate fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
289289
);
290290
return Symbol::intern("()");
291291
}
292-
PatKind::Range(..) => panic!(
293-
"tried to get argument name from PatKind::Range, \
294-
which is not allowed in function arguments"
295-
),
292+
PatKind::Range(..) => return kw::Underscore,
296293
PatKind::Slice(ref begin, ref mid, ref end) => {
297294
let begin = begin.iter().map(|p| name_from_pat(&**p).to_string());
298295
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)