diff --git a/ports/jniapi/build.rs b/ports/jniapi/build.rs index 759c2376f20..896487d80d5 100644 --- a/ports/jniapi/build.rs +++ b/ports/jniapi/build.rs @@ -28,7 +28,7 @@ fn main() { // Generate GL bindings. For now, we only support EGL. if target.contains("android") { - let mut file = File::create(&dest.join("egl_bindings.rs")).unwrap(); + let mut file = File::create(dest.join("egl_bindings.rs")).unwrap(); Registry::new(Api::Egl, (1, 5), Profile::Core, Fallbacks::All, []) .write_bindings(gl_generator::StaticStructGenerator, &mut file) .unwrap(); @@ -38,6 +38,6 @@ fn main() { let mut default_prefs = PathBuf::from(env!("CARGO_MANIFEST_DIR")); default_prefs.push("../../resources/prefs.json"); let prefs: Value = serde_json::from_reader(File::open(&default_prefs).unwrap()).unwrap(); - let file = File::create(&dest.join("prefs.json")).unwrap(); + let file = File::create(dest.join("prefs.json")).unwrap(); serde_json::to_writer(file, &prefs).unwrap(); } diff --git a/ports/servoshell/app.rs b/ports/servoshell/app.rs index 099b613ea62..1a7c1587657 100644 --- a/ports/servoshell/app.rs +++ b/ports/servoshell/app.rs @@ -84,11 +84,9 @@ impl App { // Handle browser state. let webviews = WebViewManager::new(window.clone()); - let initial_url = get_default_url( - url.as_ref().map(String::as_str), - env::current_dir().unwrap(), - |path| fs::metadata(path).is_ok(), - ); + let initial_url = get_default_url(url.as_deref(), env::current_dir().unwrap(), |path| { + fs::metadata(path).is_ok() + }); let mut app = App { event_queue: RefCell::new(vec![]), @@ -270,7 +268,7 @@ impl App { window.winit_window().unwrap().request_redraw(); }, winit::event::Event::WindowEvent { ref event, .. } => { - let response = minibrowser.on_event(&event); + let response = minibrowser.on_event(event); if response.repaint { // Request a winit redraw event, so we can recomposite, update and paint // the minibrowser, and present the new frame. diff --git a/ports/servoshell/parser.rs b/ports/servoshell/parser.rs index 860fe5a9484..e1a6334a5b9 100644 --- a/ports/servoshell/parser.rs +++ b/ports/servoshell/parser.rs @@ -28,17 +28,14 @@ pub fn get_default_url( // If the url is not provided, we fallback to the homepage in prefs, // or a blank page in case the homepage is not set either. let mut new_url = None; - let cmdline_url = url_opt - .clone() - .map(|s| s.to_string()) - .and_then(|url_string| { - parse_url_or_filename(cwd.as_ref(), &url_string) - .map_err(|error| { - warn!("URL parsing failed ({:?}).", error); - error - }) - .ok() - }); + let cmdline_url = url_opt.map(|s| s.to_string()).and_then(|url_string| { + parse_url_or_filename(cwd.as_ref(), &url_string) + .map_err(|error| { + warn!("URL parsing failed ({:?}).", error); + error + }) + .ok() + }); if let Some(url) = cmdline_url.clone() { // Check if the URL path corresponds to a file @@ -50,7 +47,7 @@ pub fn get_default_url( } } - if new_url.is_none() && !url_opt.is_none() { + if new_url.is_none() && url_opt.is_some() { new_url = location_bar_input_to_url(url_opt.unwrap()); } diff --git a/ports/servoshell/test.rs b/ports/servoshell/test.rs index c715350c7b6..0ee94d44829 100644 --- a/ports/servoshell/test.rs +++ b/ports/servoshell/test.rs @@ -7,7 +7,7 @@ use std::path::Path; use crate::parser::{get_default_url, location_bar_input_to_url, parse_url_or_filename}; #[cfg(not(target_os = "windows"))] -const FAKE_CWD: &'static str = "/fake/cwd"; +const FAKE_CWD: &str = "/fake/cwd"; #[cfg(target_os = "windows")] const FAKE_CWD: &'static str = "C:/fake/cwd"; diff --git a/support/crown/src/trace_in_no_trace.rs b/support/crown/src/trace_in_no_trace.rs index 917a2c7459b..a0936e31278 100644 --- a/support/crown/src/trace_in_no_trace.rs +++ b/support/crown/src/trace_in_no_trace.rs @@ -127,7 +127,7 @@ fn incorrect_no_trace<'tcx, I: Into + Copy>( let recur_into_subtree = match t.kind() { ty::Adt(did, substs) => { if let Some(pos) = - get_must_not_have_traceable(sym, &cx.tcx.get_attrs_unchecked(did.did())) + get_must_not_have_traceable(sym, cx.tcx.get_attrs_unchecked(did.did())) { let inner = substs.type_at(pos); if inner.is_primitive_ty() { @@ -169,7 +169,7 @@ impl<'tcx> LateLintPass<'tcx> for NotracePass { return; }*/ if let hir::ItemKind::Struct(def, ..) = &item.kind { - for ref field in def.fields() { + for field in def.fields() { let field_type = cx.tcx.type_of(field.def_id); incorrect_no_trace(&self.symbols, cx, field_type.skip_binder(), field.span); } diff --git a/support/crown/src/unrooted_must_root.rs b/support/crown/src/unrooted_must_root.rs index d01ede4c0bb..5cef81f59a1 100644 --- a/support/crown/src/unrooted_must_root.rs +++ b/support/crown/src/unrooted_must_root.rs @@ -86,7 +86,7 @@ fn is_unrooted_ty<'tcx>( let recur_into_subtree = match t.kind() { ty::Adt(did, substs) => { let has_attr = - |did, name| has_lint_attr(sym, &cx.tcx.get_attrs_unchecked(did), name); + |did, name| has_lint_attr(sym, cx.tcx.get_attrs_unchecked(did), name); if has_attr(did.did(), sym.must_root) { ret = true; false @@ -96,11 +96,7 @@ fn is_unrooted_ty<'tcx>( // Rc is okay let inner = substs.type_at(0); if let ty::Adt(did, _) = inner.kind() { - if has_attr(did.did(), sym.allow_unrooted_in_rc) { - false - } else { - true - } + !has_attr(did.did(), sym.allow_unrooted_in_rc) } else { true } @@ -185,11 +181,11 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass { /// must be #[crown::unrooted_must_root_lint::must_root] themselves fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item) { let attrs = cx.tcx.hir().attrs(item.hir_id()); - if has_lint_attr(&self.symbols, &attrs, self.symbols.must_root) { + if has_lint_attr(&self.symbols, attrs, self.symbols.must_root) { return; } if let hir::ItemKind::Struct(def, ..) = &item.kind { - for ref field in def.fields() { + for field in def.fields() { let field_type = cx.tcx.type_of(field.def_id); if is_unrooted_ty(&self.symbols, cx, field_type.skip_binder(), false) { cx.lint( @@ -206,10 +202,10 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass { /// All enums containing #[crown::unrooted_must_root_lint::must_root] types /// must be #[crown::unrooted_must_root_lint::must_root] themselves fn check_variant(&mut self, cx: &LateContext, var: &hir::Variant) { - let ref map = cx.tcx.hir(); + let map = &cx.tcx.hir(); let parent_item = map.expect_item(map.get_parent_item(var.hir_id).def_id); let attrs = cx.tcx.hir().attrs(parent_item.hir_id()); - if !has_lint_attr(&self.symbols, &attrs, self.symbols.must_root) { + if !has_lint_attr(&self.symbols, attrs, self.symbols.must_root) { match var.data { hir::VariantData::Tuple(fields, ..) => { for field in fields { @@ -241,7 +237,7 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass { ) { let in_new_function = match kind { visit::FnKind::ItemFn(n, _, _) | visit::FnKind::Method(n, _) => { - &*n.as_str() == "new" || n.as_str().starts_with("new_") + n.as_str() == "new" || n.as_str().starts_with("new_") }, visit::FnKind::Closure => return, }; @@ -271,7 +267,7 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass { cx, in_new_function, }; - visit::walk_expr(&mut visitor, &body.value); + visit::walk_expr(&mut visitor, body.value); } } @@ -288,8 +284,8 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> { let cx = self.cx; let require_rooted = |cx: &LateContext, in_new_function: bool, subexpr: &hir::Expr| { - let ty = cx.typeck_results().expr_ty(&subexpr); - if is_unrooted_ty(&self.symbols, cx, ty, in_new_function) { + let ty = cx.typeck_results().expr_ty(subexpr); + if is_unrooted_ty(self.symbols, cx, ty, in_new_function) { cx.lint( UNROOTED_MUST_ROOT, format!("Expression of type {:?} must be rooted", ty), @@ -300,7 +296,7 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for FnDefVisitor<'a, 'tcx> { match expr.kind { // Trait casts from #[crown::unrooted_must_root_lint::must_root] types are not allowed - ExprKind::Cast(subexpr, _) => require_rooted(cx, self.in_new_function, &subexpr), + ExprKind::Cast(subexpr, _) => require_rooted(cx, self.in_new_function, subexpr), // This catches assignments... the main point of this would be to catch mutable // references to `JS`. // FIXME: Enable this? Triggers on certain kinds of uses of DomRefCell. diff --git a/tests/unit/style/parsing/selectors.rs b/tests/unit/style/parsing/selectors.rs index 5e65bd504e6..edab3243b0a 100644 --- a/tests/unit/style/parsing/selectors.rs +++ b/tests/unit/style/parsing/selectors.rs @@ -9,8 +9,8 @@ use style::stylesheets::{Namespaces, Origin}; use style_traits::ParseError; use url::Url; -fn parse_selector<'i, 't>( - input: &mut Parser<'i, 't>, +fn parse_selector<'i>( + input: &mut Parser<'i, '_>, ) -> Result, ParseError<'i>> { let mut ns = Namespaces::default(); ns.prefixes diff --git a/tests/unit/style/str.rs b/tests/unit/style/str.rs index 9445ce167cc..6730bc21672 100644 --- a/tests/unit/style/str.rs +++ b/tests/unit/style/str.rs @@ -17,7 +17,7 @@ pub fn split_html_space_chars_whitespace() { #[test] pub fn test_str_join_empty() { let slice: [&str; 0] = []; - let actual = str_join(&slice, "-"); + let actual = str_join(slice, "-"); let expected = ""; assert_eq!(actual, expected); } @@ -25,7 +25,7 @@ pub fn test_str_join_empty() { #[test] pub fn test_str_join_one() { let slice = ["alpha"]; - let actual = str_join(&slice, "-"); + let actual = str_join(slice, "-"); let expected = "alpha"; assert_eq!(actual, expected); } @@ -33,7 +33,7 @@ pub fn test_str_join_one() { #[test] pub fn test_str_join_many() { let slice = ["", "alpha", "", "beta", "gamma", ""]; - let actual = str_join(&slice, "-"); + let actual = str_join(slice, "-"); let expected = "-alpha--beta-gamma-"; assert_eq!(actual, expected); } diff --git a/tests/unit/style/stylist.rs b/tests/unit/style/stylist.rs index 043774403e7..a1f2701411d 100644 --- a/tests/unit/style/stylist.rs +++ b/tests/unit/style/stylist.rs @@ -35,7 +35,7 @@ fn get_mock_rules(css_selectors: &[&str]) -> (Vec>, SharedRwLock) { .unwrap(); let locked = Arc::new(shared_lock.wrap(StyleRule { - selectors: selectors, + selectors, block: Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one( PropertyDeclaration::Display(longhands::display::SpecifiedValue::Block), Importance::Normal, @@ -75,7 +75,7 @@ fn parse_selectors(selectors: &[&str]) -> Vec> { .unwrap() .0 .into_iter() - .nth(0) + .next() .unwrap() }) .collect() @@ -130,7 +130,7 @@ fn test_revalidation_selectors() { "p:first-child span", ]) .into_iter() - .filter(|s| needs_revalidation_for_testing(&s)) + .filter(needs_revalidation_for_testing) .collect::>(); let reference = parse_selectors(&[