mirror of
https://github.com/servo/servo.git
synced 2025-09-29 16:19:14 +01:00
Replace script_plugins with a clippy like rustc driver (named crown) (#30508)
* Remove script_plugins * Use crown instead of script_plugins * crown_is_not_used * Use crown in command base * bootstrap crown * tidy happy * disable sccache * Bring crown in tree * Install crown from tree * fix windows ci * fix warning * fix mac libscript_plugins.dylib is not available anymore * Update components/script/lib.rs Co-authored-by: Martin Robinson <mrobinson@igalia.com> * Update for nightly-2023-03-18 Mostly just based off https://github.com/servo/servo/pull/30630 * Always install crown it's slow only when there is new version * Run crown test with `mach test-unit` * Small fixups; better trace_in_no_trace tests * Better doc * crown in config.toml * Fix tidy for real * no sccache on rustc_wrapper * document rustc overrides * fixup of compiletest * Make a few minor comment adjustments * Fix a typo in python/servo/platform/base.py Co-authored-by: Samson <16504129+sagudev@users.noreply.github.com> * Proper test types * Ignore tidy on crown/tests --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
20a73721de
commit
604979e367
231 changed files with 881 additions and 680 deletions
|
@ -0,0 +1,25 @@
|
|||
/* 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 https://mozilla.org/MPL/2.0/. */
|
||||
// compile-flags: --error-format=human
|
||||
/// Mock `JSTraceable`
|
||||
pub trait JSTraceable {}
|
||||
|
||||
struct TraceableStruct;
|
||||
impl JSTraceable for TraceableStruct {}
|
||||
|
||||
struct NotTraceableStruct;
|
||||
|
||||
// `must_not_have_traceable(1)` indicates that the second generic argument should
|
||||
// not be traceable and this test verifies that this lint passes enforces this.
|
||||
#[crown::trace_in_no_trace_lint::must_not_have_traceable(1)]
|
||||
struct NoTraceComposable<Traceable, NoTraceable> {
|
||||
t: Traceable,
|
||||
n: NoTraceable,
|
||||
}
|
||||
|
||||
// The lint should fail because TraceableStruct is traceable
|
||||
struct Foo(NoTraceComposable<TraceableStruct, TraceableStruct>);
|
||||
//~^ ERROR: must_not_have_traceable marked wrapper must not have jsmanaged inside on 1-th position. Consider removing the wrapper.
|
||||
|
||||
fn main() {}
|
19
support/crown/tests/compile-fail/trace_in_no_trace_works.rs
Normal file
19
support/crown/tests/compile-fail/trace_in_no_trace_works.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* 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 https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/// Mock `JSTraceable`
|
||||
pub trait JSTraceable {}
|
||||
|
||||
struct TraceableStruct;
|
||||
impl JSTraceable for TraceableStruct {}
|
||||
|
||||
struct NotTraceableStruct;
|
||||
|
||||
#[crown::trace_in_no_trace_lint::must_not_have_traceable]
|
||||
struct NoTrace<T>(T);
|
||||
|
||||
struct Foo(NoTrace<TraceableStruct>);
|
||||
//~^ ERROR: must_not_have_traceable marked wrapper must not have jsmanaged inside on 0-th position. Consider removing the wrapper.
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,10 @@
|
|||
/* 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 https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
struct Foo(i32);
|
||||
|
||||
fn foo1(_: Foo) {} //~ ERROR: Type must be rooted
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,13 @@
|
|||
/* 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 https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
struct Foo(i32);
|
||||
|
||||
fn foo2() -> Foo {
|
||||
//~^ ERROR: Type must be rooted
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,10 @@
|
|||
/* 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 https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
struct Foo(i32);
|
||||
struct Bar(Foo);
|
||||
//~^ ERROR: Type must be rooted, use #[crown::unrooted_must_root_lint::must_root] on the struct definition to propagate
|
||||
|
||||
fn main() {}
|
52
support/crown/tests/compile_test.rs
Normal file
52
support/crown/tests/compile_test.rs
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* 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 https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use compiletest_rs as compiletest;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
static PROFILE_PATH: Lazy<PathBuf> = Lazy::new(|| {
|
||||
let current_exe_path = env::current_exe().unwrap();
|
||||
let deps_path = current_exe_path.parent().unwrap();
|
||||
let profile_path = deps_path.parent().unwrap();
|
||||
profile_path.into()
|
||||
});
|
||||
|
||||
fn run_mode(mode: &'static str, bless: bool) {
|
||||
let mut config = compiletest::Config {
|
||||
bless,
|
||||
edition: Some("2021".into()),
|
||||
..Default::default()
|
||||
}
|
||||
.tempdir();
|
||||
|
||||
let cfg_mode = mode.parse().expect("Invalid mode");
|
||||
config.mode = cfg_mode;
|
||||
config.src_base = PathBuf::from("tests").join(mode);
|
||||
config.rustc_path = PROFILE_PATH.join("crown");
|
||||
config.target_rustcflags = Some(format!(
|
||||
"-L {} -L {} -Zcrate-attr=feature(register_tool) -Zcrate-attr=register_tool(crown)",
|
||||
PROFILE_PATH.display(),
|
||||
PROFILE_PATH.join("deps").display()
|
||||
));
|
||||
// Does not work reliably: https://github.com/servo/servo/pull/30508#issuecomment-1834542203
|
||||
//config.link_deps();
|
||||
config.clean_rmeta();
|
||||
config.strict_headers = true;
|
||||
|
||||
compiletest::run_tests(&config);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compile_test() {
|
||||
let bless = env::var("BLESS").map_or(false, |x| !x.trim().is_empty());
|
||||
run_mode("compile-fail", bless);
|
||||
run_mode("run-pass", bless);
|
||||
// UI test fails on windows
|
||||
if !cfg!(windows) {
|
||||
run_mode("ui", bless);
|
||||
}
|
||||
}
|
24
support/crown/tests/run-pass/trace_in_no_trace_composable.rs
Normal file
24
support/crown/tests/run-pass/trace_in_no_trace_composable.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
/* 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 https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/// Mock `JSTraceable`
|
||||
pub trait JSTraceable {}
|
||||
|
||||
struct TraceableStruct;
|
||||
impl JSTraceable for TraceableStruct {}
|
||||
|
||||
struct NotTraceableStruct;
|
||||
|
||||
// `must_not_have_traceable(1)` indicates that the second generic argument should
|
||||
// not be traceable and this test verifies that this lint passes.
|
||||
#[crown::trace_in_no_trace_lint::must_not_have_traceable(1)]
|
||||
struct NoTraceComposable<Traceable, NoTraceable> {
|
||||
t: Traceable,
|
||||
n: NoTraceable,
|
||||
}
|
||||
|
||||
// this is ok: TraceableStruct is traceable
|
||||
struct Foo(NoTraceComposable<TraceableStruct, NotTraceableStruct>);
|
||||
|
||||
fn main() {}
|
18
support/crown/tests/run-pass/trace_in_no_trace_ok.rs
Normal file
18
support/crown/tests/run-pass/trace_in_no_trace_ok.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* 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 https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/// Mock `JSTraceable`
|
||||
pub trait JSTraceable {}
|
||||
|
||||
struct TraceableStruct;
|
||||
impl JSTraceable for TraceableStruct {}
|
||||
|
||||
struct NotTraceableStruct;
|
||||
|
||||
#[crown::trace_in_no_trace_lint::must_not_have_traceable]
|
||||
struct NoTrace<T>(T);
|
||||
|
||||
struct Foo(NoTrace<NotTraceableStruct>);
|
||||
|
||||
fn main() {}
|
15
support/crown/tests/run-pass/unrooted_must_root_ok.rs
Normal file
15
support/crown/tests/run-pass/unrooted_must_root_ok.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* 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 https://mozilla.org/MPL/2.0/. */
|
||||
// compile-flags: --error-format=human
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
struct Foo(i32);
|
||||
#[crown::unrooted_must_root_lint::must_root]
|
||||
struct Bar(Foo);
|
||||
|
||||
fn foo1(_: &Foo) {}
|
||||
fn foo2(_: &()) -> &Foo {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn main() {}
|
17
support/crown/tests/ui/trace_in_no_trace_primitive.rs
Normal file
17
support/crown/tests/ui/trace_in_no_trace_primitive.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* 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 https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/// Mock `JSTraceable`
|
||||
pub trait JSTraceable {}
|
||||
impl JSTraceable for i32 {}
|
||||
|
||||
// second generic argument must not be traceable
|
||||
#[crown::trace_in_no_trace_lint::must_not_have_traceable(0)]
|
||||
struct NoTrace<NoTraceable> {
|
||||
n: NoTraceable,
|
||||
}
|
||||
|
||||
struct Foo(NoTrace<i32>);
|
||||
|
||||
fn main() {}
|
10
support/crown/tests/ui/trace_in_no_trace_primitive.stderr
Normal file
10
support/crown/tests/ui/trace_in_no_trace_primitive.stderr
Normal file
|
@ -0,0 +1,10 @@
|
|||
warning: must_not_have_traceable marked wrapper is not needed for types that implements empty Traceable (like primitive types). Consider removing the wrapper.
|
||||
--> $DIR/trace_in_no_trace_primitive.rs:15:12
|
||||
|
|
||||
15 | struct Foo(NoTrace<i32>);
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(crown::empty_trace_in_no_trace)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue