Skip to content

Commit 665b1a4

Browse files
authored
Unrolled build for rust-lang#139349
Rollup merge of rust-lang#139349 - meithecatte:destructor-constness, r=compiler-errors adt_destructor: sanity-check returned item Fixes rust-lang#139278
2 parents f174fd7 + a14e8f6 commit 665b1a4

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

compiler/rustc_middle/src/ty/util.rs

+5
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,11 @@ impl<'tcx> TyCtxt<'tcx> {
414414
continue;
415415
};
416416

417+
if self.def_kind(item_id) != DefKind::AssocFn {
418+
self.dcx().span_delayed_bug(self.def_span(item_id), "drop is not a function");
419+
continue;
420+
}
421+
417422
if let Some(old_item_id) = dtor_candidate {
418423
self.dcx()
419424
.struct_span_err(self.def_span(item_id), "multiple drop impls found")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ check-fail
2+
struct Foo;
3+
4+
impl Drop for Foo { //~ ERROR: not all trait items implemented
5+
const SPLOK: u32 = 0; //~ ERROR: not a member of trait
6+
}
7+
8+
const X: Foo = Foo;
9+
10+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0438]: const `SPLOK` is not a member of trait `Drop`
2+
--> $DIR/nonsense-drop-impl-issue-139278.rs:5:5
3+
|
4+
LL | const SPLOK: u32 = 0;
5+
| ^^^^^^^^^^^^^^^^^^^^^ not a member of trait `Drop`
6+
7+
error[E0046]: not all trait items implemented, missing: `drop`
8+
--> $DIR/nonsense-drop-impl-issue-139278.rs:4:1
9+
|
10+
LL | impl Drop for Foo {
11+
| ^^^^^^^^^^^^^^^^^ missing `drop` in implementation
12+
|
13+
= help: implement the missing item: `fn drop(&mut self) { todo!() }`
14+
15+
error: aborting due to 2 previous errors
16+
17+
Some errors have detailed explanations: E0046, E0438.
18+
For more information about an error, try `rustc --explain E0046`.

0 commit comments

Comments
 (0)