mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-27 08:43:09 -03:00
fix: clippy::ref_as_ptr
https://rust-lang.github.io/rust-clippy/master/index.html#ref_as_ptr Part of #12136
This commit is contained in:
committed by
Johannes Altmanninger
parent
ec77c34ebe
commit
831411ddd5
@@ -242,8 +242,8 @@ pub fn is_same_node(lhs: &dyn Node, rhs: &dyn Node) -> bool {
|
|||||||
// Note this is performance-sensitive.
|
// Note this is performance-sensitive.
|
||||||
|
|
||||||
// Different base pointers => not the same.
|
// Different base pointers => not the same.
|
||||||
let lptr = lhs as *const dyn Node as *const ();
|
let lptr = std::ptr::from_ref(lhs) as *const ();
|
||||||
let rptr = rhs as *const dyn Node as *const ();
|
let rptr = std::ptr::from_ref(rhs) as *const ();
|
||||||
if !std::ptr::eq(lptr, rptr) {
|
if !std::ptr::eq(lptr, rptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1879,8 +1879,8 @@ fn apply_var_assignments<T: AsRef<wstr>>(
|
|||||||
|
|
||||||
let vars = parser.vars();
|
let vars = parser.vars();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
self.ctx.vars() as *const _ as *const (),
|
std::ptr::from_ref(self.ctx.vars()) as *const (),
|
||||||
vars as *const _ as *const (),
|
std::ptr::from_ref(vars) as *const (),
|
||||||
"Don't know how to tab complete with a parser but a different variable set"
|
"Don't know how to tab complete with a parser but a different variable set"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,7 @@ fn clone(&self) -> Self {
|
|||||||
|
|
||||||
impl<T: ?Sized> AtomicRef<T> {
|
impl<T: ?Sized> AtomicRef<T> {
|
||||||
pub const fn new(value: &'static &'static T) -> Self {
|
pub const fn new(value: &'static &'static T) -> Self {
|
||||||
Self(AtomicPtr::new(
|
Self(AtomicPtr::new(std::ptr::from_ref(value) as *mut &'static T))
|
||||||
value as *const &'static T as *mut &'static T,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load(&self) -> &'static T {
|
pub fn load(&self) -> &'static T {
|
||||||
@@ -46,7 +44,7 @@ pub fn load(&self) -> &'static T {
|
|||||||
|
|
||||||
pub fn store(&self, value: &'static &'static T) {
|
pub fn store(&self, value: &'static &'static T) {
|
||||||
self.0.store(
|
self.0.store(
|
||||||
value as *const &'static T as *mut &'static T,
|
std::ptr::from_ref(value) as *mut &'static T,
|
||||||
Ordering::Relaxed,
|
Ordering::Relaxed,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -494,11 +494,11 @@ pub fn new() -> Self {
|
|||||||
}
|
}
|
||||||
pub fn remove(&mut self, element: &dyn IoData) {
|
pub fn remove(&mut self, element: &dyn IoData) {
|
||||||
// Discard vtable pointers when comparing.
|
// Discard vtable pointers when comparing.
|
||||||
let e1 = element as *const dyn IoData as *const ();
|
let e1 = std::ptr::from_ref(element) as *const ();
|
||||||
let idx = self
|
let idx = self
|
||||||
.0
|
.0
|
||||||
.iter()
|
.iter()
|
||||||
.position(|e2| Arc::as_ref(e2) as *const dyn IoData as *const () == e1)
|
.position(|e2| Arc::as_ptr(e2) as *const () == e1)
|
||||||
.expect("Element not found");
|
.expect("Element not found");
|
||||||
self.0.remove(idx);
|
self.0.remove(idx);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1525,7 +1525,7 @@ fn run_1_job(
|
|||||||
// Save the executing node.
|
// Save the executing node.
|
||||||
let _saved_node = self
|
let _saved_node = self
|
||||||
.line_counter
|
.line_counter
|
||||||
.scoped_set(job_node as *const _, |s| &mut s.node);
|
.scoped_set(std::ptr::from_ref(job_node), |s| &mut s.node);
|
||||||
|
|
||||||
// Profiling support.
|
// Profiling support.
|
||||||
let profile_item_id = ctx.parser().create_profile_item();
|
let profile_item_id = ctx.parser().create_profile_item();
|
||||||
|
|||||||
@@ -2208,7 +2208,7 @@ fn test_line_counter() {
|
|||||||
assert_eq!(line_counter.line_offset_of_node(), None);
|
assert_eq!(line_counter.line_offset_of_node(), None);
|
||||||
|
|
||||||
for (idx, &node) in pipelines.iter().enumerate() {
|
for (idx, &node) in pipelines.iter().enumerate() {
|
||||||
line_counter.node = node as *const _;
|
line_counter.node = std::ptr::from_ref(node);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
line_counter.source_offset_of_node(),
|
line_counter.source_offset_of_node(),
|
||||||
Some(node.source_range().start())
|
Some(node.source_range().start())
|
||||||
@@ -2217,7 +2217,7 @@ fn test_line_counter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (idx, &node) in pipelines.iter().enumerate().rev() {
|
for (idx, &node) in pipelines.iter().enumerate().rev() {
|
||||||
line_counter.node = node as *const _;
|
line_counter.node = std::ptr::from_ref(node);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
line_counter.source_offset_of_node(),
|
line_counter.source_offset_of_node(),
|
||||||
Some(node.source_range().start())
|
Some(node.source_range().start())
|
||||||
|
|||||||
@@ -1633,7 +1633,7 @@ fn combine_command_and_autosuggestion(
|
|||||||
if !last_token_contains_uppercase {
|
if !last_token_contains_uppercase {
|
||||||
// Use the autosuggestion's case.
|
// Use the autosuggestion's case.
|
||||||
let start: usize = unsafe {
|
let start: usize = unsafe {
|
||||||
(line.as_char_slice().first().unwrap() as *const char)
|
std::ptr::from_ref(line.as_char_slice().first().unwrap())
|
||||||
.offset_from(&cmdline.as_char_slice()[0])
|
.offset_from(&cmdline.as_char_slice()[0])
|
||||||
}
|
}
|
||||||
.try_into()
|
.try_into()
|
||||||
|
|||||||
Reference in New Issue
Block a user