servo: Merge #7643 - Check for Extra pointer dereferencing (from jdramani:extra_ptr_dref); r=jdm

Solves issue #7640

Source-Repo: https://github.com/servo/servo
Source-Revision: 9523283c14f417014ca6d4fa8179c873bbb8f21f
This commit is contained in:
Jaydeep 2015-09-27 08:19:30 -06:00
parent d81e0107b7
commit 212fb34293
5 changed files with 15 additions and 10 deletions

View File

@ -681,7 +681,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn collect_old_layers(&mut self,
pipeline_id: PipelineId,
new_layers: &Vec<LayerProperties>) {
new_layers: &[LayerProperties]) {
let root_layer = match self.scene.root {
Some(ref root_layer) => root_layer.clone(),
None => return,

View File

@ -102,7 +102,7 @@ pub trait CompositorLayer {
fn collect_old_layers<Window>(&self,
compositor: &mut IOCompositor<Window>,
pipeline_id: PipelineId,
new_layers: &Vec<LayerProperties>)
new_layers: &[LayerProperties])
where Window: WindowMethods;
/// Destroys all tiles of all layers, including children, *without* sending them back to the
@ -282,7 +282,7 @@ impl CompositorLayer for Layer<CompositorData> {
fn collect_old_layers<Window>(&self,
compositor: &mut IOCompositor<Window>,
pipeline_id: PipelineId,
new_layers: &Vec<LayerProperties>)
new_layers: &[LayerProperties])
where Window: WindowMethods {
// Traverse children first so that layers are removed
// bottom up - allowing each layer being removed to properly

View File

@ -57,14 +57,14 @@ pub fn start_sending(start_chan: LoadConsumer, metadata: Metadata) -> ProgressSe
/// For use by loaders in responding to a Load message that allows content sniffing.
pub fn start_sending_sniffed(start_chan: LoadConsumer, metadata: Metadata,
classifier: Arc<MIMEClassifier>, partial_body: &Vec<u8>)
classifier: Arc<MIMEClassifier>, partial_body: &[u8])
-> ProgressSender {
start_sending_sniffed_opt(start_chan, metadata, classifier, partial_body).ok().unwrap()
}
/// For use by loaders in responding to a Load message that allows content sniffing.
pub fn start_sending_sniffed_opt(start_chan: LoadConsumer, mut metadata: Metadata,
classifier: Arc<MIMEClassifier>, partial_body: &Vec<u8>)
classifier: Arc<MIMEClassifier>, partial_body: &[u8])
-> Result<ProgressSender, ()> {
if opts::get().sniff_mime_types {
// TODO: should be calculated in the resource loader, from pull requeset #4094

View File

@ -736,8 +736,8 @@ impl Interpolate for TextShadowList {
/// Check if it's possible to do a direct numerical interpolation
/// between these two transform lists.
/// http://dev.w3.org/csswg/css-transforms/#transform-transform-animation
fn can_interpolate_list(from_list: &Vec<TransformOperation>,
to_list: &Vec<TransformOperation>) -> bool {
fn can_interpolate_list(from_list: &[TransformOperation],
to_list: &[TransformOperation]) -> bool {
// Lists must be equal length
if from_list.len() != to_list.len() {
return false;
@ -763,8 +763,8 @@ fn can_interpolate_list(from_list: &Vec<TransformOperation>,
/// Interpolate two transform lists.
/// http://dev.w3.org/csswg/css-transforms/#interpolation-of-transforms
fn interpolate_transform_list(from_list: &Vec<TransformOperation>,
to_list: &Vec<TransformOperation>,
fn interpolate_transform_list(from_list: &[TransformOperation],
to_list: &[TransformOperation],
time: f64) -> TransformList {
let mut result = vec!();
@ -823,7 +823,7 @@ fn interpolate_transform_list(from_list: &Vec<TransformOperation>,
/// Build an equivalent 'identity transform function list' based
/// on an existing transform list.
/// http://dev.w3.org/csswg/css-transforms/#none-transform-animation
fn build_identity_transform_list(list: &Vec<TransformOperation>) -> Vec<TransformOperation> {
fn build_identity_transform_list(list: &[TransformOperation]) -> Vec<TransformOperation> {
let mut result = vec!();
for operation in list {

View File

@ -111,6 +111,7 @@ def check_by_line(file_name, contents):
check_whitespace(idx, line),
check_whatwg_url(idx, line),
)
for error in errors:
yield error
@ -349,6 +350,10 @@ def check_rust(file_name, contents):
yield (idx + 1 - len(mods) + i, message + expected + found)
mods = []
# There should not be any extra pointer dereferencing
if re.search(r": &Vec<", line) is not None:
yield (idx + 1, "use &[T] instead of &Vec<T>")
# Avoid flagging <Item=Foo> constructs
def is_associated_type(match, line, index):