Skip to content

Commit a610056

Browse files
committed
Rust upgrade for new master rebase
1 parent fe22598 commit a610056

File tree

39 files changed

+115
-165
lines changed

39 files changed

+115
-165
lines changed

src/components/gfx/platform/android/font.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl FontHandleMethods for FontHandle {
103103
let face_index = 0 as FT_Long;
104104
let result = FT_New_Memory_Face(lib, cbuf, cbuflen as FT_Long,
105105
face_index, &mut face);
106-
106+
107107
if !result.succeeded() || face.is_null() {
108108
return Err(());
109109
}

src/components/gfx/platform/linux/font.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl FontHandleMethods for FontHandle {
103103
let face_index = 0 as FT_Long;
104104
let result = FT_New_Memory_Face(lib, cbuf, cbuflen as FT_Long,
105105
face_index, &mut face);
106-
106+
107107
if !result.succeeded() || face.is_null() {
108108
return Err(());
109109
}

src/components/gfx/render_task.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,9 @@ impl<C: RenderListener + Send,T:Send+Freeze> RenderTask<C,T> {
191191
render_task.start();
192192

193193
// Destroy all the buffers.
194-
{
195-
match render_task.native_graphics_context.as_ref() {
196-
Some(ctx) => render_task.buffer_map.clear(ctx),
197-
None => (),
198-
}
194+
match render_task.native_graphics_context.as_ref() {
195+
Some(ctx) => render_task.buffer_map.clear(ctx),
196+
None => (),
199197
}
200198
}
201199

src/components/gfx/text/glyph.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use servo_util::geometry;
1010
use std::cmp::{Ord, Eq};
1111
use std::num::NumCast;
1212
use std::mem;
13-
use std::uint;
13+
use std::u16;
1414
use std::vec;
1515
use std::iter;
1616
use geom::point::Point2D;
@@ -54,7 +54,7 @@ impl GlyphEntry {
5454
// Create a GlyphEntry for uncommon case; should be accompanied by
5555
// initialization of the actual DetailedGlyph data in DetailedGlyphStore
5656
fn complex(starts_cluster: bool, starts_ligature: bool, glyph_count: uint) -> GlyphEntry {
57-
assert!(glyph_count <= uint::MAX);
57+
assert!(glyph_count <= u16::MAX as uint);
5858

5959
debug!("creating complex glyph entry: starts_cluster={}, starts_ligature={}, \
6060
glyph_count={}",
@@ -78,7 +78,7 @@ impl GlyphEntry {
7878
/// Create a GlyphEntry for the case where glyphs couldn't be found for the specified
7979
/// character.
8080
fn missing(glyph_count: uint) -> GlyphEntry {
81-
assert!(glyph_count <= uint::MAX);
81+
assert!(glyph_count <= u16::MAX as uint);
8282

8383
GlyphEntry::new((glyph_count as u32) << GLYPH_COUNT_SHIFT)
8484
}

src/components/main/compositing/compositor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl IOCompositor {
228228
loop {
229229
match (self.port.try_recv(), self.shutting_down) {
230230
(Empty, _) => break,
231-
231+
232232
(Disconnected, _) => break,
233233

234234
(Data(Exit(chan)), _) => {

src/components/main/constellation.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,7 @@ impl Constellation {
540540
already_sent.insert(pipeline.id);
541541
}
542542
};
543-
544-
543+
545544
// If the subframe is in the current frame tree, the compositor needs the new size
546545
for current_frame in self.current_frame().iter() {
547546
debug!("Constellation: Sending size for frame in current frame tree.");

src/components/main/css/matching.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<'a> Hash for ApplicableDeclarationsCacheQuery<'a> {
122122
for declaration in self.declarations.iter() {
123123
let ptr: uint = unsafe {
124124
cast::transmute_copy(declaration)
125-
};
125+
};
126126
ptr.hash(state);
127127
}
128128
}

src/components/main/platform/common/glfw_windowing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl WindowMethods<Application> for Window {
147147
if !self.event_queue.with_mut(|queue| queue.is_empty()) {
148148
return self.event_queue.with_mut(|queue| queue.shift().unwrap())
149149
}
150-
150+
151151
glfw::poll_events();
152152
for (_, event) in self.glfw_window.flush_events() {
153153
self.handle_window_event(&self.glfw_window, event);

src/components/main/servo.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ pub mod windowing;
113113
#[path="platform/mod.rs"]
114114
pub mod platform;
115115

116-
#[path = "util/mod.rs"]
117-
pub mod util;
118-
119116
#[cfg(not(test), target_os="linux")]
120117
#[cfg(not(test), target_os="macos")]
121118
#[start]

src/components/main/util/mod.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/components/main/util/task.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/components/net/image/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
6161
Some(Image(image.width as u32, image.height as u32, png::RGBA8, image.data))
6262
}
6363
stb_image::ImageF32(_image) => fail!(~"HDR images not implemented"),
64-
stb_image::Error => None
64+
stb_image::Error(_) => None
6565
}
6666
}
6767
}

src/components/net/image/holder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl ImageHolder {
7474
// If this is the first time we've called this function, load
7575
// the image and store it for the future
7676
if self.image.is_none() {
77-
let port =
77+
let port =
7878
self.local_image_cache.access(|local_image_cache| {
7979
local_image_cache.get_image(&self.url)
8080
});

src/components/net/image_cache_task.rs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -481,18 +481,30 @@ fn load_image_data(url: Url, resource_task: ResourceTask) -> Result<~[u8], ()> {
481481
}
482482
483483
484+
pub fn spawn_listener<A: Send>(f: proc(Port<A>)) -> Chan<A> {
485+
let (setup_port, setup_chan) = Chan::new();
486+
487+
spawn(proc() {
488+
let (port, chan) = Chan::new();
489+
setup_chan.send(chan);
490+
f(port);
491+
});
492+
setup_port.recv()
493+
}
494+
495+
484496
#[cfg(test)]
485497
mod tests {
486498
use super::*;
487499
488500
use resource_task;
489501
use resource_task::{ResourceTask, Metadata, start_sending};
490502
use image::base::test_image_bin;
491-
use util::spawn_listener;
492503
use servo_util::url::parse_url;
504+
use std::comm::{Empty, Data, Disconnected};
493505
494506
fn mock_resource_task(on_load: proc(resource: Chan<resource_task::ProgressMsg>)) -> ResourceTask {
495-
spawn_listener("mock_resource_task", proc(port: Port<resource_task::ControlMsg>) {
507+
spawn_listener(proc(port: Port<resource_task::ControlMsg>) {
496508
loop {
497509
match port.recv() {
498510
resource_task::Load(_, response) => {
@@ -564,7 +576,10 @@ mod tests {
564576
url_requested.recv();
565577
image_cache_task.exit();
566578
mock_resource_task.send(resource_task::Exit);
567-
assert!(url_requested.try_recv().is_none())
579+
match url_requested.try_recv() {
580+
Empty | Disconnected => (),
581+
Data(_) => assert!(false),
582+
};
568583
}
569584

570585
#[test]
@@ -658,7 +673,7 @@ mod tests {
658673

659674
let (resource_task_exited, resource_task_exited_chan) = Chan::new();
660675

661-
let mock_resource_task = spawn_listener("should_not...already_available", proc(port: Port<resource_task::ControlMsg>) {
676+
let mock_resource_task = spawn_listener(proc(port: Port<resource_task::ControlMsg>) {
662677
loop {
663678
match port.recv() {
664679
resource_task::Load(_, response) => {
@@ -692,7 +707,10 @@ mod tests {
692707

693708
// Our resource task should not have received another request for the image
694709
// because it's already cached
695-
assert!(image_bin_sent.try_recv().is_none());
710+
match image_bin_sent.try_recv() {
711+
Empty | Disconnected => (),
712+
Data(_) => assert!(false),
713+
}
696714
}
697715

698716
#[test]
@@ -701,7 +719,7 @@ mod tests {
701719

702720
let (resource_task_exited, resource_task_exited_chan) = Chan::new();
703721

704-
let mock_resource_task = spawn_listener("should_not...already_failed", proc(port: Port<resource_task::ControlMsg>) {
722+
let mock_resource_task = spawn_listener(proc(port: Port<resource_task::ControlMsg>) {
705723
loop {
706724
match port.recv() {
707725
resource_task::Load(_, response) => {
@@ -737,7 +755,10 @@ mod tests {
737755

738756
// Our resource task should not have received another request for the image
739757
// because it's already cached
740-
assert!(image_bin_sent.try_recv().is_none());
758+
match image_bin_sent.try_recv() {
759+
Empty | Disconnected => (),
760+
Data(_) => assert!(false),
761+
}
741762
}
742763

743764
#[test]

src/components/net/net.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@ pub mod data_loader;
3333
pub mod image_cache_task;
3434
pub mod local_image_cache;
3535
pub mod resource_task;
36-
pub mod util;
3736

src/components/net/resource_task.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,6 @@ fn create_resource_task_with_loaders(loaders: ~[(~str, LoaderTaskFactory)]) -> R
143143
ResourceManager(port, loaders).start();
144144
});
145145
setup_port.recv()
146-
147-
// FIXME: code cloned from spawn_listener due to:
148-
// error: internal compiler error: cannot relate bound region: ReLateBound(6270, BrNamed(syntax::ast::DefId{krate: 0u32, node: 6294u32}, a)) <= ReInfer(1)
149-
//This message reflects a bug in the Rust compiler.
150-
151-
/*
152-
let chan = spawn_listener("ResourceManager", proc(from_client) {
153-
// TODO: change copy to move once we can move out of closures
154-
ResourceManager(from_client, loaders).start()
155-
});
156-
chan
157-
*/
158146
}
159147

160148
pub struct ResourceManager {

src/components/net/util.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/components/script/dom/bindings/codegen/CodegenRust.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def pickFirstSignature(condition, filterLambda):
370370

371371
overloadCGThings = []
372372
overloadCGThings.append(
373-
CGGeneric("let argcount = cmp::min(argc,%d);" %
373+
CGGeneric("let argcount = cmp::min(argc, %d);" %
374374
maxArgCount))
375375
overloadCGThings.append(
376376
CGSwitch("argcount",
@@ -3894,7 +3894,7 @@ def definition_body(self):
38943894
}*/
38953895
//MOZ_ASSERT(IsProxy(obj));
38963896
let box_: *%s = cast::transmute(GetProxyPrivate(obj).to_private());
3897-
return cast::transmute(&*box_);""" % (self.descriptor.concreteType)
3897+
return box_;""" % (self.descriptor.concreteType)
38983898

38993899
class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
39003900
def __init__(self, descriptor):
@@ -4203,7 +4203,7 @@ def __init__(self, descriptor, name, returnType, args):
42034203

42044204
def definition_body_prologue(self):
42054205
return """
4206-
let this: *%s = &*unwrap::<*%s>(obj);
4206+
let this: *%s = unwrap::<*%s>(obj);
42074207
""" % (self.descriptor.concreteType, self.descriptor.concreteType)
42084208

42094209
def definition_body(self):

src/components/script/dom/node.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,8 @@ enum CloneChildrenFlag {
732732
DoNotCloneChildren
733733
}
734734

735+
fn as_uintptr<T>(t: &T) -> uintptr_t { t as *T as uintptr_t }
736+
735737
impl Node {
736738
pub fn ancestors(&self) -> AncestorIterator {
737739
AncestorIterator {
@@ -1564,7 +1566,7 @@ impl Node {
15641566
match prev_text {
15651567
Some(ref text_node) => {
15661568
let mut prev_characterdata: JS<CharacterData> = CharacterDataCast::to(text_node);
1567-
prev_characterdata.get_mut().AppendData(characterdata.get().Data());
1569+
let _ = prev_characterdata.get_mut().AppendData(characterdata.get().Data());
15681570
abstract_self.remove_child(&mut child);
15691571
},
15701572
None => prev_text = Some(child)
@@ -1685,20 +1687,18 @@ impl Node {
16851687
}
16861688

16871689
if lastself != lastother {
1688-
unsafe {
1689-
let abstract_uint: uintptr_t = cast::transmute(abstract_self.get());
1690-
let other_uint: uintptr_t = cast::transmute(other.get());
1691-
1692-
let random = if abstract_uint < other_uint {
1693-
NodeConstants::DOCUMENT_POSITION_FOLLOWING
1694-
} else {
1695-
NodeConstants::DOCUMENT_POSITION_PRECEDING
1696-
};
1697-
// step 3.
1698-
return random +
1699-
NodeConstants::DOCUMENT_POSITION_DISCONNECTED +
1700-
NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
1701-
}
1690+
let abstract_uint: uintptr_t = as_uintptr(&abstract_self.get());
1691+
let other_uint: uintptr_t = as_uintptr(&other.get());
1692+
1693+
let random = if abstract_uint < other_uint {
1694+
NodeConstants::DOCUMENT_POSITION_FOLLOWING
1695+
} else {
1696+
NodeConstants::DOCUMENT_POSITION_PRECEDING
1697+
};
1698+
// step 3.
1699+
return random +
1700+
NodeConstants::DOCUMENT_POSITION_DISCONNECTED +
1701+
NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
17021702
}
17031703

17041704
for child in lastself.traverse_preorder() {

src/components/script/script_task.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ impl ScriptTask {
893893
// "load" event as soon as we've finished executing all scripts parsed during
894894
// the initial load.
895895
let mut event = Event::new(&window);
896-
let _ = event.get_mut().InitEvent(~"load", false, false);
896+
event.get_mut().InitEvent(~"load", false, false);
897897
let doctarget = EventTargetCast::from(&document);
898898
let mut wintarget: JS<EventTarget> = EventTargetCast::from(&window);
899899
let winclone = wintarget.clone();
@@ -1131,7 +1131,7 @@ impl ScriptTask {
11311131
} else {
11321132
let ConstellationChan(ref chan) = self.constellation_chan;
11331133
chan.send(LoadUrlMsg(page.id, url));
1134-
}
1134+
}
11351135
}
11361136
}
11371137
}

0 commit comments

Comments
 (0)