Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support slice::get && Ignore trait predicates when not visible to local. #1434

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions source/rust_verify/src/rust_to_vir_func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1389,18 +1389,9 @@ pub(crate) fn remove_ignored_trait_bounds_from_predicates<'tcx>(
use rustc_middle::ty::{ConstKind, ScalarInt, ValTree};
preds.retain(|p: &Clause<'tcx>| match p.kind().skip_binder() {
rustc_middle::ty::ClauseKind::<'tcx>::Trait(tp) => {
let td = tcx.trait_def(tp.trait_ref.def_id);
// Recursively check parent path visibility
let mut visible = tcx.visibility(td.def_id).is_visible_locally();
let mut def_id = td.def_id;
while let Some(parent_def_id) = tcx.opt_parent(def_id) {
if !tcx.visibility(parent_def_id).is_visible_locally() {
visible = false;
break;
}
def_id = parent_def_id;
}
if !visible {
// Skip private trait bounds
let path = tcx.def_path_str(tp.trait_ref.def_id);
if path == "core::slice::index::private_slice_index::Sealed" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be better as a call to verus_items::get_rust_item, but otherwise it's fine.

false
} else if in_trait
&& trait_ids.contains(&tp.trait_ref.def_id)
Expand Down