clippy: Fix unneeded return statement warnings (#31776)

This commit is contained in:
Oluwatobi Sofela 2024-03-20 15:11:40 +01:00 committed by GitHub
parent d63615354c
commit 15bf32a4e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 31 additions and 38 deletions

View file

@ -524,7 +524,7 @@ impl HTMLInputElement {
return Some(min); return Some(min);
} }
} }
return self.default_minimum(); self.default_minimum()
} }
// https://html.spec.whatwg.org/multipage#concept-input-max // https://html.spec.whatwg.org/multipage#concept-input-max
@ -538,7 +538,7 @@ impl HTMLInputElement {
return Some(max); return Some(max);
} }
} }
return self.default_maximum(); self.default_maximum()
} }
// when allowed_value_step and minumum both exist, this is the smallest // when allowed_value_step and minumum both exist, this is the smallest
@ -2789,7 +2789,7 @@ impl Activatable for HTMLInputElement {
}, },
_ => (), _ => (),
} }
return None; None
} }
// https://dom.spec.whatwg.org/#eventtarget-legacy-canceled-activation-behavior // https://dom.spec.whatwg.org/#eventtarget-legacy-canceled-activation-behavior

View file

@ -1930,7 +1930,7 @@ impl HTMLMediaElement {
pub fn get_current_frame(&self) -> Option<VideoFrame> { pub fn get_current_frame(&self) -> Option<VideoFrame> {
match self.video_renderer.lock().unwrap().current_frame_holder { match self.video_renderer.lock().unwrap().current_frame_holder {
Some(ref holder) => Some(holder.get_frame()), Some(ref holder) => Some(holder.get_frame()),
None => return None, None => None,
} }
} }

View file

@ -111,7 +111,7 @@ impl HTMLOutputElementMethods for HTMLOutputElement {
// https://html.spec.whatwg.org/multipage/#dom-output-type // https://html.spec.whatwg.org/multipage/#dom-output-type
fn Type(&self) -> DOMString { fn Type(&self) -> DOMString {
return DOMString::from("output"); DOMString::from("output")
} }
// https://html.spec.whatwg.org/multipage/#dom-fe-name // https://html.spec.whatwg.org/multipage/#dom-fe-name

View file

@ -1122,7 +1122,6 @@ impl HTMLScriptElement {
if let Err(exception) = evaluated { if let Err(exception) = evaluated {
module_tree.set_rethrow_error(exception); module_tree.set_rethrow_error(exception);
module_tree.report_error(global); module_tree.report_error(global);
return;
} }
} }
} }

View file

