clippy: Fix let_and_return warnings (#31964)

This commit is contained in:
Oluwatobi Sofela 2024-04-01 16:43:24 +01:00 committed by GitHub
parent 0da2508e4d
commit c7b73e1ef4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 17 additions and 31 deletions

View file

@ -751,10 +751,7 @@ fn consume_body_with_promise<T: BodyMixin + DomObject>(
// Step 2.
let stream = match object.body() {
Some(stream) => stream,
None => {
let stream = ReadableStream::new_from_bytes(&global, Vec::with_capacity(0));
stream
},
None => ReadableStream::new_from_bytes(&global, Vec::with_capacity(0)),
};
// Step 3.

View file

@ -122,7 +122,7 @@ impl BaseAudioContext {
let client_context_id =
ClientContextId::build(pipeline_id.namespace_id.0, pipeline_id.index.0.get());
let context = BaseAudioContext {
BaseAudioContext {
eventtarget: EventTarget::new_inherited(),
audio_context_impl: ServoMedia::get()
.unwrap()
@ -135,9 +135,7 @@ impl BaseAudioContext {
sample_rate,
state: Cell::new(AudioContextState::Suspended),
channel_count: channel_count.into(),
};
context
}
}
/// Tells whether this is an OfflineAudioContext or not.

View file

@ -309,11 +309,10 @@ impl BlobMethods for Blob {
/// see <https://github.com/w3c/FileAPI/issues/43>
pub fn normalize_type_string(s: &str) -> String {
if is_ascii_printable(s) {
let s_lower = s.to_ascii_lowercase();
s.to_ascii_lowercase()
// match s_lower.parse() as Result<Mime, ()> {
// Ok(_) => s_lower,
// Err(_) => "".to_string()
s_lower
} else {
"".to_string()
}

View file

@ -73,8 +73,7 @@ impl CSSStyleOwner {
let lock = attr.as_ref().unwrap();
let mut guard = shared_lock.write();
let pdb = lock.write_with(&mut guard);
let result = f(pdb, &mut changed);
result
f(pdb, &mut changed)
} else {
let mut pdb = PropertyDeclarationBlock::new();
let result = f(&mut pdb, &mut changed);

View file

@ -2771,7 +2771,7 @@ impl GlobalScope {
return p;
}
let promise = match image {
match image {
ImageBitmapSource::HTMLCanvasElement(ref canvas) => {
// https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument
if !canvas.is_valid() {
@ -2815,8 +2815,7 @@ impl GlobalScope {
p.reject_error(Error::NotSupported);
return p;
},
};
promise
}
}
pub fn fire_timer(&self, handle: TimerEventId) {

View file

@ -50,14 +50,13 @@ pub struct MediaSession {
impl MediaSession {
#[allow(crown::unrooted_must_root)]
fn new_inherited() -> MediaSession {
let media_session = MediaSession {
MediaSession {
reflector_: Reflector::new(),
metadata: DomRefCell::new(None),
playback_state: DomRefCell::new(MediaSessionPlaybackState::None),
action_handlers: DomRefCell::new(HashMapTracedValues::new()),
media_instance: Default::default(),
};
media_session
}
}
pub fn new(window: &Window) -> DomRoot<MediaSession> {

View file

@ -72,7 +72,7 @@ impl RTCDataChannel {
.expect("Expected data channel id"),
);
let channel = RTCDataChannel {
RTCDataChannel {
eventtarget: EventTarget::new_inherited(),
servo_media_id,
peer_connection: Dom::from_ref(peer_connection),
@ -85,9 +85,7 @@ impl RTCDataChannel {
id: options.id,
ready_state: Cell::new(RTCDataChannelState::Connecting),
binary_type: DomRefCell::new(DOMString::from("blob")),
};
channel
}
}
pub fn new(

View file

@ -427,10 +427,9 @@ impl WebGL2RenderingContext {
let last_row_bytes = bytes_per_pixel
.checked_mul(width as usize)
.ok_or(InvalidOperation)?;
let result = full_row_bytes
full_row_bytes
.checked_add(last_row_bytes)
.ok_or(InvalidOperation)?;
result
.ok_or(InvalidOperation)?
};
let skipped_bytes = {
let skipped_row_bytes = self
@ -443,10 +442,9 @@ impl WebGL2RenderingContext {
.get()
.checked_mul(bytes_per_pixel)
.ok_or(InvalidOperation)?;
let result = skipped_row_bytes
skipped_row_bytes
.checked_add(skipped_pixel_bytes)
.ok_or(InvalidOperation)?;
result
.ok_or(InvalidOperation)?
};
Ok(ReadPixelsSizes {
row_stride,
@ -4119,12 +4117,11 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
self.base.validate_ownership(program),
return constants::INVALID_INDEX
);
let index = handle_potential_webgl_error!(
handle_potential_webgl_error!(
self.base,
program.get_uniform_block_index(block_name),
return constants::INVALID_INDEX
);
index
)
}
/// <https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.16>