Skip to content

Commit fe13bbd

Browse files
SimonSapinoli-obk
authored andcommitted
Remove unions_with_drop_fields lint
Cases where it would trigger are now hard errors.
1 parent 2f0c821 commit fe13bbd

File tree

3 files changed

+0
-57
lines changed

3 files changed

+0
-57
lines changed

src/doc/rustc/src/lints/listing/warn-by-default.md

-24
Original file line numberDiff line numberDiff line change
@@ -596,30 +596,6 @@ warning: function cannot return without recursing
596596
|
597597
```
598598

599-
## unions-with-drop-fields
600-
601-
This lint detects use of unions that contain fields with possibly non-trivial drop code. Some
602-
example code that triggers this lint:
603-
604-
```rust
605-
#![feature(untagged_unions)]
606-
607-
union U {
608-
s: String,
609-
}
610-
```
611-
612-
This will produce:
613-
614-
```text
615-
warning: union contains a field with possibly non-trivial drop code, drop code of union fields is ignored when dropping the union
616-
--> src/main.rs:4:5
617-
|
618-
4 | s: String,
619-
| ^^^^^^^^^
620-
|
621-
```
622-
623599
## unknown-lints
624600

625601
This lint detects unrecognized lint attribute. Some

src/librustc_lint/builtin.rs

-30
Original file line numberDiff line numberDiff line change
@@ -979,35 +979,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnstableFeatures {
979979
}
980980
}
981981

982-
declare_lint! {
983-
UNIONS_WITH_DROP_FIELDS,
984-
Warn,
985-
"use of unions that contain fields with possibly non-trivial drop code"
986-
}
987-
988-
declare_lint_pass!(
989-
/// Lint for unions that contain fields with possibly non-trivial destructors.
990-
UnionsWithDropFields => [UNIONS_WITH_DROP_FIELDS]
991-
);
992-
993-
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
994-
fn check_item(&mut self, ctx: &LateContext<'_, '_>, item: &hir::Item) {
995-
if let hir::ItemKind::Union(ref vdata, _) = item.kind {
996-
for field in vdata.fields() {
997-
let field_ty = ctx.tcx.type_of(
998-
ctx.tcx.hir().local_def_id(field.hir_id));
999-
if field_ty.needs_drop(ctx.tcx, ctx.param_env) {
1000-
ctx.span_lint(UNIONS_WITH_DROP_FIELDS,
1001-
field.span,
1002-
"union contains a field with possibly non-trivial drop code, \
1003-
drop code of union fields is ignored when dropping the union");
1004-
return;
1005-
}
1006-
}
1007-
}
1008-
}
1009-
}
1010-
1011982
declare_lint! {
1012983
pub UNREACHABLE_PUB,
1013984
Allow,
@@ -1287,7 +1258,6 @@ declare_lint_pass!(
12871258
NO_MANGLE_GENERIC_ITEMS,
12881259
MUTABLE_TRANSMUTES,
12891260
UNSTABLE_FEATURES,
1290-
UNIONS_WITH_DROP_FIELDS,
12911261
UNREACHABLE_PUB,
12921262
TYPE_ALIAS_BOUNDS,
12931263
TRIVIAL_BOUNDS

src/librustc_lint/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,6 @@ macro_rules! late_lint_mod_passes {
164164
// Depends on referenced function signatures in expressions
165165
MutableTransmutes: MutableTransmutes,
166166

167-
// Depends on types of fields, checks if they implement Drop
168-
UnionsWithDropFields: UnionsWithDropFields,
169-
170167
TypeAliasBounds: TypeAliasBounds,
171168

172169
TrivialConstraints: TrivialConstraints,

0 commit comments

Comments
 (0)