Skip to content

Commit

Permalink
Auto merge of #7643 - jdramani:extra_ptr_dref, r=jdm
Browse files Browse the repository at this point in the history
Check for Extra pointer dereferencing

Solves issue #7640

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7643)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Sep 27, 2015
2 parents a1fb8cf + 2a99915 commit 9523283
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion components/compositing/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions components/compositing/compositor_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions components/net/resource_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions components/style/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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!();

Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions python/tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 9523283

Please sign in to comment.