diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2017-02-14 17:35:39 +0100 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2017-02-15 10:24:01 +0100 |
commit | 8bcf36b9a59b4f30fd54fceb85eeb51b1d4dee4f (patch) | |
tree | 16f762e408981f2130095470fc4c7b868f9011c2 /components/plugins | |
parent | 19c645ff68f517929308d1f22728d72231e9a543 (diff) | |
download | servo-8bcf36b9a59b4f30fd54fceb85eeb51b1d4dee4f.tar.gz servo-8bcf36b9a59b4f30fd54fceb85eeb51b1d4dee4f.zip |
Change #[privatize] into #[derive(DenyPublicFields)]
Diffstat (limited to 'components/plugins')
-rw-r--r-- | components/plugins/jstraceable.rs | 1 | ||||
-rw-r--r-- | components/plugins/lib.rs | 6 | ||||
-rw-r--r-- | components/plugins/lints/mod.rs | 1 | ||||
-rw-r--r-- | components/plugins/lints/privatize.rs | 41 |
4 files changed, 2 insertions, 47 deletions
diff --git a/components/plugins/jstraceable.rs b/components/plugins/jstraceable.rs index 498f4006010..9bc9ead6299 100644 --- a/components/plugins/jstraceable.rs +++ b/components/plugins/jstraceable.rs @@ -11,7 +11,6 @@ pub fn expand_dom_struct(cx: &mut ExtCtxt, sp: Span, _: &MetaItem, anno: Annotat if let Annotatable::Item(item) = anno { let mut item2 = (*item).clone(); item2.attrs.push(quote_attr!(cx, #[must_root])); - item2.attrs.push(quote_attr!(cx, #[privatize])); item2.attrs.push(quote_attr!(cx, #[repr(C)])); item2.attrs.push(quote_attr!(cx, #[derive(JSTraceable)])); item2.attrs.push(quote_attr!(cx, #[derive(HeapSizeOf)])); diff --git a/components/plugins/lib.rs b/components/plugins/lib.rs index 43995876599..7b897cb10e0 100644 --- a/components/plugins/lib.rs +++ b/components/plugins/lib.rs @@ -6,11 +6,11 @@ //! //! Attributes this crate provides: //! -//! - `#[privatize]` : Forces all fields in a struct/enum to be private +//! - `#[derive(DenyPublicFields)]` : Forces all fields in a struct/enum to be private //! - `#[derive(JSTraceable)]` : Auto-derives an implementation of `JSTraceable` for a struct in the script crate //! - `#[must_root]` : Prevents data of the marked type from being used on the stack. //! See the lints module for more details -//! - `#[dom_struct]` : Implies `#[privatize]`,`#[derive(JSTraceable)]`, and `#[must_root]`. +//! - `#[dom_struct]` : Implies #[derive(JSTraceable, DenyPublicFields)]`, and `#[must_root]`. //! Use this for structs that correspond to a DOM type @@ -44,13 +44,11 @@ pub fn plugin_registrar(reg: &mut Registry) { MultiModifier(box jstraceable::expand_dom_struct)); reg.register_late_lint_pass(box lints::unrooted_must_root::UnrootedPass::new()); - reg.register_late_lint_pass(box lints::privatize::PrivatizePass); reg.register_late_lint_pass(box lints::inheritance_integrity::InheritancePass); reg.register_early_lint_pass(box lints::ban::BanPass); reg.register_attribute("_dom_struct_marker".to_string(), Whitelisted); reg.register_attribute("allow_unrooted_interior".to_string(), Whitelisted); reg.register_attribute("must_root".to_string(), Whitelisted); - reg.register_attribute("privatize".to_string(), Whitelisted); reg.register_attribute("servo_lang".to_string(), Whitelisted); register_clippy(reg); } diff --git a/components/plugins/lints/mod.rs b/components/plugins/lints/mod.rs index 3bdff2003eb..5b1debed0a2 100644 --- a/components/plugins/lints/mod.rs +++ b/components/plugins/lints/mod.rs @@ -4,5 +4,4 @@ pub mod ban; pub mod inheritance_integrity; -pub mod privatize; pub mod unrooted_must_root; diff --git a/components/plugins/lints/privatize.rs b/components/plugins/lints/privatize.rs deleted file mode 100644 index e6a44015d81..00000000000 --- a/components/plugins/lints/privatize.rs +++ /dev/null @@ -1,41 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use rustc::hir; -use rustc::lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext}; -use syntax::ast; - -declare_lint!(PRIVATIZE, Deny, - "Allows to enforce private fields for struct definitions"); - -/// Lint for keeping DOM fields private -/// -/// This lint (disable with `-A privatize`/`#[allow(privatize)]`) ensures all types marked with `#[privatize]` -/// have no public fields -pub struct PrivatizePass; - -impl LintPass for PrivatizePass { - fn get_lints(&self) -> LintArray { - lint_array!(PRIVATIZE) - } -} - -impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PrivatizePass { - fn check_struct_def(&mut self, - cx: &LateContext, - def: &hir::VariantData, - _n: ast::Name, - _gen: &hir::Generics, - id: ast::NodeId) { - if cx.tcx.has_attr(cx.tcx.hir.local_def_id(id), "privatize") { - for field in def.fields() { - if field.vis == hir::Public { - cx.span_lint(PRIVATIZE, field.span, - &format!("Field {} is public where only private fields are allowed", - field.name)); - } - } - } - } -} |