Don't use mem::transmute in from_gecko-weight

Fixes #16966.
This commit is contained in:
Malo Jaffré 2017-05-24 15:04:10 +02:00
parent 98edf5d54d
commit f867d6b66d

View file

@ -464,12 +464,13 @@ ${helpers.single_keyword_system("font-variant-caps",
} }
/// Obtain a Servo computed value from a Gecko computed font-weight /// Obtain a Servo computed value from a Gecko computed font-weight
pub unsafe fn from_gecko_weight(weight: u16) -> Self { pub fn from_gecko_weight(weight: u16) -> Self {
use std::mem::transmute; match weight {
debug_assert!(weight >= 100); % for weight in range(100, 901, 100):
debug_assert!(weight <= 900); ${weight} => T::Weight${weight},
debug_assert!(weight % 10 == 0); % endfor
transmute(weight) _ => panic!("from_gecko_weight: called with invalid weight")
}
} }
} }
} }
@ -2362,9 +2363,7 @@ ${helpers.single_keyword("-moz-math-variant",
quoted: true quoted: true
}) })
}).collect::<Vec<_>>(); }).collect::<Vec<_>>();
let weight = unsafe { let weight = longhands::font_weight::computed_value::T::from_gecko_weight(system.weight);
longhands::font_weight::computed_value::T::from_gecko_weight(system.weight)
};
let ret = ComputedSystemFont { let ret = ComputedSystemFont {
font_family: longhands::font_family::computed_value::T(family), font_family: longhands::font_family::computed_value::T(family),
font_size: Au(system.size), font_size: Au(system.size),