@ -190,7 +190,7 @@ impl HTMLTextAreaElement {
pub fn auto_directionality(&self) -> String { pub fn auto_directionality(&self) -> String {
let value: String = self.Value().to_string(); let value: String = self.Value().to_string();
return HTMLInputElement::directionality_from_value(&value); HTMLInputElement::directionality_from_value(&value)
} }
fn update_placeholder_shown_state(&self) { fn update_placeholder_shown_state(&self) {

View file

@ -59,9 +59,7 @@ impl MediaMetadata {
} }
fn queue_update_metadata_algorithm(&self) { fn queue_update_metadata_algorithm(&self) {
if self.session.get().is_none() { if self.session.get().is_none() {}
return;
}
} }
pub fn set_session(&self, session: &MediaSession) { pub fn set_session(&self, session: &MediaSession) {

View file

@ -3016,15 +3016,15 @@ impl NodeMethods for Node {
match (node1, node2) { match (node1, node2) {
(None, _) => { (None, _) => {
// node1 is null // node1 is null
return NodeConstants::DOCUMENT_POSITION_FOLLOWING + NodeConstants::DOCUMENT_POSITION_FOLLOWING +
NodeConstants::DOCUMENT_POSITION_DISCONNECTED + NodeConstants::DOCUMENT_POSITION_DISCONNECTED +
NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC; NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC
}, },
(_, None) => { (_, None) => {
// node2 is null // node2 is null
return NodeConstants::DOCUMENT_POSITION_PRECEDING + NodeConstants::DOCUMENT_POSITION_PRECEDING +
NodeConstants::DOCUMENT_POSITION_DISCONNECTED + NodeConstants::DOCUMENT_POSITION_DISCONNECTED +
NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC; NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC
}, },
(Some(node1), Some(node2)) => { (Some(node1), Some(node2)) => {
// still step 6, testing if node1 and 2 share a root // still step 6, testing if node1 and 2 share a root
@ -3080,13 +3080,13 @@ impl NodeMethods for Node {
// contained in the other. // contained in the other.
// //
// If we're the container, return that `other` is contained by us. // If we're the container, return that `other` is contained by us.
return if self_and_ancestors.len() < other_and_ancestors.len() { if self_and_ancestors.len() < other_and_ancestors.len() {
NodeConstants::DOCUMENT_POSITION_FOLLOWING + NodeConstants::DOCUMENT_POSITION_FOLLOWING +
NodeConstants::DOCUMENT_POSITION_CONTAINED_BY NodeConstants::DOCUMENT_POSITION_CONTAINED_BY
} else { } else {
NodeConstants::DOCUMENT_POSITION_PRECEDING + NodeConstants::DOCUMENT_POSITION_PRECEDING +
NodeConstants::DOCUMENT_POSITION_CONTAINS NodeConstants::DOCUMENT_POSITION_CONTAINS
}; }
}, },
} }
} }

View file

@ -171,7 +171,7 @@ impl OffscreenCanvasMethods for OffscreenCanvas {
// https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-width // https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-width
fn Width(&self) -> u64 { fn Width(&self) -> u64 {
return self.width.get(); self.width.get()
} }
// https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-width // https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-width
@ -189,7 +189,7 @@ impl OffscreenCanvasMethods for OffscreenCanvas {
// https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-height // https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-height
fn Height(&self) -> u64 { fn Height(&self) -> u64 {
return self.height.get(); self.height.get()
} }
// https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-height // https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-height

View file

@ -143,7 +143,7 @@ impl OscillatorNodeMethods for OscillatorNode {
.message(AudioNodeMessage::OscillatorNode( .message(AudioNodeMessage::OscillatorNode(
OscillatorNodeMessage::SetOscillatorType(type_.into()), OscillatorNodeMessage::SetOscillatorType(type_.into()),
)); ));
return Ok(()); Ok(())
} }
} }

View file

@ -244,6 +244,6 @@ impl PerformanceObserverMethods for PerformanceObserver {
.map(|entry| DomRoot::from_ref(&**entry)) .map(|entry| DomRoot::from_ref(&**entry))
.collect(); .collect();
entries.clear(); entries.clear();
return taken; taken
} }
} }

View file

@ -299,7 +299,7 @@ impl ResponseMethods for Response {
match *self.status.borrow() { match *self.status.borrow() {
Some(s) => { Some(s) => {
let status_num = s.as_u16(); let status_num = s.as_u16();
return status_num >= 200 && status_num <= 299; status_num >= 200 && status_num <= 299
}, },
None => false, None => false,
} }

View file

@ -359,7 +359,7 @@ impl SelectionMethods for Selection {
// Step 2 // Step 2
return Err(Error::InvalidState); return Err(Error::InvalidState);
} }
return Ok(()); Ok(())
} }
// https://w3c.github.io/selection-api/#dom-selection-setbaseandextent // https://w3c.github.io/selection-api/#dom-selection-setbaseandextent
@ -447,7 +447,7 @@ impl SelectionMethods for Selection {
// selectionchange event as it would if if mutated any other way // selectionchange event as it would if if mutated any other way
return range.DeleteContents(); return range.DeleteContents();
} }
return Ok(()); Ok(())
} }
// https://w3c.github.io/selection-api/#dom-selection-containsnode // https://w3c.github.io/selection-api/#dom-selection-containsnode
@ -478,7 +478,7 @@ impl SelectionMethods for Selection {
if node == end_node { if node == end_node {
return range.EndOffset() > 0; return range.EndOffset() > 0;
} }
return true; true
} else { } else {
if node.is_before(start_node) { if node.is_before(start_node) {
return false; return false;
@ -493,11 +493,11 @@ impl SelectionMethods for Selection {
if node == end_node { if node == end_node {
return range.EndOffset() == node.len(); return range.EndOffset() == node.len();
} }
return true; true
} }
} else { } else {
// No range // No range
return false; false
} }
} }

