tidy: Add a rule ensuring that // comments are followed by a space in Rust (#38698)

This shows up sometimes in code reviews, so it makes sense that tidy
enforces it. `rustfmt` supports this via comment normalization, but it
does many other things and is still an unstable feature (with bugs).

Testing: There are new tidy tests for this change.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-08-18 05:09:09 -07:00 committed by GitHub
parent 8ca00a3b0c
commit 8743a11ba4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
68 changed files with 169 additions and 152 deletions

View file

@ -102,12 +102,12 @@ pub(crate) struct WebSocket {
url: ServoUrl,
ready_state: Cell<WebSocketRequestState>,
buffered_amount: Cell<u64>,
clearing_buffer: Cell<bool>, //Flag to tell if there is a running thread to clear buffered_amount
clearing_buffer: Cell<bool>, // Flag to tell if there is a running thread to clear buffered_amount
#[ignore_malloc_size_of = "Defined in std"]
#[no_trace]
sender: IpcSender<WebSocketDomAction>,
binary_type: Cell<BinaryType>,
protocol: DomRefCell<String>, //Subprotocol selected by server
protocol: DomRefCell<String>, // Subprotocol selected by server
}
impl WebSocket {
@ -421,22 +421,22 @@ impl WebSocketMethods<crate::DomTypeHolder> for WebSocket {
// https://html.spec.whatwg.org/multipage/#dom-websocket-close
fn Close(&self, code: Option<u16>, reason: Option<USVString>) -> ErrorResult {
if let Some(code) = code {
//Fail if the supplied code isn't normal and isn't reserved for libraries, frameworks, and applications
// Fail if the supplied code isn't normal and isn't reserved for libraries, frameworks, and applications
if code != close_code::NORMAL && !(3000..=4999).contains(&code) {
return Err(Error::InvalidAccess);
}
}
if let Some(ref reason) = reason {
if reason.0.len() > 123 {
//reason cannot be larger than 123 bytes
// reason cannot be larger than 123 bytes
return Err(Error::Syntax);
}
}
match self.ready_state.get() {
WebSocketRequestState::Closing | WebSocketRequestState::Closed => {}, //Do nothing
WebSocketRequestState::Closing | WebSocketRequestState::Closed => {}, // Do nothing
WebSocketRequestState::Connecting => {
//Connection is not yet established
// Connection is not yet established
/*By setting the state to closing, the open function
will abort connecting the websocket*/
self.ready_state.set(WebSocketRequestState::Closing);
@ -459,7 +459,7 @@ impl WebSocketMethods<crate::DomTypeHolder> for WebSocket {
let _ = self.sender.send(WebSocketDomAction::Close(code, reason));
},
}
Ok(()) //Return Ok
Ok(()) // Return Ok
}
}