Skip to content

Commit

Permalink
Make usage of core_intrinsics optional
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Oct 16, 2017
1 parent bffec1c commit 27239e1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
10 changes: 4 additions & 6 deletions components/script/dom/bindings/root.rs
Expand Up @@ -39,8 +39,6 @@ use script_layout_interface::TrustedNodeAddress;
use std::cell::{Cell, UnsafeCell};
use std::default::Default;
use std::hash::{Hash, Hasher};
#[cfg(debug_assertions)]
use std::intrinsics::type_name;
use std::marker::PhantomData;
use std::mem;
use std::ops::Deref;
Expand Down Expand Up @@ -359,11 +357,11 @@ impl<T: DomObject> Deref for Dom<T> {

unsafe impl<T: DomObject> JSTraceable for Dom<T> {
unsafe fn trace(&self, trc: *mut JSTracer) {
#[cfg(debug_assertions)]
let trace_str = format!("for {} on heap", type_name::<T>());
#[cfg(debug_assertions)]
#[cfg(all(feature = "unstable", debug_assertions))]
let trace_str = format!("for {} on heap", ::std::intrinsics::type_name::<T>());
#[cfg(all(feature = "unstable", debug_assertions))]
let trace_info = &trace_str[..];
#[cfg(not(debug_assertions))]
#[cfg(not(all(feature = "unstable", debug_assertions)))]
let trace_info = "for DOM object on heap";

trace_reflector(trc,
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/window.rs
Expand Up @@ -805,6 +805,7 @@ impl WindowMethods for Window {

#[allow(unsafe_code)]
fn Trap(&self) {
#[cfg(feature = "unstable")]
unsafe { ::std::intrinsics::breakpoint() }
}

Expand Down
2 changes: 1 addition & 1 deletion components/script/lib.rs
Expand Up @@ -2,10 +2,10 @@
* 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/. */

#![cfg_attr(feature = "unstable", feature(core_intrinsics))]
#![cfg_attr(feature = "unstable", feature(on_unimplemented))]
#![feature(conservative_impl_trait)]
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![feature(mpsc_select)]
#![feature(plugin)]
#![feature(proc_macro)]
Expand Down
6 changes: 4 additions & 2 deletions components/script/task.rs
Expand Up @@ -5,7 +5,6 @@
//! Machinery for [tasks](https://html.spec.whatwg.org/multipage/#concept-task).

use std::fmt;
use std::intrinsics;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};

Expand Down Expand Up @@ -33,7 +32,10 @@ macro_rules! task {
pub trait TaskOnce: Send {
#[allow(unsafe_code)]
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);
Expand Down
8 changes: 4 additions & 4 deletions ports/servo/main.rs
Expand Up @@ -15,7 +15,7 @@
//!
//! [glutin]: https://github.com/tomaka/glutin

#![feature(core_intrinsics)]
#![cfg_attr(feature = "unstable", feature(core_intrinsics))]

#[cfg(target_os = "android")]
extern crate android_injected_glue;
Expand All @@ -26,7 +26,7 @@ extern crate glutin_app as app;
extern crate log;
// The Servo engine
extern crate servo;
#[cfg(not(target_os = "android"))]
#[cfg(all(feature = "unstable", not(target_os = "android")))]
#[macro_use]
extern crate sig;

Expand Down Expand Up @@ -57,7 +57,7 @@ pub mod platform {
pub fn deinit() {}
}

#[cfg(not(target_os = "android"))]
#[cfg(all(feature = "unstable", not(target_os = "android")))]
fn install_crash_handler() {
use backtrace::Backtrace;
use sig::ffi::Sig;
Expand All @@ -83,7 +83,7 @@ fn install_crash_handler() {
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 main() {
Expand Down

0 comments on commit 27239e1

Please sign in to comment.