Skip to content

Commit

Permalink
Remove redundant webidl_must_inherit compiler plugin lint
Browse files Browse the repository at this point in the history
At first I was considering moving it to a procedural macro
(source-level information should be sufficient),
and started by trying to reproduce the error case
by changing `htmldivelement.rs` to use `Element` instead of `HTMLElement`
as the first field.

The output was:

```rust
error[E0308]: mismatched types
   --> /home/simon/servo2/target/debug/build/script-4caa244faca7d10f/out/Bindings/HTMLDivElementBinding.rs:665:31
    |
665 |         let _: &HTMLElement = self.as_parent();
    |                               ^^^^^^^^^^^^^^^^ expected struct `dom::htmlelement::HTMLElement`, found struct `dom::element::Element`
    |
    = note: expected type `&dom::htmlelement::HTMLElement`
               found type `&dom::element::Element`
```

This line number is inside a generated method called `__assert_parent_type`.
As far as I can tell, any case where this lint would error is already caught
by such methods. The lint is therefore redundant and can safely be removed.
  • Loading branch information
SimonSapin committed Sep 29, 2019
1 parent 086e06b commit 47c2693
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 241 deletions.
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion components/dom_struct/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub fn dom_struct(args: TokenStream, input: TokenStream) -> TokenStream {
#[derive(DenyPublicFields, DomObject, JSTraceable, MallocSizeOf)]
#[must_root]
#[repr(C)]
#[webidl]
};

// Work around https://github.com/rust-lang/rust/issues/46489
Expand Down
3 changes: 1 addition & 2 deletions components/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ path = "lib.rs"
debugmozjs = ['js/debugmozjs']
profilemozjs = ['js/profilemozjs']
unrooted_must_root_lint = ["script_plugins/unrooted_must_root_lint"]
webidl_lint = ["script_plugins/webidl_lint"]
default = ["unrooted_must_root_lint", "webidl_lint"]
default = ["unrooted_must_root_lint"]
webgl_backtrace = ["backtrace", "canvas_traits/webgl_backtrace"]
js_backtrace = ["backtrace"]
uwp = ["js/uwp"]
Expand Down
4 changes: 0 additions & 4 deletions components/script_plugins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ plugin = true

[features]
unrooted_must_root_lint = []
webidl_lint = []

[dependencies]
weedle = "0.10"
12 changes: 0 additions & 12 deletions components/script_plugins/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,13 @@ extern crate rustc;
extern crate rustc_driver;
extern crate syntax;

extern crate weedle;

use rustc_driver::plugin::Registry;
use syntax::feature_gate::AttributeType::Whitelisted;
use syntax::symbol::Symbol;

#[cfg(feature = "unrooted_must_root_lint")]
mod unrooted_must_root;

#[cfg(feature = "webidl_lint")]
mod webidl_must_inherit;

/// Utilities for writing plugins
#[cfg(feature = "unrooted_must_root_lint")]
mod utils;
Expand All @@ -49,15 +44,9 @@ pub fn plugin_registrar(reg: &mut Registry) {
symbols.clone(),
)));

#[cfg(feature = "webidl_lint")]
reg.register_late_lint_pass(Box::new(webidl_must_inherit::WebIdlPass::new(
symbols.clone(),
)));

reg.register_attribute(symbols.allow_unrooted_interior, Whitelisted);
reg.register_attribute(symbols.allow_unrooted_in_rc, Whitelisted);
reg.register_attribute(symbols.must_root, Whitelisted);
reg.register_attribute(symbols.webidl, Whitelisted);
}

macro_rules! symbols {
Expand All @@ -82,7 +71,6 @@ symbols! {
allow_unrooted_interior
allow_unrooted_in_rc
must_root
webidl
alloc
rc
Rc
Expand Down
210 changes: 0 additions & 210 deletions components/script_plugins/webidl_must_inherit.rs

This file was deleted.

0 comments on commit 47c2693

Please sign in to comment.