mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Reduce max line length from 150 to 120 characters
Part of https://github.com/servo/servo/issues/6041
This commit is contained in:
parent
7561f7b83f
commit
8e3f4bba85
141 changed files with 1161 additions and 497 deletions
|
@ -22,7 +22,8 @@ impl LintPass for InheritancePass {
|
|||
lint_array!(INHERITANCE_INTEGRITY)
|
||||
}
|
||||
|
||||
fn check_struct_def(&mut self, cx: &Context, def: &ast::StructDef, _i: ast::Ident, _gen: &ast::Generics, id: ast::NodeId) {
|
||||
fn check_struct_def(&mut self, cx: &Context, def: &ast::StructDef, _i: ast::Ident,
|
||||
_gen: &ast::Generics, id: ast::NodeId) {
|
||||
// Lints are run post expansion, so it's fine to use
|
||||
// #[_dom_struct_marker] here without also checking for #[dom_struct]
|
||||
if ty::has_attr(cx.tcx, ast_util::local_def(id), "_dom_struct_marker") {
|
||||
|
@ -32,7 +33,8 @@ impl LintPass for InheritancePass {
|
|||
if match_lang_ty(cx, &*f.node.ty, "reflector") {
|
||||
if ctr > 0 {
|
||||
cx.span_lint(INHERITANCE_INTEGRITY, f.span,
|
||||
"The Reflector should be the first field of the DOM struct");
|
||||
"The Reflector should be the first field of the DOM \
|
||||
struct");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ declare_lint!(PRIVATIZE, Deny,
|
|||
|
||||
/// Lint for keeping DOM fields private
|
||||
///
|
||||
/// This lint (disable with `-A privatize`/`#[allow(privatize)]`) ensures all types marked with `#[privatize]` have no private fields
|
||||
/// This lint (disable with `-A privatize`/`#[allow(privatize)]`) ensures all types marked with `#[privatize]`
|
||||
/// have no private fields
|
||||
pub struct PrivatizePass;
|
||||
|
||||
impl LintPass for PrivatizePass {
|
||||
|
@ -21,13 +22,19 @@ impl LintPass for PrivatizePass {
|
|||
lint_array!(PRIVATIZE)
|
||||
}
|
||||
|
||||
fn check_struct_def(&mut self, cx: &Context, def: &ast::StructDef, _i: ast::Ident, _gen: &ast::Generics, id: ast::NodeId) {
|
||||
fn check_struct_def(&mut self,
|
||||
cx: &Context,
|
||||
def: &ast::StructDef,
|
||||
_i: ast::Ident,
|
||||
_gen: &ast::Generics,
|
||||
id: ast::NodeId) {
|
||||
if ty::has_attr(cx.tcx, ast_util::local_def(id), "privatize") {
|
||||
for field in def.fields.iter() {
|
||||
match field.node {
|
||||
ast::StructField_ { kind: ast::NamedField(ident, visibility), .. } if visibility == Public => {
|
||||
cx.span_lint(PRIVATIZE, field.span,
|
||||
&format!("Field {} is public where only private fields are allowed", ident.name));
|
||||
&format!("Field {} is public where only private fields are allowed",
|
||||
ident.name));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
@ -15,14 +15,17 @@ declare_lint!(UNROOTED_MUST_ROOT, Deny,
|
|||
|
||||
/// Lint for ensuring safe usage of unrooted pointers
|
||||
///
|
||||
/// This lint (disable with `-A unrooted-must-root`/`#[allow(unrooted_must_root)]`) ensures that `#[must_root]` values are used correctly.
|
||||
/// This lint (disable with `-A unrooted-must-root`/`#[allow(unrooted_must_root)]`) ensures that `#[must_root]`
|
||||
/// values are used correctly.
|
||||
///
|
||||
/// "Incorrect" usage includes:
|
||||
///
|
||||
/// - Not being used in a struct/enum field which is not `#[must_root]` itself
|
||||
/// - Not being used as an argument to a function (Except onces named `new` and `new_inherited`)
|
||||
/// - Not being bound locally in a `let` statement, assignment, `for` loop, or `match` statement.
|
||||
///
|
||||
/// This helps catch most situations where pointers like `JS<T>` are used in a way that they can be invalidated by a GC pass.
|
||||
/// This helps catch most situations where pointers like `JS<T>` are used in a way that they can be invalidated by a
|
||||
/// GC pass.
|
||||
pub struct UnrootedPass;
|
||||
|
||||
// Checks if a type has the #[must_root] annotation.
|
||||
|
@ -31,7 +34,8 @@ pub struct UnrootedPass;
|
|||
fn lint_unrooted_ty(cx: &Context, ty: &ast::Ty, warning: &str) {
|
||||
match ty.node {
|
||||
ast::TyVec(ref t) | ast::TyFixedLengthVec(ref t, _) |
|
||||
ast::TyPtr(ast::MutTy { ty: ref t, ..}) | ast::TyRptr(_, ast::MutTy { ty: ref t, ..}) => lint_unrooted_ty(cx, &**t, warning),
|
||||
ast::TyPtr(ast::MutTy { ty: ref t, ..}) | ast::TyRptr(_, ast::MutTy { ty: ref t, ..}) =>
|
||||
lint_unrooted_ty(cx, &**t, warning),
|
||||
ast::TyPath(..) => {
|
||||
match cx.tcx.def_map.borrow()[&ty.id] {
|
||||
def::PathResolution{ base_def: def::DefTy(def_id, _), .. } => {
|
||||
|
@ -51,7 +55,12 @@ impl LintPass for UnrootedPass {
|
|||
lint_array!(UNROOTED_MUST_ROOT)
|
||||
}
|
||||
/// All structs containing #[must_root] types must be #[must_root] themselves
|
||||
fn check_struct_def(&mut self, cx: &Context, def: &ast::StructDef, _i: ast::Ident, _gen: &ast::Generics, id: ast::NodeId) {
|
||||
fn check_struct_def(&mut self,
|
||||
cx: &Context,
|
||||
def: &ast::StructDef,
|
||||
_i: ast::Ident,
|
||||
_gen: &ast::Generics,
|
||||
id: ast::NodeId) {
|
||||
let item = match cx.tcx.map.get(id) {
|
||||
ast_map::Node::NodeItem(item) => item,
|
||||
_ => cx.tcx.map.expect_item(cx.tcx.map.get_parent(id)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue