From 9a8671316699d21841d26ab37ba0414d35825222 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Sat, 26 Sep 2015 23:12:11 +0300 Subject: [PATCH] don't crash when there are multiple conflicting implementations of Drop Fixes #28568 --- src/librustc/middle/ty/mod.rs | 1 - src/test/compile-fail/issue-28568.rs | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/test/compile-fail/issue-28568.rs diff --git a/src/librustc/middle/ty/mod.rs b/src/librustc/middle/ty/mod.rs index eb93c58f38c..c3e7fd4ceca 100644 --- a/src/librustc/middle/ty/mod.rs +++ b/src/librustc/middle/ty/mod.rs @@ -1695,7 +1695,6 @@ impl<'tcx, 'container> AdtDefData<'tcx, 'container> { } pub fn set_destructor(&self, dtor: DefId) { - assert!(self.destructor.get().is_none()); self.destructor.set(Some(dtor)); } diff --git a/src/test/compile-fail/issue-28568.rs b/src/test/compile-fail/issue-28568.rs new file mode 100644 index 00000000000..36b4a57eb11 --- /dev/null +++ b/src/test/compile-fail/issue-28568.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct MyStruct; + +impl Drop for MyStruct { +//~^ ERROR conflicting implementations for trait + fn drop(&mut self) { } +} + +impl Drop for MyStruct { +//~^ NOTE conflicting implementation here + fn drop(&mut self) { } +} + +fn main() {}