-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix warnings from clippy #7013
Fix warnings from clippy #7013
Conversation
std::path::MAIN_SEPARATOR_STR isn't stable on 1.65 and stable from 1.68 I'll update the PR by using the project toolchain instead of my local nightly rustc. |
|
||
/// Finds the current workspace folder. | ||
/// Used as a ceiling dir for LSP root resolution, the filepicker and potentially as a future filewatching root | ||
/// | ||
/// This function starts searching the FS upward from the CWD | ||
/// and returns the first directory that contains either `.git` or `.helix`. | ||
/// If no workspace was found returns (CWD, true). | ||
/// Otherwise (workspace, false) is returned | ||
pub fn find_workspace() -> (PathBuf, bool) { | ||
let current_dir = std::env::current_dir().expect("unable to determine current directory"); | ||
for ancestor in current_dir.ancestors() { | ||
if ancestor.join(".git").exists() || ancestor.join(".helix").exists() { | ||
return (ancestor.to_owned(), false); | ||
} | ||
} | ||
|
||
(current_dir, true) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the change here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clippy says the normal items should avoid being declared after testing mod: https://rust-lang.github.io/rust-clippy/master/index.html#items_after_test_module
So I just move the testing mod down, but git diff shows the changes on find_workspace
instead.
warning: items were found after the testing module
--> helix-loader\src\lib.rs:213:1
|
213 | / mod merge_toml_tests {
214 | | use std::str;
215 | |
216 | | use super::merge_toml_values;
... |
300 | | (current_dir, true)
301 | | }
| |_^
|
= help: move the items to before the testing module was defined
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#items_after_test_module
= note: `#[warn(clippy::items_after_test_module)]` on by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I think the reason why I meet clippy complaints is that I use a rustc/cargo in a higher verion.
items_after_test_module
hasn't been in clippy1.65 yet.
So the Github action doesn't catch them for now.
If this PR is not appropriate for now, feel free to close.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah all these are future lints that don't trigger in current version yet but it's good to fix them ahead of time 👍🏻
* Fix warnings from clippy * revert MAIN_SEPARATOR_STR
* Fix warnings from clippy * revert MAIN_SEPARATOR_STR
* Fix warnings from clippy * revert MAIN_SEPARATOR_STR
I found clippy complained a lot and thus fix them.
cargo clippy --workspace --all-targets