Revert PR 81473 to resolve (on mainline) issues 81626 and 81658.
Revert "Add missing brace" This reverts commit 85ad773049536d7fed9a94ae0ac74f97135c8655. Revert "Simplify base_expr" This reverts commit 899aae465eb4ef295dc1eeb2603f744568e0768c. Revert "Warn write-only fields" This reverts commit d3c69a4c0dd98af2611b7553d1a65afef6a6ccb0.
This commit is contained in:
parent
602150f21f
commit
cf337d1119
@ -338,12 +338,6 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {
|
|||||||
hir::ExprKind::MethodCall(..) => {
|
hir::ExprKind::MethodCall(..) => {
|
||||||
self.lookup_and_handle_method(expr.hir_id);
|
self.lookup_and_handle_method(expr.hir_id);
|
||||||
}
|
}
|
||||||
hir::ExprKind::Assign(ref left, ref right, ..) => {
|
|
||||||
self.handle_assign(left);
|
|
||||||
self.check_for_self_assign(expr);
|
|
||||||
self.visit_expr(right);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
hir::ExprKind::Field(ref lhs, ..) => {
|
hir::ExprKind::Field(ref lhs, ..) => {
|
||||||
self.handle_field_access(&lhs, expr.hir_id);
|
self.handle_field_access(&lhs, expr.hir_id);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// run-pass
|
// run-pass
|
||||||
// pretty-expanded FIXME #23616
|
// pretty-expanded FIXME #23616
|
||||||
#![allow(dead_code)]
|
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
struct A {
|
struct A {
|
||||||
|
@ -1,69 +0,0 @@
|
|||||||
#![deny(dead_code)]
|
|
||||||
|
|
||||||
struct S {
|
|
||||||
f: i32, //~ ERROR: field is never read
|
|
||||||
sub: Sub, //~ ERROR: field is never read
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Sub {
|
|
||||||
f: i32, //~ ERROR: field is never read
|
|
||||||
}
|
|
||||||
|
|
||||||
fn field_write(s: &mut S) {
|
|
||||||
s.f = 1;
|
|
||||||
s.sub.f = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let mut s = S { f: 0, sub: Sub { f: 0 } };
|
|
||||||
field_write(&mut s);
|
|
||||||
|
|
||||||
auto_deref();
|
|
||||||
nested_boxes();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn auto_deref() {
|
|
||||||
struct E {
|
|
||||||
x: bool,
|
|
||||||
y: bool, //~ ERROR: field is never read
|
|
||||||
}
|
|
||||||
|
|
||||||
struct P<'a> {
|
|
||||||
e: &'a mut E
|
|
||||||
}
|
|
||||||
|
|
||||||
impl P<'_> {
|
|
||||||
fn f(&mut self) {
|
|
||||||
self.e.x = true;
|
|
||||||
self.e.y = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut e = E { x: false, y: false };
|
|
||||||
let mut p = P { e: &mut e };
|
|
||||||
p.f();
|
|
||||||
assert!(e.x);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn nested_boxes() {
|
|
||||||
struct A {
|
|
||||||
b: Box<B>,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct B {
|
|
||||||
c: Box<C>,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct C {
|
|
||||||
u: u32, //~ ERROR: field is never read
|
|
||||||
v: u32, //~ ERROR: field is never read
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut a = A {
|
|
||||||
b: Box::new(B {
|
|
||||||
c: Box::new(C { u: 0, v: 0 }),
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
a.b.c.v = 10;
|
|
||||||
a.b.c = Box::new(C { u: 1, v: 2 });
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
error: field is never read: `f`
|
|
||||||
--> $DIR/write-only-field.rs:4:5
|
|
||||||
|
|
|
||||||
LL | f: i32,
|
|
||||||
| ^^^^^^
|
|
||||||
|
|
|
||||||
note: the lint level is defined here
|
|
||||||
--> $DIR/write-only-field.rs:1:9
|
|
||||||
|
|
|
||||||
LL | #![deny(dead_code)]
|
|
||||||
| ^^^^^^^^^
|
|
||||||
|
|
||||||
error: field is never read: `sub`
|
|
||||||
--> $DIR/write-only-field.rs:5:5
|
|
||||||
|
|
|
||||||
LL | sub: Sub,
|
|
||||||
| ^^^^^^^^
|
|
||||||
|
|
||||||
error: field is never read: `f`
|
|
||||||
--> $DIR/write-only-field.rs:9:5
|
|
||||||
|
|
|
||||||
LL | f: i32,
|
|
||||||
| ^^^^^^
|
|
||||||
|
|
||||||
error: field is never read: `y`
|
|
||||||
--> $DIR/write-only-field.rs:28:9
|
|
||||||
|
|
|
||||||
LL | y: bool,
|
|
||||||
| ^^^^^^^
|
|
||||||
|
|
||||||
error: field is never read: `u`
|
|
||||||
--> $DIR/write-only-field.rs:58:9
|
|
||||||
|
|
|
||||||
LL | u: u32,
|
|
||||||
| ^^^^^^
|
|
||||||
|
|
||||||
error: field is never read: `v`
|
|
||||||
--> $DIR/write-only-field.rs:59:9
|
|
||||||
|
|
|
||||||
LL | v: u32,
|
|
||||||
| ^^^^^^
|
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user