diff options
| author | Lzu Tao <taolzu@gmail.com> | 2019-07-10 18:49:05 +0000 |
|---|---|---|
| committer | Lzu Tao <taolzu@gmail.com> | 2019-07-11 18:14:56 +0000 |
| commit | ab3adf380d09005e2deea002ac172135a5c158f0 (patch) | |
| tree | 22442efb6af18eea7ea48cf69cda5b0941aa8d12 /src | |
| parent | 4bb6b4a5ed1cd377c5cfd97721ad12f52e63dd41 (diff) | |
| download | rust-ab3adf380d09005e2deea002ac172135a5c158f0.tar.gz rust-ab3adf380d09005e2deea002ac172135a5c158f0.zip | |
Replace unsafe_destructor_blind_to_params with may_dangle
Diffstat (limited to 'src')
8 files changed, 21 insertions, 31 deletions
diff --git a/src/test/run-pass/issues/issue-24805-dropck-itemless.rs b/src/test/run-pass/issues/issue-24805-dropck-itemless.rs index db427ed3d31..555eefeb3a1 100644 --- a/src/test/run-pass/issues/issue-24805-dropck-itemless.rs +++ b/src/test/run-pass/issues/issue-24805-dropck-itemless.rs @@ -1,12 +1,11 @@ // run-pass -#![allow(deprecated)] // Check that item-less traits do not cause dropck to inject extra // region constraints. #![allow(non_camel_case_types)] -#![feature(dropck_parametricity)] +#![feature(dropck_eyepatch)] trait UserDefined { } @@ -20,9 +19,8 @@ impl<'a, T> UserDefined for &'a T { } // ``` macro_rules! impl_drop { ($Bound:ident, $Id:ident) => { - struct $Id<T:$Bound>(T); - impl <T:$Bound> Drop for $Id<T> { - #[unsafe_destructor_blind_to_params] + struct $Id<T: $Bound>(T); + unsafe impl <#[may_dangle] T: $Bound> Drop for $Id<T> { fn drop(&mut self) { } } } diff --git a/src/test/run-pass/issues/issue-28498-ugeh-ex1.rs b/src/test/run-pass/issues/issue-28498-ugeh-ex1.rs index c4f249c45f1..90cf2cddcf0 100644 --- a/src/test/run-pass/issues/issue-28498-ugeh-ex1.rs +++ b/src/test/run-pass/issues/issue-28498-ugeh-ex1.rs @@ -1,21 +1,19 @@ // run-pass -#![allow(deprecated)] // FIXME: switch to `#[may_dangle]` below. // Example taken from RFC 1238 text // https://github.com/rust-lang/rfcs/blob/master/text/1238-nonparametric-dropck.md // #example-of-the-unguarded-escape-hatch -#![feature(dropck_parametricity)] +#![feature(dropck_eyepatch)] use std::cell::Cell; struct Concrete<'a>(u32, Cell<Option<&'a Concrete<'a>>>); struct Foo<T> { data: Vec<T> } -impl<T> Drop for Foo<T> { - // Below is the UGEH attribute - #[unsafe_destructor_blind_to_params] +// Below is the UGEH attribute +unsafe impl<#[may_dangle] T> Drop for Foo<T> { fn drop(&mut self) { } } diff --git a/src/test/run-pass/issues/issue-28498-ugeh-with-lifetime-param.rs b/src/test/run-pass/issues/issue-28498-ugeh-with-lifetime-param.rs index 573ec8f6131..0c94ee53d35 100644 --- a/src/test/run-pass/issues/issue-28498-ugeh-with-lifetime-param.rs +++ b/src/test/run-pass/issues/issue-28498-ugeh-with-lifetime-param.rs @@ -1,12 +1,11 @@ // run-pass -#![allow(deprecated)] // FIXME: switch to `#[may_dangle]` below. // Demonstrate the use of the unguarded escape hatch with a lifetime param // to assert that destructor will not access any dead data. // // Compare with compile-fail/issue28498-reject-lifetime-param.rs -#![feature(dropck_parametricity)] +#![feature(dropck_eyepatch)] #[derive(Debug)] struct ScribbleOnDrop(String); @@ -19,10 +18,9 @@ impl Drop for ScribbleOnDrop { struct Foo<'a>(u32, &'a ScribbleOnDrop); -impl<'a> Drop for Foo<'a> { - #[unsafe_destructor_blind_to_params] +unsafe impl<#[may_dangle] 'a> Drop for Foo<'a> { fn drop(&mut self) { - // Use of `unsafe_destructor_blind_to_params` is sound, + // Use of `may_dangle` is sound, // because destructor never accesses `self.1`. println!("Dropping Foo({}, _)", self.0); } diff --git a/src/test/run-pass/issues/issue-28498-ugeh-with-passed-to-fn.rs b/src/test/run-pass/issues/issue-28498-ugeh-with-passed-to-fn.rs index e0863fa9947..bf051b950e5 100644 --- a/src/test/run-pass/issues/issue-28498-ugeh-with-passed-to-fn.rs +++ b/src/test/run-pass/issues/issue-28498-ugeh-with-passed-to-fn.rs @@ -1,5 +1,4 @@ // run-pass -#![allow(deprecated)] // FIXME: switch to `#[may_dangle]` below. // Demonstrate the use of the unguarded escape hatch with a type param in negative position // to assert that destructor will not access any dead data. @@ -11,7 +10,7 @@ // // Compare with run-pass/issue28498-ugeh-with-passed-to-fn.rs -#![feature(dropck_parametricity)] +#![feature(dropck_eyepatch)] #[derive(Debug)] struct ScribbleOnDrop(String); @@ -24,10 +23,9 @@ impl Drop for ScribbleOnDrop { struct Foo<T>(u32, T, Box<for <'r> fn(&'r T) -> String>); -impl<T> Drop for Foo<T> { - #[unsafe_destructor_blind_to_params] +unsafe impl<#[may_dangle] T> Drop for Foo<T> { fn drop(&mut self) { - // Use of `unsafe_destructor_blind_to_params` is sound, + // Use of `may_dangle` is sound, // because destructor never passes a `self.1` to the callback // (in `self.2`) despite having it available. println!("Dropping Foo({}, _)", self.0); diff --git a/src/test/run-pass/issues/issue-28498-ugeh-with-trait-bound.rs b/src/test/run-pass/issues/issue-28498-ugeh-with-trait-bound.rs index 01d884584f6..b6f55350a6c 100644 --- a/src/test/run-pass/issues/issue-28498-ugeh-with-trait-bound.rs +++ b/src/test/run-pass/issues/issue-28498-ugeh-with-trait-bound.rs @@ -1,12 +1,11 @@ // run-pass -#![allow(deprecated)] // FIXME: switch to `#[may_dangle]` below. // Demonstrate the use of the unguarded escape hatch with a trait bound // to assert that destructor will not access any dead data. // // Compare with compile-fail/issue28498-reject-trait-bound.rs -#![feature(dropck_parametricity)] +#![feature(dropck_eyepatch)] use std::fmt; @@ -19,12 +18,11 @@ impl Drop for ScribbleOnDrop { } } -struct Foo<T:fmt::Debug>(u32, T); +struct Foo<T: fmt::Debug>(u32, T); -impl<T:fmt::Debug> Drop for Foo<T> { - #[unsafe_destructor_blind_to_params] +unsafe impl<#[may_dangle] T: fmt::Debug> Drop for Foo<T> { fn drop(&mut self) { - // Use of `unsafe_destructor_blind_to_params` is sound, + // Use of `may_dangle` is sound, // because destructor never accesses the `Debug::fmt` method // of `T`, despite having it available. println!("Dropping Foo({}, _)", self.0); diff --git a/src/test/ui/span/issue28498-reject-lifetime-param.rs b/src/test/ui/span/issue28498-reject-lifetime-param.rs index 9bc01766be5..5876d4240c0 100644 --- a/src/test/ui/span/issue28498-reject-lifetime-param.rs +++ b/src/test/ui/span/issue28498-reject-lifetime-param.rs @@ -16,7 +16,7 @@ struct Foo<'a>(u32, &'a ScribbleOnDrop); impl<'a> Drop for Foo<'a> { fn drop(&mut self) { - // Use of `unsafe_destructor_blind_to_params` is unsound, + // Use of `may_dangle` is unsound, // because destructor accesses borrowed data in `self.1` // and we must force that to strictly outlive `self`. println!("Dropping Foo({}, {:?})", self.0, self.1); diff --git a/src/test/ui/span/issue28498-reject-passed-to-fn.rs b/src/test/ui/span/issue28498-reject-passed-to-fn.rs index c59de5df411..76d84055434 100644 --- a/src/test/ui/span/issue28498-reject-passed-to-fn.rs +++ b/src/test/ui/span/issue28498-reject-passed-to-fn.rs @@ -16,7 +16,7 @@ struct Foo<T>(u32, T, Box<for <'r> fn(&'r T) -> String>); impl<T> Drop for Foo<T> { fn drop(&mut self) { - // Use of `unsafe_destructor_blind_to_params` is unsound, + // Use of `may_dangle` is unsound, // because we pass `T` to the callback in `self.2` // below, and thus potentially read from borrowed data. println!("Dropping Foo({}, {})", self.0, (self.2)(&self.1)); diff --git a/src/test/ui/span/issue28498-reject-trait-bound.rs b/src/test/ui/span/issue28498-reject-trait-bound.rs index 8813180c891..77a443286cb 100644 --- a/src/test/ui/span/issue28498-reject-trait-bound.rs +++ b/src/test/ui/span/issue28498-reject-trait-bound.rs @@ -14,11 +14,11 @@ impl Drop for ScribbleOnDrop { } } -struct Foo<T:fmt::Debug>(u32, T); +struct Foo<T: fmt::Debug>(u32, T); -impl<T:fmt::Debug> Drop for Foo<T> { +impl<T: fmt::Debug> Drop for Foo<T> { fn drop(&mut self) { - // Use of `unsafe_destructor_blind_to_params` is unsound, + // Use of `may_dangle` is unsound, // because we access `T` fmt method when we pass `self.1` // below, and thus potentially read from borrowed data. println!("Dropping Foo({}, {:?})", self.0, self.1); |
