Merge pull request #2008 from buley/feature/fix-scanner-warnings

chore: fix dead code and error swallowing warnings
This commit is contained in:
Karl Seguin
2026-03-27 08:10:31 +08:00
committed by GitHub
3 changed files with 16 additions and 16 deletions

View File

@@ -158,13 +158,13 @@ pub extern "C" fn html5ever_attribute_iterator_next(
let attr = &iter.vec[pos];
iter.pos += 1;
return CNullable::<CAttribute>::some(CAttribute {
CNullable::<CAttribute>::some(CAttribute {
name: CQualName::create(&attr.name),
value: StringSlice {
ptr: attr.value.as_ptr(),
len: attr.value.len(),
},
});
})
}
#[no_mangle]
@@ -186,12 +186,12 @@ pub extern "C" fn html5ever_get_memory_usage() -> Memory {
use tikv_jemalloc_ctl::{epoch, stats};
// many statistics are cached and only updated when the epoch is advanced.
epoch::advance().unwrap();
drop(epoch::advance());
return Memory {
resident: stats::resident::read().unwrap(),
allocated: stats::allocated::read().unwrap(),
};
Memory {
resident: stats::resident::read().unwrap_or(0),
allocated: stats::allocated::read().unwrap_or(0),
}
}
// Streaming parser API
@@ -325,7 +325,7 @@ pub extern "C" fn html5ever_streaming_parser_destroy(parser_ptr: *mut c_void) {
// Drop the parser box without finishing
// This is for cases where you want to cancel parsing
unsafe {
let _ = Box::from_raw(parser_ptr as *mut StreamingParser);
drop(Box::from_raw(parser_ptr as *mut StreamingParser));
}
}

View File

@@ -36,10 +36,10 @@ pub struct ElementData {
}
impl ElementData {
fn new(qname: QualName, flags: ElementFlags) -> Self {
return Self {
Self {
qname: qname,
mathml_annotation_xml_integration_point: flags.mathml_annotation_xml_integration_point,
};
}
}
}
@@ -130,12 +130,12 @@ impl<'arena> TreeSink for Sink<'arena> {
unsafe {
let mut attribute_iterator = CAttributeIterator { vec: attrs, pos: 0 };
return (self.create_element_callback)(
(self.create_element_callback)(
self.ctx,
data as *mut _ as *mut c_void,
CQualName::create(&name),
&mut attribute_iterator as *mut _ as *mut c_void,
);
)
}
}

View File

@@ -126,21 +126,21 @@ impl CQualName {
None => CNullable::<StringSlice>::none(),
Some(prefix) => CNullable::<StringSlice>::some(StringSlice { ptr: prefix.as_ptr(), len: prefix.len()}),
};
return CQualName{
CQualName{
// inner: q as *const _ as *const c_void,
ns: ns,
local: local,
prefix: prefix,
};
}
}
}
impl Default for CQualName {
fn default() -> Self {
return Self{
Self{
prefix: CNullable::<StringSlice>::none(),
ns: StringSlice::default(),
local: StringSlice::default(),
};
}
}
}