Skip to content

Commit 8547f57

Browse files
never is trivially const-drop, and add test
1 parent 0eccd5f commit 8547f57

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

compiler/rustc_middle/src/ty/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1054,15 +1054,15 @@ pub fn trivial_const_drop<'tcx>(ty: Ty<'tcx>) -> bool {
10541054
| ty::RawPtr(_)
10551055
| ty::Ref(..)
10561056
| ty::FnDef(..)
1057-
| ty::FnPtr(_) => true,
1057+
| ty::FnPtr(_)
1058+
| ty::Never => true,
10581059

10591060
ty::Opaque(..)
10601061
| ty::Dynamic(..)
10611062
| ty::Error(_)
10621063
| ty::Bound(..)
10631064
| ty::Param(_)
10641065
| ty::Placeholder(_)
1065-
| ty::Never
10661066
| ty::Foreign(_)
10671067
| ty::Projection(_)
10681068
| ty::Infer(_) => false,

src/test/ui/rfc-2632-const-trait-impl/const-drop.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![feature(const_trait_impl)]
44
#![feature(const_fn_trait_bound)]
55
#![feature(const_mut_refs)]
6+
#![feature(never_type)]
67
#![cfg_attr(precise, feature(const_precise_live_drops))]
78

89
struct S<'a>(&'a mut u8);
@@ -77,6 +78,7 @@ implements_const_drop! {
7778
&1,
7879
&1 as *const i32,
7980
ConstDropWithBound::<()>,
81+
Result::<i32, !>::Ok(1),
8082
}
8183

8284
fn main() {

0 commit comments

Comments
 (0)