Skip to content

Commit

Permalink
Fix regression with stub external resolve (model-checking#2248)
Browse files Browse the repository at this point in the history
I just noticed a regression on model-checking#2227 where I incorrectly updated a test that should've caught this regression. Thus, fix the issue and revert the changes to the test.
  • Loading branch information
celinval authored Mar 1, 2023
1 parent 07a48e6 commit 61c433a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions kani-compiler/src/kani_middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,20 @@ fn resolve_prefix<'tcx>(
segments.next();
resolve_super(tcx, current_module, segments)
}
SUPER => resolve_super(tcx, current_module, segments),
_ => {
let path = resolve_super(tcx, current_module, segments)?;
if !path.segments.is_empty() {
let next_name = path.segments.first().unwrap();
let def_id = resolve_in_module(tcx, path.base, &next_name)?;
Ok(Path { base: def_id, segments: Vec::from(&path.segments[1..]) })
} else {
Ok(path)
}
// No special key word was used. Try local first otherwise try external name.
let next_name = segments.next().unwrap();
let def_id =
resolve_in_module(tcx, current_module.to_def_id(), &next_name).or_else(|err| {
if matches!(err, ResolveError::MissingItem { .. }) {
// Only try external if we couldn't find anything.
resolve_external(tcx, &next_name).ok_or(err)
} else {
Err(err)
}
})?;
Ok(Path { base: def_id, segments: segments.collect() })
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/cargo-kani/stubbing-validate-random/main.expected
Original file line number Diff line number Diff line change
@@ -1 +1 @@
error: failed to resolve `rand::random`: unable to find `rand` inside module `stubbing_validate_random`
VERIFICATION:- SUCCESSFUL

0 comments on commit 61c433a

Please sign in to comment.