]> git.lizzy.rs Git - rust.git/commitdiff
Remove unions_with_drop_fields lint
authorSimon Sapin <simon.sapin@exyr.org>
Wed, 3 Jul 2019 09:56:59 +0000 (11:56 +0200)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Fri, 11 Oct 2019 08:43:54 +0000 (10:43 +0200)
Cases where it would trigger are now hard errors.

src/doc/rustc/src/lints/listing/warn-by-default.md
src/librustc_lint/builtin.rs
src/librustc_lint/lib.rs

index e486240fda896f164267093ecb8023483a0ea457..813d7c4bafef8cfdaf779be20dacf71cfc46de35 100644 (file)
@@ -596,30 +596,6 @@ warning: function cannot return without recursing
   |
 ```
 
-## unions-with-drop-fields
-
-This lint detects use of unions that contain fields with possibly non-trivial drop code. Some
-example code that triggers this lint:
-
-```rust
-#![feature(untagged_unions)]
-
-union U {
-    s: String,
-}
-```
-
-This will produce:
-
-```text
-warning: union contains a field with possibly non-trivial drop code, drop code of union fields is ignored when dropping the union
- --> src/main.rs:4:5
-  |
-4 |     s: String,
-  |     ^^^^^^^^^
-  |
-```
-
 ## unknown-lints
 
 This lint detects unrecognized lint attribute. Some
index d0a7eab071c311de1e85c66bc8ed89829c15cfac..f00bcd41b601e92cd2b58fcb089c055474f0ea0f 100644 (file)
@@ -979,35 +979,6 @@ fn check_attribute(&mut self, ctx: &LateContext<'_, '_>, attr: &ast::Attribute)
     }
 }
 
-declare_lint! {
-    UNIONS_WITH_DROP_FIELDS,
-    Warn,
-    "use of unions that contain fields with possibly non-trivial drop code"
-}
-
-declare_lint_pass!(
-    /// Lint for unions that contain fields with possibly non-trivial destructors.
-    UnionsWithDropFields => [UNIONS_WITH_DROP_FIELDS]
-);
-
-impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
-    fn check_item(&mut self, ctx: &LateContext<'_, '_>, item: &hir::Item) {
-        if let hir::ItemKind::Union(ref vdata, _) = item.kind {
-            for field in vdata.fields() {
-                let field_ty = ctx.tcx.type_of(
-                    ctx.tcx.hir().local_def_id(field.hir_id));
-                if field_ty.needs_drop(ctx.tcx, ctx.param_env) {
-                    ctx.span_lint(UNIONS_WITH_DROP_FIELDS,
-                                  field.span,
-                                  "union contains a field with possibly non-trivial drop code, \
-                                   drop code of union fields is ignored when dropping the union");
-                    return;
-                }
-            }
-        }
-    }
-}
-
 declare_lint! {
     pub UNREACHABLE_PUB,
     Allow,
@@ -1287,7 +1258,6 @@ fn check_item(
         NO_MANGLE_GENERIC_ITEMS,
         MUTABLE_TRANSMUTES,
         UNSTABLE_FEATURES,
-        UNIONS_WITH_DROP_FIELDS,
         UNREACHABLE_PUB,
         TYPE_ALIAS_BOUNDS,
         TRIVIAL_BOUNDS
index 0e054013cd779ed30eab29353d0dd4c1c7cc9b33..a898e1a3dcfa1b4030a61dfa9ee2946b93c89bd4 100644 (file)
@@ -164,9 +164,6 @@ macro_rules! late_lint_mod_passes {
             // Depends on referenced function signatures in expressions
             MutableTransmutes: MutableTransmutes,
 
-            // Depends on types of fields, checks if they implement Drop
-            UnionsWithDropFields: UnionsWithDropFields,
-
             TypeAliasBounds: TypeAliasBounds,
 
             TrivialConstraints: TrivialConstraints,