View file

@ -892,8 +892,7 @@ impl WebGL2RenderingContext {
handle_potential_webgl_error!( handle_potential_webgl_error!(
self.base, self.base,
texture.storage(target, levels, internal_format, width, height, depth), texture.storage(target, levels, internal_format, width, height, depth)
return
); );
} }
} }
@ -4197,8 +4196,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
handle_potential_webgl_error!( handle_potential_webgl_error!(
self.base, self.base,
program.bind_uniform_block(block_index, block_binding), program.bind_uniform_block(block_index, block_binding)
return
) )
} }

View file

@ -312,7 +312,7 @@ impl WebGLTexture {
}, },
constants::TEXTURE_MAG_FILTER => match int_value as u32 { constants::TEXTURE_MAG_FILTER => match int_value as u32 {
constants::NEAREST | constants::LINEAR => update_filter(&self.mag_filter), constants::NEAREST | constants::LINEAR => update_filter(&self.mag_filter),
_ => return Err(WebGLError::InvalidEnum), _ => Err(WebGLError::InvalidEnum),
}, },
constants::TEXTURE_WRAP_S | constants::TEXTURE_WRAP_T => match int_value as u32 { constants::TEXTURE_WRAP_S | constants::TEXTURE_WRAP_T => match int_value as u32 {
constants::CLAMP_TO_EDGE | constants::MIRRORED_REPEAT | constants::REPEAT => { constants::CLAMP_TO_EDGE | constants::MIRRORED_REPEAT | constants::REPEAT => {

View file

@ -537,7 +537,7 @@ impl WindowProxy {
return Ok(None); return Ok(None);
} }
// Step 17. // Step 17.
return Ok(target_document.browsing_context()); Ok(target_document.browsing_context())
} }
// https://html.spec.whatwg.org/multipage/#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name // https://html.spec.whatwg.org/multipage/#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name
@ -840,7 +840,7 @@ fn parse_open_feature_boolean(tokenized_features: &IndexMap<String, String>, nam
} }
} }
// Step 5 // Step 5
return false; false
} }
// This is only called from extern functions, // This is only called from extern functions,

View file

@ -357,8 +357,8 @@ impl<'dom, LayoutDataType: LayoutDataTrait> style::dom::TElement
fn has_animations(&self, context: &SharedStyleContext) -> bool { fn has_animations(&self, context: &SharedStyleContext) -> bool {
// This is not used for pseudo elements currently so we can pass None. // This is not used for pseudo elements currently so we can pass None.
return self.has_css_animations(context, /* pseudo_element = */ None) || self.has_css_animations(context, /* pseudo_element = */ None) ||
self.has_css_transitions(context, /* pseudo_element = */ None); self.has_css_transitions(context, /* pseudo_element = */ None)
} }
fn has_css_animations( fn has_css_animations(

View file

@ -81,7 +81,7 @@ unsafe fn gen_type_error(global: &GlobalScope, string: String) -> RethrowError {
rooted!(in(*GlobalScope::get_cx()) let mut thrown = UndefinedValue()); rooted!(in(*GlobalScope::get_cx()) let mut thrown = UndefinedValue());
Error::Type(string).to_jsval(*GlobalScope::get_cx(), global, thrown.handle_mut()); Error::Type(string).to_jsval(*GlobalScope::get_cx(), global, thrown.handle_mut());
return RethrowError(RootedTraceableBox::from_box(Heap::boxed(thrown.get()))); RethrowError(RootedTraceableBox::from_box(Heap::boxed(thrown.get())))
} }
#[derive(JSTraceable)] #[derive(JSTraceable)]

View file

@ -2469,7 +2469,6 @@ impl ScriptThread {
if let Some(document) = document { if let Some(document) = document {
let _ac = enter_realm(&*document); let _ac = enter_realm(&*document);
document.exit_fullscreen(); document.exit_fullscreen();
return;
} }
} }

View file

@ -364,7 +364,6 @@ impl ServiceWorkerManager {
active_worker: registration.active_worker.as_ref().map(|worker| worker.id), active_worker: registration.active_worker.as_ref().map(|worker| worker.id),
}, },
)); ));
return;
} }
} else { } else {
// Step 6: we do not have a registration. // Step 6: we do not have a registration.