Make usage of core_intrinsics optional

This commit is contained in:
Simon Sapin 2017-10-15 01:04:12 +02:00
parent bffec1c1a1
commit 27239e1123
5 changed files with 14 additions and 13 deletions

View file

@ -39,8 +39,6 @@ use script_layout_interface::TrustedNodeAddress;
use std::cell::{Cell, UnsafeCell}; use std::cell::{Cell, UnsafeCell};
use std::default::Default; use std::default::Default;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
#[cfg(debug_assertions)]
use std::intrinsics::type_name;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::mem; use std::mem;
use std::ops::Deref; use std::ops::Deref;
@ -359,11 +357,11 @@ impl<T: DomObject> Deref for Dom<T> {
unsafe impl<T: DomObject> JSTraceable for Dom<T> { unsafe impl<T: DomObject> JSTraceable for Dom<T> {
unsafe fn trace(&self, trc: *mut JSTracer) { unsafe fn trace(&self, trc: *mut JSTracer) {
#[cfg(debug_assertions)] #[cfg(all(feature = "unstable", debug_assertions))]
let trace_str = format!("for {} on heap", type_name::<T>()); let trace_str = format!("for {} on heap", ::std::intrinsics::type_name::<T>());
#[cfg(debug_assertions)] #[cfg(all(feature = "unstable", debug_assertions))]
let trace_info = &trace_str[..]; let trace_info = &trace_str[..];
#[cfg(not(debug_assertions))] #[cfg(not(all(feature = "unstable", debug_assertions)))]
let trace_info = "for DOM object on heap"; let trace_info = "for DOM object on heap";
trace_reflector(trc, trace_reflector(trc,

View file

@ -805,6 +805,7 @@ impl WindowMethods for Window {
#[allow(unsafe_code)] #[allow(unsafe_code)]
fn Trap(&self) { fn Trap(&self) {
#[cfg(feature = "unstable")]
unsafe { ::std::intrinsics::breakpoint() } unsafe { ::std::intrinsics::breakpoint() }
} }

View file

@ -2,10 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![cfg_attr(feature = "unstable", feature(core_intrinsics))]
#![cfg_attr(feature = "unstable", feature(on_unimplemented))] #![cfg_attr(feature = "unstable", feature(on_unimplemented))]
#![feature(conservative_impl_trait)] #![feature(conservative_impl_trait)]
#![feature(const_fn)] #![feature(const_fn)]
#![feature(core_intrinsics)]
#![feature(mpsc_select)] #![feature(mpsc_select)]
#![feature(plugin)] #![feature(plugin)]
#![feature(proc_macro)] #![feature(proc_macro)]

View file

@ -5,7 +5,6 @@
//! Machinery for [tasks](https://html.spec.whatwg.org/multipage/#concept-task). //! Machinery for [tasks](https://html.spec.whatwg.org/multipage/#concept-task).
use std::fmt; use std::fmt;
use std::intrinsics;
use std::sync::Arc; use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
@ -33,7 +32,10 @@ macro_rules! task {
pub trait TaskOnce: Send { pub trait TaskOnce: Send {
#[allow(unsafe_code)] #[allow(unsafe_code)]
fn name(&self) -> &'static str { fn name(&self) -> &'static str {
unsafe { intrinsics::type_name::<Self>() } #[cfg(feature = "unstable")]
unsafe { ::std::intrinsics::type_name::<Self>() }
#[cfg(not(feature = "unstable"))]
{ "(task name unknown)" }
} }
fn run_once(self); fn run_once(self);

View file

@ -15,7 +15,7 @@
//! //!
//! [glutin]: https://github.com/tomaka/glutin //! [glutin]: https://github.com/tomaka/glutin
#![feature(core_intrinsics)] #![cfg_attr(feature = "unstable", feature(core_intrinsics))]
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
extern crate android_injected_glue; extern crate android_injected_glue;
@ -26,7 +26,7 @@ extern crate glutin_app as app;
extern crate log; extern crate log;
// The Servo engine // The Servo engine
extern crate servo; extern crate servo;
#[cfg(not(target_os = "android"))] #[cfg(all(feature = "unstable", not(target_os = "android")))]
#[macro_use] #[macro_use]
extern crate sig; extern crate sig;
@ -57,7 +57,7 @@ pub mod platform {
pub fn deinit() {} pub fn deinit() {}
} }
#[cfg(not(target_os = "android"))] #[cfg(all(feature = "unstable", not(target_os = "android")))]
fn install_crash_handler() { fn install_crash_handler() {
use backtrace::Backtrace; use backtrace::Backtrace;
use sig::ffi::Sig; use sig::ffi::Sig;
@ -83,7 +83,7 @@ fn install_crash_handler() {
signal!(Sig::BUS, handler); // handle invalid memory access signal!(Sig::BUS, handler); // handle invalid memory access
} }
#[cfg(target_os = "android")] #[cfg(any(not(feature = "unstable"), target_os = "android"))]
fn install_crash_handler() {} fn install_crash_handler() {}
fn main() { fn main() {