Browse Source

Fixes for latest nightlies (Rust 1.16.0)

pull/10/head
Fenrir 8 years ago
parent
commit
bacd6c5e04
  1. 2
      Xargo.toml
  2. 1
      src/lib.rs
  3. 2
      std/src/ascii.rs
  4. 2
      std/src/io/mod.rs
  5. 4
      std/src/lib.rs
  6. 289
      std/src/macros.rs
  7. 2
      std/src/sys/wtf8.rs

2
Xargo.toml

@ -0,0 +1,2 @@
[target.3ds.dependencies]
collections = {}

1
src/lib.rs

@ -3,6 +3,7 @@
#[macro_use] #[macro_use]
extern crate bitflags; extern crate bitflags;
extern crate ctru_sys as libctru; extern crate ctru_sys as libctru;
pub mod console; pub mod console;

2
std/src/ascii.rs

@ -430,7 +430,7 @@ static ASCII_UPPERCASE_MAP: [u8; 256] = [
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use rustc_unicode::char::from_u32; use std_unicode::char::from_u32;
use collections::string::ToString; use collections::string::ToString;
#[test] #[test]

2
std/src/io/mod.rs

@ -248,7 +248,7 @@
//! time and may call fewer or more syscalls/library functions. //! time and may call fewer or more syscalls/library functions.
use cmp; use cmp;
use rustc_unicode::str as core_str; use std_unicode::str as core_str;
use error as std_error; use error as std_error;
use fmt; use fmt;
use result; use result;

4
std/src/lib.rs

@ -30,7 +30,7 @@ extern crate core as __core;
#[macro_reexport(vec, format)] #[macro_reexport(vec, format)]
extern crate collections as core_collections; extern crate collections as core_collections;
extern crate alloc; extern crate alloc;
extern crate rustc_unicode; extern crate std_unicode;
extern crate alloc_system; extern crate alloc_system;
@ -65,7 +65,7 @@ pub use core_collections::str;
pub use core_collections::string; pub use core_collections::string;
pub use core_collections::vec; pub use core_collections::vec;
pub use rustc_unicode::char; pub use std_unicode::char;
#[macro_use] #[macro_use]
pub mod macros; pub mod macros;

289
std/src/macros.rs

@ -28,7 +28,6 @@
/// panic!("this is a {} {message}", "fancy", message = "message"); /// panic!("this is a {} {message}", "fancy", message = "message");
/// ``` /// ```
#[macro_export] #[macro_export]
#[allow_internal_unstable]
macro_rules! panic { macro_rules! panic {
() => ({ () => ({
panic!("explicit panic") panic!("explicit panic")
@ -52,132 +51,6 @@ macro_rules! panic {
}); });
} }
/// Ensure that a boolean expression is `true` at runtime.
///
/// This will invoke the `panic!` macro if the provided expression cannot be
/// evaluated to `true` at runtime.
///
/// This macro has a second version, where a custom panic message can be provided.
///
/// # Examples
///
/// ```
/// // the panic message for these assertions is the stringified value of the
/// // expression given.
/// assert!(true);
///
/// fn some_computation() -> bool { true } // a very simple function
///
/// assert!(some_computation());
///
/// // assert with a custom message
/// let x = true;
/// assert!(x, "x wasn't true!");
///
/// let a = 3; let b = 27;
/// assert!(a + b == 30, "a = {}, b = {}", a, b);
/// ```
#[macro_export]
macro_rules! assert {
($cond:expr) => (
if !$cond {
panic!(concat!("assertion failed: ", stringify!($cond)))
}
);
($cond:expr, $($arg:tt)+) => (
if !$cond {
panic!($($arg)+)
}
);
}
/// Asserts that two expressions are equal to each other.
///
/// On panic, this macro will print the values of the expressions with their
/// debug representations.
///
/// # Examples
///
/// ```
/// let a = 3;
/// let b = 1 + 2;
/// assert_eq!(a, b);
/// ```
#[macro_export]
macro_rules! assert_eq {
($left:expr , $right:expr) => ({
match (&$left, &$right) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
panic!("assertion failed: `(left == right)` \
(left: `{:?}`, right: `{:?}`)", left_val, right_val)
}
}
}
})
}
/// Ensure that a boolean expression is `true` at runtime.
///
/// This will invoke the `panic!` macro if the provided expression cannot be
/// evaluated to `true` at runtime.
///
/// Like `assert!`, this macro also has a second version, where a custom panic
/// message can be provided.
///
/// Unlike `assert!`, `debug_assert!` statements are only enabled in non
/// optimized builds by default. An optimized build will omit all
/// `debug_assert!` statements unless `-C debug-assertions` is passed to the
/// compiler. This makes `debug_assert!` useful for checks that are too
/// expensive to be present in a release build but may be helpful during
/// development.
///
/// # Examples
///
/// ```
/// // the panic message for these assertions is the stringified value of the
/// // expression given.
/// debug_assert!(true);
///
/// fn some_expensive_computation() -> bool { true } // a very simple function
/// debug_assert!(some_expensive_computation());
///
/// // assert with a custom message
/// let x = true;
/// debug_assert!(x, "x wasn't true!");
///
/// let a = 3; let b = 27;
/// debug_assert!(a + b == 30, "a = {}, b = {}", a, b);
/// ```
#[macro_export]
macro_rules! debug_assert {
($($arg:tt)*) => (if cfg!(debug_assertions) { assert!($($arg)*); })
}
/// Asserts that two expressions are equal to each other.
///
/// On panic, this macro will print the values of the expressions with their
/// debug representations.
///
/// Unlike `assert_eq!`, `debug_assert_eq!` statements are only enabled in non
/// optimized builds by default. An optimized build will omit all
/// `debug_assert_eq!` statements unless `-C debug-assertions` is passed to the
/// compiler. This makes `debug_assert_eq!` useful for checks that are too
/// expensive to be present in a release build but may be helpful during
/// development.
///
/// # Examples
///
/// ```
/// let a = 3;
/// let b = 1 + 2;
/// debug_assert_eq!(a, b);
/// ```
#[macro_export]
macro_rules! debug_assert_eq {
($($arg:tt)*) => (if cfg!(debug_assertions) { assert_eq!($($arg)*); })
}
/// Helper macro for unwrapping `Result` values while returning early with an /// Helper macro for unwrapping `Result` values while returning early with an
/// error if the value of the expression is `Err`. Can only be used in /// error if the value of the expression is `Err`. Can only be used in
/// functions that return `Result` because of the early return of `Err` that /// functions that return `Result` because of the early return of `Err` that
@ -217,169 +90,7 @@ macro_rules! try {
}) })
} }
/// Use the `format!` syntax to write data into a buffer.
///
/// This macro is typically used with a buffer of `&mut `[`Write`][write].
///
/// See [`std::fmt`][fmt] for more information on format syntax.
///
/// [fmt]: ../std/fmt/index.html
/// [write]: ../std/io/trait.Write.html
///
/// # Examples
///
/// ```
/// use std::io::Write;
///
/// let mut w = Vec::new();
/// write!(&mut w, "test").unwrap();
/// write!(&mut w, "formatted {}", "arguments").unwrap();
///
/// assert_eq!(w, b"testformatted arguments");
/// ```
#[macro_export]
macro_rules! write {
($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*)))
}
/// Use the `format!` syntax to write data into a buffer, appending a newline.
///
/// This macro is typically used with a buffer of `&mut `[`Write`][write].
///
/// See [`std::fmt`][fmt] for more information on format syntax.
///
/// [fmt]: ../std/fmt/index.html
/// [write]: ../std/io/trait.Write.html
///
/// # Examples
///
/// ```
/// use std::io::Write;
///
/// let mut w = Vec::new();
/// writeln!(&mut w, "test").unwrap();
/// writeln!(&mut w, "formatted {}", "arguments").unwrap();
///
/// assert_eq!(&w[..], "test\nformatted arguments\n".as_bytes());
/// ```
#[macro_export]
macro_rules! writeln {
($dst:expr, $fmt:expr) => (
write!($dst, concat!($fmt, "\n"))
);
($dst:expr, $fmt:expr, $($arg:tt)*) => (
write!($dst, concat!($fmt, "\n"), $($arg)*)
);
}
/// A utility macro for indicating unreachable code.
///
/// This is useful any time that the compiler can't determine that some code is unreachable. For
/// example:
///
/// * Match arms with guard conditions.
/// * Loops that dynamically terminate.
/// * Iterators that dynamically terminate.
///
/// # Panics
///
/// This will always panic.
///
/// # Examples
///
/// Match arms:
///
/// ```
/// # #[allow(dead_code)]
/// fn foo(x: Option<i32>) {
/// match x {
/// Some(n) if n >= 0 => println!("Some(Non-negative)"),
/// Some(n) if n < 0 => println!("Some(Negative)"),
/// Some(_) => unreachable!(), // compile error if commented out
/// None => println!("None")
/// }
/// }
/// ```
///
/// Iterators:
///
/// ```
/// # #[allow(dead_code)]
/// fn divide_by_three(x: u32) -> u32 { // one of the poorest implementations of x/3
/// for i in 0.. {
/// if 3*i < i { panic!("u32 overflow"); }
/// if x < 3*i { return i-1; }
/// }
/// unreachable!();
/// }
/// ```
#[macro_export]
macro_rules! unreachable {
() => ({
panic!("internal error: entered unreachable code")
});
($msg:expr) => ({
unreachable!("{}", $msg)
});
($fmt:expr, $($arg:tt)*) => ({
panic!(concat!("internal error: entered unreachable code: ", $fmt), $($arg)*)
});
}
/// A standardized placeholder for marking unfinished code. It panics with the
/// message `"not yet implemented"` when executed.
///
/// This can be useful if you are prototyping and are just looking to have your
/// code typecheck, or if you're implementing a trait that requires multiple
/// methods, and you're only planning on using one of them.
///
/// # Examples
///
/// Here's an example of some in-progress code. We have a trait `Foo`:
///
/// ```
/// trait Foo {
/// fn bar(&self);
/// fn baz(&self);
/// }
/// ```
///
/// We want to implement `Foo` on one of our types, but we also want to work on
/// just `bar()` first. In order for our code to compile, we need to implement
/// `baz()`, so we can use `unimplemented!`:
///
/// ```
/// # trait Foo {
/// # fn bar(&self);
/// # fn baz(&self);
/// # }
/// struct MyStruct;
///
/// impl Foo for MyStruct {
/// fn bar(&self) {
/// // implementation goes here
/// }
///
/// fn baz(&self) {
/// // let's not worry about implementing baz() for now
/// unimplemented!();
/// }
/// }
///
/// fn main() {
/// let s = MyStruct;
/// s.bar();
///
/// // we aren't even using baz() yet, so this is fine.
/// }
/// ```
#[macro_export]
macro_rules! unimplemented {
() => (panic!("not yet implemented"))
}
#[macro_export] #[macro_export]
#[allow_internal_unstable]
macro_rules! print { macro_rules! print {
($($arg:tt)*) => ( ($($arg:tt)*) => (
$crate::io::_print(format_args!($($arg)*)); $crate::io::_print(format_args!($($arg)*));

2
std/src/sys/wtf8.rs

@ -29,7 +29,7 @@ use core::str::next_code_point;
use ascii::*; use ascii::*;
use borrow::Cow; use borrow::Cow;
use rustc_unicode::char; use std_unicode::char;
use fmt; use fmt;
use hash::{Hash, Hasher}; use hash::{Hash, Hasher};
use iter::FromIterator; use iter::FromIterator;

Loading…
Cancel
Save