Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 2018-edition idioms in crates that use that edition #22133

Merged
merged 3 commits into from Nov 8, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

`cargo fix --edition-idioms`

  • Loading branch information
SimonSapin committed Nov 8, 2018
commit 2012be4a8bd97f2fd69f986c8fffb1af1eec21dc

Some generated files are not rendered by default. Learn more.

@@ -10,9 +10,11 @@ static ALLOC: Allocator = Allocator;
pub use crate::platform::*;

#[cfg(not(windows))]
mod platform {
extern crate jemalloc_sys as ffi;
pub use jemalloc_sys;

#[cfg(not(windows))]
mod platform {
use jemalloc_sys as ffi;
use std::alloc::{GlobalAlloc, Layout};
use std::os::raw::{c_int, c_void};

@@ -96,9 +98,7 @@ mod platform {

#[cfg(windows)]
mod platform {
extern crate kernel32;

use self::kernel32::{GetProcessHeap, HeapSize, HeapValidate};
use kernel32::{GetProcessHeap, HeapSize, HeapValidate};
pub use std::alloc::System as Allocator;
use std::os::raw::c_void;

@@ -2,12 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

extern crate string_cache_codegen;

use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::Path;
use string_cache_codegen;

fn main() {
let static_atoms =
@@ -2,6 +2,4 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

extern crate string_cache;

include!(concat!(env!("OUT_DIR"), "/atom.rs"));
@@ -4,15 +4,8 @@

#[macro_use]
extern crate bitflags;
extern crate bluetooth_traits;
extern crate device;
extern crate embedder_traits;
extern crate ipc_channel;
#[macro_use]
extern crate log;
extern crate servo_config;
extern crate servo_rand;
extern crate uuid;

pub mod test;

@@ -29,7 +22,7 @@ use embedder_traits::{EmbedderMsg, EmbedderProxy};
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use servo_config::opts;
use servo_config::prefs::PREFS;
use servo_rand::Rng;
use servo_rand::{self, Rng};
use std::borrow::ToOwned;
use std::collections::{HashMap, HashSet};
use std::string::String;
@@ -137,7 +137,7 @@ fn generate_id() -> Uuid {
}

// Set the adapter's name, is_powered and is_discoverable attributes
fn set_adapter(adapter: &BluetoothAdapter, adapter_name: String) -> Result<(), Box<Error>> {
fn set_adapter(adapter: &BluetoothAdapter, adapter_name: String) -> Result<(), Box<dyn Error>> {
adapter.set_name(adapter_name)?;
adapter.set_powered(true)?;
adapter.set_discoverable(true)?;
@@ -149,7 +149,7 @@ fn create_device(
adapter: &BluetoothAdapter,
name: String,
address: String,
) -> Result<BluetoothDevice, Box<Error>> {
) -> Result<BluetoothDevice, Box<dyn Error>> {
let device = BluetoothDevice::create_mock_device(adapter.clone(), generate_id().to_string())?;
device.set_name(Some(name))?;
device.set_address(address)?;
@@ -163,7 +163,7 @@ fn create_device_with_uuids(
name: String,
address: String,
uuids: Vec<String>,
) -> Result<BluetoothDevice, Box<Error>> {
) -> Result<BluetoothDevice, Box<dyn Error>> {
let device = create_device(adapter, name, address)?;
device.set_uuids(uuids)?;
Ok(device)
@@ -173,7 +173,7 @@ fn create_device_with_uuids(
fn create_service(
device: &BluetoothDevice,
uuid: String,
) -> Result<BluetoothGATTService, Box<Error>> {
) -> Result<BluetoothGATTService, Box<dyn Error>> {
let service =
BluetoothGATTService::create_mock_service(device.clone(), generate_id().to_string())?;
service.set_uuid(uuid)?;
@@ -184,7 +184,7 @@ fn create_service(
fn create_characteristic(
service: &BluetoothGATTService,
uuid: String,
) -> Result<BluetoothGATTCharacteristic, Box<Error>> {
) -> Result<BluetoothGATTCharacteristic, Box<dyn Error>> {
let characteristic = BluetoothGATTCharacteristic::create_mock_characteristic(
service.clone(),
generate_id().to_string(),
@@ -198,7 +198,7 @@ fn create_characteristic_with_value(
service: &BluetoothGATTService,
uuid: String,
value: Vec<u8>,
) -> Result<BluetoothGATTCharacteristic, Box<Error>> {
) -> Result<BluetoothGATTCharacteristic, Box<dyn Error>> {
let characteristic = create_characteristic(service, uuid)?;
characteristic.set_value(value)?;
Ok(characteristic)
@@ -208,7 +208,7 @@ fn create_characteristic_with_value(
fn create_descriptor(
characteristic: &BluetoothGATTCharacteristic,
uuid: String,
) -> Result<BluetoothGATTDescriptor, Box<Error>> {
) -> Result<BluetoothGATTDescriptor, Box<dyn Error>> {
let descriptor = BluetoothGATTDescriptor::create_mock_descriptor(
characteristic.clone(),
generate_id().to_string(),
@@ -222,7 +222,7 @@ fn create_descriptor_with_value(
characteristic: &BluetoothGATTCharacteristic,
uuid: String,
value: Vec<u8>,
) -> Result<BluetoothGATTDescriptor, Box<Error>> {
) -> Result<BluetoothGATTDescriptor, Box<dyn Error>> {
let descriptor = create_descriptor(characteristic, uuid)?;
descriptor.set_value(value)?;
Ok(descriptor)
@@ -231,7 +231,7 @@ fn create_descriptor_with_value(
fn create_heart_rate_service(
device: &BluetoothDevice,
empty: bool,
) -> Result<BluetoothGATTService, Box<Error>> {
) -> Result<BluetoothGATTService, Box<dyn Error>> {
// Heart Rate Service
let heart_rate_service = create_service(device, HEART_RATE_SERVICE_UUID.to_owned())?;

@@ -274,7 +274,7 @@ fn create_heart_rate_service(
fn create_generic_access_service(
device: &BluetoothDevice,
empty: bool,
) -> Result<BluetoothGATTService, Box<Error>> {
) -> Result<BluetoothGATTService, Box<dyn Error>> {
// Generic Access Service
let generic_access_service = create_service(device, GENERIC_ACCESS_SERVICE_UUID.to_owned())?;

@@ -335,7 +335,7 @@ fn create_generic_access_service(
fn create_heart_rate_device(
adapter: &BluetoothAdapter,
empty: bool,
) -> Result<BluetoothDevice, Box<Error>> {
) -> Result<BluetoothDevice, Box<dyn Error>> {
// Heart Rate Device
let heart_rate_device = create_device_with_uuids(
adapter,
@@ -362,7 +362,7 @@ fn create_heart_rate_device(

fn create_missing_characterisitc_heart_rate_device(
adapter: &BluetoothAdapter,
) -> Result<(), Box<Error>> {
) -> Result<(), Box<dyn Error>> {
let heart_rate_device_empty = create_heart_rate_device(adapter, true)?;

let _generic_access_service_empty =
@@ -375,7 +375,7 @@ fn create_missing_characterisitc_heart_rate_device(

fn create_missing_descriptor_heart_rate_device(
adapter: &BluetoothAdapter,
) -> Result<(), Box<Error>> {
) -> Result<(), Box<dyn Error>> {
let heart_rate_device_empty = create_heart_rate_device(adapter, true)?;

let generic_access_service_empty =
@@ -399,7 +399,7 @@ fn create_missing_descriptor_heart_rate_device(
Ok(())
}

fn create_two_heart_rate_services_device(adapter: &BluetoothAdapter) -> Result<(), Box<Error>> {
fn create_two_heart_rate_services_device(adapter: &BluetoothAdapter) -> Result<(), Box<dyn Error>> {
let heart_rate_device_empty = create_heart_rate_device(adapter, true)?;

heart_rate_device_empty.set_uuids(vec![
@@ -435,7 +435,7 @@ fn create_two_heart_rate_services_device(adapter: &BluetoothAdapter) -> Result<(
Ok(())
}

fn create_blocklisted_device(adapter: &BluetoothAdapter) -> Result<(), Box<Error>> {
fn create_blocklisted_device(adapter: &BluetoothAdapter) -> Result<(), Box<dyn Error>> {
let connectable_device = create_device_with_uuids(
adapter,
CONNECTABLE_DEVICE_NAME.to_owned(),
@@ -490,7 +490,7 @@ fn create_blocklisted_device(adapter: &BluetoothAdapter) -> Result<(), Box<Error
Ok(())
}

fn create_glucose_heart_rate_devices(adapter: &BluetoothAdapter) -> Result<(), Box<Error>> {
fn create_glucose_heart_rate_devices(adapter: &BluetoothAdapter) -> Result<(), Box<dyn Error>> {
let glucose_devie = create_device_with_uuids(
adapter,
GLUCOSE_DEVICE_NAME.to_owned(),
@@ -517,7 +517,7 @@ fn create_glucose_heart_rate_devices(adapter: &BluetoothAdapter) -> Result<(), B
Ok(())
}

pub fn test(manager: &mut BluetoothManager, data_set_name: String) -> Result<(), Box<Error>> {
pub fn test(manager: &mut BluetoothManager, data_set_name: String) -> Result<(), Box<dyn Error>> {
let may_existing_adapter = manager.get_or_create_adapter();
let adapter = match may_existing_adapter.as_ref() {
Some(adapter) => adapter,
@@ -2,9 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

extern crate embedder_traits;
extern crate ipc_channel;
extern crate regex;
#[macro_use]
extern crate serde;

@@ -169,7 +169,7 @@ impl GLContextWrapper {
}
}

pub fn gl(&self) -> &gl::Gl {
pub fn gl(&self) -> &dyn gl::Gl {
match *self {
GLContextWrapper::Native(ref ctx) => ctx.gl(),
GLContextWrapper::OSMesa(ref ctx) => ctx.gl(),
@@ -236,7 +236,7 @@ impl MainThreadDispatcher {
}
}
impl GLContextDispatcher for MainThreadDispatcher {
fn dispatch(&self, f: Box<Fn() + Send>) {
fn dispatch(&self, f: Box<dyn Fn() + Send>) {
self.compositor_proxy
.lock()
.unwrap()
@@ -4,23 +4,8 @@

#![deny(unsafe_code)]

extern crate azure;
extern crate canvas_traits;
extern crate compositing;
extern crate cssparser;
extern crate euclid;
extern crate fnv;
extern crate gleam;
extern crate ipc_channel;
#[macro_use]
extern crate log;
extern crate num_traits;
extern crate offscreen_gl_context;
extern crate pixels;
extern crate serde_bytes;
extern crate servo_config;
extern crate webrender;
extern crate webrender_api;

pub mod canvas_data;
pub mod canvas_paint_thread;
@@ -23,13 +23,13 @@ impl WebGLThreads {
/// Creates a new WebGLThreads object
pub fn new(
gl_factory: GLContextFactory,
webrender_gl: Rc<gl::Gl>,
webrender_gl: Rc<dyn gl::Gl>,
webrender_api_sender: webrender_api::RenderApiSender,
webvr_compositor: Option<Box<WebVRRenderHandler>>,
webvr_compositor: Option<Box<dyn WebVRRenderHandler>>,
) -> (
WebGLThreads,
Box<webrender::ExternalImageHandler>,
Option<Box<webrender::OutputImageHandler>>,
Box<dyn webrender::ExternalImageHandler>,
Option<Box<dyn webrender::OutputImageHandler>>,
) {
// This implementation creates a single `WebGLThread` for all the pipelines.
let channel = WebGLThread::start(
@@ -70,7 +70,7 @@ impl WebGLThreads {

/// Bridge between the webrender::ExternalImage callbacks and the WebGLThreads.
struct WebGLExternalImages {
webrender_gl: Rc<gl::Gl>,
webrender_gl: Rc<dyn gl::Gl>,
webgl_channel: WebGLSender<WebGLMsg>,
// Used to avoid creating a new channel on each received WebRender request.
lock_channel: (
@@ -80,7 +80,7 @@ struct WebGLExternalImages {
}

impl WebGLExternalImages {
fn new(webrender_gl: Rc<gl::Gl>, channel: WebGLSender<WebGLMsg>) -> Self {
fn new(webrender_gl: Rc<dyn gl::Gl>, channel: WebGLSender<WebGLMsg>) -> Self {
Self {
webrender_gl,
webgl_channel: channel,
@@ -111,7 +111,7 @@ impl WebGLExternalImageApi for WebGLExternalImages {
}

/// Wrapper to send WebVR commands used in `WebGLThread`.
struct WebVRRenderWrapper(Box<WebVRRenderHandler>);
struct WebVRRenderWrapper(Box<dyn WebVRRenderHandler>);

impl WebVRRenderHandler for WebVRRenderWrapper {
fn handle(&mut self, command: WebVRCommand, texture: Option<(u32, Size2D<i32>)>) {
@@ -122,7 +122,7 @@ impl WebVRRenderHandler for WebVRRenderWrapper {
/// struct used to implement DOMToTexture feature and webrender::OutputImageHandler trait.
type OutputHandlerData = Option<(u32, Size2D<i32>)>;
struct OutputHandler {
webrender_gl: Rc<gl::Gl>,
webrender_gl: Rc<dyn gl::Gl>,
webgl_channel: WebGLSender<WebGLMsg>,
// Used to avoid creating a new channel on each received WebRender request.
lock_channel: (
@@ -133,7 +133,7 @@ struct OutputHandler {
}

impl OutputHandler {
fn new(webrender_gl: Rc<gl::Gl>, channel: WebGLSender<WebGLMsg>) -> Self {
fn new(webrender_gl: Rc<dyn gl::Gl>, channel: WebGLSender<WebGLMsg>) -> Self {
Self {
webrender_gl,
webgl_channel: channel,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.