-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Apply clippy suggestions to switch to let chains #6126
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -140,10 +140,10 @@ impl CompilationSource { | |||||||||||||||||||||||||||||
let mut code_map = HashMap::new(); | ||||||||||||||||||||||||||||||
let paths = fs::read_dir(path) | ||||||||||||||||||||||||||||||
.or_else(|e| { | ||||||||||||||||||||||||||||||
if cfg!(windows) { | ||||||||||||||||||||||||||||||
if let Ok(real_path) = fs::read_to_string(path.canonicalize().unwrap()) { | ||||||||||||||||||||||||||||||
return fs::read_dir(real_path.trim()); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
if cfg!(windows) | ||||||||||||||||||||||||||||||
&& let Ok(real_path) = fs::read_to_string(path.canonicalize().unwrap()) | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
return fs::read_dir(real_path.trim()); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
Comment on lines
+143
to
147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid panic in error-fallback path (unwrap in or_else)
- .or_else(|e| {
- if cfg!(windows)
- && let Ok(real_path) = fs::read_to_string(path.canonicalize().unwrap())
- {
- return fs::read_dir(real_path.trim());
- }
- Err(e)
- })
+ .or_else(|e| {
+ if cfg!(windows)
+ && let Ok(canonical) = path.canonicalize()
+ && let Ok(real_path) = fs::read_to_string(&canonical)
+ {
+ return fs::read_dir(real_path.trim());
+ }
+ Err(e)
+ }) 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||
Err(e) | ||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||
|
@@ -195,14 +195,14 @@ impl CompilationSource { | |||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||
let code = compile_path(&path).or_else(|e| { | ||||||||||||||||||||||||||||||
if cfg!(windows) { | ||||||||||||||||||||||||||||||
if let Ok(real_path) = fs::read_to_string(path.canonicalize().unwrap()) { | ||||||||||||||||||||||||||||||
let joined = path.parent().unwrap().join(real_path.trim()); | ||||||||||||||||||||||||||||||
if joined.exists() { | ||||||||||||||||||||||||||||||
return compile_path(&joined); | ||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||
return Err(e); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
if cfg!(windows) | ||||||||||||||||||||||||||||||
&& let Ok(real_path) = fs::read_to_string(path.canonicalize().unwrap()) | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
let joined = path.parent().unwrap().join(real_path.trim()); | ||||||||||||||||||||||||||||||
if joined.exists() { | ||||||||||||||||||||||||||||||
return compile_path(&joined); | ||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||
return Err(e); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
Err(e) | ||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -378,12 +378,11 @@ mod _contextvars { | |
let ctx = ctxs.last()?; | ||
let cached_ptr = zelf.cached.as_ptr(); | ||
debug_assert!(!cached_ptr.is_null()); | ||
if let Some(cached) = unsafe { &*cached_ptr } { | ||
if zelf.cached_id.load(Ordering::SeqCst) == ctx.get_id() | ||
&& cached.idx + 1 == ctxs.len() | ||
{ | ||
return Some(cached.object.clone()); | ||
} | ||
if let Some(cached) = unsafe { &*cached_ptr } | ||
&& zelf.cached_id.load(Ordering::SeqCst) == ctx.get_id() | ||
&& cached.idx + 1 == ctxs.len() | ||
{ | ||
return Some(cached.object.clone()); | ||
Comment on lines
+381
to
+385
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential UB: dereferencing AtomicCell::as_ptr without synchronization. Reading Consider replacing
If keeping AtomicCell, you need a design that avoids borrowing through I can open an issue and sketch a safe refactor using ArcSwapOption if you’d like. 🤖 Prompt for AI Agents
|
||
} | ||
let vars = ctx.borrow_vars(); | ||
let obj = vars.get(zelf)?; | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -86,23 +86,22 @@ mod _scproxy { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.and_then(|v| v.downcast::<CFNumber>()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.and_then(|v| v.to_i32()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.unwrap_or(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if enabled { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if let Some(host) = proxy_dict | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if enabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
&& let Some(host) = proxy_dict | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.find(host_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.and_then(|v| v.downcast::<CFString>()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let h = std::borrow::Cow::<str>::from(&host); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let v = if let Some(port) = proxy_dict | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.find(port_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.and_then(|v| v.downcast::<CFNumber>()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.and_then(|v| v.to_i32()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let h = std::borrow::Cow::<str>::from(&host); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let v = if let Some(port) = proxy_dict | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.find(port_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.and_then(|v| v.downcast::<CFNumber>()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.and_then(|v| v.to_i32()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
format!("http://{h}:{port}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
format!("http://{h}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
result.set_item(proto, vm.new_pyobj(v), vm)?; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
format!("http://{h}:{port}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
format!("http://{h}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
result.set_item(proto, vm.new_pyobj(v), vm)?; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+94
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Cow from CFString won’t compile; build the String explicitly
Apply: - let h = std::borrow::Cow::<str>::from(&host);
- let v = if let Some(port) = proxy_dict
+ let host_s = host.to_string();
+ let proxy_url = if let Some(port) = proxy_dict
.find(port_key)
.and_then(|v| v.downcast::<CFNumber>())
.and_then(|v| v.to_i32())
{
- format!("http://{h}:{port}")
+ format!("http://{host_s}:{port}")
} else {
- format!("http://{h}")
+ format!("http://{host_s}")
};
- result.set_item(proto, vm.new_pyobj(v), vm)?;
+ result.set_item(proto, vm.new_pyobj(proxy_url), vm)?; 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Ok(()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
💡 Verification agent
🧩 Analysis chain
MSRV bump to 1.89.0: verify CI/toolchain/docs match
Looks good for enabling let-chain guards. Please ensure CI images, rust-toolchain files, and any MSRV docs are updated accordingly across the workspace.
Run to spot divergences:
🏁 Script executed:
Length of output: 918
🏁 Script executed:
Length of output: 204
Pin the workspace toolchain to 1.89.0
rust-toolchain.toml still reads
channel = "stable"
—update it tochannel = "1.89.0"
(and ensure your CI images reference that exact version). No MSRV references were found in README.md or a docs/ directory.🤖 Prompt for AI Agents