Skip to content

Commit 5af730e

Browse files
committed
Clean up dead code and resolved TODO
1 parent 3929f96 commit 5af730e

File tree

2 files changed

+5
-33
lines changed

2 files changed

+5
-33
lines changed

verify/rust_verify/src/rust_to_vir.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ fn check_item<'tcx>(
6969
path
7070
);
7171
if hack_check_def_name(tcx, path.res.def_id(), "builtin", "Structural") {
72-
let struct_eq_def_id = tcx
73-
.lang_items()
74-
.structural_teq_trait()
75-
.expect("structural eq trait is not defined");
7672
let ty = {
7773
// TODO extract to rust_to_vir_base, or use
7874
// https://doc.rust-lang.org/nightly/nightly-rustc/rustc_typeck/fn.hir_ty_to_ty.html
@@ -88,7 +84,6 @@ fn check_item<'tcx>(
8884
};
8985
tcx.type_of(def_id)
9086
};
91-
let substs_ref = tcx.mk_substs([].iter());
9287
// TODO: this may be a bit of a hack: to query the TyCtxt for the StructuralEq impl it seems we need
9388
// a concrete type, so apply ! to all type parameters
9489
let ty_kind_applied_never =
@@ -106,12 +101,6 @@ fn check_item<'tcx>(
106101
panic!("Structural impl for non-adt type");
107102
};
108103
let ty_applied_never = tcx.mk_ty(ty_kind_applied_never);
109-
let ty_implements_struct_eq = tcx.type_implements_trait((
110-
struct_eq_def_id,
111-
ty_applied_never,
112-
substs_ref,
113-
rustc_middle::ty::ParamEnv::empty(),
114-
));
115104
err_unless!(
116105
ty_applied_never.is_structural_eq_shallow(tcx),
117106
item.span,
@@ -155,23 +144,6 @@ fn check_item<'tcx>(
155144
);
156145
}
157146
_ => {
158-
// TODO: a type may provide a custom PartialEq implementation, or have interior
159-
// mutability; this means that PartialEq::eq may not be the same as structural
160-
// (member-wise) adt equality. We should check whether the PartialEq implementation
161-
// is compatible with adt equality before allowing these. For now, warn that there
162-
// may be unsoundness.
163-
// As used here, StructuralEq is only sufficient for a shallow check.
164-
// In the rust doc for `StructuralEq`:
165-
// > Any type that derives Eq automatically implements this trait,
166-
// > regardless of whether its type parameters implement Eq.
167-
// warning_span(
168-
// span,
169-
// format!(
170-
// "the verifier will assume structural equality for {}, which may be un sound",
171-
// path_to_string(p)
172-
// ),
173-
// );
174-
175147
unsupported_err!(item.span, "unsupported item", item);
176148
}
177149
}

verify/rust_verify/src/rust_to_vir_base.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::util::{err_span_str, err_span_string, unsupported_err_span, warning_span};
2-
use crate::{unsupported, unsupported_err, unsupported_err_unless, unsupported_unless};
1+
use crate::util::{err_span_str, err_span_string, unsupported_err_span};
2+
use crate::{unsupported, unsupported_err, unsupported_err_unless};
33
use rustc_ast::token::{Token, TokenKind};
44
use rustc_ast::tokenstream::TokenTree;
55
use rustc_ast::{AttrKind, Attribute, IntTy, MacArgs, UintTy};
@@ -12,7 +12,7 @@ use rustc_span::symbol::Ident;
1212
use rustc_span::Span;
1313
use std::rc::Rc;
1414
use vir::ast::{Idents, IntRange, Mode, Path, Typ, TypX, VirErr};
15-
use vir::ast_util::{path_to_string, types_equal};
15+
use vir::ast_util::types_equal;
1616

1717
pub(crate) fn def_to_path<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Path {
1818
Rc::new(tcx.def_path(def_id).data.iter().map(|d| Rc::new(format!("{}", d))).collect::<Vec<_>>())
@@ -268,15 +268,15 @@ pub(crate) fn typ_of_node<'tcx>(ctxt: &Ctxt<'tcx>, id: &HirId) -> Typ {
268268
// Do equality operations on these operands translate into the SMT solver's == operation?
269269
pub(crate) fn is_smt_equality<'tcx>(
270270
ctxt: &Ctxt<'tcx>,
271-
span: Span,
271+
_span: Span,
272272
id1: &HirId,
273273
id2: &HirId,
274274
) -> bool {
275275
let (t1, t2) = (typ_of_node(ctxt, id1), typ_of_node(ctxt, id2));
276276
match (&*t1, &*t2) {
277277
(TypX::Bool, TypX::Bool) => true,
278278
(TypX::Int(_), TypX::Int(_)) => true,
279-
(TypX::Path(p), TypX::Path(_)) if types_equal(&t1, &t2) => {
279+
(TypX::Path(_), TypX::Path(_)) if types_equal(&t1, &t2) => {
280280
let structural_def_id = ctxt
281281
.tcx
282282
.get_diagnostic_item(rustc_span::Symbol::intern("builtin::Structural"))

0 commit comments

Comments
 (0)