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

Bump rust toolchain to 2018-03-24. #20589

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -353,15 +353,3 @@ impl PartialEq<BrowsingContextId> for TopLevelBrowsingContextId {

// We provide ids just for unit testing.
pub const TEST_NAMESPACE: PipelineNamespaceId = PipelineNamespaceId(1234);
#[allow(unsafe_code)]
#[cfg(feature = "unstable")]
pub const TEST_PIPELINE_INDEX: PipelineIndex = unsafe { PipelineIndex(NonZero::new_unchecked(5678)) };
#[cfg(feature = "unstable")]
pub const TEST_PIPELINE_ID: PipelineId = PipelineId { namespace_id: TEST_NAMESPACE, index: TEST_PIPELINE_INDEX };
#[allow(unsafe_code)]
#[cfg(feature = "unstable")]
pub const TEST_BROWSING_CONTEXT_INDEX: BrowsingContextIndex =
unsafe { BrowsingContextIndex(NonZero::new_unchecked(8765)) };
#[cfg(feature = "unstable")]
pub const TEST_BROWSING_CONTEXT_ID: BrowsingContextId =
BrowsingContextId { namespace_id: TEST_NAMESPACE, index: TEST_BROWSING_CONTEXT_INDEX };

This comment has been minimized.

Copy link
@mrowqa

mrowqa Apr 8, 2018

Author

Failed with:

error[E0015]: calls in constants are limited to constant functions, struct and enum constructors
   --> components/msg/constellation_msg.rs:358:71
    |
358 | pub const TEST_PIPELINE_INDEX: PipelineIndex = unsafe { PipelineIndex(NonZero::new_unchecked(5678)) };
    |                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0015]: calls in constants are limited to constant functions, struct and enum constructors
   --> components/msg/constellation_msg.rs:364:35
    |
364 |     unsafe { BrowsingContextIndex(NonZero::new_unchecked(8765)) };
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors
@@ -5,71 +5,11 @@
//! `NonZero*` types that are either `core::nonzero::NonZero<_>`
//! or some stable types with an equivalent API (but no memory layout optimization).

#![cfg_attr(feature = "unstable", feature(nonzero))]
#![cfg_attr(feature = "unstable", feature(const_fn))]
#![cfg_attr(feature = "unstable", feature(const_nonzero_new))]

#[cfg_attr(not(feature = "unstable"), macro_use)]
#[macro_use]
extern crate serde;

pub use imp::*;

#[cfg(feature = "unstable")]
mod imp {
extern crate core;
use self::core::nonzero::NonZero as CoreNonZero;
use serde::{Serialize, Serializer, Deserialize, Deserializer};

pub use self::core::nonzero::Zeroable;

#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct NonZero<T: Zeroable>(CoreNonZero<T>);

impl<T: Zeroable> NonZero<T> {
#[inline]
pub const unsafe fn new_unchecked(x: T) -> Self {
NonZero(CoreNonZero::new_unchecked(x))
}

#[inline]
pub fn new(x: T) -> Option<Self> {
CoreNonZero::new(x).map(NonZero)
}

#[inline]
pub fn get(self) -> T {
self.0.get()
}
}

// Not using derive because of the additional Clone bound required by the inner impl

impl<T> Serialize for NonZero<T>
where
T: Serialize + Zeroable + Clone,
{
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
self.0.serialize(serializer)
}
}

impl<'de, T> Deserialize<'de> for NonZero<T>
where
T: Deserialize<'de> + Zeroable,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
CoreNonZero::deserialize(deserializer).map(NonZero)
}
}
}

#[cfg(not(feature = "unstable"))]
mod imp {
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
pub struct NonZero<T: Zeroable>(T);
@@ -1 +1 @@
nightly-2018-01-27
nightly-2018-03-24
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.