Skip to content

Commit d292265

Browse files
celinvalcarolynzech
authored andcommitted
Address PR comments
1 parent 61269de commit d292265

File tree

5 files changed

+19
-26
lines changed

5 files changed

+19
-26
lines changed

docs/src/rustc-hacks.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,19 @@ Note that pretty printing for the Rust nightly toolchain (which Kani uses) is no
5252
For example, a vector may be displayed as `vec![{...}, {...}]` on nightly Rust, when it would be displayed as `vec![Some(0), None]` on stable Rust.
5353
Hopefully, this will be fixed soon.
5454

55-
### RustRover / CLion
55+
### CLion / IntelliJ
5656
This is not a great solution, but it works for now (see <https://github.com/intellij-rust/intellij-rust/issues/1618>
5757
for more details).
58-
59-
Open the `Cargo.toml` of your crate (e.g.: `kani-compiler`), and do the following:
60-
61-
1. Add optional dependencies on the `rustc` crates you are using.
62-
2. Add a feature that enable those dependencies.
63-
3. Toggle that feature using the IDE GUI.
64-
65-
Here is an example:
58+
Edit the `Cargo.toml` of the package that you're working on and add artificial dependencies on the `rustc` packages that you would like to explore.
6659

6760
```toml
68-
# ** At the bottom of the dependencies section: **
61+
# This configuration doesn't exist so it shouldn't affect your build.
62+
[target.'cfg(KANI_DEV)'.dependencies]
6963
# Adjust the path here to point to a local copy of the rust compiler.
70-
# E.g.: ~/.rustup/toolchains/<toolchain>/lib/rustlib/rustc-src/rust/compiler
71-
rustc_smir = { path = "<path_to_rustc>/rustc_smir", optional = true }
72-
stable_mir = { path = "<path_to_rustc>/stable_mir", optional = true }
73-
74-
[features]
75-
clion = ['rustc_smir', 'stable_mir']
64+
# The best way is to use the rustup path. Replace <toolchain> with the
65+
# proper name to your toolchain.
66+
rustc_driver = { path = "~/.rustup/toolchains/<toolchain>/lib/rustlib/rustc-src/rust/compiler/rustc_driver" }
67+
rustc_interface = { path = "~/.rustup/toolchains/<toolchain>/lib/rustlib/rustc-src/rust/compiler/rustc_interface" }
7668
```
7769

7870
**Don't forget to rollback the changes before you create your PR.**
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
5 test_scan_fn_loops.csv
22
20 test_scan_functions.csv
33
5 test_scan_input_tys.csv
4-
16 test_scan_overall.csv
4+
17 test_scan_overall.csv
55
3 test_scan_recursion.csv
6+
9 test_scan_unsafe_distance.csv
67
6 test_scan_unsafe_ops.csv

tests/script-based-pre/tool-scanner/test.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ pub fn generic<T: Default>() -> T {
1414
T::default()
1515
}
1616

17-
pub fn blah() {
18-
ok();
19-
assert_eq!(u8::default(), 0);
20-
}
21-
2217
pub struct RecursiveType {
2318
pub inner: Option<*const RecursiveType>,
2419
}
@@ -112,6 +107,7 @@ extern "C" {
112107
fn external_function();
113108
}
114109

110+
/// Ensure scanner finds unsafe calls to external functions.
115111
pub fn call_external() {
116112
unsafe { external_function() };
117113
}

tools/scanner/src/analysis.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33

4-
//! Provide different static analysis to be performed in the crate under compilation
4+
//! Provide passes that perform intra-function analysis on the crate under compilation
55
66
use crate::info;
77
use csv::WriterBuilder;
@@ -253,11 +253,11 @@ macro_rules! fn_props {
253253
}
254254

255255
impl $name {
256-
pub const fn num_props() -> usize {
256+
$vis const fn num_props() -> usize {
257257
[$(stringify!($prop),)+].len()
258258
}
259259

260-
pub fn new(fn_name: String) -> Self {
260+
$vis fn new(fn_name: String) -> Self {
261261
Self { fn_name, $($prop: 0,)+}
262262
}
263263
}

tools/scanner/src/call_graph.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// Copyright Kani Contributors
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33

4-
//! Provide different static analysis to be performed in the call graph
4+
//! Provide passes that perform inter-function analysis on the crate under compilation.
5+
//!
6+
//! This module also includes a `CallGraph` structure to help the analysis.
7+
//! For now, we build the CallGraph as part of the pass, but as we add more analysis,
8+
//! the call-graph could be reused by different analysis.
59
610
use crate::analysis::{FnCallVisitor, FnUnsafeOperations, OverallStats};
711
use stable_mir::mir::{MirVisitor, Safety};

0 commit comments

Comments
 (0)