Skip to content

Commit 31a4cba

Browse files
committed
Delay panic from incoherent drop implementation
1 parent bc1dda4 commit 31a4cba

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

src/librustc_typeck/check/dropck.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ pub fn check_drop_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
5959
}
6060
_ => {
6161
// Destructors only work on nominal types. This was
62-
// already checked by coherence, so we can panic here.
62+
// already checked by coherence, but compilation may
63+
// not have been terminated.
6364
let span = tcx.def_span(drop_impl_did);
64-
span_bug!(span,
65-
"should have been rejected by coherence check: {}",
66-
dtor_self_type);
65+
tcx.sess.delay_span_bug(span,
66+
&format!("should have been rejected by coherence check: {}",
67+
dtor_self_type));
68+
Err(ErrorReported)
6769
}
6870
}
6971
}

src/test/compile-fail/issue-41974.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[derive(Copy, Clone)]
12+
struct Flags;
13+
14+
trait A {
15+
}
16+
17+
impl<T> Drop for T where T: A { //~ ERROR E0119
18+
//~^ ERROR E0120
19+
//~| ERROR E0210
20+
fn drop(&mut self) {
21+
}
22+
}
23+
24+
fn main() {}

0 commit comments

Comments
 (0)