Upgrade to rustc 551a74dddd84cf01440ee84148ebd18bc68bd7c8.

This commit is contained in:
Simon Sapin 2015-04-23 00:14:02 +02:00 committed by Josh Matthews
parent 7b87085c18
commit ef8edd4e87
168 changed files with 2247 additions and 2408 deletions

View file

@ -14,7 +14,7 @@ use dom::node::window_from_node;
use std::borrow::ToOwned;
/// Trait for elements with defined activation behavior
pub trait Activatable : Copy {
pub trait Activatable {
fn as_element(&self) -> Temporary<Element>;
// Is this particular instance of the element activatable?

View file

@ -56,15 +56,14 @@ use js::jsval::{UndefinedValue, NullValue, BooleanValue, Int32Value, UInt32Value
use js::jsval::{StringValue, ObjectValue, ObjectOrNullValue};
use libc;
use num::Float;
use std::borrow::ToOwned;
use std::default;
use std::marker::MarkerTrait;
use std::num::Float;
use std::slice;
/// A trait to retrieve the constants necessary to check if a `JSObject`
/// implements a given interface.
pub trait IDLInterface: MarkerTrait {
pub trait IDLInterface {
/// Returns the prototype ID.
fn get_prototype_id() -> PrototypeList::ID;
/// Returns the prototype depth, i.e., the number of interfaces this

View file

@ -641,7 +641,6 @@ impl<T: Reflectable> Root<T> {
}
}
#[unsafe_destructor]
impl<T: Reflectable> Drop for Root<T> {
fn drop(&mut self) {
self.root_list.unroot(self);

View file

@ -5,7 +5,7 @@
//! The `Finite<T>` struct.
use core::nonzero::Zeroable;
use std::num::Float;
use num::Float;
use std::ops::Deref;
/// Encapsulates the IDL restricted float type.

View file

@ -110,7 +110,6 @@ impl<T: Reflectable> Clone for Trusted<T> {
}
}
#[unsafe_destructor]
impl<T: Reflectable> Drop for Trusted<T> {
fn drop(&mut self) {
let mut refcount = self.refcount.lock().unwrap();

View file

@ -56,7 +56,7 @@ use script_traits::UntrustedNodeAddress;
use msg::compositor_msg::ScriptListener;
use msg::constellation_msg::ConstellationChan;
use net_traits::image::base::Image;
use util::smallvec::{SmallVec1, SmallVec};
use util::smallvec::SmallVec1;
use util::str::{LengthOrPercentageOrAuto};
use std::cell::{Cell, RefCell};
use std::collections::{HashMap, HashSet};
@ -64,7 +64,6 @@ use std::collections::hash_state::HashState;
use std::ffi::CString;
use std::hash::{Hash, Hasher};
use std::intrinsics::return_address;
use std::old_io::timer::Timer;
use std::ops::{Deref, DerefMut};
use std::rc::Rc;
use std::sync::Arc;
@ -252,7 +251,7 @@ no_jsmanaged_fields!(Receiver<T>);
no_jsmanaged_fields!(Rect<T>);
no_jsmanaged_fields!(Arc<T>);
no_jsmanaged_fields!(Image, ImageCacheChan, ImageCacheTask, ScriptControlChan);
no_jsmanaged_fields!(Atom, Namespace, Timer);
no_jsmanaged_fields!(Atom, Namespace);
no_jsmanaged_fields!(Trusted<T>);
no_jsmanaged_fields!(PropertyDeclarationBlock);
no_jsmanaged_fields!(HashSet<T>);
@ -444,7 +443,6 @@ impl<T: VecRootableType> RootedVec<T> {
}
}
#[unsafe_destructor]
impl<T: VecRootableType> Drop for RootedVec<T> {
fn drop(&mut self) {
RootedCollectionSet::remove(self);

View file

@ -639,7 +639,7 @@ pub fn validate_and_extract(namespace: Option<DOMString>, qualified_name: &str)
let (prefix, local_name) = if qualified_name.contains(":") {
// Step 5.
let mut parts = qualified_name.splitn(1, ':');
let mut parts = qualified_name.splitn(2, ':');
let prefix = parts.next().unwrap();
debug_assert!(!prefix.is_empty());
let local_name = parts.next().unwrap();

View file

@ -12,10 +12,10 @@ use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
use util::str::DOMString;
use num::ToPrimitive;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::cmp::{min, max};
use std::num::ToPrimitive;
#[jstraceable]
pub enum BlobTypeId {

View file

@ -36,9 +36,9 @@ use net_traits::image::base::Image;
use net_traits::image_cache_task::ImageCacheChan;
use png::PixelsByColorType;
use num::{Float, ToPrimitive};
use std::borrow::ToOwned;
use std::cell::RefCell;
use std::num::{Float, ToPrimitive};
use std::sync::{Arc};
use std::sync::mpsc::{channel, Sender};
@ -977,7 +977,6 @@ impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D>
}
}
#[unsafe_destructor]
impl Drop for CanvasRenderingContext2D {
fn drop(&mut self) {
self.renderer.send(CanvasMsg::Common(CanvasCommonMsg::Close)).unwrap();

View file

@ -84,7 +84,6 @@ impl<'a> AutoWorkerReset<'a> {
}
}
#[unsafe_destructor]
impl<'a> Drop for AutoWorkerReset<'a> {
fn drop(&mut self) {
*self.workerscope.worker.borrow_mut() = self.old_worker.clone();

View file

@ -81,6 +81,7 @@ use string_cache::{Atom, QualName};
use url::Url;
use js::jsapi::JSRuntime;
use num::ToPrimitive;
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
@ -88,7 +89,6 @@ use std::ascii::AsciiExt;
use std::cell::{Cell, Ref};
use std::default::Default;
use std::sync::mpsc::channel;
use std::num::ToPrimitive;
use time;
#[derive(PartialEq)]

View file

@ -10,7 +10,6 @@ use dom::bindings::num::Finite;
use dom::bindings::utils::{Reflector, reflect_dom_object};
use dom::window::Window;
use util::geometry::Au;
use std::num::Float;
#[dom_struct]
pub struct DOMRect {

View file

@ -64,6 +64,7 @@ use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, parse_sty
use style::properties::DeclaredValue::SpecifiedValue;
use style::values::specified::CSSColor;
use util::namespace;
use util::smallvec::VecLike;
use util::str::{DOMString, LengthOrPercentageOrAuto};
use cssparser::Color;
@ -74,16 +75,14 @@ use html5ever::serialize::TraversalScope::{IncludeNode, ChildrenOnly};
use html5ever::tree_builder::{NoQuirks, LimitedQuirks, Quirks};
use selectors::matching::{matches, DeclarationBlock};
use selectors::parser::parse_author_origin_selector_list_from_str;
use selectors::smallvec::VecLike;
use string_cache::{Atom, Namespace, QualName};
use url::UrlParser;
use std::ascii::AsciiExt;
use std::borrow::{IntoCow, ToOwned};
use std::borrow::{Cow, ToOwned};
use std::cell::{Ref, RefMut};
use std::default::Default;
use std::mem;
use std::old_io::Writer;
use std::sync::Arc;
#[dom_struct]
@ -257,7 +256,7 @@ impl RawLayoutElementHelpers for Element {
};
if let Some(color) = bgcolor {
hints.vec_push(from_declaration(
hints.push(from_declaration(
PropertyDeclaration::BackgroundColor(SpecifiedValue(
CSSColor { parsed: Color::RGBA(color), authored: None }))));
}
@ -1011,9 +1010,9 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
fn TagName(self) -> DOMString {
let qualified_name = match self.prefix {
Some(ref prefix) => {
(format!("{}:{}", &**prefix, &*self.local_name)).into_cow()
Cow::Owned(format!("{}:{}", &**prefix, &*self.local_name))
},
None => self.local_name.into_cow()
None => Cow::Borrowed(&*self.local_name)
};
if self.html_element_in_html_document() {
qualified_name.to_ascii_uppercase()

View file

@ -87,7 +87,7 @@ impl<'a> FormDataMethods for JSRef<'a, FormData> {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let data = self.data.borrow();
if data.contains_key(&name) {
match data[name][0].clone() {
match data[&name][0].clone() {
FormDatum::StringData(ref s) => Some(eString(s.clone())),
FormDatum::FileData(ref f) => {
Some(eFile(Unrooted::from_js(*f)))

View file

@ -25,8 +25,8 @@ use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node, window_from_n
use dom::virtualmethods::VirtualMethods;
use dom::window::WindowHelpers;
use num::ToPrimitive;
use std::default::Default;
use std::num::ToPrimitive;
use string_cache::Atom;
use util::str::DOMString;

View file

@ -167,10 +167,12 @@ impl HTMLCollection {
fn traverse(root: JSRef<Node>)
-> FilterMap<Skip<TreeIterator>,
fn(Temporary<Node>) -> Option<Temporary<Element>>> {
fn to_temporary(node: Temporary<Node>) -> Option<Temporary<Element>> {
ElementCast::to_temporary(node)
}
root.traverse_preorder()
.skip(1)
.filter_map(ElementCast::to_temporary as
fn(Temporary<Node>) -> Option<Temporary<Element>>)
.filter_map(to_temporary as fn(Temporary<Node>) -> Option<Temporary<Element>>)
}
}

View file

@ -176,7 +176,7 @@ fn to_snake_case(name: DOMString) -> DOMString {
for ch in name.chars() {
if ch.is_uppercase() {
attr_name.push('\x2d');
attr_name.push(ch.to_lowercase());
attr_name.extend(ch.to_lowercase());
} else {
attr_name.push(ch);
}

View file

@ -33,7 +33,7 @@ impl ImageData {
if let Some(vec) = data {
let js_object_data: *mut uint8_t = JS_GetUint8ClampedArrayData(js_object, cx);
ptr::copy_nonoverlapping(js_object_data, vec.as_ptr(), vec.len())
ptr::copy_nonoverlapping(vec.as_ptr(), js_object_data, vec.len())
}
ImageData {

View file

@ -450,7 +450,7 @@ fn key_location(key: constellation_msg::Key) -> u32 {
fn key_charcode(key: constellation_msg::Key, mods: constellation_msg::KeyModifiers) -> Option<u32> {
let key = key_value(key, mods);
if key.len() == 1 {
Some(key.char_at(0) as u32)
Some(key.chars().next().unwrap() as u32)
} else {
None
}

View file

@ -179,7 +179,6 @@ impl NodeFlags {
}
}
#[unsafe_destructor]
impl Drop for Node {
#[allow(unsafe_code)]
fn drop(&mut self) {
@ -987,8 +986,11 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
}
fn child_elements(self) -> ChildElementIterator {
fn to_temporary(node: Temporary<Node>) -> Option<Temporary<Element>> {
ElementCast::to_temporary(node)
}
self.children()
.filter_map(ElementCast::to_temporary as fn(_) -> _)
.filter_map(to_temporary as fn(_) -> _)
.peekable()
}

View file

@ -84,7 +84,7 @@ impl<'a> TextEncoderMethods for JSRef<'a, TextEncoder> {
let js_object: *mut JSObject = JS_NewUint8Array(cx, length);
let js_object_data: *mut uint8_t = JS_GetUint8ArrayData(js_object, cx);
ptr::copy_nonoverlapping(js_object_data, encoded.as_ptr(), length as usize);
ptr::copy_nonoverlapping(encoded.as_ptr(), js_object_data, length as usize);
return js_object;
}
}

View file

@ -28,7 +28,7 @@ pub fn load_script(head: JSRef<HTMLHeadElement>) {
p.push("user-agent-js");
p
} else {
PathBuf::new(path_str)
PathBuf::from(path_str)
};
let mut files = read_dir(&path).ok().expect("Bad path passed to --userscripts")

View file

@ -61,7 +61,6 @@ impl WebGLRenderingContext {
}
}
#[unsafe_destructor]
impl Drop for WebGLRenderingContext {
fn drop(&mut self) {
self.renderer.send(CanvasMsg::Common(CanvasCommonMsg::Close)).unwrap();

View file

@ -61,7 +61,6 @@ use std::collections::HashSet;
use std::default::Default;
use std::ffi::CString;
use std::mem;
use std::num::Float;
use std::rc::Rc;
use std::sync::mpsc::{channel, Receiver, Sender};
use std::sync::mpsc::TryRecvError::{Empty, Disconnected};

View file

@ -56,15 +56,16 @@ use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::cell::{RefCell, Cell};
use std::default::Default;
use std::old_io::Timer;
use std::str::FromStr;
use std::sync::{Mutex, Arc};
use std::time::duration::Duration;
use std::sync::mpsc::{channel, Sender, TryRecvError};
use std::thread::sleep_ms;
use time;
use url::{Url, UrlParser};
use dom::bindings::codegen::UnionTypes::StringOrURLSearchParams;
use dom::bindings::codegen::UnionTypes::StringOrURLSearchParams::{eString, eURLSearchParams};
pub type SendParam = StringOrURLSearchParams;
#[derive(PartialEq, Copy, Clone)]
@ -140,7 +141,7 @@ pub struct XMLHttpRequest {
send_flag: Cell<bool>,
global: GlobalField,
timer: DOMRefCell<Timer>,
timeout_cancel: DOMRefCell<Option<Sender<()>>>,
fetch_time: Cell<i64>,
timeout_target: DOMRefCell<Option<Box<ScriptChan+Send>>>,
generation_id: Cell<GenerationId>,
@ -174,7 +175,7 @@ impl XMLHttpRequest {
upload_events: Cell::new(false),
global: GlobalField::from_rooted(&global),
timer: DOMRefCell::new(Timer::new().unwrap()),
timeout_cancel: DOMRefCell::new(None),
fetch_time: Cell::new(0),
timeout_target: DOMRefCell::new(None),
generation_id: Cell::new(GenerationId(0)),
@ -963,7 +964,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> {
let total = self.response_headers.borrow().get::<ContentLength>().map(|x| {**x as u64});
self.dispatch_progress_event(false, type_, len, total);
}
fn set_timeout(self, timeout: u32) {
fn set_timeout(self, duration_ms: u32) {
struct XHRTimeout {
xhr: TrustedXHRAddress,
gen_id: GenerationId,
@ -981,22 +982,23 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> {
// Sets up the object to timeout in a given number of milliseconds
// This will cancel all previous timeouts
let oneshot = self.timer.borrow_mut()
.oneshot(Duration::milliseconds(timeout as i64));
let timeout_target = (*self.timeout_target.borrow().as_ref().unwrap()).clone();
let global = self.global.root();
let xhr = Trusted::new(global.r().get_cx(), self, global.r().script_chan());
let gen_id = self.generation_id.get();
let (cancel_tx, cancel_rx) = channel();
*self.timeout_cancel.borrow_mut() = Some(cancel_tx);
spawn_named("XHR:Timer".to_owned(), move || {
match oneshot.recv() {
Ok(_) => {
sleep_ms(duration_ms);
match cancel_rx.try_recv() {
Err(TryRecvError::Empty) => {
timeout_target.send(ScriptMsg::RunnableMsg(box XHRTimeout {
xhr: xhr,
gen_id: gen_id,
})).unwrap();
},
Err(_) => {
// This occurs if xhr.timeout (the sender) goes out of scope (i.e, xhr went out of scope)
Err(TryRecvError::Disconnected) | Ok(()) => {
// This occurs if xhr.timeout_cancel (the sender) goes out of scope (i.e, xhr went out of scope)
// or if the oneshot timer was overwritten. The former case should not happen due to pinning.
debug!("XHR timeout was overwritten or canceled")
}
@ -1006,8 +1008,9 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> {
}
fn cancel_timeout(self) {
// oneshot() closes the previous channel, canceling the timeout
self.timer.borrow_mut().oneshot(Duration::zero());
if let Some(cancel_tx) = self.timeout_cancel.borrow_mut().take() {
let _ = cancel_tx.send(());
}
}
fn text_response(self) -> DOMString {