From 651b087155c09301f6762b7b58b14be8f6334ccf Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 31 Mar 2020 15:52:07 +0200 Subject: [PATCH 1/3] Upgrade to rustc 1.44.0-nightly (211365947 2020-03-30) --- components/script_plugins/lib.rs | 6 +++--- rust-toolchain | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/script_plugins/lib.rs b/components/script_plugins/lib.rs index c2cd3c9062a..0db4b5a5527 100644 --- a/components/script_plugins/lib.rs +++ b/components/script_plugins/lib.rs @@ -19,21 +19,21 @@ #![feature(rustc_private)] #![cfg(feature = "unrooted_must_root_lint")] -extern crate rustc; extern crate rustc_ast; extern crate rustc_driver; extern crate rustc_hir; extern crate rustc_lint; +extern crate rustc_middle; extern crate rustc_session; extern crate rustc_span; -use rustc::ty; use rustc_ast::ast::{AttrKind, Attribute}; use rustc_driver::plugin::Registry; use rustc_hir::def_id::DefId; use rustc_hir::intravisit as visit; use rustc_hir::{self as hir, ExprKind, HirId}; use rustc_lint::{LateContext, LateLintPass, LintContext, LintPass}; +use rustc_middle::ty; use rustc_session::declare_lint; use rustc_span::source_map; use rustc_span::source_map::{ExpnKind, MacroKind, Span}; @@ -298,7 +298,7 @@ struct FnDefVisitor<'a, 'b: 'a, 'tcx: 'a + 'b> { } impl<'a, 'b, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'b, 'tcx> { - type Map = rustc::hir::map::Map<'tcx>; + type Map = rustc_middle::hir::map::Map<'tcx>; fn visit_expr(&mut self, expr: &'tcx hir::Expr) { let cx = self.cx; diff --git a/rust-toolchain b/rust-toolchain index a391a62a866..cd37a8d267e 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-03-16 +nightly-2020-03-31 From 4227425c1e6374857b3d881a1d3963be27141576 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 8 Apr 2020 15:57:49 +0200 Subject: [PATCH 2/3] Remove the lint added in https://github.com/servo/servo/pull/14589 Per https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a8a5a716b3bdf52fa7960a1e4ee89add it looks like the drop order of temporaries was changed at some point and this pattern is no longer problematic. --- python/tidy/servo_tidy/tidy.py | 3 --- python/tidy/servo_tidy_tests/script_thread.rs | 18 ------------------ python/tidy/servo_tidy_tests/test_tidy.py | 6 ------ 3 files changed, 27 deletions(-) delete mode 100644 python/tidy/servo_tidy_tests/script_thread.rs diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py index cbbb1a542d4..cfeef216869 100644 --- a/python/tidy/servo_tidy/tidy.py +++ b/python/tidy/servo_tidy/tidy.py @@ -625,9 +625,6 @@ def check_rust(file_name, lines): (r": &Root<", "use &T instead of &Root", no_filter), (r": &DomRoot<", "use &T instead of &DomRoot", no_filter), (r"^&&", "operators should go at the end of the first line", no_filter), - # This particular pattern is not reentrant-safe in script_thread.rs - (r"match self.documents.borrow", "use a separate variable for the match expression", - lambda match, line: file_name.endswith('script_thread.rs')), # -> () is unnecessary (r"-> \(\)", "encountered function signature with -> ()", no_filter), ] diff --git a/python/tidy/servo_tidy_tests/script_thread.rs b/python/tidy/servo_tidy_tests/script_thread.rs deleted file mode 100644 index 5dbeaec0e17..00000000000 --- a/python/tidy/servo_tidy_tests/script_thread.rs +++ /dev/null @@ -1,18 +0,0 @@ -fn main() { - // This should trigger an error. - match self.documents.borrow_mut() { - _ => {} - } - // This should trigger an error. - match self.documents.borrow() { - _ => {} - } - // This should not trigger an error. - match { self.documents.borrow().find_window(id) } { - => {} - } - // This should not trigger an error. - match self.documents_status.borrow() { - => {} - } -} diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py index 441e9250c51..12f384b8674 100644 --- a/python/tidy/servo_tidy_tests/test_tidy.py +++ b/python/tidy/servo_tidy_tests/test_tidy.py @@ -140,12 +140,6 @@ class CheckTidiness(unittest.TestCase): self.assertEqual('method declared in webidl is missing a comment with a specification link', next(errors)[2]) self.assertNoMoreErrors(errors) - def test_script_thread(self): - errors = tidy.collect_errors_for_files(iterFile('script_thread.rs'), [], [tidy.check_rust], print_text=False) - self.assertEqual('use a separate variable for the match expression', next(errors)[2]) - self.assertEqual('use a separate variable for the match expression', next(errors)[2]) - self.assertNoMoreErrors(errors) - def test_webidl(self): errors = tidy.collect_errors_for_files(iterFile('spec.webidl'), [tidy.check_webidl_spec], [], print_text=False) self.assertEqual('No specification link found.', next(errors)[2]) From 1c0549ce7fd748511d6200e622eddf800b3e9ca4 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 8 Apr 2020 14:57:42 +0200 Subject: [PATCH 3/3] Upgrade to rustc 1.44.0-nightly (42abbd887 2020-04-07) --- Xargo.toml | 2 +- components/canvas_traits/webgl_channel/mod.rs | 2 +- components/media/media_channel/mod.rs | 2 +- components/net/http_loader.rs | 2 +- components/net/tests/main.rs | 2 +- components/script/script_thread.rs | 30 +++++++++---------- components/script_plugins/lib.rs | 17 +++++++++-- ports/glutin/events_loop.rs | 2 +- ports/libsimpleservo/capi/src/lib.rs | 2 +- rust-toolchain | 2 +- 10 files changed, 37 insertions(+), 26 deletions(-) diff --git a/Xargo.toml b/Xargo.toml index 147805d63d4..894a551a277 100644 --- a/Xargo.toml +++ b/Xargo.toml @@ -3,5 +3,5 @@ std = { features = ["panic-unwind"] } # https://github.com/rust-lang/rust/issues/65313 [target.aarch64-uwp-windows-msvc.dependencies] -std = {} +std = { features = ["panic-unwind"] } diff --git a/components/canvas_traits/webgl_channel/mod.rs b/components/canvas_traits/webgl_channel/mod.rs index 86a6cd23bf4..30dc9543f91 100644 --- a/components/canvas_traits/webgl_channel/mod.rs +++ b/components/canvas_traits/webgl_channel/mod.rs @@ -15,7 +15,7 @@ use servo_config::opts; use std::fmt; lazy_static! { - static ref IS_MULTIPROCESS: bool = { opts::multiprocess() }; + static ref IS_MULTIPROCESS: bool = opts::multiprocess(); } #[derive(Deserialize, Serialize)] diff --git a/components/media/media_channel/mod.rs b/components/media/media_channel/mod.rs index 5616a8479fd..241fec2db77 100644 --- a/components/media/media_channel/mod.rs +++ b/components/media/media_channel/mod.rs @@ -13,7 +13,7 @@ use servo_config::opts; use std::fmt; lazy_static! { - static ref IS_MULTIPROCESS: bool = { opts::multiprocess() }; + static ref IS_MULTIPROCESS: bool = opts::multiprocess(); } #[derive(Deserialize, Serialize)] diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index a8ba978df54..18dff8ca0ef 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -55,7 +55,7 @@ use tokio::prelude::{future, Future, Stream}; use tokio::runtime::Runtime; lazy_static! { - pub static ref HANDLE: Mutex = { Mutex::new(Runtime::new().unwrap()) }; + pub static ref HANDLE: Mutex = Mutex::new(Runtime::new().unwrap()); } /// The various states an entry of the HttpCache can be in. diff --git a/components/net/tests/main.rs b/components/net/tests/main.rs index 5ad2c55f728..c48ac873729 100644 --- a/components/net/tests/main.rs +++ b/components/net/tests/main.rs @@ -51,7 +51,7 @@ use tokio::runtime::Runtime; use tokio_openssl::SslAcceptorExt; lazy_static! { - pub static ref HANDLE: Mutex = { Mutex::new(Runtime::new().unwrap()) }; + pub static ref HANDLE: Mutex = Mutex::new(Runtime::new().unwrap()); } const DEFAULT_USER_AGENT: &'static str = "Such Browser. Very Layout. Wow."; diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index d6a8481afb3..18124f57423 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -2028,11 +2028,11 @@ impl ScriptThread { // occurs for the rest of the messages match msg { WebDriverScriptCommand::ExecuteScript(script, reply) => { - let window = { self.documents.borrow().find_window(pipeline_id) }; + let window = self.documents.borrow().find_window(pipeline_id); return webdriver_handlers::handle_execute_script(window, script, reply); }, WebDriverScriptCommand::ExecuteAsyncScript(script, reply) => { - let window = { self.documents.borrow().find_window(pipeline_id) }; + let window = self.documents.borrow().find_window(pipeline_id); return webdriver_handlers::handle_execute_async_script(window, script, reply); }, _ => (), @@ -2300,7 +2300,7 @@ impl ScriptThread { id: PipelineId, scroll_states: &[(UntrustedNodeAddress, Vector2D)], ) { - let window = match { self.documents.borrow().find_window(id) } { + let window = match self.documents.borrow().find_window(id) { Some(window) => window, None => { return warn!( @@ -2707,7 +2707,7 @@ impl ScriptThread { Some(r) => r, None => return, }; - let window = match { self.documents.borrow().find_window(pipeline_id) } { + let window = match self.documents.borrow().find_window(pipeline_id) { Some(window) => window, None => return warn!("Registration failed for {}", scope), }; @@ -2786,7 +2786,7 @@ impl ScriptThread { /// Handles a request for the window title. fn handle_get_title_msg(&self, pipeline_id: PipelineId) { - let document = match { self.documents.borrow().find_document(pipeline_id) } { + let document = match self.documents.borrow().find_document(pipeline_id) { Some(document) => document, None => return warn!("Message sent to closed pipeline {}.", pipeline_id), }; @@ -2903,7 +2903,7 @@ impl ScriptThread { /// Handles when layout thread finishes all animation in one tick fn handle_tick_all_animations(&self, id: PipelineId) { - let document = match { self.documents.borrow().find_document(id) } { + let document = match self.documents.borrow().find_document(id) { Some(document) => document, None => return warn!("Message sent to closed pipeline {}.", id), }; @@ -2988,7 +2988,7 @@ impl ScriptThread { old_value: Option, new_value: Option, ) { - let window = match { self.documents.borrow().find_window(pipeline_id) } { + let window = match self.documents.borrow().find_window(pipeline_id) { None => return warn!("Storage event sent to closed pipeline {}.", pipeline_id), Some(window) => window, }; @@ -3392,7 +3392,7 @@ impl ScriptThread { /// TODO: Actually perform DOM event dispatch. fn handle_event(&self, pipeline_id: PipelineId, event: CompositorEvent) { // Do not handle events if the pipeline exited. - let window = match { self.documents.borrow().find_window(pipeline_id) } { + let window = match self.documents.borrow().find_window(pipeline_id) { Some(win) => win, None => { return warn!( @@ -3436,7 +3436,7 @@ impl ScriptThread { }, MouseMoveEvent(point, node_address, pressed_mouse_buttons) => { - let document = match { self.documents.borrow().find_document(pipeline_id) } { + let document = match self.documents.borrow().find_document(pipeline_id) { Some(document) => document, None => return warn!("Message sent to closed pipeline {}.", pipeline_id), }; @@ -3529,7 +3529,7 @@ impl ScriptThread { }, KeyboardEvent(key_event) => { - let document = match { self.documents.borrow().find_document(pipeline_id) } { + let document = match self.documents.borrow().find_document(pipeline_id) { Some(document) => document, None => return warn!("Message sent to closed pipeline {}.", pipeline_id), }; @@ -3537,7 +3537,7 @@ impl ScriptThread { }, CompositionEvent(composition_event) => { - let document = match { self.documents.borrow().find_document(pipeline_id) } { + let document = match self.documents.borrow().find_document(pipeline_id) { Some(document) => document, None => return warn!("Message sent to closed pipeline {}.", pipeline_id), }; @@ -3558,7 +3558,7 @@ impl ScriptThread { point_in_node: Option>, pressed_mouse_buttons: u16, ) { - let document = match { self.documents.borrow().find_document(pipeline_id) } { + let document = match self.documents.borrow().find_document(pipeline_id) { Some(document) => document, None => return warn!("Message sent to closed pipeline {}.", pipeline_id), }; @@ -3581,7 +3581,7 @@ impl ScriptThread { point: Point2D, node_address: Option, ) -> TouchEventResult { - let document = match { self.documents.borrow().find_document(pipeline_id) } { + let document = match self.documents.borrow().find_document(pipeline_id) { Some(document) => document, None => { warn!("Message sent to closed pipeline {}.", pipeline_id); @@ -3604,7 +3604,7 @@ impl ScriptThread { point: Point2D, node_address: Option, ) { - let document = match { self.documents.borrow().find_document(pipeline_id) } { + let document = match self.documents.borrow().find_document(pipeline_id) { Some(document) => document, None => return warn!("Message sent to closed pipeline {}.", pipeline_id), }; @@ -3676,7 +3676,7 @@ impl ScriptThread { new_size: WindowSizeData, size_type: WindowSizeType, ) { - let document = match { self.documents.borrow().find_document(pipeline_id) } { + let document = match self.documents.borrow().find_document(pipeline_id) { Some(document) => document, None => return warn!("Message sent to closed pipeline {}.", pipeline_id), }; diff --git a/components/script_plugins/lib.rs b/components/script_plugins/lib.rs index 0db4b5a5527..8de2a85a47c 100644 --- a/components/script_plugins/lib.rs +++ b/components/script_plugins/lib.rs @@ -101,8 +101,16 @@ fn has_lint_attr(sym: &Symbols, attrs: &[Attribute], name: Symbol) -> bool { /// Checks if a type is unrooted or contains any owned unrooted types fn is_unrooted_ty(sym: &Symbols, cx: &LateContext, ty: &ty::TyS, in_new_function: bool) -> bool { let mut ret = false; - ty.maybe_walk(|t| { - match t.kind { + let mut walker = ty.walk(); + while let Some(generic_arg) = walker.next() { + let t = match generic_arg.unpack() { + rustc_middle::ty::subst::GenericArgKind::Type(t) => t, + _ => { + walker.skip_current_subtree(); + continue; + }, + }; + let recur_into_subtree = match t.kind { ty::Adt(did, substs) => { let has_attr = |did, name| has_lint_attr(sym, &cx.tcx.get_attrs(did), name); if has_attr(did.did, sym.must_root) { @@ -180,8 +188,11 @@ fn is_unrooted_ty(sym: &Symbols, cx: &LateContext, ty: &ty::TyS, in_new_function ty::FnDef(..) | ty::FnPtr(_) => false, _ => true, + }; + if !recur_into_subtree { + walker.skip_current_subtree(); } - }); + } ret } diff --git a/ports/glutin/events_loop.rs b/ports/glutin/events_loop.rs index 749e526b48a..0d18cd25019 100644 --- a/ports/glutin/events_loop.rs +++ b/ports/glutin/events_loop.rs @@ -96,7 +96,7 @@ impl EventsLoop { } EventLoop::Headless(ref data) => { let &(ref flag, ref condvar) = &**data; - while { !*flag.lock().unwrap() } { + while !*flag.lock().unwrap() { self.sleep(flag, condvar); if callback(glutin::Event::Awakened) == glutin::ControlFlow::Break { break; diff --git a/ports/libsimpleservo/capi/src/lib.rs b/ports/libsimpleservo/capi/src/lib.rs index 323f60575df..3e0765e70b9 100644 --- a/ports/libsimpleservo/capi/src/lib.rs +++ b/ports/libsimpleservo/capi/src/lib.rs @@ -37,7 +37,7 @@ extern "C" fn default_panic_handler(msg: *const c_char) { lazy_static! { static ref ON_PANIC: RwLock = RwLock::new(default_panic_handler); static ref SERVO_VERSION: CString = - { CString::new(simpleservo::servo_version()).expect("Can't create string") }; + CString::new(simpleservo::servo_version()).expect("Can't create string"); } #[no_mangle] diff --git a/rust-toolchain b/rust-toolchain index cd37a8d267e..0bddeb45c82 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-03-31 +nightly-2020-04-08