Skip to content

Commit

Permalink
WIP: firefox: backport some changes to fix build with newer rust
Browse files Browse the repository at this point in the history
* cssparser fails to build with:
  error[E0425]: cannot find value `MAX_LENGTH` in this scope
  error[E0425]: cannot find value `MAP` in this scope
  as shown in:
  http://errors.yoctoproject.org/Errors/Details/731831/

  which leads to
  rust-lang/rust#76480
  https://bugzilla.mozilla.org/show_bug.cgi?id=1663677

* but this still isn't enough to build firefox with current rust 1.71.0 in oe-core
  I've tried to backport multiple changes like:
  https://bugzilla.mozilla.org/show_bug.cgi?id=1663715#c5
  https://hg.mozilla.org/releases/mozilla-esr78/rev/5db8c1e9f643ec26fc93e7a3fc7a90c742b11030
  https://hg.mozilla.org/releases/mozilla-esr78/rev/6445a3a0e81d6aeeaa976be784edf2de9fab84de
  https://hg.mozilla.org/mozilla-central/rev/e2cede25c027
  https://phabricator.services.mozilla.com/D89473
  https://hg.mozilla.org/mozilla-central/rev/da77d5528a08
  https://phabricator.services.mozilla.com/D83816

* but it's neverending story of more and more fixes and esr68 is just
  too old and not worth spending more time on it (just to measure
  build time across different Yocto releases)

* still doesn't build
  http://errors.yoctoproject.org/Errors/Details/731829/

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
  • Loading branch information
shr-project committed Nov 15, 2023
1 parent 82e2184 commit b71c355
Show file tree
Hide file tree
Showing 8 changed files with 12,556 additions and 0 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
From bd43c2d63ed843668fe8cbc1b7cf4c3f67f4a9da Mon Sep 17 00:00:00 2001
From: Martin Jansa <Martin.Jansa@gmail.com>
Date: Wed, 16 Aug 2023 19:56:58 +0200
Subject: [PATCH] Backport D83816 to fix build with newer rust

Upstream-Status: Backport [https://hg.mozilla.org/mozilla-central/rev/da77d5528a08]
---
servo/components/derive_common/cg.rs | 22 +++++++++----------
.../style_derive/to_computed_value.rs | 4 +++-
2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/servo/components/derive_common/cg.rs b/servo/components/derive_common/cg.rs
index 7a8fbc2440..f66b7cde19 100644
--- a/servo/components/derive_common/cg.rs
+++ b/servo/components/derive_common/cg.rs
@@ -131,19 +131,19 @@ pub fn fmap_trait_output(input: &DeriveInput, trait_path: &Path, trait_output: &
segment.into()
}

-pub fn map_type_params<F>(ty: &Type, params: &[&TypeParam], f: &mut F) -> Type
+pub fn map_type_params<F>(ty: &Type, params: &[&TypeParam], self_type: &Path, f: &mut F) -> Type
where
F: FnMut(&Ident) -> Type,
{
match *ty {
Type::Slice(ref inner) => Type::from(TypeSlice {
- elem: Box::new(map_type_params(&inner.elem, params, f)),
+ elem: Box::new(map_type_params(&inner.elem, params, self_type, f)),
..inner.clone()
}),
Type::Array(ref inner) => {
//ref ty, ref expr) => {
Type::from(TypeArray {
- elem: Box::new(map_type_params(&inner.elem, params, f)),
+ elem: Box::new(map_type_params(&inner.elem, params, self_type, f)),
..inner.clone()
})
},
@@ -152,7 +152,7 @@ where
elems: inner
.elems
.iter()
- .map(|ty| map_type_params(&ty, params, f))
+ .map(|ty| map_type_params(&ty, params, self_type, f))
.collect(),
..inner.clone()
}),
@@ -167,7 +167,7 @@ where
}
Type::from(TypePath {
qself: None,
- path: map_type_params_in_path(path, params, f),
+ path: map_type_params_in_path(path, params, self_type, f),
})
},
Type::Path(TypePath {
@@ -175,21 +175,21 @@ where
ref path,
}) => Type::from(TypePath {
qself: qself.as_ref().map(|qself| QSelf {
- ty: Box::new(map_type_params(&qself.ty, params, f)),
+ ty: Box::new(map_type_params(&qself.ty, params, self_type, f)),
position: qself.position,
..qself.clone()
}),
- path: map_type_params_in_path(path, params, f),
+ path: map_type_params_in_path(path, params, self_type, f),
}),
Type::Paren(ref inner) => Type::from(TypeParen {
- elem: Box::new(map_type_params(&inner.elem, params, f)),
+ elem: Box::new(map_type_params(&inner.elem, params, self_type, f)),
..inner.clone()
}),
ref ty => panic!("type {:?} cannot be mapped yet", ty),
}
}

-fn map_type_params_in_path<F>(path: &Path, params: &[&TypeParam], f: &mut F) -> Path
+fn map_type_params_in_path<F>(path: &Path, params: &[&TypeParam], self_type: &Path, f: &mut F) -> Path
where
F: FnMut(&Ident) -> Type,
{
@@ -209,11 +209,11 @@ where
.map(|arg| match arg {
ty @ &GenericArgument::Lifetime(_) => ty.clone(),
&GenericArgument::Type(ref data) => {
- GenericArgument::Type(map_type_params(data, params, f))
+ GenericArgument::Type(map_type_params(data, params, self_type, f))
},
&GenericArgument::Binding(ref data) => {
GenericArgument::Binding(Binding {
- ty: map_type_params(&data.ty, params, f),
+ ty: map_type_params(&data.ty, params, self_type, f),
..data.clone()
})
},
diff --git a/servo/components/style_derive/to_computed_value.rs b/servo/components/style_derive/to_computed_value.rs
index ed6e07a2f5..c9b3b70051 100644
--- a/servo/components/style_derive/to_computed_value.rs
+++ b/servo/components/style_derive/to_computed_value.rs
@@ -58,6 +58,8 @@ pub fn derive_to_value(
cg::add_predicate(&mut where_clause, parse_quote!(#param: #trait_path));
}

+ let computed_value_type = cg::fmap_trait_output(&input, &trait_path, &output_type_name);
+
let to_body = cg::fmap_match(&input, bind_style, |binding| {
if field_bound(&binding) {
let ty = &binding.ast().ty;
@@ -65,6 +67,7 @@ pub fn derive_to_value(
let output_type = cg::map_type_params(
ty,
&params,
+ &computed_value_type,
&mut |ident| parse_quote!(<#ident as #trait_path>::#output_type_name),
);

@@ -84,7 +87,6 @@ pub fn derive_to_value(

input.generics.where_clause = where_clause;
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
- let computed_value_type = cg::fmap_trait_output(&input, &trait_path, &output_type_name);

let impl_ = trait_impl(from_body, to_body);

Loading

0 comments on commit b71c355

Please sign in to comment.