mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
clippy: fix warnings on modules outside components (#31567)
This commit is contained in:
parent
3b19189896
commit
6c7fe31db1
9 changed files with 37 additions and 46 deletions
|
@ -28,7 +28,7 @@ fn main() {
|
||||||
|
|
||||||
// Generate GL bindings. For now, we only support EGL.
|
// Generate GL bindings. For now, we only support EGL.
|
||||||
if target.contains("android") {
|
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, [])
|
Registry::new(Api::Egl, (1, 5), Profile::Core, Fallbacks::All, [])
|
||||||
.write_bindings(gl_generator::StaticStructGenerator, &mut file)
|
.write_bindings(gl_generator::StaticStructGenerator, &mut file)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -38,6 +38,6 @@ fn main() {
|
||||||
let mut default_prefs = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
let mut default_prefs = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||||
default_prefs.push("../../resources/prefs.json");
|
default_prefs.push("../../resources/prefs.json");
|
||||||
let prefs: Value = serde_json::from_reader(File::open(&default_prefs).unwrap()).unwrap();
|
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();
|
serde_json::to_writer(file, &prefs).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,11 +84,9 @@ impl App {
|
||||||
|
|
||||||
// Handle browser state.
|
// Handle browser state.
|
||||||
let webviews = WebViewManager::new(window.clone());
|
let webviews = WebViewManager::new(window.clone());
|
||||||
let initial_url = get_default_url(
|
let initial_url = get_default_url(url.as_deref(), env::current_dir().unwrap(), |path| {
|
||||||
url.as_ref().map(String::as_str),
|
fs::metadata(path).is_ok()
|
||||||
env::current_dir().unwrap(),
|
});
|
||||||
|path| fs::metadata(path).is_ok(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut app = App {
|
let mut app = App {
|
||||||
event_queue: RefCell::new(vec![]),
|
event_queue: RefCell::new(vec![]),
|
||||||
|
@ -270,7 +268,7 @@ impl App {
|
||||||
window.winit_window().unwrap().request_redraw();
|
window.winit_window().unwrap().request_redraw();
|
||||||
},
|
},
|
||||||
winit::event::Event::WindowEvent { ref event, .. } => {
|
winit::event::Event::WindowEvent { ref event, .. } => {
|
||||||
let response = minibrowser.on_event(&event);
|
let response = minibrowser.on_event(event);
|
||||||
if response.repaint {
|
if response.repaint {
|
||||||
// Request a winit redraw event, so we can recomposite, update and paint
|
// Request a winit redraw event, so we can recomposite, update and paint
|
||||||
// the minibrowser, and present the new frame.
|
// the minibrowser, and present the new frame.
|
||||||
|
|
|
@ -28,10 +28,7 @@ pub fn get_default_url(
|
||||||
// If the url is not provided, we fallback to the homepage in prefs,
|
// 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.
|
// or a blank page in case the homepage is not set either.
|
||||||
let mut new_url = None;
|
let mut new_url = None;
|
||||||
let cmdline_url = url_opt
|
let cmdline_url = url_opt.map(|s| s.to_string()).and_then(|url_string| {
|
||||||
.clone()
|
|
||||||
.map(|s| s.to_string())
|
|
||||||
.and_then(|url_string| {
|
|
||||||
parse_url_or_filename(cwd.as_ref(), &url_string)
|
parse_url_or_filename(cwd.as_ref(), &url_string)
|
||||||
.map_err(|error| {
|
.map_err(|error| {
|
||||||
warn!("URL parsing failed ({:?}).", error);
|
warn!("URL parsing failed ({:?}).", error);
|
||||||
|
@ -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());
|
new_url = location_bar_input_to_url(url_opt.unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::path::Path;
|
||||||
use crate::parser::{get_default_url, location_bar_input_to_url, parse_url_or_filename};
|
use crate::parser::{get_default_url, location_bar_input_to_url, parse_url_or_filename};
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
const FAKE_CWD: &'static str = "/fake/cwd";
|
const FAKE_CWD: &str = "/fake/cwd";
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
const FAKE_CWD: &'static str = "C:/fake/cwd";
|
const FAKE_CWD: &'static str = "C:/fake/cwd";
|
||||||
|
|
|
@ -127,7 +127,7 @@ fn incorrect_no_trace<'tcx, I: Into<MultiSpan> + Copy>(
|
||||||
let recur_into_subtree = match t.kind() {
|
let recur_into_subtree = match t.kind() {
|
||||||
ty::Adt(did, substs) => {
|
ty::Adt(did, substs) => {
|
||||||
if let Some(pos) =
|
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);
|
let inner = substs.type_at(pos);
|
||||||
if inner.is_primitive_ty() {
|
if inner.is_primitive_ty() {
|
||||||
|
@ -169,7 +169,7 @@ impl<'tcx> LateLintPass<'tcx> for NotracePass {
|
||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
if let hir::ItemKind::Struct(def, ..) = &item.kind {
|
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);
|
let field_type = cx.tcx.type_of(field.def_id);
|
||||||
incorrect_no_trace(&self.symbols, cx, field_type.skip_binder(), field.span);
|
incorrect_no_trace(&self.symbols, cx, field_type.skip_binder(), field.span);
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ fn is_unrooted_ty<'tcx>(
|
||||||
let recur_into_subtree = match t.kind() {
|
let recur_into_subtree = match t.kind() {
|
||||||
ty::Adt(did, substs) => {
|
ty::Adt(did, substs) => {
|
||||||
let has_attr =
|
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) {
|
if has_attr(did.did(), sym.must_root) {
|
||||||
ret = true;
|
ret = true;
|
||||||
false
|
false
|
||||||
|
@ -96,11 +96,7 @@ fn is_unrooted_ty<'tcx>(
|
||||||
// Rc<Promise> is okay
|
// Rc<Promise> is okay
|
||||||
let inner = substs.type_at(0);
|
let inner = substs.type_at(0);
|
||||||
if let ty::Adt(did, _) = inner.kind() {
|
if let ty::Adt(did, _) = inner.kind() {
|
||||||
if has_attr(did.did(), sym.allow_unrooted_in_rc) {
|
!has_attr(did.did(), sym.allow_unrooted_in_rc)
|
||||||
false
|
|
||||||
} else {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -185,11 +181,11 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
||||||
/// must be #[crown::unrooted_must_root_lint::must_root] themselves
|
/// must be #[crown::unrooted_must_root_lint::must_root] themselves
|
||||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item) {
|
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item) {
|
||||||
let attrs = cx.tcx.hir().attrs(item.hir_id());
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if let hir::ItemKind::Struct(def, ..) = &item.kind {
|
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);
|
let field_type = cx.tcx.type_of(field.def_id);
|
||||||
if is_unrooted_ty(&self.symbols, cx, field_type.skip_binder(), false) {
|
if is_unrooted_ty(&self.symbols, cx, field_type.skip_binder(), false) {
|
||||||
cx.lint(
|
cx.lint(
|
||||||
|
@ -206,10 +202,10 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
||||||
/// All enums containing #[crown::unrooted_must_root_lint::must_root] types
|
/// All enums containing #[crown::unrooted_must_root_lint::must_root] types
|
||||||
/// must be #[crown::unrooted_must_root_lint::must_root] themselves
|
/// must be #[crown::unrooted_must_root_lint::must_root] themselves
|
||||||
fn check_variant(&mut self, cx: &LateContext, var: &hir::Variant) {
|
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 parent_item = map.expect_item(map.get_parent_item(var.hir_id).def_id);
|
||||||
let attrs = cx.tcx.hir().attrs(parent_item.hir_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 {
|
match var.data {
|
||||||
hir::VariantData::Tuple(fields, ..) => {
|
hir::VariantData::Tuple(fields, ..) => {
|
||||||
for field in fields {
|
for field in fields {
|
||||||
|
@ -241,7 +237,7 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
||||||
) {
|
) {
|
||||||
let in_new_function = match kind {
|
let in_new_function = match kind {
|
||||||
visit::FnKind::ItemFn(n, _, _) | visit::FnKind::Method(n, _) => {
|
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,
|
visit::FnKind::Closure => return,
|
||||||
};
|
};
|
||||||
|
@ -271,7 +267,7 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass {
|
||||||
cx,
|
cx,
|
||||||
in_new_function,
|
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 cx = self.cx;
|
||||||
|
|
||||||
let require_rooted = |cx: &LateContext, in_new_function: bool, subexpr: &hir::Expr| {
|
let require_rooted = |cx: &LateContext, in_new_function: bool, subexpr: &hir::Expr| {
|
||||||
let ty = cx.typeck_results().expr_ty(&subexpr);
|
let ty = cx.typeck_results().expr_ty(subexpr);
|
||||||
if is_unrooted_ty(&self.symbols, cx, ty, in_new_function) {
|
if is_unrooted_ty(self.symbols, cx, ty, in_new_function) {
|
||||||
cx.lint(
|
cx.lint(
|
||||||
UNROOTED_MUST_ROOT,
|
UNROOTED_MUST_ROOT,
|
||||||
format!("Expression of type {:?} must be rooted", ty),
|
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 {
|
match expr.kind {
|
||||||
// Trait casts from #[crown::unrooted_must_root_lint::must_root] types are not allowed
|
// 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
|
// This catches assignments... the main point of this would be to catch mutable
|
||||||
// references to `JS<T>`.
|
// references to `JS<T>`.
|
||||||
// FIXME: Enable this? Triggers on certain kinds of uses of DomRefCell.
|
// FIXME: Enable this? Triggers on certain kinds of uses of DomRefCell.
|
||||||
|
|
|
@ -9,8 +9,8 @@ use style::stylesheets::{Namespaces, Origin};
|
||||||
use style_traits::ParseError;
|
use style_traits::ParseError;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
fn parse_selector<'i, 't>(
|
fn parse_selector<'i>(
|
||||||
input: &mut Parser<'i, 't>,
|
input: &mut Parser<'i, '_>,
|
||||||
) -> Result<SelectorList<SelectorImpl>, ParseError<'i>> {
|
) -> Result<SelectorList<SelectorImpl>, ParseError<'i>> {
|
||||||
let mut ns = Namespaces::default();
|
let mut ns = Namespaces::default();
|
||||||
ns.prefixes
|
ns.prefixes
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub fn split_html_space_chars_whitespace() {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_str_join_empty() {
|
pub fn test_str_join_empty() {
|
||||||
let slice: [&str; 0] = [];
|
let slice: [&str; 0] = [];
|
||||||
let actual = str_join(&slice, "-");
|
let actual = str_join(slice, "-");
|
||||||
let expected = "";
|
let expected = "";
|
||||||
assert_eq!(actual, expected);
|
assert_eq!(actual, expected);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ pub fn test_str_join_empty() {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_str_join_one() {
|
pub fn test_str_join_one() {
|
||||||
let slice = ["alpha"];
|
let slice = ["alpha"];
|
||||||
let actual = str_join(&slice, "-");
|
let actual = str_join(slice, "-");
|
||||||
let expected = "alpha";
|
let expected = "alpha";
|
||||||
assert_eq!(actual, expected);
|
assert_eq!(actual, expected);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ pub fn test_str_join_one() {
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_str_join_many() {
|
pub fn test_str_join_many() {
|
||||||
let slice = ["", "alpha", "", "beta", "gamma", ""];
|
let slice = ["", "alpha", "", "beta", "gamma", ""];
|
||||||
let actual = str_join(&slice, "-");
|
let actual = str_join(slice, "-");
|
||||||
let expected = "-alpha--beta-gamma-";
|
let expected = "-alpha--beta-gamma-";
|
||||||
assert_eq!(actual, expected);
|
assert_eq!(actual, expected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ fn get_mock_rules(css_selectors: &[&str]) -> (Vec<Vec<Rule>>, SharedRwLock) {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let locked = Arc::new(shared_lock.wrap(StyleRule {
|
let locked = Arc::new(shared_lock.wrap(StyleRule {
|
||||||
selectors: selectors,
|
selectors,
|
||||||
block: Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one(
|
block: Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one(
|
||||||
PropertyDeclaration::Display(longhands::display::SpecifiedValue::Block),
|
PropertyDeclaration::Display(longhands::display::SpecifiedValue::Block),
|
||||||
Importance::Normal,
|
Importance::Normal,
|
||||||
|
@ -75,7 +75,7 @@ fn parse_selectors(selectors: &[&str]) -> Vec<Selector<SelectorImpl>> {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.0
|
.0
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.nth(0)
|
.next()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
@ -130,7 +130,7 @@ fn test_revalidation_selectors() {
|
||||||
"p:first-child span",
|
"p:first-child span",
|
||||||
])
|
])
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|s| needs_revalidation_for_testing(&s))
|
.filter(needs_revalidation_for_testing)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let reference = parse_selectors(&[
|
let reference = parse_selectors(&[
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue