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

@ -2,6 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! This is a module, but this comment shouldn't trigger an error.
//* This is also a module doc comment *//
//This comment should trigger an error, because of missing space.
use app_units::Au;
use raqote::{GradientStop, Source, SolidSource};
use raqote::{Source, SolidSource},
@ -78,4 +82,11 @@ impl test {
} else {
let xif = 42 in { xif } // Should not trigger
}
//Comment with no space following it, should trigger an error.
let a = 3;//This should cause a problem.
//~^ This is a compile-test comment and shouldn't cause a problem.
// This comment has a URL, but it shouldn't trigger an error http://servo.org.
// This comment has a URL, but it shouldn't trigger an error http://servo.org.
/* This is another style of comment, but shouldn't trigger an error. */
}