Skip to content

Commit 81f9946

Browse files
committed
Auto merge of rust-lang#7034 - Jarcho:missing_doc_ice, r=phansch
Fix ICE in `missing_panics_doc` fixes: rust-lang#7033 changelog: Fix ICE in `missing_panics_doc` while searching in a `const` block
2 parents 8d221c5 + a00de90 commit 81f9946

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

clippy_lints/src/doc.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_errors::emitter::EmitterWriter;
1111
use rustc_errors::Handler;
1212
use rustc_hir as hir;
1313
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
14-
use rustc_hir::{Expr, ExprKind, QPath};
14+
use rustc_hir::{AnonConst, Expr, ExprKind, QPath};
1515
use rustc_lint::{LateContext, LateLintPass};
1616
use rustc_middle::hir::map::Map;
1717
use rustc_middle::lint::in_external_macro;
@@ -735,6 +735,9 @@ impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> {
735735
intravisit::walk_expr(self, expr);
736736
}
737737

738+
// Panics in const blocks will cause compilation to fail.
739+
fn visit_anon_const(&mut self, _: &'tcx AnonConst) {}
740+
738741
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
739742
NestedVisitorMap::OnlyBodies(self.cx.tcx.hir())
740743
}

tests/ui/doc.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! This file tests for the `DOC_MARKDOWN` lint.
22
3-
#![allow(dead_code)]
3+
#![allow(dead_code, incomplete_features)]
44
#![warn(clippy::doc_markdown)]
5-
#![feature(custom_inner_attributes)]
5+
#![feature(custom_inner_attributes, const_generics, const_evaluatable_checked, const_option)]
66
#![rustfmt::skip]
77

88
/// The foo_bar function does _nothing_. See also foo::bar. (note the dot there)
@@ -202,3 +202,20 @@ fn issue_2343() {}
202202
/// This should not cause an ICE:
203203
/// __|_ _|__||_|
204204
fn pulldown_cmark_crash() {}
205+
206+
// issue #7033 - const_evaluatable_checked ICE
207+
struct S<T, const N: usize>
208+
where [(); N.checked_next_power_of_two().unwrap()]: {
209+
arr: [T; N.checked_next_power_of_two().unwrap()],
210+
n: usize,
211+
}
212+
213+
impl<T: Copy + Default, const N: usize> S<T, N>
214+
where [(); N.checked_next_power_of_two().unwrap()]: {
215+
fn new() -> Self {
216+
Self {
217+
arr: [T::default(); N.checked_next_power_of_two().unwrap()],
218+
n: 0,
219+
}
220+
}
221+
}

0 commit comments

Comments
 (0)