Tracking import use types for more accurate redundant import checking#117772
Tracking import use types for more accurate redundant import checking#117772bors merged 1 commit intorust-lang:masterfrom
Conversation
|
r? @davidtwco (rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
|
This doesn't really need a separate lint, the warnings can be reported under regular Ideally these cases should be reported by |
Thank you very much. Sorry for not replying immediately. I will deal with it as soon as possible according to the suggestions. |
|
The required use tracking should look approximately like this - https://github.com/petrochenkov/rust/commits/usetrack Also it probably makes sense to move @rustbot author |
|
The "scope" uses are uses like this use something::Something;
fn foo() { let _s = Something; } // First segment of a path, resolves to whatever is currently in scope, other uses are typically module-relative uses like // in module `my_mod`
use something::Something;
fn foo() { let _s = crate::my_mod::Something; } // Non-first segment, resolves to what is found in module `my_mod` |
|
The |
d29d882 to
1b5d4e6
Compare
|
rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer |
d8b397b to
3f00fd2
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt This PR changes Stable MIR cc @oli-obk, @celinval, @spastorino, @ouz-a Some changes might have occurred in exhaustiveness checking cc @Nadrieril |
|
@bors r+ |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (8b21296): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 640.535s -> 640.087s (-0.07%) |
|
Lots of instruction count regressions in the perf results. |
|
Explanation for the perf changes - #117772 (comment). |
|
use std::ffi::{CStr, CString};
use libc;
fn main() {
let lib_name = CString::new("libEGL.so").unwrap();
let lib_ptr = unsafe { libc::dlopen(lib_name.as_ptr(), libc::RTLD_NOW) };
if lib_ptr.is_null() {
let error_msg = unsafe { CStr::from_ptr(libc::dlerror()) }.to_str().unwrap();
println!("Error loading library: {}", error_msg);
return;
}
// Access functions from the library
// ...
unsafe { libc::dlclose(lib_ptr) };
} Compiling playground v0.0.1 (/playground)
warning: the item `libc` is imported redundantly
--> src/main.rs:3:5
|
3 | use libc;
| ^^^^ the item `libc` is already defined here
|
= note: `#[warn(unused_imports)]` on by default
warning: `playground` (bin "playground") generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.58s
Running `target/debug/playground` |
|
Could you open an issue for that? Thanks. Related issue: #121684. |
fixes #117448
By tracking import use types to check whether it is scope uses or the other situations like module-relative uses, we can do more accurate redundant import checking.
For example unnecessary imports in std::prelude that can be eliminated: