mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 06:35:27 +00:00
Remove feature gate dropck_parametricity
completely
Therefore we also remove `#[unsafe_destructor_blind_to_params]` attribute completly.
This commit is contained in:
parent
ab3adf380d
commit
8347917dd9
@ -22,7 +22,6 @@ use rustc_macros::HashStable;
|
||||
use std::{cmp, fmt};
|
||||
use syntax::ast;
|
||||
use syntax::attr::{self, SignedInt, UnsignedInt};
|
||||
use syntax::symbol::sym;
|
||||
use syntax_pos::{Span, DUMMY_SP};
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
@ -435,20 +434,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
Some(dtor) => dtor.did
|
||||
};
|
||||
|
||||
// RFC 1238: if the destructor method is tagged with the
|
||||
// attribute `unsafe_destructor_blind_to_params`, then the
|
||||
// compiler is being instructed to *assume* that the
|
||||
// destructor will not access borrowed data,
|
||||
// even if such data is otherwise reachable.
|
||||
//
|
||||
// Such access can be in plain sight (e.g., dereferencing
|
||||
// `*foo.0` of `Foo<'a>(&'a u32)`) or indirectly hidden
|
||||
// (e.g., calling `foo.0.clone()` of `Foo<T:Clone>`).
|
||||
if self.has_attr(dtor, sym::unsafe_destructor_blind_to_params) {
|
||||
debug!("destructor_constraint({:?}) - blind", def.did);
|
||||
return vec![];
|
||||
}
|
||||
|
||||
let impl_def_id = self.associated_item(dtor).container.id();
|
||||
let impl_generics = self.generics_of(impl_def_id);
|
||||
|
||||
|
@ -246,7 +246,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
||||
///
|
||||
/// * (1.) `D` has a lifetime- or type-parametric Drop implementation,
|
||||
/// (where that `Drop` implementation does not opt-out of
|
||||
/// this check via the `unsafe_destructor_blind_to_params`
|
||||
/// this check via the `may_dangle`
|
||||
/// attribute), and
|
||||
/// * (2.) the structure of `D` can reach a reference of type `&'a _`,
|
||||
///
|
||||
@ -279,7 +279,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
||||
/// instead Drop-Check now simply assumes that if a destructor has
|
||||
/// access (direct or indirect) to a lifetime parameter, then that
|
||||
/// lifetime must be forced to outlive that destructor's dynamic
|
||||
/// extent. We then provide the `unsafe_destructor_blind_to_params`
|
||||
/// extent. We then provide the `may_dangle`
|
||||
/// attribute as a way for destructor implementations to opt-out of
|
||||
/// this conservative assumption (and thus assume the obligation of
|
||||
/// ensuring that they do not access data nor invoke methods of
|
||||
|
@ -3809,7 +3809,6 @@ const ATTRIBUTE_WHITELIST: &'static [Symbol] = &[
|
||||
sym::must_use,
|
||||
sym::no_mangle,
|
||||
sym::repr,
|
||||
sym::unsafe_destructor_blind_to_params,
|
||||
sym::non_exhaustive
|
||||
];
|
||||
|
||||
|
@ -199,9 +199,6 @@ declare_features! (
|
||||
|
||||
// no-tracking-issue-end
|
||||
|
||||
// Allows using `#[unsafe_destructor_blind_to_params]` (RFC 1238).
|
||||
(active, dropck_parametricity, "1.3.0", Some(28498), None),
|
||||
|
||||
// no-tracking-issue-start
|
||||
|
||||
// Allows using `#[omit_gdb_pretty_printer_section]`.
|
||||
@ -641,6 +638,8 @@ declare_features! (
|
||||
(removed, extern_in_paths, "1.33.0", Some(55600), None,
|
||||
Some("subsumed by `::foo::bar` paths")),
|
||||
(removed, quote, "1.33.0", Some(29601), None, None),
|
||||
// Allows using `#[unsafe_destructor_blind_to_params]` (RFC 1238).
|
||||
(removed, dropck_parametricity, "1.38.0", Some(28498), None, None),
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// feature-group-end: removed features
|
||||
@ -1447,15 +1446,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
||||
cfg_fn!(omit_gdb_pretty_printer_section)
|
||||
)
|
||||
),
|
||||
(sym::unsafe_destructor_blind_to_params,
|
||||
Normal,
|
||||
template!(Word),
|
||||
Gated(Stability::Deprecated("https://github.com/rust-lang/rust/issues/34761",
|
||||
Some("replace this attribute with `#[may_dangle]`")),
|
||||
sym::dropck_parametricity,
|
||||
"unsafe_destructor_blind_to_params has been replaced by \
|
||||
may_dangle and will be removed in the future",
|
||||
cfg_fn!(dropck_parametricity))),
|
||||
(sym::may_dangle,
|
||||
Normal,
|
||||
template!(Word),
|
||||
|
@ -695,7 +695,6 @@ symbols! {
|
||||
unmarked_api,
|
||||
unreachable_code,
|
||||
unrestricted_attribute_tokens,
|
||||
unsafe_destructor_blind_to_params,
|
||||
unsafe_no_drop_flag,
|
||||
unsized_locals,
|
||||
unsized_tuple_coercion,
|
||||
|
@ -20,8 +20,7 @@ struct Foo<'a>(u32, &'a ScribbleOnDrop);
|
||||
|
||||
unsafe impl<#[may_dangle] 'a> Drop for Foo<'a> {
|
||||
fn drop(&mut self) {
|
||||
// Use of `may_dangle` is sound,
|
||||
// because destructor never accesses `self.1`.
|
||||
// Use of `may_dangle` is sound, because destructor never accesses `self.1`.
|
||||
println!("Dropping Foo({}, _)", self.0);
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,8 @@ struct Foo<T>(u32, T, Box<for <'r> fn(&'r T) -> String>);
|
||||
|
||||
unsafe impl<#[may_dangle] T> Drop for Foo<T> {
|
||||
fn drop(&mut self) {
|
||||
// Use of `may_dangle` is sound,
|
||||
// because destructor never passes a `self.1` to the callback
|
||||
// (in `self.2`) despite having it available.
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,8 @@ struct Foo<T: fmt::Debug>(u32, T);
|
||||
|
||||
unsafe impl<#[may_dangle] T: fmt::Debug> Drop for Foo<T> {
|
||||
fn drop(&mut self) {
|
||||
// Use of `may_dangle` is sound,
|
||||
// because destructor never accesses the `Debug::fmt` method
|
||||
// of `T`, despite having it available.
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
#![deny(deprecated)]
|
||||
#![feature(dropck_parametricity)]
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl Drop for Foo {
|
||||
#[unsafe_destructor_blind_to_params]
|
||||
//~^ ERROR use of deprecated attribute `dropck_parametricity`
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,14 +0,0 @@
|
||||
error: use of deprecated attribute `dropck_parametricity`: unsafe_destructor_blind_to_params has been replaced by may_dangle and will be removed in the future. See https://github.com/rust-lang/rust/issues/34761
|
||||
--> $DIR/feature-gate-dropck-ugeh-2.rs:7:5
|
||||
|
|
||||
LL | #[unsafe_destructor_blind_to_params]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this attribute with `#[may_dangle]`
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/feature-gate-dropck-ugeh-2.rs:1:9
|
||||
|
|
||||
LL | #![deny(deprecated)]
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,29 +0,0 @@
|
||||
// gate-test-dropck_parametricity
|
||||
|
||||
// Ensure that attempts to use the unsafe attribute are feature-gated.
|
||||
// Example adapted from RFC 1238 text (just left out the feature gate).
|
||||
|
||||
// https://github.com/rust-lang/rfcs/blob/master/text/1238-nonparametric-dropck.md
|
||||
// #example-of-the-unguarded-escape-hatch
|
||||
|
||||
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> {
|
||||
#[unsafe_destructor_blind_to_params] // This is the UGEH attribute
|
||||
//~^ ERROR unsafe_destructor_blind_to_params has been replaced
|
||||
//~| WARN use of deprecated attribute `dropck_parametricity`
|
||||
fn drop(&mut self) { }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut foo = Foo { data: Vec::new() };
|
||||
foo.data.push(Concrete(0, Cell::new(None)));
|
||||
foo.data.push(Concrete(0, Cell::new(None)));
|
||||
|
||||
foo.data[0].1.set(Some(&foo.data[1]));
|
||||
foo.data[1].1.set(Some(&foo.data[0]));
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
error[E0658]: unsafe_destructor_blind_to_params has been replaced by may_dangle and will be removed in the future
|
||||
--> $DIR/feature-gate-dropck-ugeh.rs:16:5
|
||||
|
|
||||
LL | #[unsafe_destructor_blind_to_params] // This is the UGEH attribute
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: for more information, see https://github.com/rust-lang/rust/issues/28498
|
||||
= help: add `#![feature(dropck_parametricity)]` to the crate attributes to enable
|
||||
|
||||
warning: use of deprecated attribute `dropck_parametricity`: unsafe_destructor_blind_to_params has been replaced by may_dangle and will be removed in the future. See https://github.com/rust-lang/rust/issues/34761
|
||||
--> $DIR/feature-gate-dropck-ugeh.rs:16:5
|
||||
|
|
||||
LL | #[unsafe_destructor_blind_to_params] // This is the UGEH attribute
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this attribute with `#[may_dangle]`
|
||||
|
|
||||
= note: #[warn(deprecated)] on by default
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
@ -16,9 +16,8 @@ struct Foo<'a>(u32, &'a ScribbleOnDrop);
|
||||
|
||||
impl<'a> Drop for Foo<'a> {
|
||||
fn drop(&mut self) {
|
||||
// Use of `may_dangle` is unsound,
|
||||
// because destructor accesses borrowed data in `self.1`
|
||||
// and we must force that to strictly outlive `self`.
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0597]: `first_dropped` does not live long enough
|
||||
--> $DIR/issue28498-reject-lifetime-param.rs:33:19
|
||||
--> $DIR/issue28498-reject-lifetime-param.rs:32:19
|
||||
|
|
||||
LL | foo1 = Foo(1, &first_dropped);
|
||||
| ^^^^^^^^^^^^^^ borrowed value does not live long enough
|
||||
|
@ -16,8 +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 `may_dangle` is unsound,
|
||||
// because we pass `T` to the callback in `self.2`
|
||||
// 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));
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0597]: `first_dropped` does not live long enough
|
||||
--> $DIR/issue28498-reject-passed-to-fn.rs:35:19
|
||||
--> $DIR/issue28498-reject-passed-to-fn.rs:34:19
|
||||
|
|
||||
LL | foo1 = Foo(1, &first_dropped, Box::new(callback));
|
||||
| ^^^^^^^^^^^^^^ borrowed value does not live long enough
|
||||
|
@ -18,9 +18,8 @@ struct Foo<T: fmt::Debug>(u32, T);
|
||||
|
||||
impl<T: fmt::Debug> Drop for Foo<T> {
|
||||
fn drop(&mut self) {
|
||||
// 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.
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0597]: `first_dropped` does not live long enough
|
||||
--> $DIR/issue28498-reject-trait-bound.rs:35:19
|
||||
--> $DIR/issue28498-reject-trait-bound.rs:34:19
|
||||
|
|
||||
LL | foo1 = Foo(1, &first_dropped);
|
||||
| ^^^^^^^^^^^^^^ borrowed value does not live long enough
|
||||
|
Loading…
Reference in New Issue
Block a user