let guards: Vec<_> = (0..3).map(|i| {
Thread::scoped(move || {
- for j in 0..3 { numbers[j] += 1 }
+ numbers[i] += 1;
+ println!("numbers[{}] is {}", i, numbers[i]);
});
}).collect();
}
It gives us this error:
```text
-7:29: 9:10 error: cannot move out of captured outer variable in an `FnMut` closure
-7 Thread::scoped(move || {
-8 for j in 0..3 { numbers[j] += 1 }
-9 });
+7:25: 10:6 error: cannot move out of captured outer variable in an `FnMut` closure
+7 Thread::scoped(move || {
+8 numbers[i] += 1;
+9 println!("numbers[{}] is {}", i, numbers[i]);
+10 });
+error: aborting due to previous error
```
It mentions that "captured outer variable in an `FnMut` closure".
types, e.g. as the return type of a public function.
This capability may be removed in the future.
+* `allow_internal_unstable` - Allows `macro_rules!` macros to be tagged with the
+ `#[allow_internal_unstable]` attribute, designed
+ to allow `std` macros to call
+ `#[unstable]`/feature-gated functionality
+ internally without imposing on callers
+ (i.e. making them behave like function calls in
+ terms of encapsulation).
+
If a feature is promoted to a language feature, then all existing programs will
start to receive compilation warnings about #[feature] directives which enabled
the new feature (because the directive is no longer necessary). However, if a
## Tuples
-The first compound data type we're going to talk about are called *tuples*.
-Tuples are an ordered list of a fixed size. Like this:
+The first compound data type we're going to talk about is called the *tuple*.
+A tuple is an ordered list of fixed size. Like this:
```rust
let x = (1, "hello");
```
An `enum` variant can be defined as most normal types. Below are some example
-types have been listed which also would be allowed in an `enum`.
+types which also would be allowed in an `enum`.
```rust
struct Empty;
import subprocess
import re
import os
-from licenseck import *
+from licenseck import check_license
import snapshot
err = 0
tab_flag = "ignore-tidy-tab"
linelength_flag = "ignore-tidy-linelength"
-# Be careful to support Python 2.4, 2.6, and 3.x here!
-config_proc = subprocess.Popen(["git", "config", "core.autocrlf"],
- stdout=subprocess.PIPE)
-result = config_proc.communicate()[0]
-
-true = "true".encode('utf8')
-autocrlf = result.strip() == true if result is not None else False
+interesting_files = ['.rs', '.py', '.js', '.sh', '.c', '.h']
+uninteresting_files = ['miniz.c', 'jquery', 'rust_android_dummy']
def report_error_name_no(name, no, s):
if not check_license(name, contents):
report_error_name_no(name, 1, "incorrect license")
+
+def update_counts(current_name):
+ global file_counts
+ global count_other_linted_files
+
+ _, ext = os.path.splitext(current_name)
+
+ if ext in interesting_files:
+ file_counts[ext] += 1
+ else:
+ count_other_linted_files += 1
+
+
+def interesting_file(f):
+ if any(x in f for x in uninteresting_files):
+ return False
+
+ return any(os.path.splitext(f)[1] == ext for ext in interesting_files)
+
+
+# Be careful to support Python 2.4, 2.6, and 3.x here!
+config_proc = subprocess.Popen(["git", "config", "core.autocrlf"],
+ stdout=subprocess.PIPE)
+result = config_proc.communicate()[0]
+
+true = "true".encode('utf8')
+autocrlf = result.strip() == true if result is not None else False
+
current_name = ""
current_contents = ""
check_tab = True
src_dir = sys.argv[1]
-try:
- count_lines = 0
- count_non_blank_lines = 0
+count_lines = 0
+count_non_blank_lines = 0
+count_other_linted_files = 0
- interesting_files = ['.rs', '.py', '.js', '.sh', '.c', '.h']
+file_counts = {ext: 0 for ext in interesting_files}
- file_counts = {ext: 0 for ext in interesting_files}
- file_counts['other'] = 0
-
- def update_counts(current_name):
- global file_counts
- _, ext = os.path.splitext(current_name)
-
- if ext in file_counts:
- file_counts[ext] += 1
- else:
- file_counts['other'] += 1
-
- all_paths = set()
+all_paths = set()
+try:
for (dirpath, dirnames, filenames) in os.walk(src_dir):
-
# Skip some third-party directories
skippable_dirs = {
'src/jemalloc',
if any(d in dirpath for d in skippable_dirs):
continue
- def interesting_file(f):
- if "miniz.c" in f \
- or "jquery" in f \
- or "rust_android_dummy" in f:
- return False
-
- return any(os.path.splitext(f)[1] == ext for ext in interesting_files)
-
file_names = [os.path.join(dirpath, f) for f in filenames
if interesting_file(f)
and not f.endswith("_gen.rs")
report_err("UTF-8 decoding error " + str(e))
print
-for ext in file_counts:
- print "* linted " + str(file_counts[ext]) + " " + ext + " files"
-print "* total lines of code: " + str(count_lines)
-print "* total non-blank lines of code: " + str(count_non_blank_lines)
+for ext in sorted(file_counts, key=file_counts.get, reverse=True):
+ print "* linted {} {} files".format(file_counts[ext], ext)
+print "* linted {} other files".format(count_other_linted_files)
+print "* total lines of code: {}".format(count_lines)
+print "* total non-blank lines of code: {}".format(count_non_blank_lines)
print
sys.exit(err)
sys.stderr.write("cannot load %s" % f)
exit(1)
-def is_valid_unicode(n):
- return 0 <= n <= 0xD7FF or 0xE000 <= n <= 0x10FFFF
+def is_surrogate(n):
+ return 0xD800 <= n <= 0xDFFF
def load_unicode_data(f):
fetch(f)
canon_decomp = {}
compat_decomp = {}
+ udict = {};
+ range_start = -1;
for line in fileinput.input(f):
- fields = line.split(";")
- if len(fields) != 15:
+ data = line.split(';');
+ if len(data) != 15:
continue
- [code, name, gencat, combine, bidi,
- decomp, deci, digit, num, mirror,
- old, iso, upcase, lowcase, titlecase ] = fields
-
- code_org = code
- code = int(code, 16)
-
- if not is_valid_unicode(code):
+ cp = int(data[0], 16);
+ if is_surrogate(cp):
continue
+ if range_start >= 0:
+ for i in xrange(range_start, cp):
+ udict[i] = data;
+ range_start = -1;
+ if data[1].endswith(", First>"):
+ range_start = cp;
+ continue;
+ udict[cp] = data;
+
+ for code in udict:
+ [code_org, name, gencat, combine, bidi,
+ decomp, deci, digit, num, mirror,
+ old, iso, upcase, lowcase, titlecase ] = udict[code];
# generate char to char direct common and simple conversions
# uppercase to lowercase
%precedence MOD_SEP
%precedence RARROW ':'
+// In where clauses, "for" should have greater precedence when used as
+// a higher ranked constraint than when used as the beginning of a
+// for_in_type (which is a ty)
+%precedence FORTYPE
+%precedence FOR
+
// Binops & unops, and their precedences
%precedence BOX
%precedence BOXPLACE
{
$$ = mk_node("ItemImplNeg", 7, $1, $3, $5, $7, $8, $10, $11);
}
+| maybe_unsafe IMPL generic_params trait_ref FOR DOTDOT '{' '}'
+{
+ $$ = mk_node("ItemImplDefault", 3, $1, $3, $4);
+}
+| maybe_unsafe IMPL generic_params '!' trait_ref FOR DOTDOT '{' '}'
+{
+ $$ = mk_node("ItemImplDefaultNeg", 3, $1, $3, $4);
+}
;
maybe_impl_items
;
where_predicate
-: lifetime ':' bounds { $$ = mk_node("WherePredicate", 2, $1, $3); }
-| ty ':' ty_param_bounds { $$ = mk_node("WherePredicate", 2, $1, $3); }
+: maybe_for_lifetimes lifetime ':' bounds { $$ = mk_node("WherePredicate", 3, $1, $2, $4); }
+| maybe_for_lifetimes ty ':' ty_param_bounds { $$ = mk_node("WherePredicate", 3, $1, $2, $4); }
;
+maybe_for_lifetimes
+: FOR '<' lifetimes '>' { $$ = mk_none(); }
+| %prec FORTYPE %empty { $$ = mk_none(); }
+
ty_params
: ty_param { $$ = mk_node("TyParams", 1, $1); }
| ty_params ',' ty_param { $$ = ext_node($1, 1, $3); }
}
| ty_qualified_path ',' ty_sums maybe_bindings
{
- $$ = mk_node("GenericValues", 3, mk_none(), ext_node(mk_node("TySums", 1, $1), 1, $3), $4); }
+ $$ = mk_node("GenericValues", 3, mk_none(), mk_node("TySums", 2, $1, $3), $4);
+}
;
ty_qualified_path
;
expr_qualified_path
-: '<' ty_sum AS trait_ref '>' MOD_SEP ident
+: '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident
{
- $$ = mk_node("ExprQualifiedPath", 3, $2, $4, $7);
+ $$ = mk_node("ExprQualifiedPath", 3, $2, $3, $6);
}
-| '<' ty_sum AS trait_ref '>' MOD_SEP ident generic_args
+| '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args
{
- $$ = mk_node("ExprQualifiedPath", 4, $2, $4, $7, $8);
+ $$ = mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7);
}
-| SHL ty_sum AS trait_ref '>' MOD_SEP ident AS trait_ref '>' MOD_SEP ident
+| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident
{
- $$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 3, $2, $4, $7), $9, $12);
+ $$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 3, $2, $3, $6), $7, $10);
}
-| SHL ty_sum AS trait_ref '>' MOD_SEP ident generic_args AS trait_ref '>' MOD_SEP ident
+| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args maybe_as_trait_ref '>' MOD_SEP ident
{
- $$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 4, $2, $4, $7, $8), $10, $13);
+ $$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7), $8, $11);
}
-| SHL ty_sum AS trait_ref '>' MOD_SEP ident AS trait_ref '>' MOD_SEP ident generic_args
+| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident generic_args
{
- $$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 3, $2, $4, $7), $9, $12, $13);
+ $$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 3, $2, $3, $6), $7, $10, $11);
}
-| SHL ty_sum AS trait_ref '>' MOD_SEP ident generic_args AS trait_ref '>' MOD_SEP ident generic_args
+| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args maybe_as_trait_ref '>' MOD_SEP ident generic_args
{
- $$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 4, $2, $4, $7, $8), $10, $13, $14);
+ $$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7), $8, $11, $12);
}
+maybe_as_trait_ref
+: AS trait_ref { $$ = $2; }
+| %empty { $$ = mk_none(); }
+;
lambda_expr
: %prec LAMBDA
-Subproject commit b001609960ca33047e5cbc5a231c1e24b6041d4b
+Subproject commit e24a1a025a1f214e40eedafe3b9c7b1d69937922
//! }
//! ```
//!
-//! This will print `Cons(1i32, Box(Cons(2i32, Box(Nil))))`.
+//! This will print `Cons(1, Box(Cons(2, Box(Nil))))`.
#![stable(feature = "rust1", since = "1.0.0")]
#[test]
fn deref() {
fn homura<T: Deref<Target=i32>>(_: T) { }
- homura(Box::new(765i32));
+ homura(Box::new(765));
}
#[test]
fn raw_sized() {
unsafe {
- let x = Box::new(17i32);
+ let x = Box::new(17);
let p = boxed::into_raw(x);
assert_eq!(17, *p);
*p = 19;
// have to uselessly pretend to pad the longer one for type matching
if a_len < b_len {
- (a.blocks().enumerate().chain(iter::repeat(0u32).enumerate().take(b_len).skip(a_len)),
- b.blocks().enumerate().chain(iter::repeat(0u32).enumerate().take(0).skip(0)))
+ (a.blocks().enumerate().chain(iter::repeat(0).enumerate().take(b_len).skip(a_len)),
+ b.blocks().enumerate().chain(iter::repeat(0).enumerate().take(0).skip(0)))
} else {
- (a.blocks().enumerate().chain(iter::repeat(0u32).enumerate().take(0).skip(0)),
- b.blocks().enumerate().chain(iter::repeat(0u32).enumerate().take(a_len).skip(b_len)))
+ (a.blocks().enumerate().chain(iter::repeat(0).enumerate().take(0).skip(0)),
+ b.blocks().enumerate().chain(iter::repeat(0).enumerate().take(a_len).skip(b_len)))
}
}
/// Computes the bitmask for the final word of the vector
fn mask_for_bits(bits: usize) -> u32 {
// Note especially that a perfect multiple of u32::BITS should mask all 1s.
- !0u32 >> (u32::BITS as usize - bits % u32::BITS as usize) % u32::BITS as usize
+ !0 >> (u32::BITS as usize - bits % u32::BITS as usize) % u32::BITS as usize
}
impl BitVec {
pub fn from_elem(nbits: usize, bit: bool) -> BitVec {
let nblocks = blocks_for_bits(nbits);
let mut bit_vec = BitVec {
- storage: repeat(if bit { !0u32 } else { 0u32 }).take(nblocks).collect(),
+ storage: repeat(if bit { !0 } else { 0 }).take(nblocks).collect(),
nbits: nbits
};
bit_vec.fix_last_block();
}
if extra_bytes > 0 {
- let mut last_word = 0u32;
+ let mut last_word = 0;
for (i, &byte) in bytes[complete_words*4..].iter().enumerate() {
last_word |= (reverse_bits(byte) as u32) << (i * 8);
}
/// ```
#[inline]
pub fn set_all(&mut self) {
- for w in &mut self.storage { *w = !0u32; }
+ for w in &mut self.storage { *w = !0; }
self.fix_last_block();
}
/// assert_eq!(bv.all(), false);
/// ```
pub fn all(&self) -> bool {
- let mut last_word = !0u32;
+ let mut last_word = !0;
// Check that every block but the last is all-ones...
self.blocks().all(|elem| {
let tmp = last_word;
last_word = elem;
- tmp == !0u32
+ tmp == !0
// and then check the last one has enough ones
}) && (last_word == mask_for_bits(self.nbits))
}
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn clear(&mut self) {
- for w in &mut self.storage { *w = 0u32; }
+ for w in &mut self.storage { *w = 0; }
}
}
assert_eq!(bit_vec.iter().collect::<Vec<bool>>(), bools);
- let long: Vec<_> = (0i32..10000).map(|i| i % 2 == 0).collect();
+ let long: Vec<_> = (0..10000).map(|i| i % 2 == 0).collect();
let bit_vec: BitVec = long.iter().map(|n| *n).collect();
assert_eq!(bit_vec.iter().collect::<Vec<bool>>(), long)
}
//! Some examples of the output from both traits:
//!
//! ```
-//! assert_eq!(format!("{} {:?}", 3i32, 4i32), "3 4");
+//! assert_eq!(format!("{} {:?}", 3, 4), "3 4");
//! assert_eq!(format!("{} {:?}", 'a', 'b'), "a 'b'");
//! assert_eq!(format!("{} {:?}", "foo\n", "bar\n"), "foo\n \"bar\\n\"");
//! ```
#[test]
fn test_bytes_set_memory() {
use slice::bytes::MutableByteVector;
- let mut values = [1u8,2,3,4,5];
+ let mut values = [1,2,3,4,5];
values[0..5].set_memory(0xAB);
assert!(values == [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]);
values[2..4].set_memory(0xFF);
fn test_mut_chunks() {
use core::iter::ExactSizeIterator;
- let mut v = [0u8, 1, 2, 3, 4, 5, 6];
+ let mut v = [0, 1, 2, 3, 4, 5, 6];
assert_eq!(v.chunks_mut(2).len(), 4);
for (i, chunk) in v.chunks_mut(3).enumerate() {
for x in chunk {
*x = i as u8;
}
}
- let result = [0u8, 0, 0, 1, 1, 1, 2];
+ let result = [0, 0, 0, 1, 1, 1, 2];
assert!(v == result);
}
#[test]
fn test_mut_chunks_rev() {
- let mut v = [0u8, 1, 2, 3, 4, 5, 6];
+ let mut v = [0, 1, 2, 3, 4, 5, 6];
for (i, chunk) in v.chunks_mut(3).rev().enumerate() {
for x in chunk {
*x = i as u8;
}
}
- let result = [2u8, 2, 2, 1, 1, 1, 0];
+ let result = [2, 2, 2, 1, 1, 1, 0];
assert!(v == result);
}
//
// ignore-lexer-test FIXME #15679
-//! Unicode string manipulation (the `str` type).
+//! Unicode string manipulation (the [`str`](../primitive.str.html) type).
//!
-//! Rust's `str` type is one of the core primitive types of the language. `&str` is the borrowed
-//! string type. This type of string can only be created from other strings, unless it is a static
-//! string (see below). As the word "borrowed" implies, this type of string is owned elsewhere, and
-//! this string cannot be moved out of.
+//! Rust's [`str`](../primitive.str.html) type is one of the core primitive types of the
+//! language. `&str` is the borrowed string type. This type of string can only be created
+//! from other strings, unless it is a `&'static str` (see below). It is not possible to
+//! move out of borrowed strings because they are owned elsewhere.
+//!
+//! Basic operations are implemented directly by the compiler, but more advanced operations are
+//! defined on the [`StrExt`](trait.StrExt.html) trait.
//!
//! # Examples
//!
// return the value of $ch updated with continuation byte $byte
macro_rules! utf8_acc_cont_byte {
- ($ch:expr, $byte:expr) => (($ch << 6) | ($byte & 63u8) as u32)
+ ($ch:expr, $byte:expr) => (($ch << 6) | ($byte & 63) as u32)
}
#[stable(feature = "rust1", since = "1.0.0")]
#[test]
fn test_chars_decoding() {
- let mut bytes = [0u8; 4];
- for c in (0u32..0x110000).filter_map(|c| ::core::char::from_u32(c)) {
+ let mut bytes = [0; 4];
+ for c in (0..0x110000).filter_map(|c| ::core::char::from_u32(c)) {
let len = c.encode_utf8(&mut bytes).unwrap_or(0);
let s = ::core::str::from_utf8(&bytes[..len]).unwrap();
if Some(c) != s.chars().next() {
#[test]
fn test_chars_rev_decoding() {
- let mut bytes = [0u8; 4];
- for c in (0u32..0x110000).filter_map(|c| ::core::char::from_u32(c)) {
+ let mut bytes = [0; 4];
+ for c in (0..0x110000).filter_map(|c| ::core::char::from_u32(c)) {
let len = c.encode_utf8(&mut bytes).unwrap_or(0);
let s = ::core::str::from_utf8(&bytes[..len]).unwrap();
if Some(c) != s.chars().rev().next() {
}
}
- const TAG_CONT_U8: u8 = 128u8;
+ const TAG_CONT_U8: u8 = 128;
const REPLACEMENT: &'static [u8] = b"\xEF\xBF\xBD"; // U+FFFD in UTF-8
let total = v.len();
fn unsafe_get(xs: &[u8], i: usize) -> u8 {
}
})}
- if byte < 128u8 {
+ if byte < 128 {
// subseqidx handles this
} else {
let w = unicode_str::utf8_char_width(byte);
match w {
2 => {
- if safe_get(v, i, total) & 192u8 != TAG_CONT_U8 {
+ if safe_get(v, i, total) & 192 != TAG_CONT_U8 {
error!();
continue;
}
}
}
i += 1;
- if safe_get(v, i, total) & 192u8 != TAG_CONT_U8 {
+ if safe_get(v, i, total) & 192 != TAG_CONT_U8 {
error!();
continue;
}
}
}
i += 1;
- if safe_get(v, i, total) & 192u8 != TAG_CONT_U8 {
+ if safe_get(v, i, total) & 192 != TAG_CONT_U8 {
error!();
continue;
}
i += 1;
- if safe_get(v, i, total) & 192u8 != TAG_CONT_U8 {
+ if safe_get(v, i, total) & 192 != TAG_CONT_U8 {
error!();
continue;
}
fn test_from_utf16() {
let pairs =
[(String::from_str("𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n"),
- vec![0xd800_u16, 0xdf45_u16, 0xd800_u16, 0xdf3f_u16,
- 0xd800_u16, 0xdf3b_u16, 0xd800_u16, 0xdf46_u16,
- 0xd800_u16, 0xdf39_u16, 0xd800_u16, 0xdf3b_u16,
- 0xd800_u16, 0xdf30_u16, 0x000a_u16]),
+ vec![0xd800, 0xdf45, 0xd800, 0xdf3f,
+ 0xd800, 0xdf3b, 0xd800, 0xdf46,
+ 0xd800, 0xdf39, 0xd800, 0xdf3b,
+ 0xd800, 0xdf30, 0x000a]),
(String::from_str("𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n"),
- vec![0xd801_u16, 0xdc12_u16, 0xd801_u16,
- 0xdc49_u16, 0xd801_u16, 0xdc2e_u16, 0xd801_u16,
- 0xdc40_u16, 0xd801_u16, 0xdc32_u16, 0xd801_u16,
- 0xdc4b_u16, 0x0020_u16, 0xd801_u16, 0xdc0f_u16,
- 0xd801_u16, 0xdc32_u16, 0xd801_u16, 0xdc4d_u16,
- 0x000a_u16]),
+ vec![0xd801, 0xdc12, 0xd801,
+ 0xdc49, 0xd801, 0xdc2e, 0xd801,
+ 0xdc40, 0xd801, 0xdc32, 0xd801,
+ 0xdc4b, 0x0020, 0xd801, 0xdc0f,
+ 0xd801, 0xdc32, 0xd801, 0xdc4d,
+ 0x000a]),
(String::from_str("𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n"),
- vec![0xd800_u16, 0xdf00_u16, 0xd800_u16, 0xdf16_u16,
- 0xd800_u16, 0xdf0b_u16, 0xd800_u16, 0xdf04_u16,
- 0xd800_u16, 0xdf11_u16, 0xd800_u16, 0xdf09_u16,
- 0x00b7_u16, 0xd800_u16, 0xdf0c_u16, 0xd800_u16,
- 0xdf04_u16, 0xd800_u16, 0xdf15_u16, 0xd800_u16,
- 0xdf04_u16, 0xd800_u16, 0xdf0b_u16, 0xd800_u16,
- 0xdf09_u16, 0xd800_u16, 0xdf11_u16, 0x000a_u16 ]),
+ vec![0xd800, 0xdf00, 0xd800, 0xdf16,
+ 0xd800, 0xdf0b, 0xd800, 0xdf04,
+ 0xd800, 0xdf11, 0xd800, 0xdf09,
+ 0x00b7, 0xd800, 0xdf0c, 0xd800,
+ 0xdf04, 0xd800, 0xdf15, 0xd800,
+ 0xdf04, 0xd800, 0xdf0b, 0xd800,
+ 0xdf09, 0xd800, 0xdf11, 0x000a ]),
(String::from_str("𐒋𐒘𐒈𐒑𐒛𐒒 𐒕𐒓 𐒈𐒚𐒍 𐒏𐒜𐒒𐒖𐒆 𐒕𐒆\n"),
- vec![0xd801_u16, 0xdc8b_u16, 0xd801_u16, 0xdc98_u16,
- 0xd801_u16, 0xdc88_u16, 0xd801_u16, 0xdc91_u16,
- 0xd801_u16, 0xdc9b_u16, 0xd801_u16, 0xdc92_u16,
- 0x0020_u16, 0xd801_u16, 0xdc95_u16, 0xd801_u16,
- 0xdc93_u16, 0x0020_u16, 0xd801_u16, 0xdc88_u16,
- 0xd801_u16, 0xdc9a_u16, 0xd801_u16, 0xdc8d_u16,
- 0x0020_u16, 0xd801_u16, 0xdc8f_u16, 0xd801_u16,
- 0xdc9c_u16, 0xd801_u16, 0xdc92_u16, 0xd801_u16,
- 0xdc96_u16, 0xd801_u16, 0xdc86_u16, 0x0020_u16,
- 0xd801_u16, 0xdc95_u16, 0xd801_u16, 0xdc86_u16,
- 0x000a_u16 ]),
+ vec![0xd801, 0xdc8b, 0xd801, 0xdc98,
+ 0xd801, 0xdc88, 0xd801, 0xdc91,
+ 0xd801, 0xdc9b, 0xd801, 0xdc92,
+ 0x0020, 0xd801, 0xdc95, 0xd801,
+ 0xdc93, 0x0020, 0xd801, 0xdc88,
+ 0xd801, 0xdc9a, 0xd801, 0xdc8d,
+ 0x0020, 0xd801, 0xdc8f, 0xd801,
+ 0xdc9c, 0xd801, 0xdc92, 0xd801,
+ 0xdc96, 0xd801, 0xdc86, 0x0020,
+ 0xd801, 0xdc95, 0xd801, 0xdc86,
+ 0x000a ]),
// Issue #12318, even-numbered non-BMP planes
(String::from_str("\u{20000}"),
vec![0xD840, 0xDC00])];
assert_eq!(1.to_string(), "1");
assert_eq!((-1).to_string(), "-1");
assert_eq!(200.to_string(), "200");
- assert_eq!(2u8.to_string(), "2");
+ assert_eq!(2.to_string(), "2");
assert_eq!(true.to_string(), "true");
assert_eq!(false.to_string(), "false");
assert_eq!(("hi".to_string()).to_string(), "hi");
#[bench]
fn from_utf8_lossy_100_invalid(b: &mut Bencher) {
- let s = repeat(0xf5u8).take(100).collect::<Vec<_>>();
+ let s = repeat(0xf5).take(100).collect::<Vec<_>>();
b.iter(|| {
let _ = String::from_utf8_lossy(&s);
});
use slice::SliceExt;
// UTF-8 ranges and tags for encoding characters
-const TAG_CONT: u8 = 0b1000_0000u8;
-const TAG_TWO_B: u8 = 0b1100_0000u8;
-const TAG_THREE_B: u8 = 0b1110_0000u8;
-const TAG_FOUR_B: u8 = 0b1111_0000u8;
-const MAX_ONE_B: u32 = 0x80u32;
-const MAX_TWO_B: u32 = 0x800u32;
-const MAX_THREE_B: u32 = 0x10000u32;
+const TAG_CONT: u8 = 0b1000_0000;
+const TAG_TWO_B: u8 = 0b1100_0000;
+const TAG_THREE_B: u8 = 0b1110_0000;
+const TAG_FOUR_B: u8 = 0b1111_0000;
+const MAX_ONE_B: u32 = 0x80;
+const MAX_TWO_B: u32 = 0x800;
+const MAX_THREE_B: u32 = 0x10000;
/*
Lu Uppercase_Letter an uppercase letter
#[stable(feature = "rust1", since = "1.0.0")]
fn len_utf16(self) -> usize {
let ch = self as u32;
- if (ch & 0xFFFF_u32) == ch { 1 } else { 2 }
+ if (ch & 0xFFFF) == ch { 1 } else { 2 }
}
#[inline]
dst[0] = code as u8;
Some(1)
} else if code < MAX_TWO_B && dst.len() >= 2 {
- dst[0] = (code >> 6 & 0x1F_u32) as u8 | TAG_TWO_B;
- dst[1] = (code & 0x3F_u32) as u8 | TAG_CONT;
+ dst[0] = (code >> 6 & 0x1F) as u8 | TAG_TWO_B;
+ dst[1] = (code & 0x3F) as u8 | TAG_CONT;
Some(2)
} else if code < MAX_THREE_B && dst.len() >= 3 {
- dst[0] = (code >> 12 & 0x0F_u32) as u8 | TAG_THREE_B;
- dst[1] = (code >> 6 & 0x3F_u32) as u8 | TAG_CONT;
- dst[2] = (code & 0x3F_u32) as u8 | TAG_CONT;
+ dst[0] = (code >> 12 & 0x0F) as u8 | TAG_THREE_B;
+ dst[1] = (code >> 6 & 0x3F) as u8 | TAG_CONT;
+ dst[2] = (code & 0x3F) as u8 | TAG_CONT;
Some(3)
} else if dst.len() >= 4 {
- dst[0] = (code >> 18 & 0x07_u32) as u8 | TAG_FOUR_B;
- dst[1] = (code >> 12 & 0x3F_u32) as u8 | TAG_CONT;
- dst[2] = (code >> 6 & 0x3F_u32) as u8 | TAG_CONT;
- dst[3] = (code & 0x3F_u32) as u8 | TAG_CONT;
+ dst[0] = (code >> 18 & 0x07) as u8 | TAG_FOUR_B;
+ dst[1] = (code >> 12 & 0x3F) as u8 | TAG_CONT;
+ dst[2] = (code >> 6 & 0x3F) as u8 | TAG_CONT;
+ dst[3] = (code & 0x3F) as u8 | TAG_CONT;
Some(4)
} else {
None
#[unstable(feature = "core")]
pub fn encode_utf16_raw(mut ch: u32, dst: &mut [u16]) -> Option<usize> {
// Marked #[inline] to allow llvm optimizing it away
- if (ch & 0xFFFF_u32) == ch && dst.len() >= 1 {
+ if (ch & 0xFFFF) == ch && dst.len() >= 1 {
// The BMP falls through (assuming non-surrogate, as it should)
dst[0] = ch as u16;
Some(1)
} else if dst.len() >= 2 {
// Supplementary planes break into surrogates.
- ch -= 0x1_0000_u32;
- dst[0] = 0xD800_u16 | ((ch >> 10) as u16);
- dst[1] = 0xDC00_u16 | ((ch as u16) & 0x3FF_u16);
+ ch -= 0x1_0000;
+ dst[0] = 0xD800 | ((ch >> 10) as u16);
+ dst[1] = 0xDC00 | ((ch as u16) & 0x3FF);
Some(2)
} else {
None
// For an f64 the exponent is in the range of [-1022, 1023] for base 2, so
// we may have up to that many digits. Give ourselves some extra wiggle room
// otherwise as well.
- let mut buf = [0u8; 1536];
+ let mut buf = [0; 1536];
let mut end = 0;
let radix_gen: T = cast(radix as int).unwrap();
let (num, exp) = match exp_format {
- ExpNone => (num, 0i32),
- ExpDec if num == _0 => (num, 0i32),
+ ExpNone => (num, 0),
+ ExpDec if num == _0 => (num, 0),
ExpDec => {
let (exp, exp_base) = match exp_format {
ExpDec => (num.abs().log10().floor(), cast::<f64, T>(10.0f64).unwrap()),
Alignment::Center => (padding / 2, (padding + 1) / 2),
};
- let mut fill = [0u8; 4];
+ let mut fill = [0; 4];
let len = self.fill.encode_utf8(&mut fill).unwrap_or(0);
let fill = unsafe { str::from_utf8_unchecked(&fill[..len]) };
#[stable(feature = "rust1", since = "1.0.0")]
impl Display for char {
fn fmt(&self, f: &mut Formatter) -> Result {
- let mut utf8 = [0u8; 4];
+ let mut utf8 = [0; 4];
let amt = self.encode_utf8(&mut utf8).unwrap_or(0);
let s: &str = unsafe { mem::transmute(&utf8[..amt]) };
Display::fmt(s, f)
// characters for a base 2 number.
let zero = Int::zero();
let is_positive = x >= zero;
- let mut buf = [0u8; 64];
+ let mut buf = [0; 64];
let mut curr = buf.len();
let base = cast(self.base()).unwrap();
if is_positive {
($buf:expr, $i:expr, $len:expr) =>
({
let mut t = 0;
- let mut out = 0u64;
+ let mut out = 0;
while t < $len {
out |= ($buf[t+$i] as u64) << t*8;
t += 1;
/// use std::mem;
///
/// let v: &[u8] = unsafe { mem::transmute("L") };
- /// assert!(v == [76u8]);
+ /// assert!(v == [76]);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn transmute<T,U>(e: T) -> U;
/// ```
/// use std::iter::AdditiveIterator;
///
- /// let a = [1i32, 2, 3, 4, 5];
+ /// let a = [1, 2, 3, 4, 5];
/// let mut it = a.iter().cloned();
/// assert!(it.sum() == 15);
/// ```
///
/// ```rust
/// fn divide_by_three(x: u32) -> u32 { // one of the poorest implementations of x/3
-/// for i in std::iter::count(0_u32, 1) {
+/// for i in std::iter::count(0, 1) {
/// if 3*i < i { panic!("u32 overflow"); }
/// if x < 3*i { return i-1; }
/// }
macro_rules! impl_from_primitive {
($T:ty, $to_ty:ident) => (
+ #[allow(deprecated)]
impl FromPrimitive for $T {
#[inline] fn from_int(n: int) -> Option<$T> { n.$to_ty() }
#[inline] fn from_i8(n: i8) -> Option<$T> { n.$to_ty() }
($T:ty, $conv:ident) => (
impl NumCast for $T {
#[inline]
+ #[allow(deprecated)]
fn from<N: ToPrimitive>(n: N) -> Option<$T> {
// `$conv` could be generated using `concat_idents!`, but that
// macro seems to be broken at the moment
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Index<Idx: ?Sized> {
/// The returned type after indexing
+ #[stable(feature = "rust1", since = "1.0.0")]
type Output: ?Sized;
/// The method for the indexing (`Foo[Bar]`) operation
/// # Example
///
/// ```
- /// let k = 10i32;
+ /// let k = 10;
/// assert_eq!(Some(4).unwrap_or_else(|| 2 * k), 4);
/// assert_eq!(None.unwrap_or_else(|| 2 * k), 20);
/// ```
}
/// Mask of the value bits of a continuation byte
-const CONT_MASK: u8 = 0b0011_1111u8;
+const CONT_MASK: u8 = 0b0011_1111;
/// Value of the tag bits (tag mask is !CONT_MASK) of a continuation byte
-const TAG_CONT_U8: u8 = 0b1000_0000u8;
+const TAG_CONT_U8: u8 = 0b1000_0000;
/*
Section: Trait implementations
if index == self.len() { return true; }
match self.as_bytes().get(index) {
None => false,
- Some(&b) => b < 128u8 || b >= 192u8,
+ Some(&b) => b < 128 || b >= 192,
}
}
#[inline]
#[unstable(feature = "core")]
pub fn char_range_at_raw(bytes: &[u8], i: usize) -> (u32, usize) {
- if bytes[i] < 128u8 {
+ if bytes[i] < 128 {
return (bytes[i] as u32, i + 1);
}
#[test]
fn test_encode_utf8() {
fn check(input: char, expect: &[u8]) {
- let mut buf = [0u8; 4];
+ let mut buf = [0; 4];
let n = input.encode_utf8(&mut buf).unwrap_or(0);
assert_eq!(&buf[..n], expect);
}
#[test]
fn test_encode_utf16() {
fn check(input: char, expect: &[u16]) {
- let mut buf = [0u16; 2];
+ let mut buf = [0; 2];
let n = input.encode_utf16(&mut buf).unwrap_or(0);
assert_eq!(&buf[..n], expect);
}
// FIXME (#18283) Enable test
//let s: Box<str> = box "a";
//assert_eq!(hasher.hash(& s), 97 + 0xFF);
- let cs: &[u8] = &[1u8, 2u8, 3u8];
+ let cs: &[u8] = &[1, 2, 3];
assert_eq!(hash(& cs), 9);
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
- let cs: Box<[u8]> = Box::new([1u8, 2u8, 3u8]);
+ let cs: Box<[u8]> = Box::new([1, 2, 3]);
assert_eq!(hash(& cs), 9);
// FIXME (#18248) Add tests for hashing Rc<str> and Rc<[T]>
[ 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, ]
];
- let k0 = 0x_07_06_05_04_03_02_01_00_u64;
- let k1 = 0x_0f_0e_0d_0c_0b_0a_09_08_u64;
+ let k0 = 0x_07_06_05_04_03_02_01_00;
+ let k1 = 0x_0f_0e_0d_0c_0b_0a_09_08;
let mut buf = Vec::new();
let mut t = 0;
let mut state_inc = SipState::new_with_keys(k0, k1);
assert!(s != t && t != u);
assert!(hash(&s) != hash(&t) && hash(&s) != hash(&u));
- let v: (&[u8], &[u8], &[u8]) = (&[1u8], &[0u8, 0], &[0u8]);
- let w: (&[u8], &[u8], &[u8]) = (&[1u8, 0, 0, 0], &[], &[]);
+ let v: (&[u8], &[u8], &[u8]) = (&[1], &[0, 0], &[0]);
+ let w: (&[u8], &[u8], &[u8]) = (&[1, 0, 0, 0], &[], &[]);
assert!(v != w);
assert!(hash(&v) != hash(&w));
assert_eq!(range_step(0, 20, 5).collect::<Vec<int>>(), [0, 5, 10, 15]);
assert_eq!(range_step(20, 0, -5).collect::<Vec<int>>(), [20, 15, 10, 5]);
assert_eq!(range_step(20, 0, -6).collect::<Vec<int>>(), [20, 14, 8, 2]);
- assert_eq!(range_step(200u8, 255, 50).collect::<Vec<u8>>(), [200u8, 250]);
- assert_eq!(range_step(200i, -5, 1).collect::<Vec<int>>(), []);
- assert_eq!(range_step(200i, 200, 1).collect::<Vec<int>>(), []);
+ assert_eq!(range_step(200, 255, 50).collect::<Vec<u8>>(), [200, 250]);
+ assert_eq!(range_step(200, -5, 1).collect::<Vec<int>>(), []);
+ assert_eq!(range_step(200, 200, 1).collect::<Vec<int>>(), []);
}
#[test]
assert_eq!(range_step_inclusive(0, 20, 5).collect::<Vec<int>>(), [0, 5, 10, 15, 20]);
assert_eq!(range_step_inclusive(20, 0, -5).collect::<Vec<int>>(), [20, 15, 10, 5, 0]);
assert_eq!(range_step_inclusive(20, 0, -6).collect::<Vec<int>>(), [20, 14, 8, 2]);
- assert_eq!(range_step_inclusive(200u8, 255, 50).collect::<Vec<u8>>(), [200u8, 250]);
+ assert_eq!(range_step_inclusive(200, 255, 50).collect::<Vec<u8>>(), [200, 250]);
assert_eq!(range_step_inclusive(200, -5, 1).collect::<Vec<int>>(), []);
assert_eq!(range_step_inclusive(200, 200, 1).collect::<Vec<int>>(), [200]);
}
}
unsafe {
- assert_eq!([76u8], transmute::<_, Vec<u8>>("L".to_string()));
+ assert_eq!([76], transmute::<_, Vec<u8>>("L".to_string()));
}
}
#[test]
fn test_int_from_str_overflow() {
- let mut i8_val: i8 = 127_i8;
+ let mut i8_val: i8 = 127;
assert_eq!("127".parse::<i8>().ok(), Some(i8_val));
assert_eq!("128".parse::<i8>().ok(), None);
assert_eq!("-128".parse::<i8>().ok(), Some(i8_val));
assert_eq!("-129".parse::<i8>().ok(), None);
- let mut i16_val: i16 = 32_767_i16;
+ let mut i16_val: i16 = 32_767;
assert_eq!("32767".parse::<i16>().ok(), Some(i16_val));
assert_eq!("32768".parse::<i16>().ok(), None);
assert_eq!("-32768".parse::<i16>().ok(), Some(i16_val));
assert_eq!("-32769".parse::<i16>().ok(), None);
- let mut i32_val: i32 = 2_147_483_647_i32;
+ let mut i32_val: i32 = 2_147_483_647;
assert_eq!("2147483647".parse::<i32>().ok(), Some(i32_val));
assert_eq!("2147483648".parse::<i32>().ok(), None);
assert_eq!("-2147483648".parse::<i32>().ok(), Some(i32_val));
assert_eq!("-2147483649".parse::<i32>().ok(), None);
- let mut i64_val: i64 = 9_223_372_036_854_775_807_i64;
+ let mut i64_val: i64 = 9_223_372_036_854_775_807;
assert_eq!("9223372036854775807".parse::<i64>().ok(), Some(i64_val));
assert_eq!("9223372036854775808".parse::<i64>().ok(), None);
fn test_ptr_subtraction() {
unsafe {
let xs = vec![0,1,2,3,4,5,6,7,8,9];
- let mut idx = 9i8;
+ let mut idx = 9;
let ptr = xs.as_ptr();
- while idx >= 0i8 {
+ while idx >= 0 {
assert_eq!(*(ptr.offset(idx as int)), idx as int);
- idx = idx - 1i8;
+ idx = idx - 1;
}
let mut xs_mut = xs;
#![crate_name = "libc"]
#![crate_type = "rlib"]
-#![cfg_attr(not(feature = "cargo-build"),
- unstable(feature = "libc"))]
-#![cfg_attr(not(feature = "cargo-build"), feature(staged_api))]
+#![cfg_attr(not(feature = "cargo-build"), unstable(feature = "libc"))]
+#![cfg_attr(not(feature = "cargo-build"), feature(staged_api, core, no_std))]
#![cfg_attr(not(feature = "cargo-build"), staged_api)]
-#![cfg_attr(not(feature = "cargo-build"), feature(core))]
-#![feature(no_std)]
-#![no_std]
+#![cfg_attr(not(feature = "cargo-build"), no_std)]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/",
pub const _IOFBF : c_int = 0;
pub const _IONBF : c_int = 4;
pub const _IOLBF : c_int = 64;
- pub const BUFSIZ : c_uint = 512_u32;
- pub const FOPEN_MAX : c_uint = 20_u32;
- pub const FILENAME_MAX : c_uint = 260_u32;
- pub const L_tmpnam : c_uint = 16_u32;
- pub const TMP_MAX : c_uint = 32767_u32;
+ pub const BUFSIZ : c_uint = 512;
+ pub const FOPEN_MAX : c_uint = 20;
+ pub const FILENAME_MAX : c_uint = 260;
+ pub const L_tmpnam : c_uint = 16;
+ pub const TMP_MAX : c_uint = 32767;
pub const WSAEINTR: c_int = 10004;
pub const WSAEBADF: c_int = 10009;
pub const _IOFBF : c_int = 0;
pub const _IONBF : c_int = 2;
pub const _IOLBF : c_int = 1;
- pub const BUFSIZ : c_uint = 8192_u32;
- pub const FOPEN_MAX : c_uint = 16_u32;
- pub const FILENAME_MAX : c_uint = 4096_u32;
- pub const L_tmpnam : c_uint = 20_u32;
- pub const TMP_MAX : c_uint = 238328_u32;
+ pub const BUFSIZ : c_uint = 8192;
+ pub const FOPEN_MAX : c_uint = 16;
+ pub const FILENAME_MAX : c_uint = 4096;
+ pub const L_tmpnam : c_uint = 20;
+ pub const TMP_MAX : c_uint = 238328;
}
pub mod c99 {
}
pub const _IOFBF : c_int = 0;
pub const _IONBF : c_int = 2;
pub const _IOLBF : c_int = 1;
- pub const BUFSIZ : c_uint = 1024_u32;
- pub const FOPEN_MAX : c_uint = 20_u32;
- pub const FILENAME_MAX : c_uint = 1024_u32;
- pub const L_tmpnam : c_uint = 1024_u32;
- pub const TMP_MAX : c_uint = 308915776_u32;
+ pub const BUFSIZ : c_uint = 1024;
+ pub const FOPEN_MAX : c_uint = 20;
+ pub const FILENAME_MAX : c_uint = 1024;
+ pub const L_tmpnam : c_uint = 1024;
+ pub const TMP_MAX : c_uint = 308915776;
}
pub mod c99 {
}
pub const _IOFBF : c_int = 0;
pub const _IONBF : c_int = 2;
pub const _IOLBF : c_int = 1;
- pub const BUFSIZ : c_uint = 1024_u32;
- pub const FOPEN_MAX : c_uint = 20_u32;
- pub const FILENAME_MAX : c_uint = 1024_u32;
- pub const L_tmpnam : c_uint = 1024_u32;
- pub const TMP_MAX : c_uint = 308915776_u32;
+ pub const BUFSIZ : c_uint = 1024;
+ pub const FOPEN_MAX : c_uint = 20;
+ pub const FILENAME_MAX : c_uint = 1024;
+ pub const L_tmpnam : c_uint = 1024;
+ pub const TMP_MAX : c_uint = 308915776;
}
pub mod c99 {
}
pub const _IOFBF : c_int = 0;
pub const _IONBF : c_int = 2;
pub const _IOLBF : c_int = 1;
- pub const BUFSIZ : c_uint = 1024_u32;
- pub const FOPEN_MAX : c_uint = 20_u32;
- pub const FILENAME_MAX : c_uint = 1024_u32;
- pub const L_tmpnam : c_uint = 1024_u32;
- pub const TMP_MAX : c_uint = 308915776_u32;
+ pub const BUFSIZ : c_uint = 1024;
+ pub const FOPEN_MAX : c_uint = 20;
+ pub const FILENAME_MAX : c_uint = 1024;
+ pub const L_tmpnam : c_uint = 1024;
+ pub const TMP_MAX : c_uint = 308915776;
}
pub mod c99 {
}
use types::os::arch::c95::{c_char, c_int};
use types::os::arch::posix88::mode_t;
+ mod open_shim {
+ extern {
+ #[cfg(any(target_os = "macos",
+ target_os = "ios"))]
+ pub fn open(path: *const ::c_char, oflag: ::c_int, ...)
+ -> ::c_int;
+
+ #[cfg(not(any(target_os = "macos",
+ target_os = "ios")))]
+ pub fn open(path: *const ::c_char, oflag: ::c_int, mode: ::mode_t)
+ -> ::c_int;
+ }
+ }
+
+ #[cfg(any(target_os = "macos",
+ target_os = "ios"))]
+ #[inline]
+ pub unsafe extern fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
+ use types::os::arch::c95::c_uint;
+ open_shim::open(path, oflag, mode as c_uint)
+ }
+
+ #[cfg(not(any(target_os = "macos",
+ target_os = "ios")))]
+ #[inline]
+ pub unsafe extern fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
+ open_shim::open(path, oflag, mode)
+ }
+
extern {
- pub fn open(path: *const c_char, oflag: c_int, mode: mode_t)
- -> c_int;
pub fn creat(path: *const c_char, mode: mode_t) -> c_int;
pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int;
}
fn reseed(&mut self, seed: &'a [u32]) {
// reset state
- self.init(&[0u32; KEY_WORDS]);
+ self.init(&[0; KEY_WORDS]);
// set key in place
let key = &mut self.state[4 .. 4+KEY_WORDS];
for (k, s) in key.iter_mut().zip(seed.iter()) {
fn test_rng_true_values() {
// Test vectors 1 and 2 from
// http://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04
- let seed : &[_] = &[0u32; 8];
+ let seed : &[_] = &[0; 8];
let mut ra: ChaChaRng = SeedableRng::from_seed(seed);
let v = (0..16).map(|_| ra.next_u32()).collect::<Vec<_>>();
#[test]
fn test_rng_clone() {
- let seed : &[_] = &[0u32; 8];
+ let seed : &[_] = &[0; 8];
let mut rng: ChaChaRng = SeedableRng::from_seed(seed);
let mut clone = rng.clone();
for _ in 0..16 {
///
/// This gives a uniform distribution (assuming the RNG used to sample
/// it is itself uniform & the `SampleRange` implementation for the
-/// given type is correct), even for edge cases like `low = 0u8`,
-/// `high = 170u8`, for which a naive modulo operation would return
+/// given type is correct), even for edge cases like `low = 0`,
+/// `high = 170`, for which a naive modulo operation would return
/// numbers less than 85 with double the probability to those greater
/// than 85.
///
fn reseed(&mut self, seed: &'a [u32]) {
// make the seed into [seed[0], seed[1], ..., seed[seed.len()
// - 1], 0, 0, ...], to fill rng.rsl.
- let seed_iter = seed.iter().cloned().chain(repeat(0u32));
+ let seed_iter = seed.iter().cloned().chain(repeat(0));
for (rsl_elem, seed_elem) in self.rsl.iter_mut().zip(seed_iter) {
*rsl_elem = seed_elem;
fn reseed(&mut self, seed: &'a [u64]) {
// make the seed into [seed[0], seed[1], ..., seed[seed.len()
// - 1], 0, 0, ...], to fill rng.rsl.
- let seed_iter = seed.iter().cloned().chain(repeat(0u64));
+ let seed_iter = seed.iter().cloned().chain(repeat(0));
for (rsl_elem, seed_elem) in self.rsl.iter_mut().zip(seed_iter) {
*rsl_elem = seed_elem;
/// ```rust
/// use std::rand::{thread_rng, Rng};
///
- /// let mut v = [0u8; 13579];
+ /// let mut v = [0; 13579];
/// thread_rng().fill_bytes(&mut v);
/// println!("{:?}", v.as_slice());
/// ```
const FILL_BYTES_V_LEN: uint = 13579;
#[test]
fn test_rng_fill_bytes() {
- let mut v = repeat(0u8).take(FILL_BYTES_V_LEN).collect::<Vec<_>>();
+ let mut v = repeat(0).take(FILL_BYTES_V_LEN).collect::<Vec<_>>();
::test::rng().fill_bytes(&mut v);
// Sanity test: if we've gotten here, `fill_bytes` has not infinitely
#[inline(never)]
fn vuint_at_slow(data: &[u8], start: uint) -> DecodeResult<Res> {
let a = data[start];
- if a & 0x80u8 != 0u8 {
- return Ok(Res {val: (a & 0x7fu8) as uint, next: start + 1});
+ if a & 0x80 != 0 {
+ return Ok(Res {val: (a & 0x7f) as uint, next: start + 1});
}
- if a & 0x40u8 != 0u8 {
- return Ok(Res {val: ((a & 0x3fu8) as uint) << 8 |
+ if a & 0x40 != 0 {
+ return Ok(Res {val: ((a & 0x3f) as uint) << 8 |
(data[start + 1] as uint),
next: start + 2});
}
- if a & 0x20u8 != 0u8 {
- return Ok(Res {val: ((a & 0x1fu8) as uint) << 16 |
+ if a & 0x20 != 0 {
+ return Ok(Res {val: ((a & 0x1f) as uint) << 16 |
(data[start + 1] as uint) << 8 |
(data[start + 2] as uint),
next: start + 3});
}
- if a & 0x10u8 != 0u8 {
- return Ok(Res {val: ((a & 0x0fu8) as uint) << 24 |
+ if a & 0x10 != 0 {
+ return Ok(Res {val: ((a & 0x0f) as uint) << 24 |
(data[start + 1] as uint) << 16 |
(data[start + 2] as uint) << 8 |
(data[start + 3] as uint),
fn write_sized_vuint<W: Writer>(w: &mut W, n: uint, size: uint) -> EncodeResult {
match size {
- 1 => w.write_all(&[0x80u8 | (n as u8)]),
- 2 => w.write_all(&[0x40u8 | ((n >> 8) as u8), n as u8]),
- 3 => w.write_all(&[0x20u8 | ((n >> 16) as u8), (n >> 8) as u8,
+ 1 => w.write_all(&[0x80 | (n as u8)]),
+ 2 => w.write_all(&[0x40 | ((n >> 8) as u8), n as u8]),
+ 3 => w.write_all(&[0x20 | ((n >> 16) as u8), (n >> 8) as u8,
n as u8]),
- 4 => w.write_all(&[0x10u8 | ((n >> 24) as u8), (n >> 16) as u8,
+ 4 => w.write_all(&[0x10 | ((n >> 24) as u8), (n >> 16) as u8,
(n >> 8) as u8, n as u8]),
_ => Err(old_io::IoError {
kind: old_io::OtherIoError,
// Write a placeholder four-byte size.
self.size_positions.push(try!(self.writer.tell()) as uint);
- let zeroes: &[u8] = &[0u8, 0u8, 0u8, 0u8];
+ let zeroes: &[u8] = &[0, 0, 0, 0];
self.writer.write_all(zeroes)
}
#[bench]
pub fn vuint_at_A_aligned(b: &mut Bencher) {
- let data = (0i32..4*100).map(|i| {
+ let data = (0..4*100).map(|i| {
match i % 2 {
- 0 => 0x80u8,
+ 0 => 0x80,
_ => i as u8,
}
}).collect::<Vec<_>>();
#[bench]
pub fn vuint_at_A_unaligned(b: &mut Bencher) {
- let data = (0i32..4*100+1).map(|i| {
+ let data = (0..4*100+1).map(|i| {
match i % 2 {
- 1 => 0x80u8,
+ 1 => 0x80,
_ => i as u8
}
}).collect::<Vec<_>>();
#[bench]
pub fn vuint_at_D_aligned(b: &mut Bencher) {
- let data = (0i32..4*100).map(|i| {
+ let data = (0..4*100).map(|i| {
match i % 4 {
- 0 => 0x10u8,
+ 0 => 0x10,
3 => i as u8,
- _ => 0u8
+ _ => 0
}
}).collect::<Vec<_>>();
let mut sum = 0;
#[bench]
pub fn vuint_at_D_unaligned(b: &mut Bencher) {
- let data = (0i32..4*100+1).map(|i| {
+ let data = (0..4*100+1).map(|i| {
match i % 4 {
- 1 => 0x10u8,
+ 1 => 0x10,
0 => i as u8,
- _ => 0u8
+ _ => 0
}
}).collect::<Vec<_>>();
let mut sum = 0;
pub const tag_item_trait_item: uint = 0x39;
pub const tag_item_trait_ref: uint = 0x3a;
-pub const tag_item_super_trait_ref: uint = 0x3b;
// discriminator value for variants
pub const tag_disr_val: uint = 0x3c;
pub const tag_attribute_is_sugared_doc: uint = 0x8c;
-pub const tag_trait_def_bounds: uint = 0x8d;
-
pub const tag_items_data_region: uint = 0x8e;
pub const tag_region_param_def: uint = 0x8f;
pub const tag_codemap: uint = 0xa1;
pub const tag_codemap_filemap: uint = 0xa2;
+
+pub const tag_item_super_predicates: uint = 0xa3;
// overridden in plugin/load.rs
export: false,
use_locally: false,
+ allow_internal_unstable: false,
body: body,
});
decoder::get_provided_trait_methods(cstore.intr.clone(), &*cdata, def.node, tcx)
}
-pub fn get_supertraits<'tcx>(tcx: &ty::ctxt<'tcx>,
- def: ast::DefId)
- -> Vec<Rc<ty::TraitRef<'tcx>>> {
- let cstore = &tcx.sess.cstore;
- let cdata = cstore.get_crate_data(def.krate);
- decoder::get_supertraits(&*cdata, def.node, tcx)
-}
-
pub fn get_type_name_if_impl(cstore: &cstore::CStore, def: ast::DefId)
-> Option<ast::Name> {
let cdata = cstore.get_crate_data(def.krate);
decoder::get_predicates(&*cdata, def.node, tcx)
}
+pub fn get_super_predicates<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId)
+ -> ty::GenericPredicates<'tcx>
+{
+ let cstore = &tcx.sess.cstore;
+ let cdata = cstore.get_crate_data(def.krate);
+ decoder::get_super_predicates(&*cdata, def.node, tcx)
+}
+
pub fn get_field_type<'tcx>(tcx: &ty::ctxt<'tcx>, class_id: ast::DefId,
def: ast::DefId) -> ty::TypeScheme<'tcx> {
let cstore = &tcx.sess.cstore;
use metadata::csearch;
use metadata::cstore;
use metadata::tydecode::{parse_ty_data, parse_region_data, parse_def_id,
- parse_type_param_def_data, parse_bounds_data,
- parse_bare_fn_ty_data, parse_trait_ref_data,
- parse_predicate_data};
+ parse_type_param_def_data, parse_bare_fn_ty_data,
+ parse_trait_ref_data, parse_predicate_data};
use middle::def;
use middle::lang_items;
use middle::subst;
doc_trait_ref(tp, tcx, cdata)
}
-fn doc_bounds<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
- -> ty::ParamBounds<'tcx> {
- parse_bounds_data(doc.data, cdata.cnum, doc.start, tcx,
- |_, did| translate_def_id(cdata, did))
-}
-
-fn trait_def_bounds<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
- -> ty::ParamBounds<'tcx> {
- let d = reader::get_doc(doc, tag_trait_def_bounds);
- doc_bounds(d, tcx, cdata)
-}
-
fn enum_variant_ids(item: rbml::Doc, cdata: Cmd) -> Vec<ast::DefId> {
let mut ids: Vec<ast::DefId> = Vec::new();
let v = tag_items_data_item_variant;
{
let item_doc = lookup_item(item_id, cdata.data());
let generics = doc_generics(item_doc, tcx, cdata, tag_item_generics);
- let bounds = trait_def_bounds(item_doc, tcx, cdata);
let unsafety = parse_unsafety(item_doc);
let associated_type_names = parse_associated_type_names(item_doc);
let paren_sugar = parse_paren_sugar(item_doc);
paren_sugar: paren_sugar,
unsafety: unsafety,
generics: generics,
- bounds: bounds,
trait_ref: item_trait_ref(item_doc, tcx, cdata),
associated_type_names: associated_type_names,
}
doc_predicates(item_doc, tcx, cdata, tag_item_generics)
}
+pub fn get_super_predicates<'tcx>(cdata: Cmd,
+ item_id: ast::NodeId,
+ tcx: &ty::ctxt<'tcx>)
+ -> ty::GenericPredicates<'tcx>
+{
+ let item_doc = lookup_item(item_id, cdata.data());
+ doc_predicates(item_doc, tcx, cdata, tag_item_super_predicates)
+}
+
pub fn get_type<'tcx>(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt<'tcx>)
-> ty::TypeScheme<'tcx>
{
return result;
}
-/// Returns the supertraits of the given trait.
-pub fn get_supertraits<'tcx>(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt<'tcx>)
- -> Vec<Rc<ty::TraitRef<'tcx>>> {
- let mut results = Vec::new();
- let item_doc = lookup_item(id, cdata.data());
- reader::tagged_docs(item_doc, tag_item_super_trait_ref, |trait_doc| {
- // NB. Only reads the ones that *aren't* builtin-bounds. See also
- // get_trait_def() for collecting the builtin bounds.
- // FIXME(#8559): The builtin bounds shouldn't be encoded in the first place.
- let trait_ref = doc_trait_ref(trait_doc, tcx, cdata);
- if tcx.lang_items.to_builtin_kind(trait_ref.def_id).is_none() {
- results.push(trait_ref);
- }
- true
- });
- return results;
-}
-
pub fn get_type_name_if_impl(cdata: Cmd,
node_id: ast::NodeId) -> Option<ast::Name> {
let item = lookup_item(node_id, cdata.data());
tyencode::enc_region(rbml_w, ty_str_ctxt, r);
}
-fn encode_bounds<'a, 'tcx>(rbml_w: &mut Encoder,
- ecx: &EncodeContext<'a, 'tcx>,
- bounds: &ty::ParamBounds<'tcx>,
- tag: uint) {
- rbml_w.start_tag(tag);
-
- let ty_str_ctxt = &tyencode::ctxt { diag: ecx.diag,
- ds: def_to_string,
- tcx: ecx.tcx,
- abbrevs: &ecx.type_abbrevs };
- tyencode::enc_bounds(rbml_w, ty_str_ctxt, bounds);
-
- rbml_w.end_tag();
-}
-
fn encode_type<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
rbml_w: &mut Encoder,
typ: Ty<'tcx>) {
tcx: ecx.tcx,
abbrevs: &ecx.type_abbrevs
};
+
for param in generics.types.iter() {
rbml_w.start_tag(tag_type_param_def);
tyencode::enc_type_param_def(rbml_w, ty_str_ctxt, param);
rbml_w.end_tag();
}
+ encode_predicates_in_current_doc(rbml_w, ecx, predicates);
+
+ rbml_w.end_tag();
+}
+
+fn encode_predicates_in_current_doc<'a,'tcx>(rbml_w: &mut Encoder,
+ ecx: &EncodeContext<'a,'tcx>,
+ predicates: &ty::GenericPredicates<'tcx>)
+{
+ let ty_str_ctxt = &tyencode::ctxt {
+ diag: ecx.diag,
+ ds: def_to_string,
+ tcx: ecx.tcx,
+ abbrevs: &ecx.type_abbrevs
+ };
+
for (space, _, predicate) in predicates.predicates.iter_enumerated() {
rbml_w.start_tag(tag_predicate);
rbml_w.end_tag();
}
+}
+fn encode_predicates<'a,'tcx>(rbml_w: &mut Encoder,
+ ecx: &EncodeContext<'a,'tcx>,
+ predicates: &ty::GenericPredicates<'tcx>,
+ tag: uint)
+{
+ rbml_w.start_tag(tag);
+ encode_predicates_in_current_doc(rbml_w, ecx, predicates);
rbml_w.end_tag();
}
encode_paren_sugar(rbml_w, trait_def.paren_sugar);
encode_associated_type_names(rbml_w, &trait_def.associated_type_names);
encode_generics(rbml_w, ecx, &trait_def.generics, &trait_predicates, tag_item_generics);
+ encode_predicates(rbml_w, ecx, &ty::lookup_super_predicates(tcx, def_id),
+ tag_item_super_predicates);
encode_trait_ref(rbml_w, ecx, &*trait_def.trait_ref, tag_item_trait_ref);
encode_name(rbml_w, item.ident.name);
encode_attributes(rbml_w, &item.attrs);
}
encode_path(rbml_w, path.clone());
- encode_bounds(rbml_w, ecx, &trait_def.bounds, tag_trait_def_bounds);
-
// Encode the implementations of this trait.
encode_extension_implementations(ecx, rbml_w, def_id);
}
}
if self.rejected_via_kind.len() > 0 {
- self.sess.span_help(self.span, "please recompile this crate using \
+ self.sess.fileline_help(self.span, "please recompile this crate using \
--crate-type lib");
let mismatches = self.rejected_via_kind.iter();
for (i, &CrateMismatch { ref path, .. }) in mismatches.enumerate() {
}
"plugin" => {
self.sess.span_err(attr.span, "#[plugin] on `extern crate` is deprecated");
- self.sess.span_help(attr.span, &format!("use a crate attribute instead, \
+ self.sess.fileline_help(attr.span, &format!("use a crate attribute instead, \
i.e. #![plugin({})]",
item.ident.as_str()));
}
Some(sel) => sel.contains_key(&name),
};
def.export = reexport.contains_key(&name);
+ def.allow_internal_unstable = attr::contains_name(&def.attrs,
+ "allow_internal_unstable");
+ debug!("load_macros: loaded: {:?}", def);
self.macros.push(def);
}
"pattern binding `{}` is named the same as one \
of the variants of the type `{}`",
&token::get_ident(ident.node), ty_to_string(cx.tcx, pat_ty));
- span_help!(cx.tcx.sess, p.span,
+ fileline_help!(cx.tcx.sess, p.span,
"if you meant to match on a variant, \
consider making the path in the pattern qualified: `{}::{}`",
ty_to_string(cx.tcx, pat_ty), &token::get_ident(ident.node));
ast::ExprBlock(ref block) => {
match block.expr {
Some(ref expr) => try!(eval_const_expr_partial(tcx, &**expr, ety)),
- None => const_int(0i64)
+ None => const_int(0)
}
}
ast::ExprTupField(ref base, index) => {
// Does the required lifetime have a nice name we can print?
span_err!(self.tcx.sess, origin.span(), E0309,
"{} may not live long enough", labeled_user_string);
- self.tcx.sess.span_help(
+ self.tcx.sess.fileline_help(
origin.span(),
&format!(
"consider adding an explicit lifetime bound `{}: {}`...",
// Does the required lifetime have a nice name we can print?
span_err!(self.tcx.sess, origin.span(), E0310,
"{} may not live long enough", labeled_user_string);
- self.tcx.sess.span_help(
+ self.tcx.sess.fileline_help(
origin.span(),
&format!(
"consider adding an explicit lifetime bound `{}: 'static`...",
span_err!(self.tcx.sess, origin.span(), E0311,
"{} may not live long enough",
labeled_user_string);
- self.tcx.sess.span_help(
+ self.tcx.sess.fileline_help(
origin.span(),
&format!(
"consider adding an explicit lifetime bound for `{}`",
/// Helper for discovering nodes to check for stability
pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
cb: &mut FnMut(ast::DefId, Span, &Option<Stability>)) {
- if is_internal(tcx, e.span) { return; }
-
let span;
let id = match e.node {
ast::ExprMethodCall(i, _, _) => {
fn maybe_do_stability_check(tcx: &ty::ctxt, id: ast::DefId, span: Span,
cb: &mut FnMut(ast::DefId, Span, &Option<Stability>)) {
if !is_staged_api(tcx, id) { return }
+ if is_internal(tcx, span) { return }
let ref stability = lookup(tcx, id);
cb(id, span, stability);
}
fn is_internal(tcx: &ty::ctxt, span: Span) -> bool {
- tcx.sess.codemap().span_is_internal(span)
+ tcx.sess.codemap().span_allows_unstable(span)
}
fn is_staged_api(tcx: &ty::ctxt, id: DefId) -> bool {
/// for the object type `Foo`.
#[derive(PartialEq,Eq,Clone)]
pub struct VtableObjectData<'tcx> {
+ /// the object type `Foo`.
pub object_ty: Ty<'tcx>,
+
+ /// `Foo` upcast to the obligation trait. This will be some supertrait of `Foo`.
+ pub upcast_trait_ref: ty::PolyTraitRef<'tcx>,
}
/// Creates predicate obligations from the generic bounds.
use middle::subst::{self, SelfSpace, TypeSpace};
use middle::traits;
-use middle::ty::{self, Ty};
+use middle::ty::{self, ToPolyTraitRef, Ty};
use std::rc::Rc;
use syntax::ast;
use util::ppaux::Repr;
{
let trait_def = ty::lookup_trait_def(tcx, trait_def_id);
let trait_ref = trait_def.trait_ref.clone();
- let predicates = ty::predicates_for_trait_ref(tcx, &ty::Binder(trait_ref));
+ let trait_ref = trait_ref.to_poly_trait_ref();
+ let predicates = ty::lookup_super_predicates(tcx, trait_def_id);
predicates
+ .predicates
.into_iter()
+ .map(|predicate| predicate.subst_supertrait(tcx, &trait_ref))
.any(|predicate| {
match predicate {
ty::Predicate::Trait(ref data) => {
poly_trait_ref.repr(self.tcx()));
// see whether the object trait can be upcast to the trait we are looking for
- let obligation_def_id = obligation.predicate.def_id();
- let upcast_trait_ref = match util::upcast(self.tcx(), poly_trait_ref, obligation_def_id) {
- Some(r) => r,
- None => { return; }
- };
-
- debug!("assemble_candidates_from_object_ty: upcast_trait_ref={}",
- upcast_trait_ref.repr(self.tcx()));
-
- // check whether the upcast version of the trait-ref matches what we are looking for
- if let Ok(()) = self.infcx.probe(|_| self.match_poly_trait_ref(obligation,
- upcast_trait_ref.clone())) {
- debug!("assemble_candidates_from_object_ty: matched, pushing candidate");
+ let upcast_trait_refs = self.upcast(poly_trait_ref, obligation);
+ if upcast_trait_refs.len() > 1 {
+ // can be upcast in many ways; need more type information
+ candidates.ambiguous = true;
+ } else if upcast_trait_refs.len() == 1 {
candidates.vec.push(ObjectCandidate);
}
}
let principal =
data.principal_trait_ref_with_self_ty(self.tcx(),
self.tcx().types.err);
+ let desired_def_id = obligation.predicate.def_id();
for tr in util::supertraits(self.tcx(), principal) {
- let td = ty::lookup_trait_def(self.tcx(), tr.def_id());
- if td.bounds.builtin_bounds.contains(&bound) {
+ if tr.def_id() == desired_def_id {
return Ok(If(Vec::new()))
}
}
}
};
- let obligation_def_id = obligation.predicate.def_id();
- let upcast_trait_ref = match util::upcast(self.tcx(),
- poly_trait_ref.clone(),
- obligation_def_id) {
- Some(r) => r,
- None => {
- self.tcx().sess.span_bug(obligation.cause.span,
- &format!("unable to upcast from {} to {}",
- poly_trait_ref.repr(self.tcx()),
- obligation_def_id.repr(self.tcx())));
- }
- };
+ // Upcast the object type to the obligation type. There must
+ // be exactly one applicable trait-reference; if this were not
+ // the case, we would have reported an ambiguity error rather
+ // than successfully selecting one of the candidates.
+ let upcast_trait_refs = self.upcast(poly_trait_ref.clone(), obligation);
+ assert_eq!(upcast_trait_refs.len(), 1);
+ let upcast_trait_ref = upcast_trait_refs.into_iter().next().unwrap();
- match self.match_poly_trait_ref(obligation, upcast_trait_ref) {
+ match self.match_poly_trait_ref(obligation, upcast_trait_ref.clone()) {
Ok(()) => { }
Err(()) => {
self.tcx().sess.span_bug(obligation.cause.span,
}
}
- VtableObjectData { object_ty: self_ty }
+ VtableObjectData { object_ty: self_ty,
+ upcast_trait_ref: upcast_trait_ref }
}
fn confirm_fn_pointer_candidate(&mut self,
obligation.cause.clone()
}
}
+
+ /// Upcasts an object trait-reference into those that match the obligation.
+ fn upcast(&mut self, obj_trait_ref: ty::PolyTraitRef<'tcx>, obligation: &TraitObligation<'tcx>)
+ -> Vec<ty::PolyTraitRef<'tcx>>
+ {
+ debug!("upcast(obj_trait_ref={}, obligation={})",
+ obj_trait_ref.repr(self.tcx()),
+ obligation.repr(self.tcx()));
+
+ let obligation_def_id = obligation.predicate.def_id();
+ let mut upcast_trait_refs = util::upcast(self.tcx(), obj_trait_ref, obligation_def_id);
+
+ // Retain only those upcast versions that match the trait-ref
+ // we are looking for. In particular, we know that all of
+ // `upcast_trait_refs` apply to the correct trait, but
+ // possibly with incorrect type parameters. For example, we
+ // may be trying to upcast `Foo` to `Bar<i32>`, but `Foo` is
+ // declared as `trait Foo : Bar<u32>`.
+ upcast_trait_refs.retain(|upcast_trait_ref| {
+ let upcast_trait_ref = upcast_trait_ref.clone();
+ self.infcx.probe(|_| self.match_poly_trait_ref(obligation, upcast_trait_ref)).is_ok()
+ });
+
+ debug!("upcast: upcast_trait_refs={}", upcast_trait_refs.repr(self.tcx()));
+ upcast_trait_refs
+ }
}
impl<'tcx> Repr<'tcx> for SelectionCandidate<'tcx> {
/// 'static`.
pub struct Elaborator<'cx, 'tcx:'cx> {
tcx: &'cx ty::ctxt<'tcx>,
- stack: Vec<StackEntry<'tcx>>,
+ stack: Vec<ty::Predicate<'tcx>>,
visited: PredicateSet<'cx,'tcx>,
}
-struct StackEntry<'tcx> {
- position: uint,
- predicates: Vec<ty::Predicate<'tcx>>,
-}
-
pub fn elaborate_trait_ref<'cx, 'tcx>(
tcx: &'cx ty::ctxt<'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>)
{
let mut visited = PredicateSet::new(tcx);
predicates.retain(|pred| visited.insert(pred));
- let entry = StackEntry { position: 0, predicates: predicates };
- Elaborator { tcx: tcx, stack: vec![entry], visited: visited }
+ Elaborator { tcx: tcx, stack: predicates, visited: visited }
}
impl<'cx, 'tcx> Elaborator<'cx, 'tcx> {
- pub fn filter_to_traits(self) -> Supertraits<'cx, 'tcx> {
- Supertraits { elaborator: self }
+ pub fn filter_to_traits(self) -> FilterToTraits<Elaborator<'cx, 'tcx>> {
+ FilterToTraits::new(self)
}
fn push(&mut self, predicate: &ty::Predicate<'tcx>) {
match *predicate {
ty::Predicate::Trait(ref data) => {
- let mut predicates =
- ty::predicates_for_trait_ref(self.tcx,
- &data.to_poly_trait_ref());
+ // Predicates declared on the trait.
+ let predicates = ty::lookup_super_predicates(self.tcx, data.def_id());
+
+ let mut predicates: Vec<_> =
+ predicates.predicates
+ .iter()
+ .map(|p| p.subst_supertrait(self.tcx, &data.to_poly_trait_ref()))
+ .collect();
+
+ debug!("super_predicates: data={} predicates={}",
+ data.repr(self.tcx), predicates.repr(self.tcx));
// Only keep those bounds that we haven't already
// seen. This is necessary to prevent infinite
// Sized { }`.
predicates.retain(|r| self.visited.insert(r));
- self.stack.push(StackEntry { position: 0,
- predicates: predicates });
+ self.stack.extend(predicates.into_iter());
}
ty::Predicate::Equate(..) => {
// Currently, we do not "elaborate" predicates like
type Item = ty::Predicate<'tcx>;
fn next(&mut self) -> Option<ty::Predicate<'tcx>> {
- loop {
- // Extract next item from top-most stack frame, if any.
- let next_predicate = match self.stack.last_mut() {
- None => {
- // No more stack frames. Done.
- return None;
- }
- Some(entry) => {
- let p = entry.position;
- if p < entry.predicates.len() {
- // Still more predicates left in the top stack frame.
- entry.position += 1;
-
- let next_predicate =
- entry.predicates[p].clone();
-
- Some(next_predicate)
- } else {
- None
- }
- }
- };
-
- match next_predicate {
- Some(next_predicate) => {
- self.push(&next_predicate);
- return Some(next_predicate);
- }
-
- None => {
- // Top stack frame is exhausted, pop it.
- self.stack.pop();
- }
+ // Extract next item from top-most stack frame, if any.
+ let next_predicate = match self.stack.pop() {
+ Some(predicate) => predicate,
+ None => {
+ // No more stack frames. Done.
+ return None;
}
- }
+ };
+ self.push(&next_predicate);
+ return Some(next_predicate);
}
}
// Supertrait iterator
///////////////////////////////////////////////////////////////////////////
-/// A filter around the `Elaborator` that just yields up supertrait references,
-/// not other kinds of predicates.
-pub struct Supertraits<'cx, 'tcx:'cx> {
- elaborator: Elaborator<'cx, 'tcx>,
-}
+pub type Supertraits<'cx, 'tcx> = FilterToTraits<Elaborator<'cx, 'tcx>>;
pub fn supertraits<'cx, 'tcx>(tcx: &'cx ty::ctxt<'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>)
elaborate_trait_refs(tcx, bounds).filter_to_traits()
}
-impl<'cx, 'tcx> Iterator for Supertraits<'cx, 'tcx> {
+///////////////////////////////////////////////////////////////////////////
+// Other
+///////////////////////////////////////////////////////////////////////////
+
+/// A filter around an iterator of predicates that makes it yield up
+/// just trait references.
+pub struct FilterToTraits<I> {
+ base_iterator: I
+}
+
+impl<I> FilterToTraits<I> {
+ fn new(base: I) -> FilterToTraits<I> {
+ FilterToTraits { base_iterator: base }
+ }
+}
+
+impl<'tcx,I:Iterator<Item=ty::Predicate<'tcx>>> Iterator for FilterToTraits<I> {
type Item = ty::PolyTraitRef<'tcx>;
fn next(&mut self) -> Option<ty::PolyTraitRef<'tcx>> {
loop {
- match self.elaborator.next() {
+ match self.base_iterator.next() {
None => {
return None;
}
}
}
+
///////////////////////////////////////////////////////////////////////////
// Other
///////////////////////////////////////////////////////////////////////////
pub fn upcast<'tcx>(tcx: &ty::ctxt<'tcx>,
source_trait_ref: ty::PolyTraitRef<'tcx>,
target_trait_def_id: ast::DefId)
- -> Option<ty::PolyTraitRef<'tcx>>
+ -> Vec<ty::PolyTraitRef<'tcx>>
{
if source_trait_ref.def_id() == target_trait_def_id {
- return Some(source_trait_ref); // shorcut the most common case
- }
-
- for super_trait_ref in supertraits(tcx, source_trait_ref) {
- if super_trait_ref.def_id() == target_trait_def_id {
- return Some(super_trait_ref);
- }
+ return vec![source_trait_ref]; // shorcut the most common case
}
- None
+ supertraits(tcx, source_trait_ref)
+ .filter(|r| r.def_id() == target_trait_def_id)
+ .collect()
}
/// Given an object of type `object_trait_ref`, returns the index of
pub use self::InferRegion::*;
pub use self::ImplOrTraitItemId::*;
pub use self::ClosureKind::*;
-pub use self::ast_ty_to_ty_cache_entry::*;
pub use self::Variance::*;
pub use self::AutoAdjustment::*;
pub use self::Representability::*;
pub len: uint
}
-#[derive(Copy)]
-pub enum ast_ty_to_ty_cache_entry<'tcx> {
- atttce_unresolved, /* not resolved yet */
- atttce_resolved(Ty<'tcx>) /* resolved to a type, irrespective of region */
-}
-
#[derive(Clone, PartialEq, RustcDecodable, RustcEncodable)]
pub struct ItemVariances {
pub types: VecPerParamSpace<Variance>,
/// associated predicates.
pub predicates: RefCell<DefIdMap<GenericPredicates<'tcx>>>,
+ /// Maps from the def-id of a trait to the list of
+ /// super-predicates. This is a subset of the full list of
+ /// predicates. We store these in a separate map because we must
+ /// evaluate them even during type conversion, often before the
+ /// full predicates are available (note that supertraits have
+ /// additional acyclicity requirements).
+ pub super_predicates: RefCell<DefIdMap<GenericPredicates<'tcx>>>,
+
/// Maps from node-id of a trait object cast (like `foo as
/// Box<Trait>`) to the trait reference.
pub object_cast_map: ObjectCastMap<'tcx>,
pub rcache: RefCell<FnvHashMap<creader_cache_key, Ty<'tcx>>>,
pub short_names_cache: RefCell<FnvHashMap<Ty<'tcx>, String>>,
pub tc_cache: RefCell<FnvHashMap<Ty<'tcx>, TypeContents>>,
- pub ast_ty_to_ty_cache: RefCell<NodeMap<ast_ty_to_ty_cache_entry<'tcx>>>,
+ pub ast_ty_to_ty_cache: RefCell<NodeMap<Ty<'tcx>>>,
pub enum_var_cache: RefCell<DefIdMap<Rc<Vec<Rc<VariantInfo<'tcx>>>>>>,
pub ty_param_defs: RefCell<NodeMap<TypeParameterDef<'tcx>>>,
pub adjustments: RefCell<NodeMap<AutoAdjustment<'tcx>>>,
/// definition and not a concrete use of it. To get the correct `ty_enum`
/// from the tcx, use the `NodeId` from the `ast::Ty` and look it up in
/// the `ast_ty_to_ty_cache`. This is probably true for `ty_struct` as
- /// well.`
+ /// well.
ty_enum(DefId, &'tcx Substs<'tcx>),
ty_uniq(Ty<'tcx>),
ty_str,
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Binder<T>(pub T);
+impl<T> Binder<T> {
+ /// Skips the binder and returns the "bound" value. This is a
+ /// risky thing to do because it's easy to get confused about
+ /// debruijn indices and the like. It is usually better to
+ /// discharge the binder using `no_late_bound_regions` or
+ /// `replace_late_bound_regions` or something like
+ /// that. `skip_binder` is only valid when you are either
+ /// extracting data that has nothing to do with bound regions, you
+ /// are doing some sort of test that does not involve bound
+ /// regions, or you are being very careful about your depth
+ /// accounting.
+ ///
+ /// Some examples where `skip_binder` is reasonable:
+ /// - extracting the def-id from a PolyTraitRef;
+ /// - comparing the self type of a PolyTraitRef to see if it is equal to
+ /// a type parameter `X`, since the type `X` does not reference any regions
+ pub fn skip_binder(&self) -> &T {
+ &self.0
+ }
+}
+
#[derive(Clone, Copy, PartialEq)]
pub enum IntVarValue {
IntType(ast::IntTy),
predicates: self.predicates.subst(tcx, substs),
}
}
+
+ pub fn instantiate_supertrait(&self,
+ tcx: &ty::ctxt<'tcx>,
+ poly_trait_ref: &ty::PolyTraitRef<'tcx>)
+ -> InstantiatedPredicates<'tcx>
+ {
+ InstantiatedPredicates {
+ predicates: self.predicates.map(|pred| pred.subst_supertrait(tcx, poly_trait_ref))
+ }
+ }
}
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
Projection(PolyProjectionPredicate<'tcx>),
}
+impl<'tcx> Predicate<'tcx> {
+ /// Performs a substituion suitable for going from a
+ /// poly-trait-ref to supertraits that must hold if that
+ /// poly-trait-ref holds. This is slightly different from a normal
+ /// substitution in terms of what happens with bound regions. See
+ /// lengthy comment below for details.
+ pub fn subst_supertrait(&self,
+ tcx: &ty::ctxt<'tcx>,
+ trait_ref: &ty::PolyTraitRef<'tcx>)
+ -> ty::Predicate<'tcx>
+ {
+ // The interaction between HRTB and supertraits is not entirely
+ // obvious. Let me walk you (and myself) through an example.
+ //
+ // Let's start with an easy case. Consider two traits:
+ //
+ // trait Foo<'a> : Bar<'a,'a> { }
+ // trait Bar<'b,'c> { }
+ //
+ // Now, if we have a trait reference `for<'x> T : Foo<'x>`, then
+ // we can deduce that `for<'x> T : Bar<'x,'x>`. Basically, if we
+ // knew that `Foo<'x>` (for any 'x) then we also know that
+ // `Bar<'x,'x>` (for any 'x). This more-or-less falls out from
+ // normal substitution.
+ //
+ // In terms of why this is sound, the idea is that whenever there
+ // is an impl of `T:Foo<'a>`, it must show that `T:Bar<'a,'a>`
+ // holds. So if there is an impl of `T:Foo<'a>` that applies to
+ // all `'a`, then we must know that `T:Bar<'a,'a>` holds for all
+ // `'a`.
+ //
+ // Another example to be careful of is this:
+ //
+ // trait Foo1<'a> : for<'b> Bar1<'a,'b> { }
+ // trait Bar1<'b,'c> { }
+ //
+ // Here, if we have `for<'x> T : Foo1<'x>`, then what do we know?
+ // The answer is that we know `for<'x,'b> T : Bar1<'x,'b>`. The
+ // reason is similar to the previous example: any impl of
+ // `T:Foo1<'x>` must show that `for<'b> T : Bar1<'x, 'b>`. So
+ // basically we would want to collapse the bound lifetimes from
+ // the input (`trait_ref`) and the supertraits.
+ //
+ // To achieve this in practice is fairly straightforward. Let's
+ // consider the more complicated scenario:
+ //
+ // - We start out with `for<'x> T : Foo1<'x>`. In this case, `'x`
+ // has a De Bruijn index of 1. We want to produce `for<'x,'b> T : Bar1<'x,'b>`,
+ // where both `'x` and `'b` would have a DB index of 1.
+ // The substitution from the input trait-ref is therefore going to be
+ // `'a => 'x` (where `'x` has a DB index of 1).
+ // - The super-trait-ref is `for<'b> Bar1<'a,'b>`, where `'a` is an
+ // early-bound parameter and `'b' is a late-bound parameter with a
+ // DB index of 1.
+ // - If we replace `'a` with `'x` from the input, it too will have
+ // a DB index of 1, and thus we'll have `for<'x,'b> Bar1<'x,'b>`
+ // just as we wanted.
+ //
+ // There is only one catch. If we just apply the substitution `'a
+ // => 'x` to `for<'b> Bar1<'a,'b>`, the substitution code will
+ // adjust the DB index because we substituting into a binder (it
+ // tries to be so smart...) resulting in `for<'x> for<'b>
+ // Bar1<'x,'b>` (we have no syntax for this, so use your
+ // imagination). Basically the 'x will have DB index of 2 and 'b
+ // will have DB index of 1. Not quite what we want. So we apply
+ // the substitution to the *contents* of the trait reference,
+ // rather than the trait reference itself (put another way, the
+ // substitution code expects equal binding levels in the values
+ // from the substitution and the value being substituted into, and
+ // this trick achieves that).
+
+ let substs = &trait_ref.0.substs;
+ match *self {
+ Predicate::Trait(ty::Binder(ref data)) =>
+ Predicate::Trait(ty::Binder(data.subst(tcx, substs))),
+ Predicate::Equate(ty::Binder(ref data)) =>
+ Predicate::Equate(ty::Binder(data.subst(tcx, substs))),
+ Predicate::RegionOutlives(ty::Binder(ref data)) =>
+ Predicate::RegionOutlives(ty::Binder(data.subst(tcx, substs))),
+ Predicate::TypeOutlives(ty::Binder(ref data)) =>
+ Predicate::TypeOutlives(ty::Binder(data.subst(tcx, substs))),
+ Predicate::Projection(ty::Binder(ref data)) =>
+ Predicate::Projection(ty::Binder(data.subst(tcx, substs))),
+ }
+ }
+}
+
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct TraitPredicate<'tcx> {
pub trait_ref: Rc<TraitRef<'tcx>>
/// implements the trait.
pub generics: Generics<'tcx>,
- /// The "supertrait" bounds.
- pub bounds: ParamBounds<'tcx>,
-
pub trait_ref: Rc<ty::TraitRef<'tcx>>,
/// A list of the associated types defined in this trait. Useful
impl_trait_refs: RefCell::new(NodeMap()),
trait_defs: RefCell::new(DefIdMap()),
predicates: RefCell::new(DefIdMap()),
+ super_predicates: RefCell::new(DefIdMap()),
object_cast_map: RefCell::new(NodeMap()),
map: map,
intrinsic_defs: RefCell::new(DefIdMap()),
})
}
-/// Given the did of a trait, returns its full set of predicates.
+/// Given the did of an item, returns its full set of predicates.
pub fn lookup_predicates<'tcx>(cx: &ctxt<'tcx>, did: ast::DefId)
-> GenericPredicates<'tcx>
{
})
}
-/// Given a reference to a trait, returns the "superbounds" declared
-/// on the trait, with appropriate substitutions applied. Basically,
-/// this applies a filter to the where clauses on the trait, returning
-/// those that have the form:
-///
-/// Self : SuperTrait<...>
-/// Self : 'region
-pub fn predicates_for_trait_ref<'tcx>(tcx: &ctxt<'tcx>,
- trait_ref: &PolyTraitRef<'tcx>)
- -> Vec<ty::Predicate<'tcx>>
+/// Given the did of a trait, returns its superpredicates.
+pub fn lookup_super_predicates<'tcx>(cx: &ctxt<'tcx>, did: ast::DefId)
+ -> GenericPredicates<'tcx>
{
- let trait_def = lookup_trait_def(tcx, trait_ref.def_id());
-
- debug!("bounds_for_trait_ref(trait_def={:?}, trait_ref={:?})",
- trait_def.repr(tcx), trait_ref.repr(tcx));
-
- // The interaction between HRTB and supertraits is not entirely
- // obvious. Let me walk you (and myself) through an example.
- //
- // Let's start with an easy case. Consider two traits:
- //
- // trait Foo<'a> : Bar<'a,'a> { }
- // trait Bar<'b,'c> { }
- //
- // Now, if we have a trait reference `for<'x> T : Foo<'x>`, then
- // we can deduce that `for<'x> T : Bar<'x,'x>`. Basically, if we
- // knew that `Foo<'x>` (for any 'x) then we also know that
- // `Bar<'x,'x>` (for any 'x). This more-or-less falls out from
- // normal substitution.
- //
- // In terms of why this is sound, the idea is that whenever there
- // is an impl of `T:Foo<'a>`, it must show that `T:Bar<'a,'a>`
- // holds. So if there is an impl of `T:Foo<'a>` that applies to
- // all `'a`, then we must know that `T:Bar<'a,'a>` holds for all
- // `'a`.
- //
- // Another example to be careful of is this:
- //
- // trait Foo1<'a> : for<'b> Bar1<'a,'b> { }
- // trait Bar1<'b,'c> { }
- //
- // Here, if we have `for<'x> T : Foo1<'x>`, then what do we know?
- // The answer is that we know `for<'x,'b> T : Bar1<'x,'b>`. The
- // reason is similar to the previous example: any impl of
- // `T:Foo1<'x>` must show that `for<'b> T : Bar1<'x, 'b>`. So
- // basically we would want to collapse the bound lifetimes from
- // the input (`trait_ref`) and the supertraits.
- //
- // To achieve this in practice is fairly straightforward. Let's
- // consider the more complicated scenario:
- //
- // - We start out with `for<'x> T : Foo1<'x>`. In this case, `'x`
- // has a De Bruijn index of 1. We want to produce `for<'x,'b> T : Bar1<'x,'b>`,
- // where both `'x` and `'b` would have a DB index of 1.
- // The substitution from the input trait-ref is therefore going to be
- // `'a => 'x` (where `'x` has a DB index of 1).
- // - The super-trait-ref is `for<'b> Bar1<'a,'b>`, where `'a` is an
- // early-bound parameter and `'b' is a late-bound parameter with a
- // DB index of 1.
- // - If we replace `'a` with `'x` from the input, it too will have
- // a DB index of 1, and thus we'll have `for<'x,'b> Bar1<'x,'b>`
- // just as we wanted.
- //
- // There is only one catch. If we just apply the substitution `'a
- // => 'x` to `for<'b> Bar1<'a,'b>`, the substitution code will
- // adjust the DB index because we substituting into a binder (it
- // tries to be so smart...) resulting in `for<'x> for<'b>
- // Bar1<'x,'b>` (we have no syntax for this, so use your
- // imagination). Basically the 'x will have DB index of 2 and 'b
- // will have DB index of 1. Not quite what we want. So we apply
- // the substitution to the *contents* of the trait reference,
- // rather than the trait reference itself (put another way, the
- // substitution code expects equal binding levels in the values
- // from the substitution and the value being substituted into, and
- // this trick achieves that).
-
- // Carefully avoid the binder introduced by each trait-ref by
- // substituting over the substs, not the trait-refs themselves,
- // thus achieving the "collapse" described in the big comment
- // above.
- let trait_bounds: Vec<_> =
- trait_def.bounds.trait_bounds
- .iter()
- .map(|poly_trait_ref| ty::Binder(poly_trait_ref.0.subst(tcx, trait_ref.substs())))
- .collect();
-
- let projection_bounds: Vec<_> =
- trait_def.bounds.projection_bounds
- .iter()
- .map(|poly_proj| ty::Binder(poly_proj.0.subst(tcx, trait_ref.substs())))
- .collect();
-
- debug!("bounds_for_trait_ref: trait_bounds={} projection_bounds={}",
- trait_bounds.repr(tcx),
- projection_bounds.repr(tcx));
-
- // The region bounds and builtin bounds do not currently introduce
- // binders so we can just substitute in a straightforward way here.
- let region_bounds =
- trait_def.bounds.region_bounds.subst(tcx, trait_ref.substs());
- let builtin_bounds =
- trait_def.bounds.builtin_bounds.subst(tcx, trait_ref.substs());
-
- let bounds = ty::ParamBounds {
- trait_bounds: trait_bounds,
- region_bounds: region_bounds,
- builtin_bounds: builtin_bounds,
- projection_bounds: projection_bounds,
- };
-
- predicates(tcx, trait_ref.self_ty(), &bounds)
+ memoized(&cx.super_predicates, did, |did: DefId| {
+ assert!(did.krate != ast::LOCAL_CRATE);
+ csearch::get_super_predicates(cx, did)
+ })
}
pub fn predicates<'tcx>(
impl<'tcx> TypeFoldable<'tcx> for traits::VtableObjectData<'tcx> {
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::VtableObjectData<'tcx> {
traits::VtableObjectData {
- object_ty: self.object_ty.fold_with(folder)
+ object_ty: self.object_ty.fold_with(folder),
+ upcast_trait_ref: self.upcast_trait_ref.fold_with(folder),
}
}
}
/// This is the most general hook into `libsyntax`'s expansion behavior.
pub fn register_syntax_extension(&mut self, name: ast::Name, extension: SyntaxExtension) {
self.syntax_exts.push((name, match extension {
- NormalTT(ext, _) => NormalTT(ext, Some(self.krate_span)),
- IdentTT(ext, _) => IdentTT(ext, Some(self.krate_span)),
+ NormalTT(ext, _, allow_internal_unstable) => {
+ NormalTT(ext, Some(self.krate_span), allow_internal_unstable)
+ }
+ IdentTT(ext, _, allow_internal_unstable) => {
+ IdentTT(ext, Some(self.krate_span), allow_internal_unstable)
+ }
Decorator(ext) => Decorator(ext),
Modifier(ext) => Modifier(ext),
MultiModifier(ext) => MultiModifier(ext),
/// It builds for you a `NormalTT` that calls `expander`,
/// and also takes care of interning the macro's name.
pub fn register_macro(&mut self, name: &str, expander: MacroExpanderFn) {
- self.register_syntax_extension(token::intern(name), NormalTT(Box::new(expander), None));
+ self.register_syntax_extension(token::intern(name),
+ NormalTT(Box::new(expander), None, false));
}
/// Register a compiler lint pass.
impl Session {
pub fn span_fatal(&self, sp: Span, msg: &str) -> ! {
+ if self.opts.treat_err_as_bug {
+ self.span_bug(sp, msg);
+ }
self.diagnostic().span_fatal(sp, msg)
}
pub fn span_fatal_with_code(&self, sp: Span, msg: &str, code: &str) -> ! {
+ if self.opts.treat_err_as_bug {
+ self.span_bug(sp, msg);
+ }
self.diagnostic().span_fatal_with_code(sp, msg, code)
}
pub fn fatal(&self, msg: &str) -> ! {
+ if self.opts.treat_err_as_bug {
+ self.bug(msg);
+ }
self.diagnostic().handler().fatal(msg)
}
pub fn span_err(&self, sp: Span, msg: &str) {
fn test_lev_distance() {
use std::char::{ from_u32, MAX };
// Test bytelength agnosticity
- for c in (0u32..MAX as u32)
+ for c in (0..MAX as u32)
.filter_map(|i| from_u32(i))
.map(|i| i.to_string()) {
assert_eq!(lev_distance(&c[..], &c[..]), 0);
impl<'tcx> Repr<'tcx> for ty::TraitDef<'tcx> {
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
- format!("TraitDef(generics={}, bounds={}, trait_ref={})",
+ format!("TraitDef(generics={}, trait_ref={})",
self.generics.repr(tcx),
- self.bounds.repr(tcx),
self.trait_ref.repr(tcx))
}
}
/// Create a new FixedBuffer64
fn new() -> FixedBuffer64 {
return FixedBuffer64 {
- buffer: [0u8; 64],
+ buffer: [0; 64],
buffer_idx: 0
};
}
/// Convenience function that retrieves the result of a digest as a
/// newly allocated vec of bytes.
fn result_bytes(&mut self) -> Vec<u8> {
- let mut buf: Vec<u8> = repeat(0u8).take((self.output_bits()+7)/8).collect();
+ let mut buf: Vec<u8> = repeat(0).take((self.output_bits()+7)/8).collect();
self.result(&mut buf);
buf
}
let mut g = self.h6;
let mut h = self.h7;
- let mut w = [0u32; 64];
+ let mut w = [0; 64];
// Sha-512 and Sha-256 use basically the same calculations which are implemented
// by these macros. Inlining the calculations seems to result in better generated code.
#[bench]
pub fn sha256_10(b: &mut Bencher) {
let mut sh = Sha256::new();
- let bytes = [1u8; 10];
+ let bytes = [1; 10];
b.iter(|| {
sh.input(&bytes);
});
#[bench]
pub fn sha256_1k(b: &mut Bencher) {
let mut sh = Sha256::new();
- let bytes = [1u8; 1024];
+ let bytes = [1; 1024];
b.iter(|| {
sh.input(&bytes);
});
#[bench]
pub fn sha256_64k(b: &mut Bencher) {
let mut sh = Sha256::new();
- let bytes = [1u8; 65536];
+ let bytes = [1; 65536];
b.iter(|| {
sh.input(&bytes);
});
bitflags! {
flags AnotherSetOfFlags: i8 {
- const AnotherFlag = -1_i8,
+ const AnotherFlag = -1,
}
}
assert_eq!(FlagABC.bits(), 0b00000111);
assert_eq!(AnotherSetOfFlags::empty().bits(), 0b00);
- assert_eq!(AnotherFlag.bits(), !0_i8);
+ assert_eq!(AnotherFlag.bits(), !0);
}
#[test]
assert!(Flags::from_bits(0b11) == Some(FlagA | FlagB));
assert!(Flags::from_bits(0b1000) == None);
- assert!(AnotherSetOfFlags::from_bits(!0_i8) == Some(AnotherFlag));
+ assert!(AnotherSetOfFlags::from_bits(!0) == Some(AnotherFlag));
}
#[test]
assert!(Flags::from_bits_truncate(0b1000) == Flags::empty());
assert!(Flags::from_bits_truncate(0b1001) == FlagA);
- assert!(AnotherSetOfFlags::from_bits_truncate(0_i8) == AnotherSetOfFlags::empty());
+ assert!(AnotherSetOfFlags::from_bits_truncate(0) == AnotherSetOfFlags::empty());
}
#[test]
bccx.span_note(
move_to_span,
"attempting to move value to here");
- bccx.span_help(
+ bccx.fileline_help(
move_to_span,
&format!("to prevent the move, \
use `ref {0}` or `ref mut {0}` to capture value by \
ol,
moved_lp_msg,
pat_ty.user_string(self.tcx)));
- self.tcx.sess.span_help(span,
+ self.tcx.sess.fileline_help(span,
"use `ref` to override");
}
moved_lp_msg,
expr_ty.user_string(self.tcx),
suggestion));
- self.tcx.sess.span_help(expr_span, help);
+ self.tcx.sess.fileline_help(expr_span, help);
}
}
self.tcx.sess.span_help(s, m);
}
+ pub fn fileline_help(&self, s: Span, m: &str) {
+ self.tcx.sess.fileline_help(s, m);
+ }
+
pub fn bckerr_to_string(&self, err: &BckError<'tcx>) -> String {
match err.code {
err_mutbl => {
}
if is_closure {
- self.tcx.sess.span_help(
+ self.tcx.sess.fileline_help(
span,
"closures behind references must be called via `&mut`");
}
}
);
- // Needs to go *after* expansion to be able to check the results of macro expansion.
- time(time_passes, "complete gated feature checking", (), |_| {
+ // Needs to go *after* expansion to be able to check the results
+ // of macro expansion. This runs before #[cfg] to try to catch as
+ // much as possible (e.g. help the programmer avoid platform
+ // specific differences)
+ time(time_passes, "complete gated feature checking 1", (), |_| {
let features =
syntax::feature_gate::check_crate(sess.codemap(),
- &sess.parse_sess.span_diagnostic,
- &krate);
+ &sess.parse_sess.span_diagnostic,
+ &krate,
+ true);
*sess.features.borrow_mut() = features;
sess.abort_if_errors();
});
time(time_passes, "checking that all macro invocations are gone", &krate, |krate|
syntax::ext::expand::check_for_macros(&sess.parse_sess, krate));
+ // One final feature gating of the true AST that gets compiled
+ // later, to make sure we've got everything (e.g. configuration
+ // can insert new attributes via `cfg_attr`)
+ time(time_passes, "complete gated feature checking 2", (), |_| {
+ let features =
+ syntax::feature_gate::check_crate(sess.codemap(),
+ &sess.parse_sess.span_diagnostic,
+ &krate,
+ false);
+ *sess.features.borrow_mut() = features;
+ sess.abort_if_errors();
+ });
+
Some(krate)
}
}
def::DefTy(..) => {
let tty = match self.cx.tcx.ast_ty_to_ty_cache.borrow().get(&id) {
- Some(&ty::atttce_resolved(t)) => t,
- _ => panic!("ast_ty_to_ty_cache was incomplete after typeck!")
+ Some(&t) => t,
+ None => panic!("ast_ty_to_ty_cache was incomplete after typeck!")
};
if !ty::is_ffi_safe(self.cx.tcx, tty) {
for call in &self_call_spans {
sess.span_note(*call, "recursive call site")
}
- sess.span_help(sp, "a `loop` may express intention better if this is on purpose")
+ sess.fileline_help(sp, "a `loop` may express intention \
+ better if this is on purpose")
}
}
uses it like a function name",
path_name));
- self.session.span_help(expr.span,
- &format!("Did you mean to write: \
- `{} {{ /* fields */ }}`?",
- path_name));
+ let msg = format!("Did you mean to write: \
+ `{} {{ /* fields */ }}`?",
+ path_name);
+ if self.emit_errors {
+ self.session.fileline_help(expr.span, &msg);
+ } else {
+ self.session.span_help(expr.span, &msg);
+ }
} else {
// Write the result into the def map.
debug!("(resolving expr) resolved `{}`",
match type_res.map(|r| r.base_def) {
Some(DefTy(struct_id, _))
if self.structs.contains_key(&struct_id) => {
- self.resolve_error(expr.span,
+ self.resolve_error(expr.span,
&format!("`{}` is a structure name, but \
this expression \
uses it like a function name",
path_name));
- self.session.span_help(expr.span,
- &format!("Did you mean to write: \
- `{} {{ /* fields */ }}`?",
- path_name));
-
- }
+ let msg = format!("Did you mean to write: \
+ `{} {{ /* fields */ }}`?",
+ path_name);
+ if self.emit_errors {
+ self.session.fileline_help(expr.span, &msg);
+ } else {
+ self.session.span_help(expr.span, &msg);
+ }
+ }
_ => {
// Keep reporting some errors even if they're ignored above.
self.resolve_path(expr.id, path, 0, ValueNS, true);
let (is_zero, is_signed) = match rhs_t.sty {
ty::ty_int(t) => {
- let zero = C_integral(Type::int_from_ty(cx.ccx(), t), 0u64, false);
+ let zero = C_integral(Type::int_from_ty(cx.ccx(), t), 0, false);
(ICmp(cx, llvm::IntEQ, rhs, zero, debug_loc), true)
}
ty::ty_uint(t) => {
- let zero = C_integral(Type::uint_from_ty(cx.ccx(), t), 0u64, false);
+ let zero = C_integral(Type::uint_from_ty(cx.ccx(), t), 0, false);
(ICmp(cx, llvm::IntEQ, rhs, zero, debug_loc), false)
}
_ => {
let size = ty_size(ty);
if size <= 16 {
let llty = if size == 0 {
- Type::array(&Type::i64(ccx), 0u64)
+ Type::array(&Type::i64(ccx), 0)
} else if size == 1 {
Type::i8(ccx)
} else if size == 2 {
&format!("use of SIMD type `{}` in FFI is highly experimental and \
may result in invalid code",
pprust::ty_to_string(ast_ty)));
- tcx.sess.span_help(ast_ty.span,
+ tcx.sess.fileline_help(ast_ty.span,
"add #![feature(simd_ffi)] to the crate attributes to enable");
}
};
.position(|item| item.def_id() == method_id)
.unwrap();
let (llfn, ty) =
- trans_object_shim(ccx, data.object_ty, trait_id, method_offset_in_trait);
+ trans_object_shim(ccx,
+ data.object_ty,
+ data.upcast_trait_ref.clone(),
+ method_offset_in_trait);
immediate_rvalue(llfn, ty)
}
_ => {
Callee { bcx: bcx, data: Fn(llfn) }
}
traits::VtableObject(ref data) => {
- let (llfn, _) = trans_object_shim(bcx.ccx(), data.object_ty, trait_id, n_method);
+ let (llfn, _) = trans_object_shim(bcx.ccx(),
+ data.object_ty,
+ data.upcast_trait_ref.clone(),
+ n_method);
Callee { bcx: bcx, data: Fn(llfn) }
}
traits::VtableBuiltin(..) |
pub fn trans_object_shim<'a, 'tcx>(
ccx: &'a CrateContext<'a, 'tcx>,
object_ty: Ty<'tcx>,
- trait_id: ast::DefId,
+ upcast_trait_ref: ty::PolyTraitRef<'tcx>,
method_offset_in_trait: uint)
-> (ValueRef, Ty<'tcx>)
{
let _icx = push_ctxt("trans_object_shim");
let tcx = ccx.tcx();
+ let trait_id = upcast_trait_ref.def_id();
- debug!("trans_object_shim(object_ty={}, trait_id={}, method_offset_in_trait={})",
+ debug!("trans_object_shim(object_ty={}, upcast_trait_ref={}, method_offset_in_trait={})",
object_ty.repr(tcx),
- trait_id.repr(tcx),
+ upcast_trait_ref.repr(tcx),
method_offset_in_trait);
let object_trait_ref =
};
// Upcast to the trait in question and extract out the substitutions.
- let upcast_trait_ref = traits::upcast(ccx.tcx(), object_trait_ref.clone(), trait_id).unwrap();
let upcast_trait_ref = ty::erase_late_bound_regions(tcx, &upcast_trait_ref);
let object_substs = upcast_trait_ref.substs.clone().erase_regions();
debug!("trans_object_shim: object_substs={}", object_substs.repr(tcx));
use rscope::{self, UnelidableRscope, RegionScope, ElidableRscope,
ObjectLifetimeDefaultRscope, ShiftedRscope, BindingRscope};
use util::common::{ErrorReported, FN_OUTPUT_NAME};
-use util::nodemap::DefIdMap;
use util::ppaux::{self, Repr, UserString};
use std::iter::{repeat, AdditiveIterator};
pub trait AstConv<'tcx> {
fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx>;
+ /// Identify the type scheme for an item with a type, like a type
+ /// alias, fn, or struct. This allows you to figure out the set of
+ /// type parameters defined on the item.
fn get_item_type_scheme(&self, span: Span, id: ast::DefId)
-> Result<ty::TypeScheme<'tcx>, ErrorReported>;
+ /// Returns the `TraitDef` for a given trait. This allows you to
+ /// figure out the set of type parameters defined on the trait.
fn get_trait_def(&self, span: Span, id: ast::DefId)
-> Result<Rc<ty::TraitDef<'tcx>>, ErrorReported>;
+ /// Ensure that the super-predicates for the trait with the given
+ /// id are available and also for the transitive set of
+ /// super-predicates.
+ fn ensure_super_predicates(&self, span: Span, id: ast::DefId)
+ -> Result<(), ErrorReported>;
+
+ /// Returns the set of bounds in scope for the type parameter with
+ /// the given id.
fn get_type_parameter_bounds(&self, span: Span, def_id: ast::NodeId)
-> Result<Vec<ty::PolyTraitRef<'tcx>>, ErrorReported>;
+ /// Returns true if the trait with id `trait_def_id` defines an
+ /// associated type with the name `name`.
+ fn trait_defines_associated_type_named(&self, trait_def_id: ast::DefId, name: ast::Name)
+ -> bool;
+
/// Return an (optional) substitution to convert bound type parameters that
/// are in scope into free ones. This function should only return Some
/// within a fn body.
}
}
if len == 1 {
- span_help!(this.tcx().sess, default_span,
+ fileline_help!(this.tcx().sess, default_span,
"this function's return type contains a borrowed value, but \
the signature does not say which {} it is borrowed from",
m);
} else if len == 0 {
- span_help!(this.tcx().sess, default_span,
+ fileline_help!(this.tcx().sess, default_span,
"this function's return type contains a borrowed value, but \
there is no value for it to be borrowed from");
- span_help!(this.tcx().sess, default_span,
+ fileline_help!(this.tcx().sess, default_span,
"consider giving it a 'static lifetime");
} else {
- span_help!(this.tcx().sess, default_span,
+ fileline_help!(this.tcx().sess, default_span,
"this function's return type contains a borrowed value, but \
the signature does not say whether it is borrowed from {}",
m);
span_err!(this.tcx().sess, span, E0215,
"angle-bracket notation is not stable when \
used with the `Fn` family of traits, use parentheses");
- span_help!(this.tcx().sess, span,
+ fileline_help!(this.tcx().sess, span,
"add `#![feature(unboxed_closures)]` to \
the crate attributes to enable");
}
span_err!(this.tcx().sess, span, E0216,
"parenthetical notation is only stable when \
used with the `Fn` family of traits");
- span_help!(this.tcx().sess, span,
+ fileline_help!(this.tcx().sess, span,
"add `#![feature(unboxed_closures)]` to \
the crate attributes to enable");
}
// We want to produce `<B as SuperTrait<int>>::T == foo`.
// Simple case: X is defined in the current trait.
- if trait_defines_associated_type_named(this, trait_ref.def_id, binding.item_name) {
+ if this.trait_defines_associated_type_named(trait_ref.def_id, binding.item_name) {
return Ok(ty::ProjectionPredicate {
projection_ty: ty::ProjectionTy {
trait_ref: trait_ref,
tcx.mk_substs(dummy_substs)));
}
+ try!(this.ensure_super_predicates(binding.span, trait_ref.def_id));
+
let mut candidates: Vec<ty::PolyTraitRef> =
traits::supertraits(tcx, trait_ref.to_poly_trait_ref())
- .filter(|r| trait_defines_associated_type_named(this, r.def_id(), binding.item_name))
+ .filter(|r| this.trait_defines_associated_type_named(r.def_id(), binding.item_name))
.collect();
// If converting for an object type, then remove the dummy-ty from `Self` now.
pprust::ty_to_string(ty));
match ty.node {
ast::TyRptr(None, ref mut_ty) => {
- span_help!(this.tcx().sess, ty.span,
+ fileline_help!(this.tcx().sess, ty.span,
"perhaps you meant `&{}({} +{})`? (per RFC 438)",
ppaux::mutability_to_string(mut_ty.mutbl),
pprust::ty_to_string(&*mut_ty.ty),
pprust::bounds_to_string(bounds));
}
ast::TyRptr(Some(ref lt), ref mut_ty) => {
- span_help!(this.tcx().sess, ty.span,
+ fileline_help!(this.tcx().sess, ty.span,
"perhaps you meant `&{} {}({} +{})`? (per RFC 438)",
pprust::lifetime_to_string(lt),
ppaux::mutability_to_string(mut_ty.mutbl),
}
_ => {
- span_help!(this.tcx().sess, ty.span,
+ fileline_help!(this.tcx().sess, ty.span,
"perhaps you forgot parentheses? (per RFC 438)");
}
}
let ty_param_name = tcx.ty_param_defs.borrow()[ty_param_node_id].name;
- // FIXME(#20300) -- search where clauses, not bounds
- let bounds =
- this.get_type_parameter_bounds(span, ty_param_node_id)
- .unwrap_or(Vec::new());
+ let bounds = match this.get_type_parameter_bounds(span, ty_param_node_id) {
+ Ok(v) => v,
+ Err(ErrorReported) => { return (tcx.types.err, ty_path_def); }
+ };
+
+ // ensure the super predicates and stop if we encountered an error
+ if bounds.iter().any(|b| this.ensure_super_predicates(span, b.def_id()).is_err()) {
+ return (this.tcx().types.err, ty_path_def);
+ }
let mut suitable_bounds: Vec<_> =
traits::transitive_bounds(tcx, &bounds)
- .filter(|b| trait_defines_associated_type_named(this, b.def_id(), assoc_name))
+ .filter(|b| this.trait_defines_associated_type_named(b.def_id(), assoc_name))
.collect();
if suitable_bounds.len() == 0 {
(ty, def::DefAssociatedTy(trait_did, item_did))
}
-fn trait_defines_associated_type_named(this: &AstConv,
- trait_def_id: ast::DefId,
- assoc_name: ast::Name)
- -> bool
-{
- let tcx = this.tcx();
- let trait_def = ty::lookup_trait_def(tcx, trait_def_id);
- trait_def.associated_type_names.contains(&assoc_name)
-}
-
fn qpath_to_ty<'tcx>(this: &AstConv<'tcx>,
rscope: &RegionScope,
span: Span,
let tcx = this.tcx();
- let mut ast_ty_to_ty_cache = tcx.ast_ty_to_ty_cache.borrow_mut();
- match ast_ty_to_ty_cache.get(&ast_ty.id) {
- Some(&ty::atttce_resolved(ty)) => return ty,
- Some(&ty::atttce_unresolved) => {
- span_err!(tcx.sess, ast_ty.span, E0246,
- "illegal recursive type; insert an enum \
- or struct in the cycle, if this is \
- desired");
- return this.tcx().types.err;
- }
- None => { /* go on */ }
+ if let Some(&ty) = tcx.ast_ty_to_ty_cache.borrow().get(&ast_ty.id) {
+ return ty;
}
- ast_ty_to_ty_cache.insert(ast_ty.id, ty::atttce_unresolved);
- drop(ast_ty_to_ty_cache);
let typ = match ast_ty.node {
ast::TyVec(ref ty) => {
}
};
- tcx.ast_ty_to_ty_cache.borrow_mut().insert(ast_ty.id, ty::atttce_resolved(typ));
+ tcx.ast_ty_to_ty_cache.borrow_mut().insert(ast_ty.id, typ);
return typ;
}
return ast_region_to_region(tcx, r);
}
+ if let Err(ErrorReported) = this.ensure_super_predicates(span,principal_trait_ref.def_id()) {
+ return ty::ReStatic;
+ }
+
// No explicit region bound specified. Therefore, examine trait
// bounds and see if we can derive region bounds from those.
let derived_region_bounds =
let mut builtin_bounds = ty::empty_builtin_bounds();
let mut region_bounds = Vec::new();
let mut trait_bounds = Vec::new();
- let mut trait_def_ids = DefIdMap();
for ast_bound in ast_bounds {
match *ast_bound {
ast::TraitTyParamBound(ref b, ast::TraitBoundModifier::None) => {
match ::lookup_full_def(tcx, b.trait_ref.path.span, b.trait_ref.ref_id) {
def::DefTrait(trait_did) => {
- match trait_def_ids.get(&trait_did) {
- // Already seen this trait. We forbid
- // duplicates in the list (for some
- // reason).
- Some(span) => {
- span_err!(
- tcx.sess, b.trait_ref.path.span, E0127,
- "trait `{}` already appears in the \
- list of bounds",
- b.trait_ref.path.user_string(tcx));
- tcx.sess.span_note(
- *span,
- "previous appearance is here");
-
- continue;
- }
-
- None => { }
- }
-
- trait_def_ids.insert(trait_did, b.trait_ref.path.span);
-
if ty::try_add_builtin_trait(tcx,
trait_did,
&mut builtin_bounds) {
span_err!(tcx.sess, span, E0174,
"explicit use of unboxed closure method `{}` is experimental",
method);
- span_help!(tcx.sess, span,
+ fileline_help!(tcx.sess, span,
"add `#![feature(unboxed_closures)]` to the crate attributes to enable");
}
}
use syntax::codemap::Span;
use util::common::ErrorReported;
+use util::nodemap::FnvHashSet;
use util::ppaux::Repr;
// Helper functions related to manipulating region types.
stack: Vec<(ty::Region, Option<Ty<'tcx>>)>,
span: Span,
out: Vec<Implication<'tcx>>,
+ visited: FnvHashSet<Ty<'tcx>>,
}
/// This routine computes the well-formedness constraints that must hold for the type `ty` to
body_id: body_id,
span: span,
stack: stack,
- out: Vec::new() };
+ out: Vec::new(),
+ visited: FnvHashSet() };
wf.accumulate_from_ty(ty);
debug!("implications: out={}", wf.out.repr(closure_typer.tcx()));
wf.out
debug!("accumulate_from_ty(ty={})",
ty.repr(self.tcx()));
+ // When expanding out associated types, we can visit a cyclic
+ // set of types. Issue #23003.
+ if !self.visited.insert(ty) {
+ return;
+ }
+
match ty.sty {
ty::ty_bool |
ty::ty_char |
target_trait_def_id: ast::DefId)
-> ty::PolyTraitRef<'tcx>
{
- match traits::upcast(self.tcx(), source_trait_ref.clone(), target_trait_def_id) {
- Some(super_trait_ref) => super_trait_ref,
- None => {
- self.tcx().sess.span_bug(
- self.span,
- &format!("cannot upcast `{}` to `{}`",
- source_trait_ref.repr(self.tcx()),
- target_trait_def_id.repr(self.tcx())));
- }
+ let upcast_trait_refs = traits::upcast(self.tcx(),
+ source_trait_ref.clone(),
+ target_trait_def_id);
+
+ // must be exactly one trait ref or we'd get an ambig error etc
+ if upcast_trait_refs.len() != 1 {
+ self.tcx().sess.span_bug(
+ self.span,
+ &format!("cannot uniquely upcast `{}` to `{}`: `{}`",
+ source_trait_ref.repr(self.tcx()),
+ target_trait_def_id.repr(self.tcx()),
+ upcast_trait_refs.repr(self.tcx())));
}
+
+ upcast_trait_refs.into_iter().next().unwrap()
}
fn replace_late_bound_regions_with_fresh_var<T>(&self, value: &ty::Binder<T>) -> T
debug!("elaborate_bounds(bounds={})", bounds.repr(self.tcx()));
let tcx = self.tcx();
- let mut cache = HashSet::new();
for bound_trait_ref in traits::transitive_bounds(tcx, bounds) {
- // Already visited this trait, skip it.
- if !cache.insert(bound_trait_ref.def_id()) {
- continue;
- }
-
let (pos, method) = match trait_method(tcx,
bound_trait_ref.def_id(),
self.method_name) {
fn to_trait_data(&self) -> Option<(ast::DefId,MethodIndex)> {
match self.kind {
- InherentImplCandidate(..) |
- ObjectCandidate(..) => {
+ InherentImplCandidate(..) => {
None
}
+ ObjectCandidate(trait_def_id, method_num, _) => {
+ Some((trait_def_id, method_num))
+ }
ClosureCandidate(trait_def_id, method_num) => {
Some((trait_def_id, method_num))
}
Ok(ty::lookup_trait_def(self.tcx(), id))
}
+ fn ensure_super_predicates(&self, _: Span, _: ast::DefId) -> Result<(), ErrorReported> {
+ // all super predicates are ensured during collect pass
+ Ok(())
+ }
+
fn get_free_substs(&self) -> Option<&Substs<'tcx>> {
Some(&self.inh.param_env.free_substs)
}
Ok(r)
}
+ fn trait_defines_associated_type_named(&self,
+ trait_def_id: ast::DefId,
+ assoc_name: ast::Name)
+ -> bool
+ {
+ let trait_def = ty::lookup_trait_def(self.ccx.tcx, trait_def_id);
+ trait_def.associated_type_names.contains(&assoc_name)
+ }
+
fn ty_infer(&self, _span: Span) -> Ty<'tcx> {
self.infcx().next_ty_var()
}
},
expr_t, None);
- tcx.sess.span_help(field.span,
+ tcx.sess.fileline_help(field.span,
"maybe a `()` to call it is missing? \
If not, try an anonymous function");
} else {
span_err!(tcx.sess, sp, E0073,
"this type cannot be instantiated without an \
instance of itself");
- span_help!(tcx.sess, sp, "consider using `Option<{}>`",
+ fileline_help!(tcx.sess, sp, "consider using `Option<{}>`",
ppaux::ty_to_string(tcx, item_ty));
false
} else {
// Find the supertrait bounds. This will add `int:Bar`.
let poly_trait_ref = ty::Binder(trait_ref);
- let predicates = ty::predicates_for_trait_ref(fcx.tcx(), &poly_trait_ref);
+ let predicates = ty::lookup_super_predicates(fcx.tcx(), poly_trait_ref.def_id());
+ let predicates = predicates.instantiate_supertrait(fcx.tcx(), &poly_trait_ref);
let predicates = {
let selcx = &mut traits::SelectionContext::new(fcx.infcx(), fcx);
traits::normalize(selcx, cause.clone(), &predicates)
};
- for predicate in predicates.value {
+ for predicate in predicates.value.predicates {
fcx.register_predicate(traits::Obligation::new(cause.clone(), predicate));
}
for obligation in predicates.obligations {
match suggested_marker_id {
Some(def_id) => {
- self.tcx().sess.span_help(
+ self.tcx().sess.fileline_help(
span,
format!("consider removing `{}` or using a marker such as `{}`",
param_name.user_string(self.tcx()),
return // everything OK
};
span_err!(tcx.sess, sp, E0183, "manual implementations of `{}` are experimental", trait_name);
- span_help!(tcx.sess, sp,
+ fileline_help!(tcx.sess, sp,
"add `#![feature(unboxed_closures)]` to the crate attributes to enable");
}
core type along with a list of the bounds for each parameter. Type
parameters themselves are represented as `ty_param()` instances.
-The phasing of type conversion is somewhat complicated. There are a
-number of possible cycles that can arise.
-
-Converting types can require:
-
-1. `Foo<X>` where `Foo` is a type alias, or trait requires knowing:
- - number of region / type parameters
- - for type parameters, `T:'a` annotations to control defaults for object lifetimes
- - defaults for type parameters (which are themselves types!)
-2. `Foo<X>` where `Foo` is a type alias requires knowing what `Foo` expands to
-3. Translating `SomeTrait` with no explicit lifetime bound requires knowing
- - supertraits of `SomeTrait`
-4. Translating `T::X` (vs `<T as Trait>::X`) requires knowing
- - bounds on `T`
- - supertraits of those bounds
-
-So as you can see, in general translating types requires knowing the
-trait hierarchy. But this gets a bit tricky because translating the
-trait hierarchy requires converting the types that appear in trait
-references. One potential saving grace is that in general knowing the
-trait hierarchy is only necessary for shorthands like `T::X` or
-handling omitted lifetime bounds on object types. Therefore, if we are
-lazy about expanding out the trait hierachy, users can sever cycles if
-necessary. Lazy expansion is also needed for type aliases.
-
-This system is not perfect yet. Currently, we "convert" types and
-traits in three phases (note that conversion only affects the types of
-items / enum variants / methods; it does not e.g. compute the types of
-individual expressions):
+The phasing of type conversion is somewhat complicated. There is no
+clear set of phases we can enforce (e.g., converting traits first,
+then types, or something like that) because the user can introduce
+arbitrary interdependencies. So instead we generally convert things
+lazilly and on demand, and include logic that checks for cycles.
+Demand is driven by calls to `AstConv::get_item_type_scheme` or
+`AstConv::lookup_trait_def`.
+
+Currently, we "convert" types and traits in three phases (note that
+conversion only affects the types of items / enum variants / methods;
+it does not e.g. compute the types of individual expressions):
0. Intrinsics
1. Trait definitions
and invoking an appropriate function (e.g., `trait_def_of_item` or
`convert_item`). However, it is possible that while converting an
item, we may need to compute the *type scheme* or *trait definition*
-for other items. This is a kind of shallow conversion that is
-triggered on demand by calls to `AstConv::get_item_type_scheme` or
-`AstConv::lookup_trait_def`. It is possible for cycles to result from
-this (e.g., `type A = B; type B = A;`), in which case astconv
-(currently) reports the error.
+for other items.
There are some shortcomings in this design:
-- Cycles through trait definitions (e.g. supertraits) are not currently
- detected by astconv. (#12511)
+- Before walking the set of supertraits for a given trait, you must
+ call `ensure_super_predicates` on that trait def-id. Otherwise,
+ `lookup_super_predicates` will result in ICEs.
- Because the type scheme includes defaults, cycles through type
parameter defaults are illegal even if those defaults are never
employed. This is not necessarily a bug.
enum AstConvRequest {
GetItemTypeScheme(ast::DefId),
GetTraitDef(ast::DefId),
+ EnsureSuperPredicates(ast::DefId),
GetTypeParameterBounds(ast::NodeId),
}
request: AstConvRequest,
code: F)
-> Result<R,ErrorReported>
- where F: FnOnce() -> R
+ where F: FnOnce() -> Result<R,ErrorReported>
{
{
let mut stack = self.stack.borrow_mut();
let result = code();
self.stack.borrow_mut().pop();
- Ok(result)
+ result
}
fn report_cycle(&self,
&format!("the cycle begins when processing `{}`...",
ty::item_path_str(tcx, def_id)));
}
+ AstConvRequest::EnsureSuperPredicates(def_id) => {
+ tcx.sess.note(
+ &format!("the cycle begins when computing the supertraits of `{}`...",
+ ty::item_path_str(tcx, def_id)));
+ }
AstConvRequest::GetTypeParameterBounds(id) => {
let def = tcx.type_parameter_def(id);
tcx.sess.note(
&format!("...which then requires processing `{}`...",
ty::item_path_str(tcx, def_id)));
}
+ AstConvRequest::EnsureSuperPredicates(def_id) => {
+ tcx.sess.note(
+ &format!("...which then requires computing the supertraits of `{}`...",
+ ty::item_path_str(tcx, def_id)));
+ }
AstConvRequest::GetTypeParameterBounds(id) => {
let def = tcx.type_parameter_def(id);
tcx.sess.note(
&format!("...which then again requires processing `{}`, completing the cycle.",
ty::item_path_str(tcx, def_id)));
}
+ AstConvRequest::EnsureSuperPredicates(def_id) => {
+ tcx.sess.note(
+ &format!("...which then again requires computing the supertraits of `{}`, \
+ completing the cycle.",
+ ty::item_path_str(tcx, def_id)));
+ }
AstConvRequest::GetTypeParameterBounds(id) => {
let def = tcx.type_parameter_def(id);
tcx.sess.note(
}
}
}
+
+ /// Loads the trait def for a given trait, returning ErrorReported if a cycle arises.
+ fn get_trait_def(&self, trait_id: ast::DefId)
+ -> Rc<ty::TraitDef<'tcx>>
+ {
+ let tcx = self.tcx;
+
+ if trait_id.krate != ast::LOCAL_CRATE {
+ return ty::lookup_trait_def(tcx, trait_id)
+ }
+
+ let item = match tcx.map.get(trait_id.node) {
+ ast_map::NodeItem(item) => item,
+ _ => tcx.sess.bug(&format!("get_trait_def({}): not an item", trait_id.repr(tcx)))
+ };
+
+ trait_def_of_item(self, &*item)
+ }
+
+ /// Ensure that the (transitive) super predicates for
+ /// `trait_def_id` are available. This will report a cycle error
+ /// if a trait `X` (transitively) extends itself in some form.
+ fn ensure_super_predicates(&self, span: Span, trait_def_id: ast::DefId)
+ -> Result<(), ErrorReported>
+ {
+ self.cycle_check(span, AstConvRequest::EnsureSuperPredicates(trait_def_id), || {
+ let def_ids = ensure_super_predicates_step(self, trait_def_id);
+
+ for def_id in def_ids {
+ try!(self.ensure_super_predicates(span, def_id));
+ }
+
+ Ok(())
+ })
+ }
}
impl<'a,'tcx> ItemCtxt<'a,'tcx> {
-> Result<ty::TypeScheme<'tcx>, ErrorReported>
{
self.ccx.cycle_check(span, AstConvRequest::GetItemTypeScheme(id), || {
- type_scheme_of_def_id(self.ccx, id)
+ Ok(type_scheme_of_def_id(self.ccx, id))
})
}
-> Result<Rc<ty::TraitDef<'tcx>>, ErrorReported>
{
self.ccx.cycle_check(span, AstConvRequest::GetTraitDef(id), || {
- get_trait_def(self.ccx, id)
+ Ok(self.ccx.get_trait_def(id))
})
}
+ fn ensure_super_predicates(&self,
+ span: Span,
+ trait_def_id: ast::DefId)
+ -> Result<(), ErrorReported>
+ {
+ debug!("ensure_super_predicates(trait_def_id={})",
+ trait_def_id.repr(self.tcx()));
+
+ self.ccx.ensure_super_predicates(span, trait_def_id)
+ }
+
+
fn get_type_parameter_bounds(&self,
span: Span,
node_id: ast::NodeId)
-> Result<Vec<ty::PolyTraitRef<'tcx>>, ErrorReported>
{
self.ccx.cycle_check(span, AstConvRequest::GetTypeParameterBounds(node_id), || {
- self.param_bounds.get_type_parameter_bounds(self, span, node_id)
+ let v = self.param_bounds.get_type_parameter_bounds(self, span, node_id)
+ .into_iter()
+ .filter_map(|p| p.to_opt_poly_trait_ref())
+ .collect();
+ Ok(v)
})
}
+ fn trait_defines_associated_type_named(&self,
+ trait_def_id: ast::DefId,
+ assoc_name: ast::Name)
+ -> bool
+ {
+ if trait_def_id.krate == ast::LOCAL_CRATE {
+ trait_defines_associated_type_named(self.ccx, trait_def_id.node, assoc_name)
+ } else {
+ let trait_def = ty::lookup_trait_def(self.tcx(), trait_def_id);
+ trait_def.associated_type_names.contains(&assoc_name)
+ }
+ }
+
fn ty_infer(&self, span: Span) -> Ty<'tcx> {
span_err!(self.tcx().sess, span, E0121,
"the type placeholder `_` is not allowed within types on item signatures");
astconv: &AstConv<'tcx>,
span: Span,
node_id: ast::NodeId)
- -> Vec<ty::PolyTraitRef<'tcx>>;
+ -> Vec<ty::Predicate<'tcx>>;
}
/// Find bounds from both elements of the tuple.
astconv: &AstConv<'tcx>,
span: Span,
node_id: ast::NodeId)
- -> Vec<ty::PolyTraitRef<'tcx>>
+ -> Vec<ty::Predicate<'tcx>>
{
let mut v = self.0.get_type_parameter_bounds(astconv, span, node_id);
v.extend(self.1.get_type_parameter_bounds(astconv, span, node_id).into_iter());
_astconv: &AstConv<'tcx>,
_span: Span,
_node_id: ast::NodeId)
- -> Vec<ty::PolyTraitRef<'tcx>>
+ -> Vec<ty::Predicate<'tcx>>
{
Vec::new()
}
astconv: &AstConv<'tcx>,
_span: Span,
node_id: ast::NodeId)
- -> Vec<ty::PolyTraitRef<'tcx>>
+ -> Vec<ty::Predicate<'tcx>>
{
let def = astconv.tcx().type_parameter_def(node_id);
self.predicates
.iter()
- .filter_map(|predicate| {
- match *predicate {
+ .filter(|predicate| {
+ match **predicate {
ty::Predicate::Trait(ref data) => {
- if data.0.self_ty().is_param(def.space, def.index) {
- Some(data.to_poly_trait_ref())
- } else {
- None
- }
+ data.skip_binder().self_ty().is_param(def.space, def.index)
+ }
+ ty::Predicate::TypeOutlives(ref data) => {
+ data.skip_binder().0.is_param(def.space, def.index)
}
ty::Predicate::Equate(..) |
ty::Predicate::RegionOutlives(..) |
- ty::Predicate::TypeOutlives(..) |
ty::Predicate::Projection(..) => {
- None
+ false
}
}
})
+ .cloned()
.collect()
}
}
astconv: &AstConv<'tcx>,
_: Span,
node_id: ast::NodeId)
- -> Vec<ty::PolyTraitRef<'tcx>>
+ -> Vec<ty::Predicate<'tcx>>
{
// In the AST, bounds can derive from two places. Either
// written inline like `<T:Foo>` or in a where clause like
.iter()
.filter(|p| p.id == node_id)
.flat_map(|p| p.bounds.iter())
- .filter_map(|b| poly_trait_ref_from_bound(astconv, ty, b, &mut Vec::new()));
+ .flat_map(|b| predicates_from_bound(astconv, ty, b).into_iter());
let from_where_clauses =
self.where_clause
})
.filter(|bp| is_param(astconv.tcx(), &bp.bounded_ty, node_id))
.flat_map(|bp| bp.bounds.iter())
- .filter_map(|b| poly_trait_ref_from_bound(astconv, ty, b, &mut Vec::new()));
+ .flat_map(|b| predicates_from_bound(astconv, ty, b).into_iter());
from_ty_params.chain(from_where_clauses).collect()
}
{
if let ast::TyPath(None, _) = ast_ty.node {
let path_res = tcx.def_map.borrow()[ast_ty.id];
- if let def::DefTyParam(_, _, def_id, _) = path_res.base_def {
- path_res.depth == 0 && def_id == local_def(param_id)
- } else {
- false
+ match path_res.base_def {
+ def::DefSelfTy(node_id) =>
+ path_res.depth == 0 && node_id == param_id,
+
+ def::DefTyParam(_, _, def_id, _) =>
+ path_res.depth == 0 && def_id == local_def(param_id),
+
+ _ =>
+ false,
}
} else {
false
rcvr_visibility: ast::Visibility)
where I: Iterator<Item=&'i ast::Method>
{
- debug!("convert_methods(untransformed_rcvr_ty={}, rcvr_ty_generics={})",
+ debug!("convert_methods(untransformed_rcvr_ty={}, rcvr_ty_generics={}, rcvr_ty_predicates={})",
untransformed_rcvr_ty.repr(ccx.tcx),
- rcvr_ty_generics.repr(ccx.tcx));
+ rcvr_ty_generics.repr(ccx.tcx),
+ rcvr_ty_predicates.repr(ccx.tcx));
let tcx = ccx.tcx;
let mut seen_methods = FnvHashSet();
},
ast::ItemTrait(_, _, _, ref trait_items) => {
let trait_def = trait_def_of_item(ccx, it);
+ let _: Result<(), ErrorReported> = // any error is already reported, can ignore
+ ccx.ensure_super_predicates(it.span, local_def(it.id));
convert_trait_predicates(ccx, it);
let trait_predicates = ty::lookup_predicates(ccx.tcx, local_def(it.id));
}
}
-fn get_trait_def<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
- trait_id: ast::DefId)
- -> Rc<ty::TraitDef<'tcx>> {
+/// Ensures that the super-predicates of the trait with def-id
+/// trait_def_id are converted and stored. This does NOT ensure that
+/// the transitive super-predicates are converted; that is the job of
+/// the `ensure_super_predicates()` method in the `AstConv` impl
+/// above. Returns a list of trait def-ids that must be ensured as
+/// well to guarantee that the transitive superpredicates are
+/// converted.
+fn ensure_super_predicates_step(ccx: &CrateCtxt,
+ trait_def_id: ast::DefId)
+ -> Vec<ast::DefId>
+{
let tcx = ccx.tcx;
- if trait_id.krate != ast::LOCAL_CRATE {
- return ty::lookup_trait_def(tcx, trait_id)
- }
+ debug!("ensure_super_predicates_step(trait_def_id={})", trait_def_id.repr(tcx));
- match tcx.map.get(trait_id.node) {
- ast_map::NodeItem(item) => trait_def_of_item(ccx, &*item),
- _ => {
- tcx.sess.bug(&format!("get_trait_def({}): not an item",
- trait_id.node))
- }
+ if trait_def_id.krate != ast::LOCAL_CRATE {
+ // If this trait comes from an external crate, then all of the
+ // supertraits it may depend on also must come from external
+ // crates, and hence all of them already have their
+ // super-predicates "converted" (and available from crate
+ // meta-data), so there is no need to transitively test them.
+ return Vec::new();
}
+
+ let superpredicates = tcx.super_predicates.borrow().get(&trait_def_id).cloned();
+ let superpredicates = superpredicates.unwrap_or_else(|| {
+ let trait_node_id = trait_def_id.node;
+
+ let item = match ccx.tcx.map.get(trait_node_id) {
+ ast_map::NodeItem(item) => item,
+ _ => ccx.tcx.sess.bug(&format!("trait_node_id {} is not an item", trait_node_id))
+ };
+
+ let (generics, bounds) = match item.node {
+ ast::ItemTrait(_, ref generics, ref supertraits, _) => (generics, supertraits),
+ _ => tcx.sess.span_bug(item.span,
+ "ensure_super_predicates_step invoked on non-trait"),
+ };
+
+ // In-scope when converting the superbounds for `Trait` are
+ // that `Self:Trait` as well as any bounds that appear on the
+ // generic types:
+ let trait_def = trait_def_of_item(ccx, item);
+ let self_predicate = ty::GenericPredicates {
+ predicates: VecPerParamSpace::new(vec![],
+ vec![trait_def.trait_ref.as_predicate()],
+ vec![])
+ };
+ let scope = &(generics, &self_predicate);
+
+ // Convert the bounds that follow the colon, e.g. `Bar+Zed` in `trait Foo : Bar+Zed`.
+ let self_param_ty = ty::mk_self_type(tcx);
+ let superbounds1 = compute_bounds(&ccx.icx(scope), self_param_ty, bounds,
+ SizedByDefault::No, item.span);
+ let superbounds1 = ty::predicates(tcx, self_param_ty, &superbounds1);
+
+ // Convert any explicit superbounds in the where clause,
+ // e.g. `trait Foo where Self : Bar`:
+ let superbounds2 = generics.get_type_parameter_bounds(&ccx.icx(scope), item.span, item.id);
+
+ // Combine the two lists to form the complete set of superbounds:
+ let superbounds = superbounds1.into_iter().chain(superbounds2.into_iter()).collect();
+ let superpredicates = ty::GenericPredicates {
+ predicates: VecPerParamSpace::new(superbounds, vec![], vec![])
+ };
+ debug!("superpredicates for trait {} = {}",
+ local_def(item.id).repr(ccx.tcx),
+ superpredicates.repr(ccx.tcx));
+
+ tcx.super_predicates.borrow_mut().insert(trait_def_id, superpredicates.clone());
+
+ superpredicates
+ });
+
+ let def_ids: Vec<_> = superpredicates.predicates
+ .iter()
+ .filter_map(|p| p.to_opt_poly_trait_ref())
+ .map(|tr| tr.def_id())
+ .collect();
+
+ debug!("ensure_super_predicates_step: def_ids={}", def_ids.repr(tcx));
+
+ def_ids
}
fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
return def.clone();
}
- let (unsafety, generics, bounds, items) = match it.node {
- ast::ItemTrait(unsafety,
- ref generics,
- ref supertraits,
- ref items) => {
- (unsafety, generics, supertraits, items)
- }
- ref s => {
- tcx.sess.span_bug(
- it.span,
- &format!("trait_def_of_item invoked on {:?}", s));
- }
+ let (unsafety, generics, items) = match it.node {
+ ast::ItemTrait(unsafety, ref generics, _, ref items) => (unsafety, generics, items),
+ _ => tcx.sess.span_bug(it.span, "trait_def_of_item invoked on non-trait"),
};
let paren_sugar = ty::has_attr(tcx, def_id, "rustc_paren_sugar");
it.span,
"the `#[rustc_paren_sugar]` attribute is a temporary means of controlling \
which traits can use parenthetical notation");
- span_help!(ccx.tcx.sess, it.span,
+ fileline_help!(ccx.tcx.sess, it.span,
"add `#![feature(unboxed_closures)]` to \
the crate attributes to use it");
}
let ty_generics = ty_generics_for_trait(ccx, it.id, substs, generics);
- let self_param_ty = ty::ParamTy::for_self().to_ty(ccx.tcx);
-
- // supertraits:
- let bounds = compute_bounds(&ccx.icx(generics),
- self_param_ty,
- bounds,
- SizedByDefault::No,
- it.span);
-
let associated_type_names: Vec<_> =
items.iter()
.filter_map(|item| {
paren_sugar: paren_sugar,
unsafety: unsafety,
generics: ty_generics,
- bounds: bounds,
trait_ref: trait_ref,
associated_type_names: associated_type_names,
});
}
}
+fn trait_defines_associated_type_named(ccx: &CrateCtxt,
+ trait_node_id: ast::NodeId,
+ assoc_name: ast::Name)
+ -> bool
+{
+ let item = match ccx.tcx.map.get(trait_node_id) {
+ ast_map::NodeItem(item) => item,
+ _ => ccx.tcx.sess.bug(&format!("trait_node_id {} is not an item", trait_node_id))
+ };
+
+ let trait_items = match item.node {
+ ast::ItemTrait(_, _, _, ref trait_items) => trait_items,
+ _ => ccx.tcx.sess.bug(&format!("trait_node_id {} is not a trait", trait_node_id))
+ };
+
+ trait_items.iter()
+ .any(|trait_item| {
+ match *trait_item {
+ ast::TypeTraitItem(ref t) => t.ty_param.ident.name == assoc_name,
+ ast::RequiredMethod(..) | ast::ProvidedMethod(..) => false,
+ }
+ })
+}
+
fn convert_trait_predicates<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &ast::Item) {
let tcx = ccx.tcx;
let trait_def = trait_def_of_item(ccx, it);
}
};
- let self_param_ty = ty::ParamTy::for_self().to_ty(ccx.tcx);
-
- let super_predicates = ty::predicates(ccx.tcx, self_param_ty, &trait_def.bounds);
+ let super_predicates = ty::lookup_super_predicates(ccx.tcx, def_id);
// `ty_generic_predicates` below will consider the bounds on the type
// parameters (including `Self`) and the explicit where-clauses,
// but to get the full set of predicates on a trait we need to add
// in the supertrait bounds and anything declared on the
// associated types.
- let mut base_predicates =
- ty::GenericPredicates {
- predicates: VecPerParamSpace::new(super_predicates, vec![], vec![])
- };
+ let mut base_predicates = super_predicates;
// Add in a predicate that `Self:Trait` (where `Trait` is the
// current trait). This is needed for builtin bounds.
}
}
-enum SizedByDefault { Yes, No }
+enum SizedByDefault { Yes, No, }
/// Translate the AST's notion of ty param bounds (which are an enum consisting of a newtyped Ty or
/// a region) to ty's notion of ty param bounds, which can either be user-defined traits, or the
&mut param_bounds.builtin_bounds,
ast_bounds,
span);
-
- check_bounds_compatible(astconv,
- param_ty,
- ¶m_bounds,
- span);
}
param_bounds.trait_bounds.sort_by(|a,b| a.def_id().cmp(&b.def_id()));
param_bounds
}
-fn check_bounds_compatible<'tcx>(astconv: &AstConv<'tcx>,
- param_ty: Ty<'tcx>,
- param_bounds: &ty::ParamBounds<'tcx>,
- span: Span) {
- let tcx = astconv.tcx();
- if !param_bounds.builtin_bounds.contains(&ty::BoundSized) {
- ty::each_bound_trait_and_supertraits(
- tcx,
- ¶m_bounds.trait_bounds,
- |trait_ref| {
- match astconv.get_trait_def(span, trait_ref.def_id()) {
- Ok(trait_def) => {
- if trait_def.bounds.builtin_bounds.contains(&ty::BoundSized) {
- span_err!(tcx.sess, span, E0129,
- "incompatible bounds on `{}`, \
- bound `{}` does not allow unsized type",
- param_ty.user_string(tcx),
- trait_ref.user_string(tcx));
- }
- }
- Err(ErrorReported) => { }
- }
- true
- });
- }
-}
-
-/// Converts a specific TyParamBound from the AST into the
-/// appropriate poly-trait-reference.
-fn poly_trait_ref_from_bound<'tcx>(astconv: &AstConv<'tcx>,
- param_ty: Ty<'tcx>,
- bound: &ast::TyParamBound,
- projections: &mut Vec<ty::PolyProjectionPredicate<'tcx>>)
- -> Option<ty::PolyTraitRef<'tcx>>
+/// Converts a specific TyParamBound from the AST into a set of
+/// predicates that apply to the self-type. A vector is returned
+/// because this can be anywhere from 0 predicates (`T:?Sized` adds no
+/// predicates) to 1 (`T:Foo`) to many (`T:Bar<X=i32>` adds `T:Bar`
+/// and `<T as Bar>::X == i32`).
+fn predicates_from_bound<'tcx>(astconv: &AstConv<'tcx>,
+ param_ty: Ty<'tcx>,
+ bound: &ast::TyParamBound)
+ -> Vec<ty::Predicate<'tcx>>
{
match *bound {
ast::TraitTyParamBound(ref tr, ast::TraitBoundModifier::None) => {
- Some(conv_poly_trait_ref(astconv, param_ty, tr, projections))
+ let mut projections = Vec::new();
+ let pred = conv_poly_trait_ref(astconv, param_ty, tr, &mut projections);
+ projections.into_iter()
+ .map(|p| p.as_predicate())
+ .chain(Some(pred.as_predicate()).into_iter())
+ .collect()
}
- ast::TraitTyParamBound(_, ast::TraitBoundModifier::Maybe) |
- ast::RegionTyParamBound(_) => {
- None
+ ast::RegionTyParamBound(ref lifetime) => {
+ let region = ast_region_to_region(astconv.tcx(), lifetime);
+ let pred = ty::Binder(ty::OutlivesPredicate(param_ty, region));
+ vec![ty::Predicate::TypeOutlives(pred)]
+ }
+ ast::TraitTyParamBound(_, ast::TraitBoundModifier::Maybe) => {
+ Vec::new()
}
}
}
ast::ItemTrait(..) => {
let trait_def = ty::lookup_trait_def(tcx, did);
- let predicates = ty::predicates(tcx, ty::mk_self_type(tcx), &trait_def.bounds);
+ let predicates = ty::lookup_super_predicates(tcx, did);
self.add_constraints_from_predicates(&trait_def.generics,
- &predicates,
+ predicates.predicates.as_slice(),
self.covariant);
let trait_items = ty::trait_items(tcx, did);
_ => unreachable!()
}
});
- let trait_def = ty::lookup_trait_def(tcx, did);
let predicates = ty::lookup_predicates(tcx, did);
- let bounds = trait_def.bounds.clean(cx);
clean::Trait {
unsafety: def.unsafety,
generics: (&def.generics, &predicates, subst::TypeSpace).clean(cx),
items: items.collect(),
- bounds: bounds,
+ bounds: vec![], // supertraits can be found in the list of predicates
}
}
// This may be an overestimate if there is any whitespace
let mut b = Vec::with_capacity(self.len() / 2);
let mut modulus = 0;
- let mut buf = 0u8;
+ let mut buf = 0;
for (idx, byte) in self.bytes().enumerate() {
buf <<= 4;
fn decode_hex_escape(&mut self) -> Result<u16, ParserError> {
let mut i = 0;
- let mut n = 0u16;
+ let mut n = 0;
while i < 4 && !self.eof() {
self.bump();
n = match self.ch_or_null() {
impl AsciiExt for u8 {
type Owned = u8;
#[inline]
- fn is_ascii(&self) -> bool { *self & 128 == 0u8 }
+ fn is_ascii(&self) -> bool { *self & 128 == 0 }
#[inline]
fn to_ascii_uppercase(&self) -> u8 { ASCII_UPPERCASE_MAP[*self as usize] }
#[inline]
assert_eq!("url()URL()uRl()ürl".to_ascii_uppercase(), "URL()URL()URL()üRL");
assert_eq!("hıKß".to_ascii_uppercase(), "HıKß");
- for i in 0u32..501 {
+ for i in 0..501 {
let upper = if 'a' as u32 <= i && i <= 'z' as u32 { i + 'A' as u32 - 'a' as u32 }
else { i };
assert_eq!((from_u32(i).unwrap()).to_string().to_ascii_uppercase(),
// Dotted capital I, Kelvin sign, Sharp S.
assert_eq!("HİKß".to_ascii_lowercase(), "hİKß");
- for i in 0u32..501 {
+ for i in 0..501 {
let lower = if 'A' as u32 <= i && i <= 'Z' as u32 { i + 'a' as u32 - 'A' as u32 }
else { i };
assert_eq!((from_u32(i).unwrap()).to_string().to_ascii_lowercase(),
"URL()URL()URL()üRL".to_string());
assert_eq!(("hıKß".to_string()).into_ascii_uppercase(), "HıKß");
- for i in 0u32..501 {
+ for i in 0..501 {
let upper = if 'a' as u32 <= i && i <= 'z' as u32 { i + 'A' as u32 - 'a' as u32 }
else { i };
assert_eq!((from_u32(i).unwrap()).to_string().into_ascii_uppercase(),
// Dotted capital I, Kelvin sign, Sharp S.
assert_eq!(("HİKß".to_string()).into_ascii_lowercase(), "hİKß");
- for i in 0u32..501 {
+ for i in 0..501 {
let lower = if 'A' as u32 <= i && i <= 'Z' as u32 { i + 'a' as u32 - 'A' as u32 }
else { i };
assert_eq!((from_u32(i).unwrap()).to_string().into_ascii_lowercase(),
assert!(!"K".eq_ignore_ascii_case("k"));
assert!(!"ß".eq_ignore_ascii_case("s"));
- for i in 0u32..501 {
+ for i in 0..501 {
let lower = if 'A' as u32 <= i && i <= 'Z' as u32 { i + 'a' as u32 - 'A' as u32 }
else { i };
assert!((from_u32(i).unwrap()).to_string().eq_ignore_ascii_case(
use rt::heap::{allocate, deallocate, EMPTY};
use collections::hash_state::HashState;
-const EMPTY_BUCKET: u64 = 0u64;
+const EMPTY_BUCKET: u64 = 0;
/// The raw hashtable, providing safe-ish access to the unzipped and highly
/// optimized arrays of hashes, keys, and values.
{
let mut state = hash_state.hasher();
t.hash(&mut state);
- // We need to avoid 0u64 in order to prevent collisions with
+ // We need to avoid 0 in order to prevent collisions with
// EMPTY_HASH. We can maintain our precious uniform distribution
// of initial indexes by unconditionally setting the MSB,
// effectively reducing 64-bits hashes to 63 bits.
//! * You want a bit vector.
//!
//! ### Use a `BitSet` when:
-//! * You want a `VecSet`.
+//! * You want a `BitVec`, but want `Set` properties
//!
//! ### Use a `BinaryHeap` when:
//! * You want to store a bunch of elements, but only ever want to process the "biggest"
//!
//! Choosing the right collection for the job requires an understanding of what each collection
//! is good at. Here we briefly summarize the performance of different collections for certain
-//! important operations. For further details, see each type's documentation.
+//! important operations. For further details, see each type's documentation, and note that the
+//! names of actual methods may differ from the tables below on certain collections.
//!
//! Throughout the documentation, we will follow a few conventions. For all operations,
//! the collection's size is denoted by n. If another collection is involved in the operation, it
//! a variant of the `Entry` enum.
//!
//! If a `Vacant(entry)` is yielded, then the key *was not* found. In this case the
-//! only valid operation is to `set` the value of the entry. When this is done,
+//! only valid operation is to `insert` a value into the entry. When this is done,
//! the vacant entry is consumed and converted into a mutable reference to the
//! the value that was inserted. This allows for further manipulation of the value
//! beyond the lifetime of the search itself. This is useful if complex logic needs to
//! be performed on the value regardless of whether the value was just inserted.
//!
//! If an `Occupied(entry)` is yielded, then the key *was* found. In this case, the user
-//! has several options: they can `get`, `set`, or `take` the value of the occupied
+//! has several options: they can `get`, `insert`, or `remove` the value of the occupied
//! entry. Additionally, they can convert the occupied entry into a mutable reference
-//! to its value, providing symmetry to the vacant `set` case.
+//! to its value, providing symmetry to the vacant `insert` case.
//!
//! ### Examples
//!
//! use std::collections::btree_map::{BTreeMap, Entry};
//!
//! // A client of the bar. They have an id and a blood alcohol level.
-//! struct Person { id: u32, blood_alcohol: f32 };
+//! struct Person { id: u32, blood_alcohol: f32 }
//!
//! // All the orders made to the bar, by client id.
//! let orders = vec![1,2,1,2,3,4,1,2,2,3,4,1,1,1];
mod os {
pub const FAMILY: &'static str = "unix";
pub const OS: &'static str = "ios";
+ pub const DLL_PREFIX: &'static str = "lib";
+ pub const DLL_SUFFIX: &'static str = ".dylib";
+ pub const DLL_EXTENSION: &'static str = "dylib";
pub const EXE_SUFFIX: &'static str = "";
pub const EXE_EXTENSION: &'static str = "";
}
check!(w.write(msg));
}
let files = check!(fs::read_dir(dir));
- let mut mem = [0u8; 4];
+ let mut mem = [0; 4];
for f in files {
let f = f.unwrap().path();
{
check!(File::create(&dir2.join("14")));
let files = check!(fs::walk_dir(dir));
- let mut cur = [0u8; 2];
+ let mut cur = [0; 2];
for f in files {
let f = f.unwrap().path();
let stem = f.file_stem().unwrap().to_str().unwrap();
#[test]
fn read_char_buffered() {
- let buf = [195u8, 159u8];
+ let buf = [195, 159];
let reader = BufReader::with_capacity(1, &buf[..]);
assert_eq!(reader.chars().next(), Some(Ok('ß')));
}
#[test]
fn test_chars() {
- let buf = [195u8, 159u8, b'a'];
+ let buf = [195, 159, b'a'];
let reader = BufReader::with_capacity(1, &buf[..]);
let mut it = reader.chars();
assert_eq!(it.next(), Some(Ok('ß')));
#[test]
fn test_mem_reader() {
- let mut reader = Cursor::new(vec!(0u8, 1, 2, 3, 4, 5, 6, 7));
+ let mut reader = Cursor::new(vec!(0, 1, 2, 3, 4, 5, 6, 7));
let mut buf = [];
assert_eq!(reader.read(&mut buf), Ok(0));
assert_eq!(reader.position(), 0);
#[test]
fn read_to_end() {
- let mut reader = Cursor::new(vec!(0u8, 1, 2, 3, 4, 5, 6, 7));
+ let mut reader = Cursor::new(vec!(0, 1, 2, 3, 4, 5, 6, 7));
let mut v = Vec::new();
reader.read_to_end(&mut v).ok().unwrap();
assert_eq!(v, [0, 1, 2, 3, 4, 5, 6, 7]);
#[test]
fn test_slice_reader() {
- let in_buf = vec![0u8, 1, 2, 3, 4, 5, 6, 7];
+ let in_buf = vec![0, 1, 2, 3, 4, 5, 6, 7];
let mut reader = &mut in_buf.as_slice();
let mut buf = [];
assert_eq!(reader.read(&mut buf), Ok(0));
#[test]
fn test_buf_reader() {
- let in_buf = vec![0u8, 1, 2, 3, 4, 5, 6, 7];
+ let in_buf = vec![0, 1, 2, 3, 4, 5, 6, 7];
let mut reader = Cursor::new(in_buf.as_slice());
let mut buf = [];
assert_eq!(reader.read(&mut buf), Ok(0));
assert_eq!(r.seek(SeekFrom::Start(10)), Ok(10));
assert_eq!(r.read(&mut [0]), Ok(0));
- let mut r = Cursor::new(vec!(10u8));
+ let mut r = Cursor::new(vec!(10));
assert_eq!(r.seek(SeekFrom::Start(10)), Ok(10));
assert_eq!(r.read(&mut [0]), Ok(0));
#[test]
fn seek_before_0() {
- let buf = [0xff_u8];
+ let buf = [0xff];
let mut r = Cursor::new(&buf[..]);
assert!(r.seek(SeekFrom::End(-2)).is_err());
- let mut r = Cursor::new(vec!(10u8));
+ let mut r = Cursor::new(vec!(10));
assert!(r.seek(SeekFrom::End(-2)).is_err());
let mut buf = [0];
#![feature(hash)]
#![feature(int_uint)]
#![feature(unique)]
+#![feature(allow_internal_unstable)]
#![cfg_attr(test, feature(test, rustc_private))]
// Don't link to std. We are std.
#[test]
fn to_socket_addr_ipaddr_u16() {
let a = IpAddr::new_v4(77, 88, 21, 11);
- let p = 12345u16;
+ let p = 12345;
let e = SocketAddr::new(a, p);
assert_eq!(Ok(vec![e]), tsa((a, p)));
}
#[test]
fn to_socket_addr_str_u16() {
let a = SocketAddr::new(IpAddr::new_v4(77, 88, 21, 11), 24352);
- assert_eq!(Ok(vec![a]), tsa(("77.88.21.11", 24352u16)));
+ assert_eq!(Ok(vec![a]), tsa(("77.88.21.11", 24352)));
let a = SocketAddr::new(IpAddr::new_v6(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 53);
assert_eq!(Ok(vec![a]), tsa(("2a02:6b8:0:1::1", 53)));
let a = SocketAddr::new(IpAddr::new_v4(127, 0, 0, 1), 23924);
- assert!(tsa(("localhost", 23924u16)).unwrap().contains(&a));
+ assert!(tsa(("localhost", 23924)).unwrap().contains(&a));
}
#[test]
}
fn read_number_impl(&mut self, radix: u8, max_digits: u32, upto: u32) -> Option<u32> {
- let mut r = 0u32;
+ let mut r = 0;
let mut digit_count = 0;
loop {
match self.read_digit(radix) {
}
fn read_ipv4_addr_impl(&mut self) -> Option<Ipv4Addr> {
- let mut bs = [0u8; 4];
+ let mut bs = [0; 4];
let mut i = 0;
while i < 4 {
if i != 0 && self.read_given_char('.').is_none() {
fn read_ipv6_addr_impl(&mut self) -> Option<Ipv6Addr> {
fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> Ipv6Addr {
assert!(head.len() + tail.len() <= 8);
- let mut gs = [0u16; 8];
+ let mut gs = [0; 8];
gs.clone_from_slice(head);
gs[(8 - tail.len()) .. 8].clone_from_slice(tail);
Ipv6Addr::new(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7])
(i, false)
}
- let mut head = [0u16; 8];
+ let mut head = [0; 8];
let (head_size, head_ipv4) = read_groups(self, &mut head, 8);
if head_size == 8 {
return None;
}
- let mut tail = [0u16; 8];
+ let mut tail = [0; 8];
let (tail_size, _) = read_groups(self, &mut tail, 8 - head_size);
Some(ipv6_addr_from_head_tail(&head[..head_size], &tail[..tail_size]))
}
#[test]
fn test_integer_decode() {
- assert_eq!(3.14159265359f32.integer_decode(), (13176795u64, -22i16, 1i8));
- assert_eq!((-8573.5918555f32).integer_decode(), (8779358u64, -10i16, -1i8));
- assert_eq!(2f32.powf(100.0).integer_decode(), (8388608u64, 77i16, 1i8));
- assert_eq!(0f32.integer_decode(), (0u64, -150i16, 1i8));
- assert_eq!((-0f32).integer_decode(), (0u64, -150i16, -1i8));
- assert_eq!(INFINITY.integer_decode(), (8388608u64, 105i16, 1i8));
- assert_eq!(NEG_INFINITY.integer_decode(), (8388608u64, 105i16, -1i8));
- assert_eq!(NAN.integer_decode(), (12582912u64, 105i16, 1i8));
+ assert_eq!(3.14159265359f32.integer_decode(), (13176795, -22, 1));
+ assert_eq!((-8573.5918555f32).integer_decode(), (8779358, -10, -1));
+ assert_eq!(2f32.powf(100.0).integer_decode(), (8388608, 77, 1));
+ assert_eq!(0f32.integer_decode(), (0, -150, 1));
+ assert_eq!((-0f32).integer_decode(), (0, -150, -1));
+ assert_eq!(INFINITY.integer_decode(), (8388608, 105, 1));
+ assert_eq!(NEG_INFINITY.integer_decode(), (8388608, 105, -1));
+ assert_eq!(NAN.integer_decode(), (12582912, 105, 1));
}
#[test]
#[test]
fn test_integer_decode() {
- assert_eq!(3.14159265359f64.integer_decode(), (7074237752028906u64, -51i16, 1i8));
- assert_eq!((-8573.5918555f64).integer_decode(), (4713381968463931u64, -39i16, -1i8));
- assert_eq!(2f64.powf(100.0).integer_decode(), (4503599627370496u64, 48i16, 1i8));
- assert_eq!(0f64.integer_decode(), (0u64, -1075i16, 1i8));
- assert_eq!((-0f64).integer_decode(), (0u64, -1075i16, -1i8));
- assert_eq!(INFINITY.integer_decode(), (4503599627370496u64, 972i16, 1i8));
+ assert_eq!(3.14159265359f64.integer_decode(), (7074237752028906, -51, 1));
+ assert_eq!((-8573.5918555f64).integer_decode(), (4713381968463931, -39, -1));
+ assert_eq!(2f64.powf(100.0).integer_decode(), (4503599627370496, 48, 1));
+ assert_eq!(0f64.integer_decode(), (0, -1075, 1));
+ assert_eq!((-0f64).integer_decode(), (0, -1075, -1));
+ assert_eq!(INFINITY.integer_decode(), (4503599627370496, 972, 1));
assert_eq!(NEG_INFINITY.integer_decode(), (4503599627370496, 972, -1));
- assert_eq!(NAN.integer_decode(), (6755399441055744u64, 972i16, 1i8));
+ assert_eq!(NAN.integer_decode(), (6755399441055744, 972, 1));
}
#[test]
///
/// let num = 2.0f32;
///
- /// // (8388608u64, -22i16, 1i8)
+ /// // (8388608, -22, 1)
/// let (mantissa, exponent, sign) = num.integer_decode();
/// let sign_f = sign as f32;
/// let mantissa_f = mantissa as f32;
#[test]
fn test_uint_to_str_overflow() {
- let mut u8_val: u8 = 255_u8;
+ let mut u8_val: u8 = 255;
assert_eq!(u8_val.to_string(), "255");
u8_val = u8_val.wrapping_add(1);
assert_eq!(u8_val.to_string(), "0");
- let mut u16_val: u16 = 65_535_u16;
+ let mut u16_val: u16 = 65_535;
assert_eq!(u16_val.to_string(), "65535");
u16_val = u16_val.wrapping_add(1);
assert_eq!(u16_val.to_string(), "0");
- let mut u32_val: u32 = 4_294_967_295_u32;
+ let mut u32_val: u32 = 4_294_967_295;
assert_eq!(u32_val.to_string(), "4294967295");
u32_val = u32_val.wrapping_add(1);
assert_eq!(u32_val.to_string(), "0");
- let mut u64_val: u64 = 18_446_744_073_709_551_615_u64;
+ let mut u64_val: u64 = 18_446_744_073_709_551_615;
assert_eq!(u64_val.to_string(), "18446744073709551615");
u64_val = u64_val.wrapping_add(1);
#[test]
fn test_uint_from_str_overflow() {
- let mut u8_val: u8 = 255_u8;
+ let mut u8_val: u8 = 255;
assert_eq!(from_str::<u8>("255"), Some(u8_val));
assert_eq!(from_str::<u8>("256"), None);
assert_eq!(from_str::<u8>("0"), Some(u8_val));
assert_eq!(from_str::<u8>("-1"), None);
- let mut u16_val: u16 = 65_535_u16;
+ let mut u16_val: u16 = 65_535;
assert_eq!(from_str::<u16>("65535"), Some(u16_val));
assert_eq!(from_str::<u16>("65536"), None);
assert_eq!(from_str::<u16>("0"), Some(u16_val));
assert_eq!(from_str::<u16>("-1"), None);
- let mut u32_val: u32 = 4_294_967_295_u32;
+ let mut u32_val: u32 = 4_294_967_295;
assert_eq!(from_str::<u32>("4294967295"), Some(u32_val));
assert_eq!(from_str::<u32>("4294967296"), None);
assert_eq!(from_str::<u32>("0"), Some(u32_val));
assert_eq!(from_str::<u32>("-1"), None);
- let mut u64_val: u64 = 18_446_744_073_709_551_615_u64;
+ let mut u64_val: u64 = 18_446_744_073_709_551_615;
assert_eq!(from_str::<u64>("18446744073709551615"), Some(u64_val));
assert_eq!(from_str::<u64>("18446744073709551616"), None);
// This is just for integral types, the largest of which is a u64. The
// smallest base that we can have is 2, so the most number of digits we're
// ever going to have is 64
- let mut buf = [0u8; 64];
+ let mut buf = [0; 64];
let mut cur = 0;
// Loop at least once to make sure at least a `0` gets emitted.
let radix_gen: T = num::cast(radix as int).unwrap();
let (num, exp) = match exp_format {
- ExpNone => (num, 0i32),
+ ExpNone => (num, 0),
ExpDec | ExpBin => {
if num == _0 {
- (num, 0i32)
+ (num, 0)
} else {
let (exp, exp_base) = match exp_format {
ExpDec => (num.abs().log10().floor(), num::cast::<f64, T>(10.0f64).unwrap()),
#[test]
fn test_int_to_str_overflow() {
- let mut i8_val: i8 = 127_i8;
+ let mut i8_val: i8 = 127;
assert_eq!(i8_val.to_string(), "127");
i8_val = i8_val.wrapping_add(1);
assert_eq!(i8_val.to_string(), "-128");
- let mut i16_val: i16 = 32_767_i16;
+ let mut i16_val: i16 = 32_767;
assert_eq!(i16_val.to_string(), "32767");
i16_val = i16_val.wrapping_add(1);
assert_eq!(i16_val.to_string(), "-32768");
- let mut i32_val: i32 = 2_147_483_647_i32;
+ let mut i32_val: i32 = 2_147_483_647;
assert_eq!(i32_val.to_string(), "2147483647");
i32_val = i32_val.wrapping_add(1);
assert_eq!(i32_val.to_string(), "-2147483648");
- let mut i64_val: i64 = 9_223_372_036_854_775_807_i64;
+ let mut i64_val: i64 = 9_223_372_036_854_775_807;
assert_eq!(i64_val.to_string(), "9223372036854775807");
i64_val = i64_val.wrapping_add(1);
#[test]
fn read_char_buffered() {
- let buf = [195u8, 159u8];
+ let buf = [195, 159];
let mut reader = BufferedReader::with_capacity(1, &buf[..]);
assert_eq!(reader.read_char(), Ok('ß'));
}
#[test]
fn test_chars() {
- let buf = [195u8, 159u8, b'a'];
+ let buf = [195, 159, b'a'];
let mut reader = BufferedReader::with_capacity(1, &buf[..]);
let mut it = reader.chars();
assert_eq!(it.next(), Some(Ok('ß')));
/// # drop(tx);
/// let mut reader = ChanReader::new(rx);
///
-/// let mut buf = [0u8; 100];
+/// let mut buf = [0; 100];
/// match reader.read(&mut buf) {
/// Ok(nread) => println!("Read {} bytes", nread),
/// Err(e) => println!("read error: {}", e),
fn test_rx_reader() {
let (tx, rx) = channel();
thread::spawn(move|| {
- tx.send(vec![1u8, 2u8]).unwrap();
+ tx.send(vec![1, 2]).unwrap();
tx.send(vec![]).unwrap();
- tx.send(vec![3u8, 4u8]).unwrap();
- tx.send(vec![5u8, 6u8]).unwrap();
- tx.send(vec![7u8, 8u8]).unwrap();
+ tx.send(vec![3, 4]).unwrap();
+ tx.send(vec![5, 6]).unwrap();
+ tx.send(vec![7, 8]).unwrap();
});
let mut reader = ChanReader::new(rx);
- let mut buf = [0u8; 3];
+ let mut buf = [0; 3];
assert_eq!(Ok(0), reader.read(&mut []));
let mut writer = ChanWriter::new(tx);
writer.write_be_u32(42).unwrap();
- let wanted = vec![0u8, 0u8, 0u8, 42u8];
+ let wanted = vec![0, 0, 0, 42];
let got = thread::scoped(move|| { rx.recv().unwrap() }).join();
assert_eq!(wanted, got);
let mut i = size;
let mut n = n;
while i > 0 {
- bytes.push((n & 255_u64) as u8);
+ bytes.push((n & 255) as u8);
n >>= 8;
i -= 1;
}
panic!("index out of bounds");
}
- let mut buf = [0u8; 8];
+ let mut buf = [0; 8];
unsafe {
let ptr = data.as_ptr().offset(start as int);
let out = buf.as_mut_ptr();
({
use super::u64_from_be_bytes;
- let data = (0u8..$stride*100+$start_index).collect::<Vec<_>>();
- let mut sum = 0u64;
+ let data = (0..$stride*100+$start_index).collect::<Vec<_>>();
+ let mut sum = 0;
$b.iter(|| {
let mut i = $start_index;
while i < data.len() {
check!(w.write(msg));
}
let files = check!(readdir(dir));
- let mut mem = [0u8; 4];
+ let mut mem = [0; 4];
for f in &files {
{
let n = f.filestem_str();
check!(File::create(&dir2.join("14")));
let mut files = check!(walk_dir(dir));
- let mut cur = [0u8; 2];
+ let mut cur = [0; 2];
for f in files {
let stem = f.filestem_str().unwrap();
let root = stem.as_bytes()[0] - b'0';
fn read_le_uint_n(&mut self, nbytes: uint) -> IoResult<u64> {
assert!(nbytes > 0 && nbytes <= 8);
- let mut val = 0u64;
+ let mut val = 0;
let mut pos = 0;
let mut i = nbytes;
while i > 0 {
fn read_be_uint_n(&mut self, nbytes: uint) -> IoResult<u64> {
assert!(nbytes > 0 && nbytes <= 8);
- let mut val = 0u64;
+ let mut val = 0;
let mut i = nbytes;
while i > 0 {
i -= 1;
/// Write a single char, encoded as UTF-8.
#[inline]
fn write_char(&mut self, c: char) -> IoResult<()> {
- let mut buf = [0u8; 4];
+ let mut buf = [0; 4];
let n = c.encode_utf8(&mut buf).unwrap_or(0);
self.write_all(&buf[..n])
}
fn test_read_at_least() {
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
vec![GoodBehavior(usize::MAX)]);
- let buf = &mut [0u8; 5];
+ let buf = &mut [0; 5];
assert!(r.read_at_least(1, buf).unwrap() >= 1);
assert!(r.read_exact(5).unwrap().len() == 5); // read_exact uses read_at_least
assert!(r.read_at_least(0, buf).is_ok());
}
fn read_number_impl(&mut self, radix: u8, max_digits: u32, upto: u32) -> Option<u32> {
- let mut r = 0u32;
+ let mut r = 0;
let mut digit_count = 0;
loop {
match self.read_digit(radix) {
}
fn read_ipv4_addr_impl(&mut self) -> Option<IpAddr> {
- let mut bs = [0u8; 4];
+ let mut bs = [0; 4];
let mut i = 0;
while i < 4 {
if i != 0 && self.read_given_char('.').is_none() {
fn read_ipv6_addr_impl(&mut self) -> Option<IpAddr> {
fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> IpAddr {
assert!(head.len() + tail.len() <= 8);
- let mut gs = [0u16; 8];
+ let mut gs = [0; 8];
gs.clone_from_slice(head);
gs[(8 - tail.len()) .. 8].clone_from_slice(tail);
Ipv6Addr(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7])
(i, false)
}
- let mut head = [0u16; 8];
+ let mut head = [0; 8];
let (head_size, head_ipv4) = read_groups(self, &mut head, 8);
if head_size == 8 {
return None;
}
- let mut tail = [0u16; 8];
+ let mut tail = [0; 8];
let (tail_size, _) = read_groups(self, &mut tail, 8 - head_size);
Some(ipv6_addr_from_head_tail(&head[..head_size], &tail[..tail_size]))
}
/// // The following lines are equivalent modulo possible "localhost" name resolution
/// // differences
/// let tcp_s = TcpStream::connect(SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 12345 });
-/// let tcp_s = TcpStream::connect((Ipv4Addr(127, 0, 0, 1), 12345u16));
-/// let tcp_s = TcpStream::connect(("127.0.0.1", 12345u16));
-/// let tcp_s = TcpStream::connect(("localhost", 12345u16));
+/// let tcp_s = TcpStream::connect((Ipv4Addr(127, 0, 0, 1), 12345));
+/// let tcp_s = TcpStream::connect(("127.0.0.1", 12345));
+/// let tcp_s = TcpStream::connect(("localhost", 12345));
/// let tcp_s = TcpStream::connect("127.0.0.1:12345");
/// let tcp_s = TcpStream::connect("localhost:12345");
///
/// // TcpListener::bind(), UdpSocket::bind() and UdpSocket::send_to() behave similarly
/// let tcp_l = TcpListener::bind("localhost:12345");
///
-/// let mut udp_s = UdpSocket::bind(("127.0.0.1", 23451u16)).unwrap();
-/// udp_s.send_to([7u8, 7u8, 7u8].as_slice(), (Ipv4Addr(127, 0, 0, 1), 23451u16));
+/// let mut udp_s = UdpSocket::bind(("127.0.0.1", 23451)).unwrap();
+/// udp_s.send_to([7, 7, 7].as_slice(), (Ipv4Addr(127, 0, 0, 1), 23451));
/// }
/// ```
pub trait ToSocketAddr {
#[test]
fn to_socket_addr_ipaddr_u16() {
let a = Ipv4Addr(77, 88, 21, 11);
- let p = 12345u16;
+ let p = 12345;
let e = SocketAddr { ip: a, port: p };
assert_eq!(Ok(e), (a, p).to_socket_addr());
assert_eq!(Ok(vec![e]), (a, p).to_socket_addr_all());
#[test]
fn to_socket_addr_str_u16() {
let a = SocketAddr { ip: Ipv4Addr(77, 88, 21, 11), port: 24352 };
- assert_eq!(Ok(a), ("77.88.21.11", 24352u16).to_socket_addr());
- assert_eq!(Ok(vec![a]), ("77.88.21.11", 24352u16).to_socket_addr_all());
+ assert_eq!(Ok(a), ("77.88.21.11", 24352).to_socket_addr());
+ assert_eq!(Ok(vec![a]), ("77.88.21.11", 24352).to_socket_addr_all());
let a = SocketAddr { ip: Ipv6Addr(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), port: 53 };
assert_eq!(Ok(a), ("2a02:6b8:0:1::1", 53).to_socket_addr());
assert_eq!(Ok(vec![a]), ("2a02:6b8:0:1::1", 53).to_socket_addr_all());
let a = SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 23924 };
- assert!(("localhost", 23924u16).to_socket_addr_all().unwrap().contains(&a));
+ assert!(("localhost", 23924).to_socket_addr_all().unwrap().contains(&a));
}
#[test]
tx.send(TcpStream::connect(addr).unwrap()).unwrap();
});
let _l = rx.recv().unwrap();
- for i in 0i32..1001 {
+ for i in 0..1001 {
match a.accept() {
Ok(..) => break,
Err(ref e) if e.kind == TimedOut => {}
assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
s.set_timeout(Some(20));
- for i in 0i32..1001 {
+ for i in 0..1001 {
match s.write(&[0; 128 * 1024]) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break,
let mut s = a.accept().unwrap();
s.set_write_timeout(Some(20));
- for i in 0i32..1001 {
+ for i in 0..1001 {
match s.write(&[0; 128 * 1024]) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break,
*/
fn base_port() -> u16 {
- let base = 9600u16;
- let range = 1000u16;
+ let base = 9600;
+ let range = 1000;
let bases = [
("32-opt", base + range * 1),
#[test]
fn test_iter_reader() {
- let mut r = IterReader::new(0u8..8);
+ let mut r = IterReader::new(0..8);
let mut buf = [0, 0, 0];
let len = r.read(&mut buf).unwrap();
assert_eq!(len, 3);
#[test]
fn iter_reader_zero_length() {
- let mut r = IterReader::new(0u8..8);
+ let mut r = IterReader::new(0..8);
let mut buf = [];
assert_eq!(Ok(0), r.read(&mut buf));
}
let lengths = [0, 1, 2, 3, 4, 5, 6, 7,
80, 81, 82, 83, 84, 85, 86, 87];
for &n in &lengths {
- let mut v = repeat(0u8).take(n).collect::<Vec<_>>();
+ let mut v = repeat(0).take(n).collect::<Vec<_>>();
r.fill_bytes(&mut v);
// use this to get nicer error messages.
}
fn getrandom_next_u32() -> u32 {
- let mut buf: [u8; 4] = [0u8; 4];
+ let mut buf: [u8; 4] = [0; 4];
getrandom_fill_bytes(&mut buf);
unsafe { mem::transmute::<[u8; 4], u32>(buf) }
}
fn getrandom_next_u64() -> u64 {
- let mut buf: [u8; 8] = [0u8; 8];
+ let mut buf: [u8; 8] = [0; 8];
getrandom_fill_bytes(&mut buf);
unsafe { mem::transmute::<[u8; 8], u64>(buf) }
}
impl Rng for OsRng {
fn next_u32(&mut self) -> u32 {
- let mut v = [0u8; 4];
+ let mut v = [0; 4];
self.fill_bytes(&mut v);
unsafe { mem::transmute(v) }
}
fn next_u64(&mut self) -> u64 {
- let mut v = [0u8; 8];
+ let mut v = [0; 8];
self.fill_bytes(&mut v);
unsafe { mem::transmute(v) }
}
impl Rng for OsRng {
fn next_u32(&mut self) -> u32 {
- let mut v = [0u8; 4];
+ let mut v = [0; 4];
self.fill_bytes(&mut v);
unsafe { mem::transmute(v) }
}
fn next_u64(&mut self) -> u64 {
- let mut v = [0u8; 8];
+ let mut v = [0; 8];
self.fill_bytes(&mut v);
unsafe { mem::transmute(v) }
}
r.next_u32();
r.next_u64();
- let mut v = [0u8; 1000];
+ let mut v = [0; 1000];
r.fill_bytes(&mut v);
}
// as possible (XXX: is this a good test?)
let mut r = OsRng::new().unwrap();
thread::yield_now();
- let mut v = [0u8; 1000];
+ let mut v = [0; 1000];
for _ in 0..100 {
r.next_u32();
#[test]
fn test_reader_rng_u64() {
// transmute from the target to avoid endianness concerns.
- let v = vec![0u8, 0, 0, 0, 0, 0, 0, 1,
+ let v = vec![0, 0, 0, 0, 0, 0, 0, 1,
0 , 0, 0, 0, 0, 0, 0, 2,
0, 0, 0, 0, 0, 0, 0, 3];
let mut rng = ReaderRng::new(MemReader::new(v));
- assert_eq!(rng.next_u64(), 1_u64.to_be());
- assert_eq!(rng.next_u64(), 2_u64.to_be());
- assert_eq!(rng.next_u64(), 3_u64.to_be());
+ assert_eq!(rng.next_u64(), 1.to_be());
+ assert_eq!(rng.next_u64(), 2.to_be());
+ assert_eq!(rng.next_u64(), 3.to_be());
}
#[test]
fn test_reader_rng_u32() {
- let v = vec![0u8, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3];
+ let v = vec![0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3];
let mut rng = ReaderRng::new(MemReader::new(v));
- assert_eq!(rng.next_u32(), 1_u32.to_be());
- assert_eq!(rng.next_u32(), 2_u32.to_be());
- assert_eq!(rng.next_u32(), 3_u32.to_be());
+ assert_eq!(rng.next_u32(), 1.to_be());
+ assert_eq!(rng.next_u32(), 2.to_be());
+ assert_eq!(rng.next_u32(), 3.to_be());
}
#[test]
fn test_reader_rng_fill_bytes() {
- let v = [1u8, 2, 3, 4, 5, 6, 7, 8];
- let mut w = [0u8; 8];
+ let v = [1, 2, 3, 4, 5, 6, 7, 8];
+ let mut w = [0; 8];
let mut rng = ReaderRng::new(MemReader::new(v.to_vec()));
rng.fill_bytes(&mut w);
#[should_fail]
fn test_reader_rng_insufficient_bytes() {
let mut rng = ReaderRng::new(MemReader::new(vec!()));
- let mut v = [0u8; 3];
+ let mut v = [0; 3];
rng.fill_bytes(&mut v);
}
}
}
// Convert the arguments into a stack-allocated string
- let mut msg = [0u8; 512];
+ let mut msg = [0; 512];
let mut w = BufWriter { buf: &mut msg, pos: 0 };
let _ = write!(&mut w, "{}", args);
let msg = str::from_utf8(&w.buf[..w.pos]).unwrap_or("aborted");
//! ```
#![allow(non_camel_case_types)]
+#![unstable(feature = "thread_local_internals")]
use prelude::v1::*;
/// KEY.set(1 as *mut u8);
/// }
/// ```
-#[stable(feature = "rust1", since = "1.0.0")]
pub struct StaticKey {
/// Inner static TLS key (internals), created with by `INIT_INNER` in this
/// module.
- #[stable(feature = "rust1", since = "1.0.0")]
pub inner: StaticKeyInner,
/// Destructor for the TLS value.
///
/// See `Key::new` for information about when the destructor runs and how
/// it runs.
- #[stable(feature = "rust1", since = "1.0.0")]
pub dtor: Option<unsafe extern fn(*mut u8)>,
}
/// Constant initialization value for static TLS keys.
///
/// This value specifies no destructor by default.
-#[stable(feature = "rust1", since = "1.0.0")]
pub const INIT: StaticKey = StaticKey {
inner: INIT_INNER,
dtor: None,
/// Constant initialization value for the inner part of static TLS keys.
///
/// This value allows specific configuration of the destructor for a TLS key.
-#[stable(feature = "rust1", since = "1.0.0")]
pub const INIT_INNER: StaticKeyInner = StaticKeyInner {
key: atomic::ATOMIC_USIZE_INIT,
};
if index == slice.len() { return true; }
match slice.bytes.get(index) {
None => false,
- Some(&b) => b < 128u8 || b >= 192u8,
+ Some(&b) => b < 128 || b >= 192,
}
}
return Some(tmp);
}
- let mut buf = [0u16; 2];
+ let mut buf = [0; 2];
self.code_points.next().map(|code_point| {
let n = encode_utf16_raw(code_point.value, &mut buf)
.unwrap_or(0);
let mut writer = FileDesc::new(writer, true);
writer.write(b"test").ok().unwrap();
- let mut buf = [0u8; 4];
+ let mut buf = [0; 4];
match reader.read(&mut buf) {
Ok(4) => {
assert_eq!(buf[0], 't' as u8);
assert!(e.is::<T>());
let any = e.downcast::<T>().ok().unwrap();
assert!(any.is::<u16>());
- assert_eq!(*any.downcast::<u16>().ok().unwrap(), 413u16);
+ assert_eq!(*any.downcast::<u16>().ok().unwrap(), 413);
}
Ok(()) => panic!()
}
// Sure wish we had macro hygiene, no?
#[doc(hidden)]
-#[stable(feature = "rust1", since = "1.0.0")]
+#[unstable(feature = "thread_local_internals")]
pub mod __impl {
pub use super::imp::Key as KeyInner;
pub use super::imp::destroy_value;
/// Declare a new thread local storage key of type `std::thread_local::Key`.
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
+#[allow_internal_unstable]
macro_rules! thread_local {
(static $name:ident: $t:ty = $init:expr) => (
static $name: ::std::thread_local::Key<$t> = {
#[macro_export]
#[doc(hidden)]
+#[allow_internal_unstable]
macro_rules! __thread_local_inner {
(static $name:ident: $t:ty = $init:expr) => (
#[cfg_attr(all(any(target_os = "macos", target_os = "linux"),
use ptr;
#[doc(hidden)]
- #[stable(since = "1.0.0", feature = "rust1")]
+ #[unstable(feature = "thread_local_internals")]
pub struct Key<T> {
// Place the inner bits in an `UnsafeCell` to currently get around the
// "only Sync statics" restriction. This allows any type to be placed in
//
// Note that all access requires `T: 'static` so it can't be a type with
// any borrowed pointers still.
- #[stable(since = "1.0.0", feature = "rust1")]
+ #[unstable(feature = "thread_local_internals")]
pub inner: UnsafeCell<T>,
// Metadata to keep track of the state of the destructor. Remember that
// these variables are thread-local, not global.
- #[stable(since = "1.0.0", feature = "rust1")]
+ #[unstable(feature = "thread_local_internals")]
pub dtor_registered: UnsafeCell<bool>, // should be Cell
- #[stable(since = "1.0.0", feature = "rust1")]
+ #[unstable(feature = "thread_local_internals")]
pub dtor_running: UnsafeCell<bool>, // should be Cell
}
}
#[doc(hidden)]
- #[stable(feature = "rust1", since = "1.0.0")]
+ #[unstable(feature = "thread_local_internals")]
pub unsafe extern fn destroy_value<T>(ptr: *mut u8) {
let ptr = ptr as *mut Key<T>;
// Right before we run the user destructor be sure to flag the
use sys_common::thread_local::StaticKey as OsStaticKey;
#[doc(hidden)]
- #[stable(since = "1.0.0", feature = "rust1")]
+ #[unstable(feature = "thread_local_internals")]
pub struct Key<T> {
// Statically allocated initialization expression, using an `UnsafeCell`
// for the same reasons as above.
- #[stable(since = "1.0.0", feature = "rust1")]
+ #[unstable(feature = "thread_local_internals")]
pub inner: UnsafeCell<T>,
// OS-TLS key that we'll use to key off.
- #[stable(since = "1.0.0", feature = "rust1")]
+ #[unstable(feature = "thread_local_internals")]
pub os: OsStaticKey,
}
}
#[doc(hidden)]
- #[stable(feature = "rust1", since = "1.0.0")]
+ #[unstable(feature = "thread_local_internals")]
pub unsafe extern fn destroy_value<T: 'static>(ptr: *mut u8) {
// The OS TLS ensures that this key contains a NULL value when this
// destructor starts to run. We set it back to a sentinel value of 1 to
/// This macro declares a `static` item on which methods are used to get and
/// set the value stored within.
#[macro_export]
+#[allow_internal_unstable]
macro_rules! scoped_thread_local {
(static $name:ident: $t:ty) => (
__scoped_thread_local_inner!(static $name: $t);
#[macro_export]
#[doc(hidden)]
+#[allow_internal_unstable]
macro_rules! __scoped_thread_local_inner {
(static $name:ident: $t:ty) => (
#[cfg_attr(not(any(windows,
impl Duration {
/// Makes a new `Duration` with given number of weeks.
- /// Equivalent to `Duration::seconds(weeks * 7 * 24 * 60 * 60), with overflow checks.
+ /// Equivalent to `Duration::seconds(weeks * 7 * 24 * 60 * 60)` with overflow checks.
/// Panics when the duration is out of bounds.
#[inline]
#[unstable(feature = "std_misc")]
//! assert!(b == c);
//!
//! let d : (u32, f32) = Default::default();
-//! assert_eq!(d, (0u32, 0.0f32));
+//! assert_eq!(d, (0, 0.0f32));
//! ```
#![doc(primitive = "tuple")]
pub imported_from: Option<Ident>,
pub export: bool,
pub use_locally: bool,
+ pub allow_internal_unstable: bool,
pub body: Vec<TokenTree>,
}
pub fn int_ty_max(t: IntTy) -> u64 {
match t {
- TyI8 => 0x80u64,
- TyI16 => 0x8000u64,
- TyIs(_) | TyI32 => 0x80000000u64, // actually ni about TyIs
- TyI64 => 0x8000000000000000u64
+ TyI8 => 0x80,
+ TyI16 => 0x8000,
+ TyIs(_) | TyI32 => 0x80000000, // actually ni about TyIs
+ TyI64 => 0x8000000000000000
}
}
pub fn uint_ty_max(t: UintTy) -> u64 {
match t {
- TyU8 => 0xffu64,
- TyU16 => 0xffffu64,
- TyUs(_) | TyU32 => 0xffffffffu64, // actually ni about TyUs
- TyU64 => 0xffffffffffffffffu64
+ TyU8 => 0xff,
+ TyU16 => 0xffff,
+ TyUs(_) | TyU32 => 0xffffffff, // actually ni about TyUs
+ TyU64 => 0xffffffffffffffff
}
}
pub name: String,
/// The format with which the macro was invoked.
pub format: MacroFormat,
+ /// Whether the macro is allowed to use #[unstable]/feature-gated
+ /// features internally without forcing the whole crate to opt-in
+ /// to them.
+ pub allow_internal_unstable: bool,
/// The span of the macro definition itself. The macro may not
/// have a sensible definition span (e.g. something defined
/// completely inside libsyntax) in which case this is None.
}
}
- /// Check if a span is "internal" to a macro. This means that it is entirely generated by a
- /// macro expansion and contains no code that was passed in as an argument.
- pub fn span_is_internal(&self, span: Span) -> bool {
- // first, check if the given expression was generated by a macro or not
- // we need to go back the expn_info tree to check only the arguments
- // of the initial macro call, not the nested ones.
- let mut is_internal = false;
- let mut expnid = span.expn_id;
- while self.with_expn_info(expnid, |expninfo| {
- match expninfo {
- Some(ref info) => {
- // save the parent expn_id for next loop iteration
- expnid = info.call_site.expn_id;
- if info.callee.name == "format_args" {
- // This is a hack because the format_args builtin calls unstable APIs.
- // I spent like 6 hours trying to solve this more generally but am stupid.
- is_internal = true;
- false
- } else if info.callee.span.is_none() {
- // it's a compiler built-in, we *really* don't want to mess with it
- // so we skip it, unless it was called by a regular macro, in which case
- // we will handle the caller macro next turn
- is_internal = true;
- true // continue looping
+ /// Check if a span is "internal" to a macro in which #[unstable]
+ /// items can be used (that is, a macro marked with
+ /// `#[allow_internal_unstable]`).
+ pub fn span_allows_unstable(&self, span: Span) -> bool {
+ debug!("span_allows_unstable(span = {:?})", span);
+ let mut allows_unstable = false;
+ let mut expn_id = span.expn_id;
+ loop {
+ let quit = self.with_expn_info(expn_id, |expninfo| {
+ debug!("span_allows_unstable: expninfo = {:?}", expninfo);
+ expninfo.map_or(/* hit the top level */ true, |info| {
+
+ let span_comes_from_this_expansion =
+ info.callee.span.map_or(span == info.call_site, |mac_span| {
+ mac_span.lo <= span.lo && span.hi < mac_span.hi
+ });
+
+ debug!("span_allows_unstable: from this expansion? {}, allows unstable? {}",
+ span_comes_from_this_expansion,
+ info.callee.allow_internal_unstable);
+ if span_comes_from_this_expansion {
+ allows_unstable = info.callee.allow_internal_unstable;
+ // we've found the right place, stop looking
+ true
} else {
- // was this expression from the current macro arguments ?
- is_internal = !( span.lo > info.call_site.lo &&
- span.hi < info.call_site.hi );
- true // continue looping
+ // not the right place, keep looking
+ expn_id = info.call_site.expn_id;
+ false
}
- },
- _ => false // stop looping
+ })
+ });
+ if quit {
+ break
}
- }) { /* empty while loop body */ }
- return is_internal;
+ }
+ debug!("span_allows_unstable? {}", allows_unstable);
+ allows_unstable
}
}
})
}
+#[macro_export]
+macro_rules! fileline_help {
+ ($session:expr, $span:expr, $($message:tt)*) => ({
+ ($session).fileline_help($span, &format!($($message)*))
+ })
+}
+
#[macro_export]
macro_rules! register_diagnostics {
($($code:tt),*) => (
name: "asm".to_string(),
format: codemap::MacroBang,
span: None,
+ allow_internal_unstable: false,
},
});
/// A normal, function-like syntax extension.
///
/// `bytes!` is a `NormalTT`.
- NormalTT(Box<TTMacroExpander + 'static>, Option<Span>),
+ ///
+ /// The `bool` dictates whether the contents of the macro can
+ /// directly use `#[unstable]` things (true == yes).
+ NormalTT(Box<TTMacroExpander + 'static>, Option<Span>, bool),
/// A function-like syntax extension that has an extra ident before
/// the block.
///
- IdentTT(Box<IdentMacroExpander + 'static>, Option<Span>),
+ IdentTT(Box<IdentMacroExpander + 'static>, Option<Span>, bool),
/// Represents `macro_rules!` itself.
MacroRulesTT,
-> SyntaxEnv {
// utility function to simplify creating NormalTT syntax extensions
fn builtin_normal_expander(f: MacroExpanderFn) -> SyntaxExtension {
- NormalTT(Box::new(f), None)
+ NormalTT(Box::new(f), None, false)
}
let mut syntax_expanders = SyntaxEnv::new();
syntax_expanders.insert(intern("macro_rules"), MacroRulesTT);
syntax_expanders.insert(intern("format_args"),
- builtin_normal_expander(
- ext::format::expand_format_args));
+ // format_args uses `unstable` things internally.
+ NormalTT(Box::new(ext::format::expand_format_args), None, true));
syntax_expanders.insert(intern("env"),
builtin_normal_expander(
ext::env::expand_env));
self.print_backtrace();
self.parse_sess.span_diagnostic.span_help(sp, msg);
}
+ pub fn fileline_help(&self, sp: Span, msg: &str) {
+ self.print_backtrace();
+ self.parse_sess.span_diagnostic.fileline_help(sp, msg);
+ }
pub fn bug(&self, msg: &str) -> ! {
self.print_backtrace();
self.parse_sess.span_diagnostic.handler().bug(msg);
callee: codemap::NameAndSpan {
name: format!("derive({})", trait_name),
format: codemap::MacroAttribute,
- span: Some(self.span)
+ span: Some(self.span),
+ allow_internal_unstable: false,
}
});
to_set
use codemap;
use codemap::{Span, Spanned, ExpnInfo, NameAndSpan, MacroBang, MacroAttribute};
use ext::base::*;
-use feature_gate::{Features};
+use feature_gate::{self, Features};
use fold;
use fold::*;
use parse;
None
}
Some(rc) => match *rc {
- NormalTT(ref expandfun, exp_span) => {
+ NormalTT(ref expandfun, exp_span, allow_internal_unstable) => {
fld.cx.bt_push(ExpnInfo {
call_site: span,
callee: NameAndSpan {
name: extnamestr.to_string(),
format: MacroBang,
span: exp_span,
+ allow_internal_unstable: allow_internal_unstable,
},
});
let fm = fresh_mark();
name: mname.to_string(),
format: MacroAttribute,
span: None,
+ // attributes can do whatever they like,
+ // for now
+ allow_internal_unstable: true,
}
});
it = mac.expand(fld.cx, attr.span, &*attr.node.value, it);
fld.cx.span_warn(attr.span, "macro_escape is a deprecated synonym for macro_use");
is_use = true;
if let ast::AttrInner = attr.node.style {
- fld.cx.span_help(attr.span, "consider an outer attribute, \
+ fld.cx.fileline_help(attr.span, "consider an outer attribute, \
#[macro_use] mod ...");
}
};
}
Some(rc) => match *rc {
- NormalTT(ref expander, span) => {
+ NormalTT(ref expander, span, allow_internal_unstable) => {
if it.ident.name != parse::token::special_idents::invalid.name {
fld.cx
.span_err(path_span,
callee: NameAndSpan {
name: extnamestr.to_string(),
format: MacroBang,
- span: span
+ span: span,
+ allow_internal_unstable: allow_internal_unstable,
}
});
// mark before expansion:
let marked_before = mark_tts(&tts[..], fm);
expander.expand(fld.cx, it.span, &marked_before[..])
}
- IdentTT(ref expander, span) => {
+ IdentTT(ref expander, span, allow_internal_unstable) => {
if it.ident.name == parse::token::special_idents::invalid.name {
fld.cx.span_err(path_span,
&format!("macro {}! expects an ident argument",
callee: NameAndSpan {
name: extnamestr.to_string(),
format: MacroBang,
- span: span
+ span: span,
+ allow_internal_unstable: allow_internal_unstable,
}
});
// mark before expansion:
);
return SmallVector::zero();
}
+
fld.cx.bt_push(ExpnInfo {
call_site: it.span,
callee: NameAndSpan {
name: extnamestr.to_string(),
format: MacroBang,
span: None,
+ // `macro_rules!` doesn't directly allow
+ // unstable (this is orthogonal to whether
+ // the macro it creates allows it)
+ allow_internal_unstable: false,
}
});
// DON'T mark before expansion.
+ let allow_internal_unstable = attr::contains_name(&it.attrs,
+ "allow_internal_unstable");
+
+ // ensure any #[allow_internal_unstable]s are
+ // detected (including nested macro definitions
+ // etc.)
+ if allow_internal_unstable && !fld.cx.ecfg.enable_allow_internal_unstable() {
+ feature_gate::emit_feature_err(
+ &fld.cx.parse_sess.span_diagnostic,
+ "allow_internal_unstable",
+ it.span,
+ feature_gate::EXPLAIN_ALLOW_INTERNAL_UNSTABLE)
+ }
+
let def = ast::MacroDef {
ident: it.ident,
attrs: it.attrs.clone(),
imported_from: None,
export: attr::contains_name(&it.attrs, "macro_export"),
use_locally: true,
+ allow_internal_unstable: allow_internal_unstable,
body: tts,
};
fld.cx.insert_macro(def);
}
Some(rc) => match *rc {
- NormalTT(ref expander, tt_span) => {
+ NormalTT(ref expander, tt_span, allow_internal_unstable) => {
fld.cx.bt_push(ExpnInfo {
call_site: span,
callee: NameAndSpan {
name: extnamestr.to_string(),
format: MacroBang,
- span: tt_span
+ span: tt_span,
+ allow_internal_unstable: allow_internal_unstable,
}
});
callee: NameAndSpan {
name: mname.to_string(),
format: MacroAttribute,
- span: None
+ span: None,
+ // attributes can do whatever they like,
+ // for now.
+ allow_internal_unstable: true,
}
});
name: mname.to_string(),
format: MacroAttribute,
span: None,
+ // attributes can do whatever they like,
+ // for now
+ allow_internal_unstable: true,
}
});
it = mac.expand(fld.cx, attr.span, &*attr.node.value, it);
_ => false,
}
}
+
+ pub fn enable_allow_internal_unstable(&self) -> bool {
+ match self.features {
+ Some(&Features { allow_internal_unstable: true, .. }) => true,
+ _ => false
+ }
+ }
}
pub fn expand_crate<'feat>(parse_sess: &parse::ParseSess,
token::FatArrow => "FatArrow",
token::Pound => "Pound",
token::Dollar => "Dollar",
+ token::Question => "Question",
token::Underscore => "Underscore",
token::Eof => "Eof",
- _ => panic!(),
+ _ => panic!("unhandled token in quote!"),
};
mk_token_path(cx, sp, name)
}
rhses: rhses,
};
- NormalTT(exp, Some(def.span))
+ NormalTT(exp, Some(def.span), def.allow_internal_unstable)
}
fn check_lhs_nt_follows(cx: &mut ExtCtxt, lhs: &NamedMatch, sp: Span) {
// Allows the use of `static_assert`
("static_assert", "1.0.0", Active),
+
+ // Allows the use of #[allow_internal_unstable]. This is an
+ // attribute on macro_rules! and can't use the attribute handling
+ // below (it has to be checked before expansion possibly makes
+ // macros disappear).
+ ("allow_internal_unstable", "1.0.0", Active),
];
// (changing above list without updating src/doc/reference.md makes @cmr sad)
("recursion_limit", CrateLevel),
];
-#[derive(PartialEq, Copy)]
+#[derive(PartialEq, Copy, Debug)]
pub enum AttributeType {
/// Normal, builtin attribute that is consumed
/// by the compiler before the unused_attribute check
pub allow_log_syntax: bool,
pub allow_concat_idents: bool,
pub allow_trace_macros: bool,
+ pub allow_internal_unstable: bool,
pub old_orphan_check: bool,
pub simd_ffi: bool,
pub unmarked_api: bool,
allow_log_syntax: false,
allow_concat_idents: false,
allow_trace_macros: false,
+ allow_internal_unstable: false,
old_orphan_check: false,
simd_ffi: false,
unmarked_api: false,
features: Vec<&'static str>,
span_handler: &'a SpanHandler,
cm: &'a CodeMap,
+ do_warnings: bool,
}
impl<'a> Context<'a> {
fn gate_feature(&self, feature: &str, span: Span, explain: &str) {
- if !self.has_feature(feature) {
+ let has_feature = self.has_feature(feature);
+ debug!("gate_feature(feature = {:?}, span = {:?}); has? {}", feature, span, has_feature);
+ if !has_feature {
emit_feature_err(self.span_handler, feature, span, explain);
}
}
fn warn_feature(&self, feature: &str, span: Span, explain: &str) {
- if !self.has_feature(feature) {
+ if !self.has_feature(feature) && self.do_warnings {
emit_feature_warn(self.span_handler, feature, span, explain);
}
}
pub fn emit_feature_err(diag: &SpanHandler, feature: &str, span: Span, explain: &str) {
diag.span_err(span, explain);
- diag.span_help(span, &format!("add #![feature({})] to the \
+ diag.fileline_help(span, &format!("add #![feature({})] to the \
crate attributes to enable",
feature));
}
pub fn emit_feature_warn(diag: &SpanHandler, feature: &str, span: Span, explain: &str) {
diag.span_warn(span, explain);
if diag.handler.can_emit_warnings {
- diag.span_help(span, &format!("add #![feature({})] to the \
+ diag.fileline_help(span, &format!("add #![feature({})] to the \
crate attributes to silence this warning",
feature));
}
pub const EXPLAIN_TRACE_MACROS: &'static str =
"`trace_macros` is not stable enough for use and is subject to change";
+pub const EXPLAIN_ALLOW_INTERNAL_UNSTABLE: &'static str =
+ "allow_internal_unstable side-steps feature gating and stability checks";
struct MacroVisitor<'a> {
context: &'a Context<'a>
self.context.gate_feature("concat_idents", path.span, EXPLAIN_CONCAT_IDENTS);
}
}
+
+ fn visit_attribute(&mut self, attr: &'v ast::Attribute) {
+ if attr.name() == "allow_internal_unstable" {
+ self.context.gate_feature("allow_internal_unstable", attr.span,
+ EXPLAIN_ALLOW_INTERNAL_UNSTABLE)
+ }
+ }
}
struct PostExpansionVisitor<'a> {
impl<'a> PostExpansionVisitor<'a> {
fn gate_feature(&self, feature: &str, span: Span, explain: &str) {
- if !self.context.cm.span_is_internal(span) {
+ if !self.context.cm.span_allows_unstable(span) {
self.context.gate_feature(feature, span, explain)
}
}
}
fn visit_attribute(&mut self, attr: &ast::Attribute) {
+ debug!("visit_attribute(attr = {:?})", attr);
let name = &*attr.name();
for &(n, ty) in KNOWN_ATTRIBUTES {
if n == name {
if let Gated(gate, desc) = ty {
self.gate_feature(gate, attr.span, desc);
}
+ debug!("visit_attribute: {:?} is known, {:?}", name, ty);
return;
}
}
}
fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate,
+ do_warnings: bool,
check: F)
-> Features
where F: FnOnce(&mut Context, &ast::Crate)
let mut cx = Context {
features: Vec::new(),
span_handler: span_handler,
+ do_warnings: do_warnings,
cm: cm,
};
allow_log_syntax: cx.has_feature("log_syntax"),
allow_concat_idents: cx.has_feature("concat_idents"),
allow_trace_macros: cx.has_feature("trace_macros"),
+ allow_internal_unstable: cx.has_feature("allow_internal_unstable"),
old_orphan_check: cx.has_feature("old_orphan_check"),
simd_ffi: cx.has_feature("simd_ffi"),
unmarked_api: cx.has_feature("unmarked_api"),
pub fn check_crate_macros(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate)
-> Features {
- check_crate_inner(cm, span_handler, krate,
+ check_crate_inner(cm, span_handler, krate, true,
|ctx, krate| visit::walk_crate(&mut MacroVisitor { context: ctx }, krate))
}
-pub fn check_crate(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate)
--> Features {
- check_crate_inner(cm, span_handler, krate,
+pub fn check_crate(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate,
+ do_warnings: bool) -> Features
+{
+ check_crate_inner(cm, span_handler, krate, do_warnings,
|ctx, krate| visit::walk_crate(&mut PostExpansionVisitor { context: ctx },
krate))
}
self.span_err(span,
"an inner attribute is not permitted in \
this context");
- self.span_help(span,
+ self.fileline_help(span,
"place inner attribute at the top of the module or block");
}
ast::AttrInner
self.span_diagnostic
.span_warn(sp, "\\U00ABCD12 and \\uABCD escapes are deprecated");
self.span_diagnostic
- .span_help(sp, "use \\u{ABCD12} escapes instead");
+ .fileline_help(sp, "use \\u{ABCD12} escapes instead");
}
/// Scan for a single (possibly escaped) byte or char
&suf[1..]));
} else {
sd.span_err(sp, &*format!("illegal suffix `{}` for numeric literal", suf));
- sd.span_help(sp, "the suffix must be one of the integral types \
+ sd.fileline_help(sp, "the suffix must be one of the integral types \
(`u32`, `isize`, etc)");
}
}
pub fn span_fatal_help(&self, sp: Span, m: &str, help: &str) -> ! {
self.span_err(sp, m);
- self.span_help(sp, help);
+ self.fileline_help(sp, help);
panic!(diagnostic::FatalError);
}
pub fn span_note(&self, sp: Span, m: &str) {
pub fn span_help(&self, sp: Span, m: &str) {
self.sess.span_diagnostic.span_help(sp, m)
}
+ pub fn fileline_help(&self, sp: Span, m: &str) {
+ self.sess.span_diagnostic.fileline_help(sp, m)
+ }
pub fn bug(&self, m: &str) -> ! {
self.sess.span_diagnostic.span_bug(self.span, m)
}
Some(f) => f,
None => continue,
};
- self.span_help(last_span,
+ self.fileline_help(last_span,
&format!("try parenthesizing the first index; e.g., `(foo.{}){}`",
float.trunc() as usize,
&float.fract().to_string()[1..]));
self.span_err(op_span,
"chained comparison operators require parentheses");
if op.node == BiLt && outer_op == BiGt {
- self.span_help(op_span,
+ self.fileline_help(op_span,
"use `::<...>` instead of `<...>` if you meant to specify type arguments");
}
}
match visa {
Public => {
self.span_err(span, "can't qualify macro invocation with `pub`");
- self.span_help(span, "try adjusting the macro to put `pub` inside \
+ self.fileline_help(span, "try adjusting the macro to put `pub` inside \
the invocation");
}
Inherited => (),
if self.token.is_ident() { self.bump(); }
self.span_err(span, "expected `;`, found `as`");
- self.span_help(span,
+ self.fileline_help(span,
&format!("perhaps you meant to enclose the crate name `{}` in \
a string?",
the_ident.as_str()));
if self.eat_keyword(keywords::Mut) {
let last_span = self.last_span;
self.span_err(last_span, "const globals cannot be mutable");
- self.span_help(last_span, "did you mean to declare a static?");
+ self.fileline_help(last_span, "did you mean to declare a static?");
}
let (ident, item_, extra_attrs) = self.parse_item_const(None);
let last_span = self.last_span;
callee: NameAndSpan {
name: "test".to_string(),
format: MacroAttribute,
- span: None
+ span: None,
+ allow_internal_unstable: false,
}
});
callee: NameAndSpan {
name: "test".to_string(),
format: MacroAttribute,
- span: None
+ span: None,
+ allow_internal_unstable: true,
}
};
let expn_id = cx.sess.span_diagnostic.cm.record_expansion(info);
/// Number for a terminal color
pub type Color = u16;
- pub const BLACK: Color = 0u16;
- pub const RED: Color = 1u16;
- pub const GREEN: Color = 2u16;
- pub const YELLOW: Color = 3u16;
- pub const BLUE: Color = 4u16;
- pub const MAGENTA: Color = 5u16;
- pub const CYAN: Color = 6u16;
- pub const WHITE: Color = 7u16;
-
- pub const BRIGHT_BLACK: Color = 8u16;
- pub const BRIGHT_RED: Color = 9u16;
- pub const BRIGHT_GREEN: Color = 10u16;
- pub const BRIGHT_YELLOW: Color = 11u16;
- pub const BRIGHT_BLUE: Color = 12u16;
- pub const BRIGHT_MAGENTA: Color = 13u16;
- pub const BRIGHT_CYAN: Color = 14u16;
- pub const BRIGHT_WHITE: Color = 15u16;
+ pub const BLACK: Color = 0;
+ pub const RED: Color = 1;
+ pub const GREEN: Color = 2;
+ pub const YELLOW: Color = 3;
+ pub const BLUE: Color = 4;
+ pub const MAGENTA: Color = 5;
+ pub const CYAN: Color = 6;
+ pub const WHITE: Color = 7;
+
+ pub const BRIGHT_BLACK: Color = 8;
+ pub const BRIGHT_RED: Color = 9;
+ pub const BRIGHT_GREEN: Color = 10;
+ pub const BRIGHT_YELLOW: Color = 11;
+ pub const BRIGHT_BLUE: Color = 12;
+ pub const BRIGHT_MAGENTA: Color = 13;
+ pub const BRIGHT_CYAN: Color = 14;
+ pub const BRIGHT_WHITE: Color = 15;
}
/// Terminal attributes
// if c is 0, use 0200 (128) for ncurses compatibility
Number(c) => {
output.push(if c == 0 {
- 128u8
+ 128
} else {
c as u8
})
#[test]
fn test_comparison_ops() {
- let v = [('<', [1u8, 0u8, 0u8]), ('=', [0u8, 1u8, 0u8]), ('>', [0u8, 0u8, 1u8])];
+ let v = [('<', [1, 0, 0]), ('=', [0, 1, 0]), ('>', [0, 0, 1])];
for &(op, bs) in &v {
let s = format!("%{{1}}%{{2}}%{}%d", op);
let res = expand(s.as_bytes(), &[], &mut Variables::new());
pub fn iter<T, F>(&mut self, mut inner: F) where F: FnMut() -> T {
self.dur = Duration::span(|| {
let k = self.iterations;
- for _ in 0u64..k {
+ for _ in 0..k {
black_box(inner());
}
});
// This is a more statistics-driven benchmark algorithm
pub fn auto_bench<F>(&mut self, mut f: F) -> stats::Summary<f64> where F: FnMut(&mut Bencher) {
// Initial bench run to get ballpark figure.
- let mut n = 1_u64;
+ let mut n = 1;
self.bench_n(n, |x| f(x));
// Try to estimate iter count for 1ms falling back to 1m
'\u{2eff}'), ('\u{2fd6}', '\u{2fef}'), ('\u{2ffc}', '\u{2fff}'), ('\u{3040}', '\u{3040}'),
('\u{3097}', '\u{3098}'), ('\u{3100}', '\u{3104}'), ('\u{312e}', '\u{3130}'), ('\u{318f}',
'\u{318f}'), ('\u{31bb}', '\u{31bf}'), ('\u{31e4}', '\u{31ef}'), ('\u{321f}', '\u{321f}'),
- ('\u{32ff}', '\u{32ff}'), ('\u{3401}', '\u{4db4}'), ('\u{4db6}', '\u{4dbf}'), ('\u{4e01}',
- '\u{9fcb}'), ('\u{9fcd}', '\u{9fff}'), ('\u{a48d}', '\u{a48f}'), ('\u{a4c7}', '\u{a4cf}'),
- ('\u{a62c}', '\u{a63f}'), ('\u{a69e}', '\u{a69e}'), ('\u{a6f8}', '\u{a6ff}'), ('\u{a78f}',
- '\u{a78f}'), ('\u{a7ae}', '\u{a7af}'), ('\u{a7b2}', '\u{a7f6}'), ('\u{a82c}', '\u{a82f}'),
- ('\u{a83a}', '\u{a83f}'), ('\u{a878}', '\u{a87f}'), ('\u{a8c5}', '\u{a8cd}'), ('\u{a8da}',
- '\u{a8df}'), ('\u{a8fc}', '\u{a8ff}'), ('\u{a954}', '\u{a95e}'), ('\u{a97d}', '\u{a97f}'),
- ('\u{a9ce}', '\u{a9ce}'), ('\u{a9da}', '\u{a9dd}'), ('\u{a9ff}', '\u{a9ff}'), ('\u{aa37}',
- '\u{aa3f}'), ('\u{aa4e}', '\u{aa4f}'), ('\u{aa5a}', '\u{aa5b}'), ('\u{aac3}', '\u{aada}'),
- ('\u{aaf7}', '\u{ab00}'), ('\u{ab07}', '\u{ab08}'), ('\u{ab0f}', '\u{ab10}'), ('\u{ab17}',
- '\u{ab1f}'), ('\u{ab27}', '\u{ab27}'), ('\u{ab2f}', '\u{ab2f}'), ('\u{ab60}', '\u{ab63}'),
- ('\u{ab66}', '\u{abbf}'), ('\u{abee}', '\u{abef}'), ('\u{abfa}', '\u{abff}'), ('\u{ac01}',
- '\u{d7a2}'), ('\u{d7a4}', '\u{d7af}'), ('\u{d7c7}', '\u{d7ca}'), ('\u{d7fc}', '\u{d7ff}'),
- ('\u{e000}', '\u{f8ff}'), ('\u{fa6e}', '\u{fa6f}'), ('\u{fada}', '\u{faff}'), ('\u{fb07}',
- '\u{fb12}'), ('\u{fb18}', '\u{fb1c}'), ('\u{fb37}', '\u{fb37}'), ('\u{fb3d}', '\u{fb3d}'),
- ('\u{fb3f}', '\u{fb3f}'), ('\u{fb42}', '\u{fb42}'), ('\u{fb45}', '\u{fb45}'), ('\u{fbc2}',
- '\u{fbd2}'), ('\u{fd40}', '\u{fd4f}'), ('\u{fd90}', '\u{fd91}'), ('\u{fdc8}', '\u{fdef}'),
- ('\u{fdfe}', '\u{fdff}'), ('\u{fe1a}', '\u{fe1f}'), ('\u{fe2e}', '\u{fe2f}'), ('\u{fe53}',
- '\u{fe53}'), ('\u{fe67}', '\u{fe67}'), ('\u{fe6c}', '\u{fe6f}'), ('\u{fe75}', '\u{fe75}'),
- ('\u{fefd}', '\u{ff00}'), ('\u{ffbf}', '\u{ffc1}'), ('\u{ffc8}', '\u{ffc9}'), ('\u{ffd0}',
- '\u{ffd1}'), ('\u{ffd8}', '\u{ffd9}'), ('\u{ffdd}', '\u{ffdf}'), ('\u{ffe7}', '\u{ffe7}'),
- ('\u{ffef}', '\u{fffb}'), ('\u{fffe}', '\u{ffff}'), ('\u{1000c}', '\u{1000c}'),
+ ('\u{32ff}', '\u{32ff}'), ('\u{4db6}', '\u{4dbf}'), ('\u{9fcd}', '\u{9fff}'), ('\u{a48d}',
+ '\u{a48f}'), ('\u{a4c7}', '\u{a4cf}'), ('\u{a62c}', '\u{a63f}'), ('\u{a69e}', '\u{a69e}'),
+ ('\u{a6f8}', '\u{a6ff}'), ('\u{a78f}', '\u{a78f}'), ('\u{a7ae}', '\u{a7af}'), ('\u{a7b2}',
+ '\u{a7f6}'), ('\u{a82c}', '\u{a82f}'), ('\u{a83a}', '\u{a83f}'), ('\u{a878}', '\u{a87f}'),
+ ('\u{a8c5}', '\u{a8cd}'), ('\u{a8da}', '\u{a8df}'), ('\u{a8fc}', '\u{a8ff}'), ('\u{a954}',
+ '\u{a95e}'), ('\u{a97d}', '\u{a97f}'), ('\u{a9ce}', '\u{a9ce}'), ('\u{a9da}', '\u{a9dd}'),
+ ('\u{a9ff}', '\u{a9ff}'), ('\u{aa37}', '\u{aa3f}'), ('\u{aa4e}', '\u{aa4f}'), ('\u{aa5a}',
+ '\u{aa5b}'), ('\u{aac3}', '\u{aada}'), ('\u{aaf7}', '\u{ab00}'), ('\u{ab07}', '\u{ab08}'),
+ ('\u{ab0f}', '\u{ab10}'), ('\u{ab17}', '\u{ab1f}'), ('\u{ab27}', '\u{ab27}'), ('\u{ab2f}',
+ '\u{ab2f}'), ('\u{ab60}', '\u{ab63}'), ('\u{ab66}', '\u{abbf}'), ('\u{abee}', '\u{abef}'),
+ ('\u{abfa}', '\u{abff}'), ('\u{d7a4}', '\u{d7af}'), ('\u{d7c7}', '\u{d7ca}'), ('\u{d7fc}',
+ '\u{d7ff}'), ('\u{e000}', '\u{f8ff}'), ('\u{fa6e}', '\u{fa6f}'), ('\u{fada}', '\u{faff}'),
+ ('\u{fb07}', '\u{fb12}'), ('\u{fb18}', '\u{fb1c}'), ('\u{fb37}', '\u{fb37}'), ('\u{fb3d}',
+ '\u{fb3d}'), ('\u{fb3f}', '\u{fb3f}'), ('\u{fb42}', '\u{fb42}'), ('\u{fb45}', '\u{fb45}'),
+ ('\u{fbc2}', '\u{fbd2}'), ('\u{fd40}', '\u{fd4f}'), ('\u{fd90}', '\u{fd91}'), ('\u{fdc8}',
+ '\u{fdef}'), ('\u{fdfe}', '\u{fdff}'), ('\u{fe1a}', '\u{fe1f}'), ('\u{fe2e}', '\u{fe2f}'),
+ ('\u{fe53}', '\u{fe53}'), ('\u{fe67}', '\u{fe67}'), ('\u{fe6c}', '\u{fe6f}'), ('\u{fe75}',
+ '\u{fe75}'), ('\u{fefd}', '\u{ff00}'), ('\u{ffbf}', '\u{ffc1}'), ('\u{ffc8}', '\u{ffc9}'),
+ ('\u{ffd0}', '\u{ffd1}'), ('\u{ffd8}', '\u{ffd9}'), ('\u{ffdd}', '\u{ffdf}'), ('\u{ffe7}',
+ '\u{ffe7}'), ('\u{ffef}', '\u{fffb}'), ('\u{fffe}', '\u{ffff}'), ('\u{1000c}', '\u{1000c}'),
('\u{10027}', '\u{10027}'), ('\u{1003b}', '\u{1003b}'), ('\u{1003e}', '\u{1003e}'),
('\u{1004e}', '\u{1004f}'), ('\u{1005e}', '\u{1007f}'), ('\u{100fb}', '\u{100ff}'),
('\u{10103}', '\u{10106}'), ('\u{10134}', '\u{10136}'), ('\u{1018d}', '\u{1018f}'),
('\u{1f643}', '\u{1f644}'), ('\u{1f6d0}', '\u{1f6df}'), ('\u{1f6ed}', '\u{1f6ef}'),
('\u{1f6f4}', '\u{1f6ff}'), ('\u{1f774}', '\u{1f77f}'), ('\u{1f7d5}', '\u{1f7ff}'),
('\u{1f80c}', '\u{1f80f}'), ('\u{1f848}', '\u{1f84f}'), ('\u{1f85a}', '\u{1f85f}'),
- ('\u{1f888}', '\u{1f88f}'), ('\u{1f8ae}', '\u{1ffff}'), ('\u{20001}', '\u{2a6d5}'),
- ('\u{2a6d7}', '\u{2a6ff}'), ('\u{2a701}', '\u{2b733}'), ('\u{2b735}', '\u{2b73f}'),
- ('\u{2b741}', '\u{2b81c}'), ('\u{2b81e}', '\u{2f7ff}'), ('\u{2fa1e}', '\u{e00ff}'),
+ ('\u{1f888}', '\u{1f88f}'), ('\u{1f8ae}', '\u{1ffff}'), ('\u{2a6d7}', '\u{2a6ff}'),
+ ('\u{2b735}', '\u{2b73f}'), ('\u{2b81e}', '\u{2f7ff}'), ('\u{2fa1e}', '\u{e00ff}'),
('\u{e01f0}', '\u{10ffff}')
];
('\u{2e9a}', '\u{2e9a}'), ('\u{2ef4}', '\u{2eff}'), ('\u{2fd6}', '\u{2fef}'), ('\u{2ffc}',
'\u{2fff}'), ('\u{3040}', '\u{3040}'), ('\u{3097}', '\u{3098}'), ('\u{3100}', '\u{3104}'),
('\u{312e}', '\u{3130}'), ('\u{318f}', '\u{318f}'), ('\u{31bb}', '\u{31bf}'), ('\u{31e4}',
- '\u{31ef}'), ('\u{321f}', '\u{321f}'), ('\u{32ff}', '\u{32ff}'), ('\u{3401}', '\u{4db4}'),
- ('\u{4db6}', '\u{4dbf}'), ('\u{4e01}', '\u{9fcb}'), ('\u{9fcd}', '\u{9fff}'), ('\u{a48d}',
- '\u{a48f}'), ('\u{a4c7}', '\u{a4cf}'), ('\u{a62c}', '\u{a63f}'), ('\u{a69e}', '\u{a69e}'),
- ('\u{a6f8}', '\u{a6ff}'), ('\u{a78f}', '\u{a78f}'), ('\u{a7ae}', '\u{a7af}'), ('\u{a7b2}',
- '\u{a7f6}'), ('\u{a82c}', '\u{a82f}'), ('\u{a83a}', '\u{a83f}'), ('\u{a878}', '\u{a87f}'),
- ('\u{a8c5}', '\u{a8cd}'), ('\u{a8da}', '\u{a8df}'), ('\u{a8fc}', '\u{a8ff}'), ('\u{a954}',
- '\u{a95e}'), ('\u{a97d}', '\u{a97f}'), ('\u{a9ce}', '\u{a9ce}'), ('\u{a9da}', '\u{a9dd}'),
- ('\u{a9ff}', '\u{a9ff}'), ('\u{aa37}', '\u{aa3f}'), ('\u{aa4e}', '\u{aa4f}'), ('\u{aa5a}',
- '\u{aa5b}'), ('\u{aac3}', '\u{aada}'), ('\u{aaf7}', '\u{ab00}'), ('\u{ab07}', '\u{ab08}'),
- ('\u{ab0f}', '\u{ab10}'), ('\u{ab17}', '\u{ab1f}'), ('\u{ab27}', '\u{ab27}'), ('\u{ab2f}',
- '\u{ab2f}'), ('\u{ab60}', '\u{ab63}'), ('\u{ab66}', '\u{abbf}'), ('\u{abee}', '\u{abef}'),
- ('\u{abfa}', '\u{abff}'), ('\u{ac01}', '\u{d7a2}'), ('\u{d7a4}', '\u{d7af}'), ('\u{d7c7}',
- '\u{d7ca}'), ('\u{d7fc}', '\u{d7ff}'), ('\u{e001}', '\u{f8fe}'), ('\u{fa6e}', '\u{fa6f}'),
- ('\u{fada}', '\u{faff}'), ('\u{fb07}', '\u{fb12}'), ('\u{fb18}', '\u{fb1c}'), ('\u{fb37}',
- '\u{fb37}'), ('\u{fb3d}', '\u{fb3d}'), ('\u{fb3f}', '\u{fb3f}'), ('\u{fb42}', '\u{fb42}'),
- ('\u{fb45}', '\u{fb45}'), ('\u{fbc2}', '\u{fbd2}'), ('\u{fd40}', '\u{fd4f}'), ('\u{fd90}',
- '\u{fd91}'), ('\u{fdc8}', '\u{fdef}'), ('\u{fdfe}', '\u{fdff}'), ('\u{fe1a}', '\u{fe1f}'),
- ('\u{fe2e}', '\u{fe2f}'), ('\u{fe53}', '\u{fe53}'), ('\u{fe67}', '\u{fe67}'), ('\u{fe6c}',
- '\u{fe6f}'), ('\u{fe75}', '\u{fe75}'), ('\u{fefd}', '\u{fefe}'), ('\u{ff00}', '\u{ff00}'),
- ('\u{ffbf}', '\u{ffc1}'), ('\u{ffc8}', '\u{ffc9}'), ('\u{ffd0}', '\u{ffd1}'), ('\u{ffd8}',
- '\u{ffd9}'), ('\u{ffdd}', '\u{ffdf}'), ('\u{ffe7}', '\u{ffe7}'), ('\u{ffef}', '\u{fff8}'),
- ('\u{fffe}', '\u{ffff}'), ('\u{1000c}', '\u{1000c}'), ('\u{10027}', '\u{10027}'),
- ('\u{1003b}', '\u{1003b}'), ('\u{1003e}', '\u{1003e}'), ('\u{1004e}', '\u{1004f}'),
- ('\u{1005e}', '\u{1007f}'), ('\u{100fb}', '\u{100ff}'), ('\u{10103}', '\u{10106}'),
- ('\u{10134}', '\u{10136}'), ('\u{1018d}', '\u{1018f}'), ('\u{1019c}', '\u{1019f}'),
- ('\u{101a1}', '\u{101cf}'), ('\u{101fe}', '\u{1027f}'), ('\u{1029d}', '\u{1029f}'),
- ('\u{102d1}', '\u{102df}'), ('\u{102fc}', '\u{102ff}'), ('\u{10324}', '\u{1032f}'),
- ('\u{1034b}', '\u{1034f}'), ('\u{1037b}', '\u{1037f}'), ('\u{1039e}', '\u{1039e}'),
- ('\u{103c4}', '\u{103c7}'), ('\u{103d6}', '\u{103ff}'), ('\u{1049e}', '\u{1049f}'),
- ('\u{104aa}', '\u{104ff}'), ('\u{10528}', '\u{1052f}'), ('\u{10564}', '\u{1056e}'),
- ('\u{10570}', '\u{105ff}'), ('\u{10737}', '\u{1073f}'), ('\u{10756}', '\u{1075f}'),
- ('\u{10768}', '\u{107ff}'), ('\u{10806}', '\u{10807}'), ('\u{10809}', '\u{10809}'),
- ('\u{10836}', '\u{10836}'), ('\u{10839}', '\u{1083b}'), ('\u{1083d}', '\u{1083e}'),
- ('\u{10856}', '\u{10856}'), ('\u{1089f}', '\u{108a6}'), ('\u{108b0}', '\u{108ff}'),
- ('\u{1091c}', '\u{1091e}'), ('\u{1093a}', '\u{1093e}'), ('\u{10940}', '\u{1097f}'),
- ('\u{109b8}', '\u{109bd}'), ('\u{109c0}', '\u{109ff}'), ('\u{10a04}', '\u{10a04}'),
- ('\u{10a07}', '\u{10a0b}'), ('\u{10a14}', '\u{10a14}'), ('\u{10a18}', '\u{10a18}'),
- ('\u{10a34}', '\u{10a37}'), ('\u{10a3b}', '\u{10a3e}'), ('\u{10a48}', '\u{10a4f}'),
- ('\u{10a59}', '\u{10a5f}'), ('\u{10aa0}', '\u{10abf}'), ('\u{10ae7}', '\u{10aea}'),
- ('\u{10af7}', '\u{10aff}'), ('\u{10b36}', '\u{10b38}'), ('\u{10b56}', '\u{10b57}'),
- ('\u{10b73}', '\u{10b77}'), ('\u{10b92}', '\u{10b98}'), ('\u{10b9d}', '\u{10ba8}'),
- ('\u{10bb0}', '\u{10bff}'), ('\u{10c49}', '\u{10e5f}'), ('\u{10e7f}', '\u{10fff}'),
- ('\u{1104e}', '\u{11051}'), ('\u{11070}', '\u{1107e}'), ('\u{110c2}', '\u{110cf}'),
- ('\u{110e9}', '\u{110ef}'), ('\u{110fa}', '\u{110ff}'), ('\u{11135}', '\u{11135}'),
- ('\u{11144}', '\u{1114f}'), ('\u{11177}', '\u{1117f}'), ('\u{111c9}', '\u{111cc}'),
- ('\u{111ce}', '\u{111cf}'), ('\u{111db}', '\u{111e0}'), ('\u{111f5}', '\u{111ff}'),
- ('\u{11212}', '\u{11212}'), ('\u{1123e}', '\u{112af}'), ('\u{112eb}', '\u{112ef}'),
- ('\u{112fa}', '\u{11300}'), ('\u{11304}', '\u{11304}'), ('\u{1130d}', '\u{1130e}'),
- ('\u{11311}', '\u{11312}'), ('\u{11329}', '\u{11329}'), ('\u{11331}', '\u{11331}'),
- ('\u{11334}', '\u{11334}'), ('\u{1133a}', '\u{1133b}'), ('\u{11345}', '\u{11346}'),
- ('\u{11349}', '\u{1134a}'), ('\u{1134e}', '\u{11356}'), ('\u{11358}', '\u{1135c}'),
- ('\u{11364}', '\u{11365}'), ('\u{1136d}', '\u{1136f}'), ('\u{11375}', '\u{1147f}'),
- ('\u{114c8}', '\u{114cf}'), ('\u{114da}', '\u{1157f}'), ('\u{115b6}', '\u{115b7}'),
- ('\u{115ca}', '\u{115ff}'), ('\u{11645}', '\u{1164f}'), ('\u{1165a}', '\u{1167f}'),
- ('\u{116b8}', '\u{116bf}'), ('\u{116ca}', '\u{1189f}'), ('\u{118f3}', '\u{118fe}'),
- ('\u{11900}', '\u{11abf}'), ('\u{11af9}', '\u{11fff}'), ('\u{12399}', '\u{123ff}'),
- ('\u{1246f}', '\u{1246f}'), ('\u{12475}', '\u{12fff}'), ('\u{1342f}', '\u{167ff}'),
- ('\u{16a39}', '\u{16a3f}'), ('\u{16a5f}', '\u{16a5f}'), ('\u{16a6a}', '\u{16a6d}'),
- ('\u{16a70}', '\u{16acf}'), ('\u{16aee}', '\u{16aef}'), ('\u{16af6}', '\u{16aff}'),
- ('\u{16b46}', '\u{16b4f}'), ('\u{16b5a}', '\u{16b5a}'), ('\u{16b62}', '\u{16b62}'),
- ('\u{16b78}', '\u{16b7c}'), ('\u{16b90}', '\u{16eff}'), ('\u{16f45}', '\u{16f4f}'),
- ('\u{16f7f}', '\u{16f8e}'), ('\u{16fa0}', '\u{1afff}'), ('\u{1b002}', '\u{1bbff}'),
- ('\u{1bc6b}', '\u{1bc6f}'), ('\u{1bc7d}', '\u{1bc7f}'), ('\u{1bc89}', '\u{1bc8f}'),
- ('\u{1bc9a}', '\u{1bc9b}'), ('\u{1bca4}', '\u{1cfff}'), ('\u{1d0f6}', '\u{1d0ff}'),
- ('\u{1d127}', '\u{1d128}'), ('\u{1d1de}', '\u{1d1ff}'), ('\u{1d246}', '\u{1d2ff}'),
- ('\u{1d357}', '\u{1d35f}'), ('\u{1d372}', '\u{1d3ff}'), ('\u{1d455}', '\u{1d455}'),
- ('\u{1d49d}', '\u{1d49d}'), ('\u{1d4a0}', '\u{1d4a1}'), ('\u{1d4a3}', '\u{1d4a4}'),
- ('\u{1d4a7}', '\u{1d4a8}'), ('\u{1d4ad}', '\u{1d4ad}'), ('\u{1d4ba}', '\u{1d4ba}'),
- ('\u{1d4bc}', '\u{1d4bc}'), ('\u{1d4c4}', '\u{1d4c4}'), ('\u{1d506}', '\u{1d506}'),
- ('\u{1d50b}', '\u{1d50c}'), ('\u{1d515}', '\u{1d515}'), ('\u{1d51d}', '\u{1d51d}'),
- ('\u{1d53a}', '\u{1d53a}'), ('\u{1d53f}', '\u{1d53f}'), ('\u{1d545}', '\u{1d545}'),
- ('\u{1d547}', '\u{1d549}'), ('\u{1d551}', '\u{1d551}'), ('\u{1d6a6}', '\u{1d6a7}'),
- ('\u{1d7cc}', '\u{1d7cd}'), ('\u{1d800}', '\u{1e7ff}'), ('\u{1e8c5}', '\u{1e8c6}'),
- ('\u{1e8d7}', '\u{1edff}'), ('\u{1ee04}', '\u{1ee04}'), ('\u{1ee20}', '\u{1ee20}'),
- ('\u{1ee23}', '\u{1ee23}'), ('\u{1ee25}', '\u{1ee26}'), ('\u{1ee28}', '\u{1ee28}'),
- ('\u{1ee33}', '\u{1ee33}'), ('\u{1ee38}', '\u{1ee38}'), ('\u{1ee3a}', '\u{1ee3a}'),
- ('\u{1ee3c}', '\u{1ee41}'), ('\u{1ee43}', '\u{1ee46}'), ('\u{1ee48}', '\u{1ee48}'),
- ('\u{1ee4a}', '\u{1ee4a}'), ('\u{1ee4c}', '\u{1ee4c}'), ('\u{1ee50}', '\u{1ee50}'),
- ('\u{1ee53}', '\u{1ee53}'), ('\u{1ee55}', '\u{1ee56}'), ('\u{1ee58}', '\u{1ee58}'),
- ('\u{1ee5a}', '\u{1ee5a}'), ('\u{1ee5c}', '\u{1ee5c}'), ('\u{1ee5e}', '\u{1ee5e}'),
- ('\u{1ee60}', '\u{1ee60}'), ('\u{1ee63}', '\u{1ee63}'), ('\u{1ee65}', '\u{1ee66}'),
- ('\u{1ee6b}', '\u{1ee6b}'), ('\u{1ee73}', '\u{1ee73}'), ('\u{1ee78}', '\u{1ee78}'),
- ('\u{1ee7d}', '\u{1ee7d}'), ('\u{1ee7f}', '\u{1ee7f}'), ('\u{1ee8a}', '\u{1ee8a}'),
- ('\u{1ee9c}', '\u{1eea0}'), ('\u{1eea4}', '\u{1eea4}'), ('\u{1eeaa}', '\u{1eeaa}'),
- ('\u{1eebc}', '\u{1eeef}'), ('\u{1eef2}', '\u{1efff}'), ('\u{1f02c}', '\u{1f02f}'),
- ('\u{1f094}', '\u{1f09f}'), ('\u{1f0af}', '\u{1f0b0}'), ('\u{1f0c0}', '\u{1f0c0}'),
- ('\u{1f0d0}', '\u{1f0d0}'), ('\u{1f0f6}', '\u{1f0ff}'), ('\u{1f10d}', '\u{1f10f}'),
- ('\u{1f12f}', '\u{1f12f}'), ('\u{1f16c}', '\u{1f16f}'), ('\u{1f19b}', '\u{1f1e5}'),
- ('\u{1f203}', '\u{1f20f}'), ('\u{1f23b}', '\u{1f23f}'), ('\u{1f249}', '\u{1f24f}'),
- ('\u{1f252}', '\u{1f2ff}'), ('\u{1f32d}', '\u{1f32f}'), ('\u{1f37e}', '\u{1f37f}'),
- ('\u{1f3cf}', '\u{1f3d3}'), ('\u{1f3f8}', '\u{1f3ff}'), ('\u{1f4ff}', '\u{1f4ff}'),
- ('\u{1f54b}', '\u{1f54f}'), ('\u{1f57a}', '\u{1f57a}'), ('\u{1f5a4}', '\u{1f5a4}'),
- ('\u{1f643}', '\u{1f644}'), ('\u{1f6d0}', '\u{1f6df}'), ('\u{1f6ed}', '\u{1f6ef}'),
- ('\u{1f6f4}', '\u{1f6ff}'), ('\u{1f774}', '\u{1f77f}'), ('\u{1f7d5}', '\u{1f7ff}'),
- ('\u{1f80c}', '\u{1f80f}'), ('\u{1f848}', '\u{1f84f}'), ('\u{1f85a}', '\u{1f85f}'),
- ('\u{1f888}', '\u{1f88f}'), ('\u{1f8ae}', '\u{1ffff}'), ('\u{20001}', '\u{2a6d5}'),
- ('\u{2a6d7}', '\u{2a6ff}'), ('\u{2a701}', '\u{2b733}'), ('\u{2b735}', '\u{2b73f}'),
- ('\u{2b741}', '\u{2b81c}'), ('\u{2b81e}', '\u{2f7ff}'), ('\u{2fa1e}', '\u{e0000}'),
- ('\u{e0002}', '\u{e001f}'), ('\u{e0080}', '\u{e00ff}'), ('\u{e01f0}', '\u{effff}'),
- ('\u{f0001}', '\u{ffffc}'), ('\u{ffffe}', '\u{fffff}'), ('\u{100001}', '\u{10fffc}'),
- ('\u{10fffe}', '\u{10ffff}')
+ '\u{31ef}'), ('\u{321f}', '\u{321f}'), ('\u{32ff}', '\u{32ff}'), ('\u{4db6}', '\u{4dbf}'),
+ ('\u{9fcd}', '\u{9fff}'), ('\u{a48d}', '\u{a48f}'), ('\u{a4c7}', '\u{a4cf}'), ('\u{a62c}',
+ '\u{a63f}'), ('\u{a69e}', '\u{a69e}'), ('\u{a6f8}', '\u{a6ff}'), ('\u{a78f}', '\u{a78f}'),
+ ('\u{a7ae}', '\u{a7af}'), ('\u{a7b2}', '\u{a7f6}'), ('\u{a82c}', '\u{a82f}'), ('\u{a83a}',
+ '\u{a83f}'), ('\u{a878}', '\u{a87f}'), ('\u{a8c5}', '\u{a8cd}'), ('\u{a8da}', '\u{a8df}'),
+ ('\u{a8fc}', '\u{a8ff}'), ('\u{a954}', '\u{a95e}'), ('\u{a97d}', '\u{a97f}'), ('\u{a9ce}',
+ '\u{a9ce}'), ('\u{a9da}', '\u{a9dd}'), ('\u{a9ff}', '\u{a9ff}'), ('\u{aa37}', '\u{aa3f}'),
+ ('\u{aa4e}', '\u{aa4f}'), ('\u{aa5a}', '\u{aa5b}'), ('\u{aac3}', '\u{aada}'), ('\u{aaf7}',
+ '\u{ab00}'), ('\u{ab07}', '\u{ab08}'), ('\u{ab0f}', '\u{ab10}'), ('\u{ab17}', '\u{ab1f}'),
+ ('\u{ab27}', '\u{ab27}'), ('\u{ab2f}', '\u{ab2f}'), ('\u{ab60}', '\u{ab63}'), ('\u{ab66}',
+ '\u{abbf}'), ('\u{abee}', '\u{abef}'), ('\u{abfa}', '\u{abff}'), ('\u{d7a4}', '\u{d7af}'),
+ ('\u{d7c7}', '\u{d7ca}'), ('\u{d7fc}', '\u{d7ff}'), ('\u{fa6e}', '\u{fa6f}'), ('\u{fada}',
+ '\u{faff}'), ('\u{fb07}', '\u{fb12}'), ('\u{fb18}', '\u{fb1c}'), ('\u{fb37}', '\u{fb37}'),
+ ('\u{fb3d}', '\u{fb3d}'), ('\u{fb3f}', '\u{fb3f}'), ('\u{fb42}', '\u{fb42}'), ('\u{fb45}',
+ '\u{fb45}'), ('\u{fbc2}', '\u{fbd2}'), ('\u{fd40}', '\u{fd4f}'), ('\u{fd90}', '\u{fd91}'),
+ ('\u{fdc8}', '\u{fdef}'), ('\u{fdfe}', '\u{fdff}'), ('\u{fe1a}', '\u{fe1f}'), ('\u{fe2e}',
+ '\u{fe2f}'), ('\u{fe53}', '\u{fe53}'), ('\u{fe67}', '\u{fe67}'), ('\u{fe6c}', '\u{fe6f}'),
+ ('\u{fe75}', '\u{fe75}'), ('\u{fefd}', '\u{fefe}'), ('\u{ff00}', '\u{ff00}'), ('\u{ffbf}',
+ '\u{ffc1}'), ('\u{ffc8}', '\u{ffc9}'), ('\u{ffd0}', '\u{ffd1}'), ('\u{ffd8}', '\u{ffd9}'),
+ ('\u{ffdd}', '\u{ffdf}'), ('\u{ffe7}', '\u{ffe7}'), ('\u{ffef}', '\u{fff8}'), ('\u{fffe}',
+ '\u{ffff}'), ('\u{1000c}', '\u{1000c}'), ('\u{10027}', '\u{10027}'), ('\u{1003b}',
+ '\u{1003b}'), ('\u{1003e}', '\u{1003e}'), ('\u{1004e}', '\u{1004f}'), ('\u{1005e}',
+ '\u{1007f}'), ('\u{100fb}', '\u{100ff}'), ('\u{10103}', '\u{10106}'), ('\u{10134}',
+ '\u{10136}'), ('\u{1018d}', '\u{1018f}'), ('\u{1019c}', '\u{1019f}'), ('\u{101a1}',
+ '\u{101cf}'), ('\u{101fe}', '\u{1027f}'), ('\u{1029d}', '\u{1029f}'), ('\u{102d1}',
+ '\u{102df}'), ('\u{102fc}', '\u{102ff}'), ('\u{10324}', '\u{1032f}'), ('\u{1034b}',
+ '\u{1034f}'), ('\u{1037b}', '\u{1037f}'), ('\u{1039e}', '\u{1039e}'), ('\u{103c4}',
+ '\u{103c7}'), ('\u{103d6}', '\u{103ff}'), ('\u{1049e}', '\u{1049f}'), ('\u{104aa}',
+ '\u{104ff}'), ('\u{10528}', '\u{1052f}'), ('\u{10564}', '\u{1056e}'), ('\u{10570}',
+ '\u{105ff}'), ('\u{10737}', '\u{1073f}'), ('\u{10756}', '\u{1075f}'), ('\u{10768}',
+ '\u{107ff}'), ('\u{10806}', '\u{10807}'), ('\u{10809}', '\u{10809}'), ('\u{10836}',
+ '\u{10836}'), ('\u{10839}', '\u{1083b}'), ('\u{1083d}', '\u{1083e}'), ('\u{10856}',
+ '\u{10856}'), ('\u{1089f}', '\u{108a6}'), ('\u{108b0}', '\u{108ff}'), ('\u{1091c}',
+ '\u{1091e}'), ('\u{1093a}', '\u{1093e}'), ('\u{10940}', '\u{1097f}'), ('\u{109b8}',
+ '\u{109bd}'), ('\u{109c0}', '\u{109ff}'), ('\u{10a04}', '\u{10a04}'), ('\u{10a07}',
+ '\u{10a0b}'), ('\u{10a14}', '\u{10a14}'), ('\u{10a18}', '\u{10a18}'), ('\u{10a34}',
+ '\u{10a37}'), ('\u{10a3b}', '\u{10a3e}'), ('\u{10a48}', '\u{10a4f}'), ('\u{10a59}',
+ '\u{10a5f}'), ('\u{10aa0}', '\u{10abf}'), ('\u{10ae7}', '\u{10aea}'), ('\u{10af7}',
+ '\u{10aff}'), ('\u{10b36}', '\u{10b38}'), ('\u{10b56}', '\u{10b57}'), ('\u{10b73}',
+ '\u{10b77}'), ('\u{10b92}', '\u{10b98}'), ('\u{10b9d}', '\u{10ba8}'), ('\u{10bb0}',
+ '\u{10bff}'), ('\u{10c49}', '\u{10e5f}'), ('\u{10e7f}', '\u{10fff}'), ('\u{1104e}',
+ '\u{11051}'), ('\u{11070}', '\u{1107e}'), ('\u{110c2}', '\u{110cf}'), ('\u{110e9}',
+ '\u{110ef}'), ('\u{110fa}', '\u{110ff}'), ('\u{11135}', '\u{11135}'), ('\u{11144}',
+ '\u{1114f}'), ('\u{11177}', '\u{1117f}'), ('\u{111c9}', '\u{111cc}'), ('\u{111ce}',
+ '\u{111cf}'), ('\u{111db}', '\u{111e0}'), ('\u{111f5}', '\u{111ff}'), ('\u{11212}',
+ '\u{11212}'), ('\u{1123e}', '\u{112af}'), ('\u{112eb}', '\u{112ef}'), ('\u{112fa}',
+ '\u{11300}'), ('\u{11304}', '\u{11304}'), ('\u{1130d}', '\u{1130e}'), ('\u{11311}',
+ '\u{11312}'), ('\u{11329}', '\u{11329}'), ('\u{11331}', '\u{11331}'), ('\u{11334}',
+ '\u{11334}'), ('\u{1133a}', '\u{1133b}'), ('\u{11345}', '\u{11346}'), ('\u{11349}',
+ '\u{1134a}'), ('\u{1134e}', '\u{11356}'), ('\u{11358}', '\u{1135c}'), ('\u{11364}',
+ '\u{11365}'), ('\u{1136d}', '\u{1136f}'), ('\u{11375}', '\u{1147f}'), ('\u{114c8}',
+ '\u{114cf}'), ('\u{114da}', '\u{1157f}'), ('\u{115b6}', '\u{115b7}'), ('\u{115ca}',
+ '\u{115ff}'), ('\u{11645}', '\u{1164f}'), ('\u{1165a}', '\u{1167f}'), ('\u{116b8}',
+ '\u{116bf}'), ('\u{116ca}', '\u{1189f}'), ('\u{118f3}', '\u{118fe}'), ('\u{11900}',
+ '\u{11abf}'), ('\u{11af9}', '\u{11fff}'), ('\u{12399}', '\u{123ff}'), ('\u{1246f}',
+ '\u{1246f}'), ('\u{12475}', '\u{12fff}'), ('\u{1342f}', '\u{167ff}'), ('\u{16a39}',
+ '\u{16a3f}'), ('\u{16a5f}', '\u{16a5f}'), ('\u{16a6a}', '\u{16a6d}'), ('\u{16a70}',
+ '\u{16acf}'), ('\u{16aee}', '\u{16aef}'), ('\u{16af6}', '\u{16aff}'), ('\u{16b46}',
+ '\u{16b4f}'), ('\u{16b5a}', '\u{16b5a}'), ('\u{16b62}', '\u{16b62}'), ('\u{16b78}',
+ '\u{16b7c}'), ('\u{16b90}', '\u{16eff}'), ('\u{16f45}', '\u{16f4f}'), ('\u{16f7f}',
+ '\u{16f8e}'), ('\u{16fa0}', '\u{1afff}'), ('\u{1b002}', '\u{1bbff}'), ('\u{1bc6b}',
+ '\u{1bc6f}'), ('\u{1bc7d}', '\u{1bc7f}'), ('\u{1bc89}', '\u{1bc8f}'), ('\u{1bc9a}',
+ '\u{1bc9b}'), ('\u{1bca4}', '\u{1cfff}'), ('\u{1d0f6}', '\u{1d0ff}'), ('\u{1d127}',
+ '\u{1d128}'), ('\u{1d1de}', '\u{1d1ff}'), ('\u{1d246}', '\u{1d2ff}'), ('\u{1d357}',
+ '\u{1d35f}'), ('\u{1d372}', '\u{1d3ff}'), ('\u{1d455}', '\u{1d455}'), ('\u{1d49d}',
+ '\u{1d49d}'), ('\u{1d4a0}', '\u{1d4a1}'), ('\u{1d4a3}', '\u{1d4a4}'), ('\u{1d4a7}',
+ '\u{1d4a8}'), ('\u{1d4ad}', '\u{1d4ad}'), ('\u{1d4ba}', '\u{1d4ba}'), ('\u{1d4bc}',
+ '\u{1d4bc}'), ('\u{1d4c4}', '\u{1d4c4}'), ('\u{1d506}', '\u{1d506}'), ('\u{1d50b}',
+ '\u{1d50c}'), ('\u{1d515}', '\u{1d515}'), ('\u{1d51d}', '\u{1d51d}'), ('\u{1d53a}',
+ '\u{1d53a}'), ('\u{1d53f}', '\u{1d53f}'), ('\u{1d545}', '\u{1d545}'), ('\u{1d547}',
+ '\u{1d549}'), ('\u{1d551}', '\u{1d551}'), ('\u{1d6a6}', '\u{1d6a7}'), ('\u{1d7cc}',
+ '\u{1d7cd}'), ('\u{1d800}', '\u{1e7ff}'), ('\u{1e8c5}', '\u{1e8c6}'), ('\u{1e8d7}',
+ '\u{1edff}'), ('\u{1ee04}', '\u{1ee04}'), ('\u{1ee20}', '\u{1ee20}'), ('\u{1ee23}',
+ '\u{1ee23}'), ('\u{1ee25}', '\u{1ee26}'), ('\u{1ee28}', '\u{1ee28}'), ('\u{1ee33}',
+ '\u{1ee33}'), ('\u{1ee38}', '\u{1ee38}'), ('\u{1ee3a}', '\u{1ee3a}'), ('\u{1ee3c}',
+ '\u{1ee41}'), ('\u{1ee43}', '\u{1ee46}'), ('\u{1ee48}', '\u{1ee48}'), ('\u{1ee4a}',
+ '\u{1ee4a}'), ('\u{1ee4c}', '\u{1ee4c}'), ('\u{1ee50}', '\u{1ee50}'), ('\u{1ee53}',
+ '\u{1ee53}'), ('\u{1ee55}', '\u{1ee56}'), ('\u{1ee58}', '\u{1ee58}'), ('\u{1ee5a}',
+ '\u{1ee5a}'), ('\u{1ee5c}', '\u{1ee5c}'), ('\u{1ee5e}', '\u{1ee5e}'), ('\u{1ee60}',
+ '\u{1ee60}'), ('\u{1ee63}', '\u{1ee63}'), ('\u{1ee65}', '\u{1ee66}'), ('\u{1ee6b}',
+ '\u{1ee6b}'), ('\u{1ee73}', '\u{1ee73}'), ('\u{1ee78}', '\u{1ee78}'), ('\u{1ee7d}',
+ '\u{1ee7d}'), ('\u{1ee7f}', '\u{1ee7f}'), ('\u{1ee8a}', '\u{1ee8a}'), ('\u{1ee9c}',
+ '\u{1eea0}'), ('\u{1eea4}', '\u{1eea4}'), ('\u{1eeaa}', '\u{1eeaa}'), ('\u{1eebc}',
+ '\u{1eeef}'), ('\u{1eef2}', '\u{1efff}'), ('\u{1f02c}', '\u{1f02f}'), ('\u{1f094}',
+ '\u{1f09f}'), ('\u{1f0af}', '\u{1f0b0}'), ('\u{1f0c0}', '\u{1f0c0}'), ('\u{1f0d0}',
+ '\u{1f0d0}'), ('\u{1f0f6}', '\u{1f0ff}'), ('\u{1f10d}', '\u{1f10f}'), ('\u{1f12f}',
+ '\u{1f12f}'), ('\u{1f16c}', '\u{1f16f}'), ('\u{1f19b}', '\u{1f1e5}'), ('\u{1f203}',
+ '\u{1f20f}'), ('\u{1f23b}', '\u{1f23f}'), ('\u{1f249}', '\u{1f24f}'), ('\u{1f252}',
+ '\u{1f2ff}'), ('\u{1f32d}', '\u{1f32f}'), ('\u{1f37e}', '\u{1f37f}'), ('\u{1f3cf}',
+ '\u{1f3d3}'), ('\u{1f3f8}', '\u{1f3ff}'), ('\u{1f4ff}', '\u{1f4ff}'), ('\u{1f54b}',
+ '\u{1f54f}'), ('\u{1f57a}', '\u{1f57a}'), ('\u{1f5a4}', '\u{1f5a4}'), ('\u{1f643}',
+ '\u{1f644}'), ('\u{1f6d0}', '\u{1f6df}'), ('\u{1f6ed}', '\u{1f6ef}'), ('\u{1f6f4}',
+ '\u{1f6ff}'), ('\u{1f774}', '\u{1f77f}'), ('\u{1f7d5}', '\u{1f7ff}'), ('\u{1f80c}',
+ '\u{1f80f}'), ('\u{1f848}', '\u{1f84f}'), ('\u{1f85a}', '\u{1f85f}'), ('\u{1f888}',
+ '\u{1f88f}'), ('\u{1f8ae}', '\u{1ffff}'), ('\u{2a6d7}', '\u{2a6ff}'), ('\u{2b735}',
+ '\u{2b73f}'), ('\u{2b81e}', '\u{2f7ff}'), ('\u{2fa1e}', '\u{e0000}'), ('\u{e0002}',
+ '\u{e001f}'), ('\u{e0080}', '\u{e00ff}'), ('\u{e01f0}', '\u{effff}'), ('\u{ffffe}',
+ '\u{fffff}'), ('\u{10fffe}', '\u{10ffff}')
];
pub const Co_table: &'static [(char, char)] = &[
- ('\u{e000}', '\u{e000}'), ('\u{f8ff}', '\u{f8ff}'), ('\u{f0000}', '\u{f0000}'),
- ('\u{ffffd}', '\u{ffffd}'), ('\u{100000}', '\u{100000}'), ('\u{10fffd}', '\u{10fffd}')
+ ('\u{e000}', '\u{f8ff}'), ('\u{f0000}', '\u{ffffd}'), ('\u{100000}', '\u{10fffd}')
];
pub const L_table: &'static [(char, char)] = &[
('\u{2e2f}', '\u{2e2f}'), ('\u{3005}', '\u{3006}'), ('\u{3031}', '\u{3035}'), ('\u{303b}',
'\u{303c}'), ('\u{3041}', '\u{3096}'), ('\u{309d}', '\u{309f}'), ('\u{30a1}', '\u{30fa}'),
('\u{30fc}', '\u{30ff}'), ('\u{3105}', '\u{312d}'), ('\u{3131}', '\u{318e}'), ('\u{31a0}',
- '\u{31ba}'), ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{3400}'), ('\u{4db5}', '\u{4db5}'),
- ('\u{4e00}', '\u{4e00}'), ('\u{9fcc}', '\u{9fcc}'), ('\u{a000}', '\u{a48c}'), ('\u{a4d0}',
- '\u{a4fd}'), ('\u{a500}', '\u{a60c}'), ('\u{a610}', '\u{a61f}'), ('\u{a62a}', '\u{a62b}'),
- ('\u{a640}', '\u{a66e}'), ('\u{a67f}', '\u{a69d}'), ('\u{a6a0}', '\u{a6e5}'), ('\u{a717}',
- '\u{a71f}'), ('\u{a722}', '\u{a788}'), ('\u{a78b}', '\u{a78e}'), ('\u{a790}', '\u{a7ad}'),
- ('\u{a7b0}', '\u{a7b1}'), ('\u{a7f7}', '\u{a801}'), ('\u{a803}', '\u{a805}'), ('\u{a807}',
- '\u{a80a}'), ('\u{a80c}', '\u{a822}'), ('\u{a840}', '\u{a873}'), ('\u{a882}', '\u{a8b3}'),
- ('\u{a8f2}', '\u{a8f7}'), ('\u{a8fb}', '\u{a8fb}'), ('\u{a90a}', '\u{a925}'), ('\u{a930}',
- '\u{a946}'), ('\u{a960}', '\u{a97c}'), ('\u{a984}', '\u{a9b2}'), ('\u{a9cf}', '\u{a9cf}'),
- ('\u{a9e0}', '\u{a9e4}'), ('\u{a9e6}', '\u{a9ef}'), ('\u{a9fa}', '\u{a9fe}'), ('\u{aa00}',
- '\u{aa28}'), ('\u{aa40}', '\u{aa42}'), ('\u{aa44}', '\u{aa4b}'), ('\u{aa60}', '\u{aa76}'),
- ('\u{aa7a}', '\u{aa7a}'), ('\u{aa7e}', '\u{aaaf}'), ('\u{aab1}', '\u{aab1}'), ('\u{aab5}',
- '\u{aab6}'), ('\u{aab9}', '\u{aabd}'), ('\u{aac0}', '\u{aac0}'), ('\u{aac2}', '\u{aac2}'),
- ('\u{aadb}', '\u{aadd}'), ('\u{aae0}', '\u{aaea}'), ('\u{aaf2}', '\u{aaf4}'), ('\u{ab01}',
- '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), ('\u{ab20}', '\u{ab26}'),
- ('\u{ab28}', '\u{ab2e}'), ('\u{ab30}', '\u{ab5a}'), ('\u{ab5c}', '\u{ab5f}'), ('\u{ab64}',
- '\u{ab65}'), ('\u{abc0}', '\u{abe2}'), ('\u{ac00}', '\u{ac00}'), ('\u{d7a3}', '\u{d7a3}'),
- ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', '\u{fa6d}'), ('\u{fa70}',
- '\u{fad9}'), ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{fb1d}', '\u{fb1d}'),
- ('\u{fb1f}', '\u{fb28}'), ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}',
- '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), ('\u{fb46}', '\u{fbb1}'),
- ('\u{fbd3}', '\u{fd3d}'), ('\u{fd50}', '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}',
- '\u{fdfb}'), ('\u{fe70}', '\u{fe74}'), ('\u{fe76}', '\u{fefc}'), ('\u{ff21}', '\u{ff3a}'),
- ('\u{ff41}', '\u{ff5a}'), ('\u{ff66}', '\u{ffbe}'), ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}',
- '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'), ('\u{10000}', '\u{1000b}'),
- ('\u{1000d}', '\u{10026}'), ('\u{10028}', '\u{1003a}'), ('\u{1003c}', '\u{1003d}'),
- ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'), ('\u{10080}', '\u{100fa}'),
- ('\u{10280}', '\u{1029c}'), ('\u{102a0}', '\u{102d0}'), ('\u{10300}', '\u{1031f}'),
- ('\u{10330}', '\u{10340}'), ('\u{10342}', '\u{10349}'), ('\u{10350}', '\u{10375}'),
- ('\u{10380}', '\u{1039d}'), ('\u{103a0}', '\u{103c3}'), ('\u{103c8}', '\u{103cf}'),
- ('\u{10400}', '\u{1049d}'), ('\u{10500}', '\u{10527}'), ('\u{10530}', '\u{10563}'),
- ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), ('\u{10760}', '\u{10767}'),
- ('\u{10800}', '\u{10805}'), ('\u{10808}', '\u{10808}'), ('\u{1080a}', '\u{10835}'),
- ('\u{10837}', '\u{10838}'), ('\u{1083c}', '\u{1083c}'), ('\u{1083f}', '\u{10855}'),
- ('\u{10860}', '\u{10876}'), ('\u{10880}', '\u{1089e}'), ('\u{10900}', '\u{10915}'),
- ('\u{10920}', '\u{10939}'), ('\u{10980}', '\u{109b7}'), ('\u{109be}', '\u{109bf}'),
- ('\u{10a00}', '\u{10a00}'), ('\u{10a10}', '\u{10a13}'), ('\u{10a15}', '\u{10a17}'),
- ('\u{10a19}', '\u{10a33}'), ('\u{10a60}', '\u{10a7c}'), ('\u{10a80}', '\u{10a9c}'),
- ('\u{10ac0}', '\u{10ac7}'), ('\u{10ac9}', '\u{10ae4}'), ('\u{10b00}', '\u{10b35}'),
- ('\u{10b40}', '\u{10b55}'), ('\u{10b60}', '\u{10b72}'), ('\u{10b80}', '\u{10b91}'),
- ('\u{10c00}', '\u{10c48}'), ('\u{11003}', '\u{11037}'), ('\u{11083}', '\u{110af}'),
- ('\u{110d0}', '\u{110e8}'), ('\u{11103}', '\u{11126}'), ('\u{11150}', '\u{11172}'),
- ('\u{11176}', '\u{11176}'), ('\u{11183}', '\u{111b2}'), ('\u{111c1}', '\u{111c4}'),
- ('\u{111da}', '\u{111da}'), ('\u{11200}', '\u{11211}'), ('\u{11213}', '\u{1122b}'),
- ('\u{112b0}', '\u{112de}'), ('\u{11305}', '\u{1130c}'), ('\u{1130f}', '\u{11310}'),
- ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'), ('\u{11332}', '\u{11333}'),
- ('\u{11335}', '\u{11339}'), ('\u{1133d}', '\u{1133d}'), ('\u{1135d}', '\u{11361}'),
- ('\u{11480}', '\u{114af}'), ('\u{114c4}', '\u{114c5}'), ('\u{114c7}', '\u{114c7}'),
- ('\u{11580}', '\u{115ae}'), ('\u{11600}', '\u{1162f}'), ('\u{11644}', '\u{11644}'),
- ('\u{11680}', '\u{116aa}'), ('\u{118a0}', '\u{118df}'), ('\u{118ff}', '\u{118ff}'),
- ('\u{11ac0}', '\u{11af8}'), ('\u{12000}', '\u{12398}'), ('\u{13000}', '\u{1342e}'),
- ('\u{16800}', '\u{16a38}'), ('\u{16a40}', '\u{16a5e}'), ('\u{16ad0}', '\u{16aed}'),
- ('\u{16b00}', '\u{16b2f}'), ('\u{16b40}', '\u{16b43}'), ('\u{16b63}', '\u{16b77}'),
- ('\u{16b7d}', '\u{16b8f}'), ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f50}'),
- ('\u{16f93}', '\u{16f9f}'), ('\u{1b000}', '\u{1b001}'), ('\u{1bc00}', '\u{1bc6a}'),
- ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}', '\u{1bc99}'),
- ('\u{1d400}', '\u{1d454}'), ('\u{1d456}', '\u{1d49c}'), ('\u{1d49e}', '\u{1d49f}'),
- ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}', '\u{1d4ac}'),
- ('\u{1d4ae}', '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}', '\u{1d4c3}'),
- ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}', '\u{1d514}'),
- ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'), ('\u{1d53b}', '\u{1d53e}'),
- ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}', '\u{1d550}'),
- ('\u{1d552}', '\u{1d6a5}'), ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6c2}', '\u{1d6da}'),
- ('\u{1d6dc}', '\u{1d6fa}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}', '\u{1d734}'),
- ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d76e}'), ('\u{1d770}', '\u{1d788}'),
- ('\u{1d78a}', '\u{1d7a8}'), ('\u{1d7aa}', '\u{1d7c2}'), ('\u{1d7c4}', '\u{1d7cb}'),
- ('\u{1e800}', '\u{1e8c4}'), ('\u{1ee00}', '\u{1ee03}'), ('\u{1ee05}', '\u{1ee1f}'),
- ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'),
- ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'),
- ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}', '\u{1ee47}'),
- ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}', '\u{1ee4f}'),
- ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), ('\u{1ee57}', '\u{1ee57}'),
- ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'),
- ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'),
- ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}', '\u{1ee77}'),
- ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}', '\u{1ee89}'),
- ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), ('\u{1eea5}', '\u{1eea9}'),
- ('\u{1eeab}', '\u{1eebb}'), ('\u{20000}', '\u{20000}'), ('\u{2a6d6}', '\u{2a6d6}'),
- ('\u{2a700}', '\u{2a700}'), ('\u{2b734}', '\u{2b734}'), ('\u{2b740}', '\u{2b740}'),
- ('\u{2b81d}', '\u{2b81d}'), ('\u{2f800}', '\u{2fa1d}')
+ '\u{31ba}'), ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{4db5}'), ('\u{4e00}', '\u{9fcc}'),
+ ('\u{a000}', '\u{a48c}'), ('\u{a4d0}', '\u{a4fd}'), ('\u{a500}', '\u{a60c}'), ('\u{a610}',
+ '\u{a61f}'), ('\u{a62a}', '\u{a62b}'), ('\u{a640}', '\u{a66e}'), ('\u{a67f}', '\u{a69d}'),
+ ('\u{a6a0}', '\u{a6e5}'), ('\u{a717}', '\u{a71f}'), ('\u{a722}', '\u{a788}'), ('\u{a78b}',
+ '\u{a78e}'), ('\u{a790}', '\u{a7ad}'), ('\u{a7b0}', '\u{a7b1}'), ('\u{a7f7}', '\u{a801}'),
+ ('\u{a803}', '\u{a805}'), ('\u{a807}', '\u{a80a}'), ('\u{a80c}', '\u{a822}'), ('\u{a840}',
+ '\u{a873}'), ('\u{a882}', '\u{a8b3}'), ('\u{a8f2}', '\u{a8f7}'), ('\u{a8fb}', '\u{a8fb}'),
+ ('\u{a90a}', '\u{a925}'), ('\u{a930}', '\u{a946}'), ('\u{a960}', '\u{a97c}'), ('\u{a984}',
+ '\u{a9b2}'), ('\u{a9cf}', '\u{a9cf}'), ('\u{a9e0}', '\u{a9e4}'), ('\u{a9e6}', '\u{a9ef}'),
+ ('\u{a9fa}', '\u{a9fe}'), ('\u{aa00}', '\u{aa28}'), ('\u{aa40}', '\u{aa42}'), ('\u{aa44}',
+ '\u{aa4b}'), ('\u{aa60}', '\u{aa76}'), ('\u{aa7a}', '\u{aa7a}'), ('\u{aa7e}', '\u{aaaf}'),
+ ('\u{aab1}', '\u{aab1}'), ('\u{aab5}', '\u{aab6}'), ('\u{aab9}', '\u{aabd}'), ('\u{aac0}',
+ '\u{aac0}'), ('\u{aac2}', '\u{aac2}'), ('\u{aadb}', '\u{aadd}'), ('\u{aae0}', '\u{aaea}'),
+ ('\u{aaf2}', '\u{aaf4}'), ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'), ('\u{ab11}',
+ '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}'), ('\u{ab30}', '\u{ab5a}'),
+ ('\u{ab5c}', '\u{ab5f}'), ('\u{ab64}', '\u{ab65}'), ('\u{abc0}', '\u{abe2}'), ('\u{ac00}',
+ '\u{d7a3}'), ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', '\u{fa6d}'),
+ ('\u{fa70}', '\u{fad9}'), ('\u{fb00}', '\u{fb06}'), ('\u{fb13}', '\u{fb17}'), ('\u{fb1d}',
+ '\u{fb1d}'), ('\u{fb1f}', '\u{fb28}'), ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}', '\u{fb3c}'),
+ ('\u{fb3e}', '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'), ('\u{fb46}',
+ '\u{fbb1}'), ('\u{fbd3}', '\u{fd3d}'), ('\u{fd50}', '\u{fd8f}'), ('\u{fd92}', '\u{fdc7}'),
+ ('\u{fdf0}', '\u{fdfb}'), ('\u{fe70}', '\u{fe74}'), ('\u{fe76}', '\u{fefc}'), ('\u{ff21}',
+ '\u{ff3a}'), ('\u{ff41}', '\u{ff5a}'), ('\u{ff66}', '\u{ffbe}'), ('\u{ffc2}', '\u{ffc7}'),
+ ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'), ('\u{10000}',
+ '\u{1000b}'), ('\u{1000d}', '\u{10026}'), ('\u{10028}', '\u{1003a}'), ('\u{1003c}',
+ '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'), ('\u{10080}',
+ '\u{100fa}'), ('\u{10280}', '\u{1029c}'), ('\u{102a0}', '\u{102d0}'), ('\u{10300}',
+ '\u{1031f}'), ('\u{10330}', '\u{10340}'), ('\u{10342}', '\u{10349}'), ('\u{10350}',
+ '\u{10375}'), ('\u{10380}', '\u{1039d}'), ('\u{103a0}', '\u{103c3}'), ('\u{103c8}',
+ '\u{103cf}'), ('\u{10400}', '\u{1049d}'), ('\u{10500}', '\u{10527}'), ('\u{10530}',
+ '\u{10563}'), ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'), ('\u{10760}',
+ '\u{10767}'), ('\u{10800}', '\u{10805}'), ('\u{10808}', '\u{10808}'), ('\u{1080a}',
+ '\u{10835}'), ('\u{10837}', '\u{10838}'), ('\u{1083c}', '\u{1083c}'), ('\u{1083f}',
+ '\u{10855}'), ('\u{10860}', '\u{10876}'), ('\u{10880}', '\u{1089e}'), ('\u{10900}',
+ '\u{10915}'), ('\u{10920}', '\u{10939}'), ('\u{10980}', '\u{109b7}'), ('\u{109be}',
+ '\u{109bf}'), ('\u{10a00}', '\u{10a00}'), ('\u{10a10}', '\u{10a13}'), ('\u{10a15}',
+ '\u{10a17}'), ('\u{10a19}', '\u{10a33}'), ('\u{10a60}', '\u{10a7c}'), ('\u{10a80}',
+ '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'), ('\u{10ac9}', '\u{10ae4}'), ('\u{10b00}',
+ '\u{10b35}'), ('\u{10b40}', '\u{10b55}'), ('\u{10b60}', '\u{10b72}'), ('\u{10b80}',
+ '\u{10b91}'), ('\u{10c00}', '\u{10c48}'), ('\u{11003}', '\u{11037}'), ('\u{11083}',
+ '\u{110af}'), ('\u{110d0}', '\u{110e8}'), ('\u{11103}', '\u{11126}'), ('\u{11150}',
+ '\u{11172}'), ('\u{11176}', '\u{11176}'), ('\u{11183}', '\u{111b2}'), ('\u{111c1}',
+ '\u{111c4}'), ('\u{111da}', '\u{111da}'), ('\u{11200}', '\u{11211}'), ('\u{11213}',
+ '\u{1122b}'), ('\u{112b0}', '\u{112de}'), ('\u{11305}', '\u{1130c}'), ('\u{1130f}',
+ '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'), ('\u{11332}',
+ '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133d}', '\u{1133d}'), ('\u{1135d}',
+ '\u{11361}'), ('\u{11480}', '\u{114af}'), ('\u{114c4}', '\u{114c5}'), ('\u{114c7}',
+ '\u{114c7}'), ('\u{11580}', '\u{115ae}'), ('\u{11600}', '\u{1162f}'), ('\u{11644}',
+ '\u{11644}'), ('\u{11680}', '\u{116aa}'), ('\u{118a0}', '\u{118df}'), ('\u{118ff}',
+ '\u{118ff}'), ('\u{11ac0}', '\u{11af8}'), ('\u{12000}', '\u{12398}'), ('\u{13000}',
+ '\u{1342e}'), ('\u{16800}', '\u{16a38}'), ('\u{16a40}', '\u{16a5e}'), ('\u{16ad0}',
+ '\u{16aed}'), ('\u{16b00}', '\u{16b2f}'), ('\u{16b40}', '\u{16b43}'), ('\u{16b63}',
+ '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}'), ('\u{16f00}', '\u{16f44}'), ('\u{16f50}',
+ '\u{16f50}'), ('\u{16f93}', '\u{16f9f}'), ('\u{1b000}', '\u{1b001}'), ('\u{1bc00}',
+ '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'), ('\u{1bc90}',
+ '\u{1bc99}'), ('\u{1d400}', '\u{1d454}'), ('\u{1d456}', '\u{1d49c}'), ('\u{1d49e}',
+ '\u{1d49f}'), ('\u{1d4a2}', '\u{1d4a2}'), ('\u{1d4a5}', '\u{1d4a6}'), ('\u{1d4a9}',
+ '\u{1d4ac}'), ('\u{1d4ae}', '\u{1d4b9}'), ('\u{1d4bb}', '\u{1d4bb}'), ('\u{1d4bd}',
+ '\u{1d4c3}'), ('\u{1d4c5}', '\u{1d505}'), ('\u{1d507}', '\u{1d50a}'), ('\u{1d50d}',
+ '\u{1d514}'), ('\u{1d516}', '\u{1d51c}'), ('\u{1d51e}', '\u{1d539}'), ('\u{1d53b}',
+ '\u{1d53e}'), ('\u{1d540}', '\u{1d544}'), ('\u{1d546}', '\u{1d546}'), ('\u{1d54a}',
+ '\u{1d550}'), ('\u{1d552}', '\u{1d6a5}'), ('\u{1d6a8}', '\u{1d6c0}'), ('\u{1d6c2}',
+ '\u{1d6da}'), ('\u{1d6dc}', '\u{1d6fa}'), ('\u{1d6fc}', '\u{1d714}'), ('\u{1d716}',
+ '\u{1d734}'), ('\u{1d736}', '\u{1d74e}'), ('\u{1d750}', '\u{1d76e}'), ('\u{1d770}',
+ '\u{1d788}'), ('\u{1d78a}', '\u{1d7a8}'), ('\u{1d7aa}', '\u{1d7c2}'), ('\u{1d7c4}',
+ '\u{1d7cb}'), ('\u{1e800}', '\u{1e8c4}'), ('\u{1ee00}', '\u{1ee03}'), ('\u{1ee05}',
+ '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'), ('\u{1ee27}',
+ '\u{1ee27}'), ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'), ('\u{1ee39}',
+ '\u{1ee39}'), ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'), ('\u{1ee47}',
+ '\u{1ee47}'), ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'), ('\u{1ee4d}',
+ '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'), ('\u{1ee57}',
+ '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'), ('\u{1ee5d}',
+ '\u{1ee5d}'), ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'), ('\u{1ee64}',
+ '\u{1ee64}'), ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'), ('\u{1ee74}',
+ '\u{1ee77}'), ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'), ('\u{1ee80}',
+ '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'), ('\u{1eea5}',
+ '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), ('\u{20000}', '\u{2a6d6}'), ('\u{2a700}',
+ '\u{2b734}'), ('\u{2b740}', '\u{2b81d}'), ('\u{2f800}', '\u{2fa1d}')
];
pub const LC_table: &'static [(char, char)] = &[
'\u{2dd6}'), ('\u{2dd8}', '\u{2dde}'), ('\u{3006}', '\u{3006}'), ('\u{303c}', '\u{303c}'),
('\u{3041}', '\u{3096}'), ('\u{309f}', '\u{309f}'), ('\u{30a1}', '\u{30fa}'), ('\u{30ff}',
'\u{30ff}'), ('\u{3105}', '\u{312d}'), ('\u{3131}', '\u{318e}'), ('\u{31a0}', '\u{31ba}'),
- ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{3400}'), ('\u{4db5}', '\u{4db5}'), ('\u{4e00}',
- '\u{4e00}'), ('\u{9fcc}', '\u{9fcc}'), ('\u{a000}', '\u{a014}'), ('\u{a016}', '\u{a48c}'),
- ('\u{a4d0}', '\u{a4f7}'), ('\u{a500}', '\u{a60b}'), ('\u{a610}', '\u{a61f}'), ('\u{a62a}',
- '\u{a62b}'), ('\u{a66e}', '\u{a66e}'), ('\u{a6a0}', '\u{a6e5}'), ('\u{a7f7}', '\u{a7f7}'),
- ('\u{a7fb}', '\u{a801}'), ('\u{a803}', '\u{a805}'), ('\u{a807}', '\u{a80a}'), ('\u{a80c}',
- '\u{a822}'), ('\u{a840}', '\u{a873}'), ('\u{a882}', '\u{a8b3}'), ('\u{a8f2}', '\u{a8f7}'),
- ('\u{a8fb}', '\u{a8fb}'), ('\u{a90a}', '\u{a925}'), ('\u{a930}', '\u{a946}'), ('\u{a960}',
- '\u{a97c}'), ('\u{a984}', '\u{a9b2}'), ('\u{a9e0}', '\u{a9e4}'), ('\u{a9e7}', '\u{a9ef}'),
- ('\u{a9fa}', '\u{a9fe}'), ('\u{aa00}', '\u{aa28}'), ('\u{aa40}', '\u{aa42}'), ('\u{aa44}',
- '\u{aa4b}'), ('\u{aa60}', '\u{aa6f}'), ('\u{aa71}', '\u{aa76}'), ('\u{aa7a}', '\u{aa7a}'),
- ('\u{aa7e}', '\u{aaaf}'), ('\u{aab1}', '\u{aab1}'), ('\u{aab5}', '\u{aab6}'), ('\u{aab9}',
- '\u{aabd}'), ('\u{aac0}', '\u{aac0}'), ('\u{aac2}', '\u{aac2}'), ('\u{aadb}', '\u{aadc}'),
- ('\u{aae0}', '\u{aaea}'), ('\u{aaf2}', '\u{aaf2}'), ('\u{ab01}', '\u{ab06}'), ('\u{ab09}',
- '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), ('\u{ab20}', '\u{ab26}'), ('\u{ab28}', '\u{ab2e}'),
- ('\u{abc0}', '\u{abe2}'), ('\u{ac00}', '\u{ac00}'), ('\u{d7a3}', '\u{d7a3}'), ('\u{d7b0}',
- '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', '\u{fa6d}'), ('\u{fa70}', '\u{fad9}'),
- ('\u{fb1d}', '\u{fb1d}'), ('\u{fb1f}', '\u{fb28}'), ('\u{fb2a}', '\u{fb36}'), ('\u{fb38}',
- '\u{fb3c}'), ('\u{fb3e}', '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}', '\u{fb44}'),
- ('\u{fb46}', '\u{fbb1}'), ('\u{fbd3}', '\u{fd3d}'), ('\u{fd50}', '\u{fd8f}'), ('\u{fd92}',
- '\u{fdc7}'), ('\u{fdf0}', '\u{fdfb}'), ('\u{fe70}', '\u{fe74}'), ('\u{fe76}', '\u{fefc}'),
- ('\u{ff66}', '\u{ff6f}'), ('\u{ff71}', '\u{ff9d}'), ('\u{ffa0}', '\u{ffbe}'), ('\u{ffc2}',
- '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}', '\u{ffdc}'),
- ('\u{10000}', '\u{1000b}'), ('\u{1000d}', '\u{10026}'), ('\u{10028}', '\u{1003a}'),
- ('\u{1003c}', '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), ('\u{10050}', '\u{1005d}'),
- ('\u{10080}', '\u{100fa}'), ('\u{10280}', '\u{1029c}'), ('\u{102a0}', '\u{102d0}'),
- ('\u{10300}', '\u{1031f}'), ('\u{10330}', '\u{10340}'), ('\u{10342}', '\u{10349}'),
- ('\u{10350}', '\u{10375}'), ('\u{10380}', '\u{1039d}'), ('\u{103a0}', '\u{103c3}'),
- ('\u{103c8}', '\u{103cf}'), ('\u{10450}', '\u{1049d}'), ('\u{10500}', '\u{10527}'),
- ('\u{10530}', '\u{10563}'), ('\u{10600}', '\u{10736}'), ('\u{10740}', '\u{10755}'),
- ('\u{10760}', '\u{10767}'), ('\u{10800}', '\u{10805}'), ('\u{10808}', '\u{10808}'),
- ('\u{1080a}', '\u{10835}'), ('\u{10837}', '\u{10838}'), ('\u{1083c}', '\u{1083c}'),
- ('\u{1083f}', '\u{10855}'), ('\u{10860}', '\u{10876}'), ('\u{10880}', '\u{1089e}'),
- ('\u{10900}', '\u{10915}'), ('\u{10920}', '\u{10939}'), ('\u{10980}', '\u{109b7}'),
- ('\u{109be}', '\u{109bf}'), ('\u{10a00}', '\u{10a00}'), ('\u{10a10}', '\u{10a13}'),
- ('\u{10a15}', '\u{10a17}'), ('\u{10a19}', '\u{10a33}'), ('\u{10a60}', '\u{10a7c}'),
- ('\u{10a80}', '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'), ('\u{10ac9}', '\u{10ae4}'),
- ('\u{10b00}', '\u{10b35}'), ('\u{10b40}', '\u{10b55}'), ('\u{10b60}', '\u{10b72}'),
- ('\u{10b80}', '\u{10b91}'), ('\u{10c00}', '\u{10c48}'), ('\u{11003}', '\u{11037}'),
- ('\u{11083}', '\u{110af}'), ('\u{110d0}', '\u{110e8}'), ('\u{11103}', '\u{11126}'),
- ('\u{11150}', '\u{11172}'), ('\u{11176}', '\u{11176}'), ('\u{11183}', '\u{111b2}'),
- ('\u{111c1}', '\u{111c4}'), ('\u{111da}', '\u{111da}'), ('\u{11200}', '\u{11211}'),
- ('\u{11213}', '\u{1122b}'), ('\u{112b0}', '\u{112de}'), ('\u{11305}', '\u{1130c}'),
- ('\u{1130f}', '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}', '\u{11330}'),
- ('\u{11332}', '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133d}', '\u{1133d}'),
- ('\u{1135d}', '\u{11361}'), ('\u{11480}', '\u{114af}'), ('\u{114c4}', '\u{114c5}'),
- ('\u{114c7}', '\u{114c7}'), ('\u{11580}', '\u{115ae}'), ('\u{11600}', '\u{1162f}'),
- ('\u{11644}', '\u{11644}'), ('\u{11680}', '\u{116aa}'), ('\u{118ff}', '\u{118ff}'),
- ('\u{11ac0}', '\u{11af8}'), ('\u{12000}', '\u{12398}'), ('\u{13000}', '\u{1342e}'),
- ('\u{16800}', '\u{16a38}'), ('\u{16a40}', '\u{16a5e}'), ('\u{16ad0}', '\u{16aed}'),
- ('\u{16b00}', '\u{16b2f}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}', '\u{16b8f}'),
- ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f50}'), ('\u{1b000}', '\u{1b001}'),
- ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}', '\u{1bc88}'),
- ('\u{1bc90}', '\u{1bc99}'), ('\u{1e800}', '\u{1e8c4}'), ('\u{1ee00}', '\u{1ee03}'),
- ('\u{1ee05}', '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}', '\u{1ee24}'),
- ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}', '\u{1ee37}'),
- ('\u{1ee39}', '\u{1ee39}'), ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}', '\u{1ee42}'),
- ('\u{1ee47}', '\u{1ee47}'), ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}', '\u{1ee4b}'),
- ('\u{1ee4d}', '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}', '\u{1ee54}'),
- ('\u{1ee57}', '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}', '\u{1ee5b}'),
- ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}', '\u{1ee62}'),
- ('\u{1ee64}', '\u{1ee64}'), ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}', '\u{1ee72}'),
- ('\u{1ee74}', '\u{1ee77}'), ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}', '\u{1ee7e}'),
- ('\u{1ee80}', '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}', '\u{1eea3}'),
- ('\u{1eea5}', '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), ('\u{20000}', '\u{20000}'),
- ('\u{2a6d6}', '\u{2a6d6}'), ('\u{2a700}', '\u{2a700}'), ('\u{2b734}', '\u{2b734}'),
- ('\u{2b740}', '\u{2b740}'), ('\u{2b81d}', '\u{2b81d}'), ('\u{2f800}', '\u{2fa1d}')
+ ('\u{31f0}', '\u{31ff}'), ('\u{3400}', '\u{4db5}'), ('\u{4e00}', '\u{9fcc}'), ('\u{a000}',
+ '\u{a014}'), ('\u{a016}', '\u{a48c}'), ('\u{a4d0}', '\u{a4f7}'), ('\u{a500}', '\u{a60b}'),
+ ('\u{a610}', '\u{a61f}'), ('\u{a62a}', '\u{a62b}'), ('\u{a66e}', '\u{a66e}'), ('\u{a6a0}',
+ '\u{a6e5}'), ('\u{a7f7}', '\u{a7f7}'), ('\u{a7fb}', '\u{a801}'), ('\u{a803}', '\u{a805}'),
+ ('\u{a807}', '\u{a80a}'), ('\u{a80c}', '\u{a822}'), ('\u{a840}', '\u{a873}'), ('\u{a882}',
+ '\u{a8b3}'), ('\u{a8f2}', '\u{a8f7}'), ('\u{a8fb}', '\u{a8fb}'), ('\u{a90a}', '\u{a925}'),
+ ('\u{a930}', '\u{a946}'), ('\u{a960}', '\u{a97c}'), ('\u{a984}', '\u{a9b2}'), ('\u{a9e0}',
+ '\u{a9e4}'), ('\u{a9e7}', '\u{a9ef}'), ('\u{a9fa}', '\u{a9fe}'), ('\u{aa00}', '\u{aa28}'),
+ ('\u{aa40}', '\u{aa42}'), ('\u{aa44}', '\u{aa4b}'), ('\u{aa60}', '\u{aa6f}'), ('\u{aa71}',
+ '\u{aa76}'), ('\u{aa7a}', '\u{aa7a}'), ('\u{aa7e}', '\u{aaaf}'), ('\u{aab1}', '\u{aab1}'),
+ ('\u{aab5}', '\u{aab6}'), ('\u{aab9}', '\u{aabd}'), ('\u{aac0}', '\u{aac0}'), ('\u{aac2}',
+ '\u{aac2}'), ('\u{aadb}', '\u{aadc}'), ('\u{aae0}', '\u{aaea}'), ('\u{aaf2}', '\u{aaf2}'),
+ ('\u{ab01}', '\u{ab06}'), ('\u{ab09}', '\u{ab0e}'), ('\u{ab11}', '\u{ab16}'), ('\u{ab20}',
+ '\u{ab26}'), ('\u{ab28}', '\u{ab2e}'), ('\u{abc0}', '\u{abe2}'), ('\u{ac00}', '\u{d7a3}'),
+ ('\u{d7b0}', '\u{d7c6}'), ('\u{d7cb}', '\u{d7fb}'), ('\u{f900}', '\u{fa6d}'), ('\u{fa70}',
+ '\u{fad9}'), ('\u{fb1d}', '\u{fb1d}'), ('\u{fb1f}', '\u{fb28}'), ('\u{fb2a}', '\u{fb36}'),
+ ('\u{fb38}', '\u{fb3c}'), ('\u{fb3e}', '\u{fb3e}'), ('\u{fb40}', '\u{fb41}'), ('\u{fb43}',
+ '\u{fb44}'), ('\u{fb46}', '\u{fbb1}'), ('\u{fbd3}', '\u{fd3d}'), ('\u{fd50}', '\u{fd8f}'),
+ ('\u{fd92}', '\u{fdc7}'), ('\u{fdf0}', '\u{fdfb}'), ('\u{fe70}', '\u{fe74}'), ('\u{fe76}',
+ '\u{fefc}'), ('\u{ff66}', '\u{ff6f}'), ('\u{ff71}', '\u{ff9d}'), ('\u{ffa0}', '\u{ffbe}'),
+ ('\u{ffc2}', '\u{ffc7}'), ('\u{ffca}', '\u{ffcf}'), ('\u{ffd2}', '\u{ffd7}'), ('\u{ffda}',
+ '\u{ffdc}'), ('\u{10000}', '\u{1000b}'), ('\u{1000d}', '\u{10026}'), ('\u{10028}',
+ '\u{1003a}'), ('\u{1003c}', '\u{1003d}'), ('\u{1003f}', '\u{1004d}'), ('\u{10050}',
+ '\u{1005d}'), ('\u{10080}', '\u{100fa}'), ('\u{10280}', '\u{1029c}'), ('\u{102a0}',
+ '\u{102d0}'), ('\u{10300}', '\u{1031f}'), ('\u{10330}', '\u{10340}'), ('\u{10342}',
+ '\u{10349}'), ('\u{10350}', '\u{10375}'), ('\u{10380}', '\u{1039d}'), ('\u{103a0}',
+ '\u{103c3}'), ('\u{103c8}', '\u{103cf}'), ('\u{10450}', '\u{1049d}'), ('\u{10500}',
+ '\u{10527}'), ('\u{10530}', '\u{10563}'), ('\u{10600}', '\u{10736}'), ('\u{10740}',
+ '\u{10755}'), ('\u{10760}', '\u{10767}'), ('\u{10800}', '\u{10805}'), ('\u{10808}',
+ '\u{10808}'), ('\u{1080a}', '\u{10835}'), ('\u{10837}', '\u{10838}'), ('\u{1083c}',
+ '\u{1083c}'), ('\u{1083f}', '\u{10855}'), ('\u{10860}', '\u{10876}'), ('\u{10880}',
+ '\u{1089e}'), ('\u{10900}', '\u{10915}'), ('\u{10920}', '\u{10939}'), ('\u{10980}',
+ '\u{109b7}'), ('\u{109be}', '\u{109bf}'), ('\u{10a00}', '\u{10a00}'), ('\u{10a10}',
+ '\u{10a13}'), ('\u{10a15}', '\u{10a17}'), ('\u{10a19}', '\u{10a33}'), ('\u{10a60}',
+ '\u{10a7c}'), ('\u{10a80}', '\u{10a9c}'), ('\u{10ac0}', '\u{10ac7}'), ('\u{10ac9}',
+ '\u{10ae4}'), ('\u{10b00}', '\u{10b35}'), ('\u{10b40}', '\u{10b55}'), ('\u{10b60}',
+ '\u{10b72}'), ('\u{10b80}', '\u{10b91}'), ('\u{10c00}', '\u{10c48}'), ('\u{11003}',
+ '\u{11037}'), ('\u{11083}', '\u{110af}'), ('\u{110d0}', '\u{110e8}'), ('\u{11103}',
+ '\u{11126}'), ('\u{11150}', '\u{11172}'), ('\u{11176}', '\u{11176}'), ('\u{11183}',
+ '\u{111b2}'), ('\u{111c1}', '\u{111c4}'), ('\u{111da}', '\u{111da}'), ('\u{11200}',
+ '\u{11211}'), ('\u{11213}', '\u{1122b}'), ('\u{112b0}', '\u{112de}'), ('\u{11305}',
+ '\u{1130c}'), ('\u{1130f}', '\u{11310}'), ('\u{11313}', '\u{11328}'), ('\u{1132a}',
+ '\u{11330}'), ('\u{11332}', '\u{11333}'), ('\u{11335}', '\u{11339}'), ('\u{1133d}',
+ '\u{1133d}'), ('\u{1135d}', '\u{11361}'), ('\u{11480}', '\u{114af}'), ('\u{114c4}',
+ '\u{114c5}'), ('\u{114c7}', '\u{114c7}'), ('\u{11580}', '\u{115ae}'), ('\u{11600}',
+ '\u{1162f}'), ('\u{11644}', '\u{11644}'), ('\u{11680}', '\u{116aa}'), ('\u{118ff}',
+ '\u{118ff}'), ('\u{11ac0}', '\u{11af8}'), ('\u{12000}', '\u{12398}'), ('\u{13000}',
+ '\u{1342e}'), ('\u{16800}', '\u{16a38}'), ('\u{16a40}', '\u{16a5e}'), ('\u{16ad0}',
+ '\u{16aed}'), ('\u{16b00}', '\u{16b2f}'), ('\u{16b63}', '\u{16b77}'), ('\u{16b7d}',
+ '\u{16b8f}'), ('\u{16f00}', '\u{16f44}'), ('\u{16f50}', '\u{16f50}'), ('\u{1b000}',
+ '\u{1b001}'), ('\u{1bc00}', '\u{1bc6a}'), ('\u{1bc70}', '\u{1bc7c}'), ('\u{1bc80}',
+ '\u{1bc88}'), ('\u{1bc90}', '\u{1bc99}'), ('\u{1e800}', '\u{1e8c4}'), ('\u{1ee00}',
+ '\u{1ee03}'), ('\u{1ee05}', '\u{1ee1f}'), ('\u{1ee21}', '\u{1ee22}'), ('\u{1ee24}',
+ '\u{1ee24}'), ('\u{1ee27}', '\u{1ee27}'), ('\u{1ee29}', '\u{1ee32}'), ('\u{1ee34}',
+ '\u{1ee37}'), ('\u{1ee39}', '\u{1ee39}'), ('\u{1ee3b}', '\u{1ee3b}'), ('\u{1ee42}',
+ '\u{1ee42}'), ('\u{1ee47}', '\u{1ee47}'), ('\u{1ee49}', '\u{1ee49}'), ('\u{1ee4b}',
+ '\u{1ee4b}'), ('\u{1ee4d}', '\u{1ee4f}'), ('\u{1ee51}', '\u{1ee52}'), ('\u{1ee54}',
+ '\u{1ee54}'), ('\u{1ee57}', '\u{1ee57}'), ('\u{1ee59}', '\u{1ee59}'), ('\u{1ee5b}',
+ '\u{1ee5b}'), ('\u{1ee5d}', '\u{1ee5d}'), ('\u{1ee5f}', '\u{1ee5f}'), ('\u{1ee61}',
+ '\u{1ee62}'), ('\u{1ee64}', '\u{1ee64}'), ('\u{1ee67}', '\u{1ee6a}'), ('\u{1ee6c}',
+ '\u{1ee72}'), ('\u{1ee74}', '\u{1ee77}'), ('\u{1ee79}', '\u{1ee7c}'), ('\u{1ee7e}',
+ '\u{1ee7e}'), ('\u{1ee80}', '\u{1ee89}'), ('\u{1ee8b}', '\u{1ee9b}'), ('\u{1eea1}',
+ '\u{1eea3}'), ('\u{1eea5}', '\u{1eea9}'), ('\u{1eeab}', '\u{1eebb}'), ('\u{20000}',
+ '\u{2a6d6}'), ('\u{2a700}', '\u{2b734}'), ('\u{2b740}', '\u{2b81d}'), ('\u{2f800}',
+ '\u{2fa1d}')
];
pub const Lt_table: &'static [(char, char)] = &[
return Some(tmp);
}
- let mut buf = [0u16; 2];
+ let mut buf = [0; 2];
self.chars.next().map(|ch| {
let n = CharExt::encode_utf16(ch, &mut buf).unwrap_or(0);
if n == 2 { self.extra = buf[1]; }
-Subproject commit b89c3f039b61edbb077771eda2ee8a718dbec7e0
+Subproject commit bff69076975642c64e76dbeaa53476bfa7212086
# If this file is modified, then llvm will be forcibly cleaned and then rebuilt.
# The actual contents of this file do not matter, but to trigger a change on the
# build bots then the contents should be changed so git updates the mtime.
-2015-02-19
+2015-03-04
S 2015-02-25 880fb89
+ bitrig-x86_64 8cdc4ca0a80103100f46cbf8caa9fe497df048c5
freebsd-x86_64 f4cbe4227739de986444211f8ee8d74745ab8f7f
linux-i386 3278ebbce8cb269acc0614dac5ddac07eab6a99c
linux-x86_64 72287d0d88de3e5a53bae78ac0d958e1a7637d73
}
impl cat {
- pub fn speak(&mut self) { self.meows += 1_usize; }
+ pub fn speak(&mut self) { self.meows += 1; }
pub fn meow_count(&mut self) -> uint { self.meows }
}
impl cat {
pub fn meow(&mut self) {
println!("Meow");
- self.meows += 1_usize;
- if self.meows % 5_usize == 0_usize {
+ self.meows += 1;
+ if self.meows % 5 == 0 {
self.how_hungry += 1;
}
}
impl cat {
fn meow(&mut self) {
println!("Meow");
- self.meows += 1_usize;
- if self.meows % 5_usize == 0_usize {
+ self.meows += 1;
+ if self.meows % 5 == 0 {
self.how_hungry += 1;
}
}
let mut i = *self;
while i < v {
f(i);
- i += 1_usize;
+ i += 1;
}
}
}
#[inline]
pub fn iter<T, F>(v: &[T], mut f: F) where F: FnMut(&T) {
- let mut i = 0_usize;
+ let mut i = 0;
let n = v.len();
while i < n {
f(&v[i]);
- i += 1_usize;
+ i += 1;
}
}
// same as cci_iter_lib, more-or-less, but not marked inline
pub fn iter<F>(v: Vec<uint> , mut f: F) where F: FnMut(uint) {
- let mut i = 0_usize;
+ let mut i = 0;
let n = v.len();
while i < n {
f(v[i]);
- i += 1_usize;
+ i += 1;
}
}
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(staged_api, allow_internal_unstable)]
+#![staged_api]
+#![stable(feature = "stable", since = "1.0.0")]
+
+#[unstable(feature = "function")]
+pub fn unstable() {}
+
+
+#[stable(feature = "stable", since = "1.0.0")]
+pub struct Foo {
+ #[unstable(feature = "struct_field")]
+ pub x: u8
+}
+
+#[allow_internal_unstable]
+#[macro_export]
+macro_rules! call_unstable_allow {
+ () => { $crate::unstable() }
+}
+
+#[allow_internal_unstable]
+#[macro_export]
+macro_rules! construct_unstable_allow {
+ ($e: expr) => {
+ $crate::Foo { x: $e }
+ }
+}
+
+#[allow_internal_unstable]
+#[macro_export]
+macro_rules! pass_through_allow {
+ ($e: expr) => { $e }
+}
+
+#[macro_export]
+macro_rules! call_unstable_noallow {
+ () => { $crate::unstable() }
+}
+
+#[macro_export]
+macro_rules! construct_unstable_noallow {
+ ($e: expr) => {
+ $crate::Foo { x: $e }
+ }
+}
+
+#[macro_export]
+macro_rules! pass_through_noallow {
+ ($e: expr) => { $e }
+}
#![crate_type = "dylib"]
#[macro_export]
macro_rules! reexported {
- () => ( 3_usize )
+ () => ( 3 )
}
let args = reg.args().clone();
reg.register_syntax_extension(token::intern("plugin_args"),
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
- NormalTT(Box::new(Expander { args: args, }), None));
+ NormalTT(Box::new(Expander { args: args, }), None, false));
}
};
let mut text = &*text;
- let mut total = 0_usize;
+ let mut total = 0;
while !text.is_empty() {
match NUMERALS.iter().find(|&&(rn, _)| text.starts_with(rn)) {
Some(&(rn, val)) => {
#[inline]
pub fn has_closures() -> uint {
- let x = 1_usize;
+ let x = 1;
let mut f = move || x;
- let y = 1_usize;
+ let y = 1;
let g = || y;
f() + g()
}
*x = random_gradient(&mut rng);
}
- let mut permutations = [0i32; 256];
+ let mut permutations = [0; 256];
for (i, x) in permutations.iter_mut().enumerate() {
*x = i as i32;
}
to_rendezvous: Sender<CreatureInfo>,
to_rendezvous_log: Sender<String>
) {
- let mut creatures_met = 0i32;
+ let mut creatures_met = 0;
let mut evil_clones_met = 0;
let mut rendezvous = from_rendezvous.iter();
}
fn get(&mut self, mut idx: i32) -> P {
- let mut pp = [0u8; 16];
+ let mut pp = [0; 16];
self.permcount = idx as u32;
for (i, place) in self.perm.p.iter_mut().enumerate() {
*place = i as i32 + 1;
let n = std::env::args()
.nth(1)
.and_then(|arg| arg.parse().ok())
- .unwrap_or(2i32);
+ .unwrap_or(2);
let (checksum, maxflips) = fannkuch(n);
println!("{}\nPfannkuchen({}) = {}", checksum, n, maxflips);
fn make(&mut self, n: usize) -> IoResult<()> {
let alu_len = self.alu.len();
- let mut buf = repeat(0u8).take(alu_len + LINE_LEN).collect::<Vec<_>>();
+ let mut buf = repeat(0).take(alu_len + LINE_LEN).collect::<Vec<_>>();
let alu: &[u8] = self.alu.as_bytes();
copy_memory(&mut buf, alu);
-> std::old_io::IoResult<()>
{
try!(wr.write(header.as_bytes()));
- let mut line = [0u8; LINE_LENGTH + 1];
+ let mut line = [0; LINE_LENGTH + 1];
while n > 0 {
let nb = min(LINE_LENGTH, n);
for i in 0..nb {
}
fn rotate(&self, c: u8, frame: usize) -> Code {
- Code(self.push_char(c).hash() & ((1u64 << (2 * frame)) - 1))
+ Code(self.push_char(c).hash() & ((1 << (2 * frame)) - 1))
}
fn pack(string: &str) -> Code {
- string.bytes().fold(Code(0u64), |a, b| a.push_char(b))
+ string.bytes().fold(Code(0), |a, b| a.push_char(b))
}
fn unpack(&self, frame: usize) -> String {
.map(|(id, p)| transform(p, id != 3))
.collect();
- (0i32..50).map(|yx| {
+ (0..50).map(|yx| {
transforms.iter().enumerate().map(|(id, t)| {
t.iter().filter_map(|p| mask(yx / 5, yx % 5, id, p)).collect()
}).collect()
// Gets the identifier of a mask.
fn get_id(m: u64) -> u8 {
- for id in 0u8..10 {
+ for id in 0..10 {
if m & (1 << (id + 50) as usize) != 0 {return id;}
}
panic!("{:016x} does not have a valid identifier", m);
reader.read_line(&mut s).unwrap();
assert_eq!(s, "9,9\n");
- let mut g = repeat(vec![0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8])
+ let mut g = repeat(vec![0, 0, 0, 0, 0, 0, 0, 0, 0])
.take(10).collect::<Vec<_>>();
for line in reader.lines() {
let line = line.unwrap();
// solve sudoku grid
pub fn solve(&mut self) {
let mut work: Vec<(u8, u8)> = Vec::new(); /* queue of uncolored fields */
- for row in 0u8..9u8 {
- for col in 0u8..9u8 {
+ for row in 0..9 {
+ for col in 0..9 {
let color = self.grid[row as usize][col as usize];
- if color == 0u8 {
+ if color == 0 {
work.push((row, col));
}
}
}
fn next_color(&mut self, row: u8, col: u8, start_color: u8) -> bool {
- if start_color < 10u8 {
+ if start_color < 10 {
// colors not yet used
let mut avail: Box<_> = box Colors::new(start_color);
// find first remaining color that is available
let next = avail.next();
self.grid[row as usize][col as usize] = next;
- return 0u8 != next;
+ return 0 != next;
}
- self.grid[row as usize][col as usize] = 0u8;
+ self.grid[row as usize][col as usize] = 0;
return false;
}
// find colors available in neighbourhood of (row, col)
fn drop_colors(&mut self, avail: &mut Colors, row: u8, col: u8) {
- for idx in 0u8..9u8 {
+ for idx in 0..9 {
/* check same column fields */
avail.remove(self.grid[idx as usize][col as usize]);
/* check same row fields */
}
// check same block fields
- let row0 = (row / 3u8) * 3u8;
- let col0 = (col / 3u8) * 3u8;
- for alt_row in row0..row0 + 3u8 {
- for alt_col in col0..col0 + 3u8 {
+ let row0 = (row / 3) * 3;
+ let col0 = (col / 3) * 3;
+ for alt_row in row0..row0 + 3 {
+ for alt_col in col0..col0 + 3 {
avail.remove(self.grid[alt_row as usize][alt_col as usize]);
}
}
// Stores available colors as simple bitfield, bit 0 is always unset
struct Colors(u16);
-static HEADS: u16 = (1u16 << 10) - 1; /* bits 9..0 */
+static HEADS: u16 = (1 << 10) - 1; /* bits 9..0 */
impl Colors {
fn new(start_color: u8) -> Colors {
// Sets bits 9..start_color
- let tails = !0u16 << start_color as usize;
+ let tails = !0 << start_color as usize;
return Colors(HEADS & tails);
}
fn next(&self) -> u8 {
let Colors(c) = *self;
let val = c & HEADS;
- if 0u16 == val {
- return 0u8;
+ if 0 == val {
+ return 0;
} else {
return val.trailing_zeros() as u8
}
}
fn remove(&mut self, color: u8) {
- if color != 0u8 {
+ if color != 0 {
let Colors(val) = *self;
- let mask = !(1u16 << color as usize);
+ let mask = !(1 << color as usize);
*self = Colors(val & mask);
}
}
static DEFAULT_SUDOKU: [[u8;9];9] = [
/* 0 1 2 3 4 5 6 7 8 */
- /* 0 */ [0u8, 4u8, 0u8, 6u8, 0u8, 0u8, 0u8, 3u8, 2u8],
- /* 1 */ [0u8, 0u8, 8u8, 0u8, 2u8, 0u8, 0u8, 0u8, 0u8],
- /* 2 */ [7u8, 0u8, 0u8, 8u8, 0u8, 0u8, 0u8, 0u8, 0u8],
- /* 3 */ [0u8, 0u8, 0u8, 5u8, 0u8, 0u8, 0u8, 0u8, 0u8],
- /* 4 */ [0u8, 5u8, 0u8, 0u8, 0u8, 3u8, 6u8, 0u8, 0u8],
- /* 5 */ [6u8, 8u8, 0u8, 0u8, 0u8, 0u8, 0u8, 9u8, 0u8],
- /* 6 */ [0u8, 9u8, 5u8, 0u8, 0u8, 6u8, 0u8, 7u8, 0u8],
- /* 7 */ [0u8, 0u8, 0u8, 0u8, 4u8, 0u8, 0u8, 6u8, 0u8],
- /* 8 */ [4u8, 0u8, 0u8, 0u8, 0u8, 7u8, 2u8, 0u8, 3u8]
+ /* 0 */ [0, 4, 0, 6, 0, 0, 0, 3, 2],
+ /* 1 */ [0, 0, 8, 0, 2, 0, 0, 0, 0],
+ /* 2 */ [7, 0, 0, 8, 0, 0, 0, 0, 0],
+ /* 3 */ [0, 0, 0, 5, 0, 0, 0, 0, 0],
+ /* 4 */ [0, 5, 0, 0, 0, 3, 6, 0, 0],
+ /* 5 */ [6, 8, 0, 0, 0, 0, 0, 9, 0],
+ /* 6 */ [0, 9, 5, 0, 0, 6, 0, 7, 0],
+ /* 7 */ [0, 0, 0, 0, 4, 0, 0, 6, 0],
+ /* 8 */ [4, 0, 0, 0, 0, 7, 2, 0, 3]
];
#[cfg(test)]
static DEFAULT_SOLUTION: [[u8;9];9] = [
/* 0 1 2 3 4 5 6 7 8 */
- /* 0 */ [1u8, 4u8, 9u8, 6u8, 7u8, 5u8, 8u8, 3u8, 2u8],
- /* 1 */ [5u8, 3u8, 8u8, 1u8, 2u8, 9u8, 7u8, 4u8, 6u8],
- /* 2 */ [7u8, 2u8, 6u8, 8u8, 3u8, 4u8, 1u8, 5u8, 9u8],
- /* 3 */ [9u8, 1u8, 4u8, 5u8, 6u8, 8u8, 3u8, 2u8, 7u8],
- /* 4 */ [2u8, 5u8, 7u8, 4u8, 9u8, 3u8, 6u8, 1u8, 8u8],
- /* 5 */ [6u8, 8u8, 3u8, 7u8, 1u8, 2u8, 5u8, 9u8, 4u8],
- /* 6 */ [3u8, 9u8, 5u8, 2u8, 8u8, 6u8, 4u8, 7u8, 1u8],
- /* 7 */ [8u8, 7u8, 2u8, 3u8, 4u8, 1u8, 9u8, 6u8, 5u8],
- /* 8 */ [4u8, 6u8, 1u8, 9u8, 5u8, 7u8, 2u8, 8u8, 3u8]
+ /* 0 */ [1, 4, 9, 6, 7, 5, 8, 3, 2],
+ /* 1 */ [5, 3, 8, 1, 2, 9, 7, 4, 6],
+ /* 2 */ [7, 2, 6, 8, 3, 4, 1, 5, 9],
+ /* 3 */ [9, 1, 4, 5, 6, 8, 3, 2, 7],
+ /* 4 */ [2, 5, 7, 4, 9, 3, 6, 1, 8],
+ /* 5 */ [6, 8, 3, 7, 1, 2, 5, 9, 4],
+ /* 6 */ [3, 9, 5, 2, 8, 6, 4, 7, 1],
+ /* 7 */ [8, 7, 2, 3, 4, 1, 9, 6, 5],
+ /* 8 */ [4, 6, 1, 9, 5, 7, 2, 8, 3]
];
#[test]
fn colors_new_works() {
- assert_eq!(*Colors::new(1), 1022u16);
- assert_eq!(*Colors::new(2), 1020u16);
- assert_eq!(*Colors::new(3), 1016u16);
- assert_eq!(*Colors::new(4), 1008u16);
- assert_eq!(*Colors::new(5), 992u16);
- assert_eq!(*Colors::new(6), 960u16);
- assert_eq!(*Colors::new(7), 896u16);
- assert_eq!(*Colors::new(8), 768u16);
- assert_eq!(*Colors::new(9), 512u16);
+ assert_eq!(*Colors::new(1), 1022);
+ assert_eq!(*Colors::new(2), 1020);
+ assert_eq!(*Colors::new(3), 1016);
+ assert_eq!(*Colors::new(4), 1008);
+ assert_eq!(*Colors::new(5), 992);
+ assert_eq!(*Colors::new(6), 960);
+ assert_eq!(*Colors::new(7), 896);
+ assert_eq!(*Colors::new(8), 768);
+ assert_eq!(*Colors::new(9), 512);
}
#[test]
fn colors_next_works() {
- assert_eq!(Colors(0).next(), 0u8);
- assert_eq!(Colors(2).next(), 1u8);
- assert_eq!(Colors(4).next(), 2u8);
- assert_eq!(Colors(8).next(), 3u8);
- assert_eq!(Colors(16).next(), 4u8);
- assert_eq!(Colors(32).next(), 5u8);
- assert_eq!(Colors(64).next(), 6u8);
- assert_eq!(Colors(128).next(), 7u8);
- assert_eq!(Colors(256).next(), 8u8);
- assert_eq!(Colors(512).next(), 9u8);
- assert_eq!(Colors(1024).next(), 0u8);
+ assert_eq!(Colors(0).next(), 0);
+ assert_eq!(Colors(2).next(), 1);
+ assert_eq!(Colors(4).next(), 2);
+ assert_eq!(Colors(8).next(), 3);
+ assert_eq!(Colors(16).next(), 4);
+ assert_eq!(Colors(32).next(), 5);
+ assert_eq!(Colors(64).next(), 6);
+ assert_eq!(Colors(128).next(), 7);
+ assert_eq!(Colors(256).next(), 8);
+ assert_eq!(Colors(512).next(), 9);
+ assert_eq!(Colors(1024).next(), 0);
}
#[test]
colors.remove(1);
// THEN
- assert_eq!(colors.next(), 2u8);
+ assert_eq!(colors.next(), 2);
}
#[test]
fn main() {
match () {
- Trait { x: 42_usize } => () //~ ERROR use of trait `Trait` in a struct pattern
+ Trait { x: 42 } => () //~ ERROR use of trait `Trait` in a struct pattern
}
}
// except according to those terms.
fn main() {
- let _x: i32 = [1i32, 2, 3];
+ let _x: i32 = [1, 2, 3];
//~^ ERROR mismatched types
//~| expected `i32`
- //~| found `[i32; 3]`
+ //~| found `[_; 3]`
//~| expected i32
//~| found array of 3 elements
- let x: &[i32] = &[1i32, 2, 3];
+ let x: &[i32] = &[1, 2, 3];
let _y: &i32 = x;
//~^ ERROR mismatched types
//~| expected `&i32`
let x: isize;
let y: isize;
unsafe {
- asm!("mov $1, $0" : "=r"(x) : "=r"(5_usize)); //~ ERROR operand constraint contains '='
- asm!("mov $1, $0" : "=r"(y) : "+r"(5_usize)); //~ ERROR operand constraint contains '+'
+ asm!("mov $1, $0" : "=r"(x) : "=r"(5)); //~ ERROR operand constraint contains '='
+ asm!("mov $1, $0" : "=r"(y) : "+r"(5)); //~ ERROR operand constraint contains '+'
}
foo(x);
foo(y);
x = 1; //~ NOTE prior assignment occurs here
foo(x);
unsafe {
- asm!("mov $1, $0" : "=r"(x) : "r"(5_usize));
+ asm!("mov $1, $0" : "=r"(x) : "r"(5));
//~^ ERROR re-assignment of immutable variable `x`
}
foo(x);
pub fn main() {
let x: isize;
unsafe {
- asm!("mov $1, $0" : "r"(x) : "r"(5_usize)); //~ ERROR output operand constraint lacks '='
+ asm!("mov $1, $0" : "r"(x) : "r"(5)); //~ ERROR output operand constraint lacks '='
}
foo(x);
}
}
impl cat {
- pub fn speak(&self) { self.meows += 1_usize; }
+ pub fn speak(&self) { self.meows += 1; }
}
fn cat(in_x : usize, in_y : isize) -> cat {
}
fn main() {
- let nyan : cat = cat(52_usize, 99);
+ let nyan : cat = cat(52, 99);
nyan.speak = || println!("meow"); //~ ERROR attempted to take value of method
}
// Tests that a function with a ! annotation always actually fails
fn bad_bang(i: usize) -> ! {
- return 7_usize; //~ ERROR `return` in a function declared as diverging [E0166]
+ return 7; //~ ERROR `return` in a function declared as diverging [E0166]
}
fn main() { bad_bang(5); }
// Tests that a function with a ! annotation always actually fails
fn bad_bang(i: usize) -> ! { //~ ERROR computation may converge in a function marked as diverging
- if i < 0_usize { } else { panic!(); }
+ if i < 0 { } else { panic!(); }
}
fn main() { bad_bang(5); }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-static i: String = 10i32;
+static i: String = 10;
//~^ ERROR mismatched types
//~| expected `collections::string::String`
-//~| found `i32`
+//~| found `_`
//~| expected struct `collections::string::String`
-//~| found i32
+//~| found integral variable
fn main() { println!("{}", i); }
// except according to those terms.
fn foo<T:'static>() {
- 1_usize.bar::<T>(); //~ ERROR `core::marker::Send` is not implemented
+ 1.bar::<T>(); //~ ERROR `core::marker::Send` is not implemented
}
trait bar {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// error-pattern:`&&` cannot be applied to type `i32`
+// error-pattern:`&&` cannot be applied to type `_`
-fn main() { let x = 1i32 && 2i32; }
+fn main() { let x = 1 && 2; }
fn main() {
// By-ref captures
{
- let mut x = 0_usize;
+ let mut x = 0;
let _f = to_fn(|| x = 42); //~ ERROR cannot assign
- let mut y = 0_usize;
+ let mut y = 0;
let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow
- let mut z = 0_usize;
+ let mut z = 0;
let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign
}
// By-value captures
{
- let mut x = 0_usize;
+ let mut x = 0;
let _f = to_fn(move || x = 42); //~ ERROR cannot assign
- let mut y = 0_usize;
+ let mut y = 0;
let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow
- let mut z = 0_usize;
+ let mut z = 0;
let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign
}
}
}
fn blah() {
- let f = &Foo::Foo1(box 1u32, box 2u32);
+ let f = &Foo::Foo1(box 1, box 2);
match *f { //~ ERROR cannot move out of
Foo::Foo1(num1, //~ NOTE attempting to move value to here
num2) => (), //~ NOTE and here
#![allow(dead_code)]
fn main() {
// Original borrow ends at end of function
- let mut x = 1_usize;
+ let mut x = 1;
let y = &mut x;
let z = &x; //~ ERROR cannot borrow
}
match true {
true => {
// Original borrow ends at end of match arm
- let mut x = 1_usize;
+ let mut x = 1;
let y = &x;
let z = &mut x; //~ ERROR cannot borrow
}
fn bar() {
// Original borrow ends at end of closure
|| {
- let mut x = 1_usize;
+ let mut x = 1;
let y = &mut x;
let z = &mut x; //~ ERROR cannot borrow
};
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+macro_rules! foo {
+ () => {
+ #[cfg_attr(all(), unknown)] //~ ERROR `unknown` is currently unknown
+ fn foo() {}
+ }
+}
+
+foo!();
+
+fn main() {}
}
fn main() {
- let nyan = cat(0_usize);
+ let nyan = cat(0);
}
fn sleep(&self) { loop{} }
fn meow(&self) {
println!("Meow");
- meows += 1_usize; //~ ERROR unresolved name
+ meows += 1; //~ ERROR unresolved name
sleep(); //~ ERROR unresolved name
}
// Tests that we forbid coercion from `[T; n]` to `&[T]`
fn main() {
- let _: &[i32] = [0i32];
+ let _: &[i32] = [0];
//~^ ERROR mismatched types
//~| expected `&[i32]`
- //~| found `[i32; 1]`
+ //~| found `[_; 1]`
//~| expected &-ptr
//~| found array of 1 elements
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-const A: usize = { 1_usize; 2 };
+const A: usize = { 1; 2 };
//~^ ERROR: blocks in constants are limited to items and tail expressions
const B: usize = { { } 2 };
}
const C: usize = { foo!(); 2 };
-const D: usize = { let x = 4_usize; 2 };
+const D: usize = { let x = 4; 2 };
//~^ ERROR: blocks in constants are limited to items and tail expressions
pub fn main() {
struct A<T>
where T : Trait,
T : Add<T::Item>
- //~^ ERROR illegal recursive type
+ //~^ ERROR unsupported cyclic reference between types/traits detected
{
data: T
}
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test a cycle where a type parameter on a trait has a default that
+// again references the trait.
+
+trait Foo<X = Box<Foo>> {
+ //~^ ERROR unsupported cyclic reference
+}
+
+fn main() { }
// a direct participant in the cycle.
trait A: B {
+ //~^ ERROR unsupported cyclic reference
}
-trait B: C { }
+trait B: C {
+ //~^ ERROR unsupported cyclic reference
+}
trait C: B { }
//~^ ERROR unsupported cyclic reference
impl T for S { }
#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums
-static s: usize = 0_usize;
+static s: usize = 0;
#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums
-const c: usize = 0_usize;
+const c: usize = 0;
#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums
mod m { }
fn main() {
let b = {
- let a = Box::new(RefCell::new(4i8));
- *a.borrow() + 1i8 //~ ERROR `*a` does not live long enough
+ let a = Box::new(RefCell::new(4));
+ *a.borrow() + 1 //~ ERROR `*a` does not live long enough
};
println!("{}", b);
}
+++ /dev/null
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-trait Foo {}
-
-fn foo<T: Foo + Foo>() {} //~ ERROR `Foo` already appears in the list of bounds
-
-fn main() {}
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+macro_rules! bar {
+ () => {
+ // more layers don't help:
+ #[allow_internal_unstable]
+ macro_rules! baz { //~ ERROR allow_internal_unstable side-steps
+ () => {}
+ }
+ }
+}
+
+bar!();
+
+fn main() {}
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps
+macro_rules! foo {
+ () => {}
+}
+
+fn main() {}
// test. Not ideal, but oh well :(
fn main() {
- let a = &[1i32, 2, 3];
+ let a = &[1, 2, 3];
println!("{}", {
extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change
fn atomic_fence();
mod circ1 {
pub use circ2::f2;
pub fn f1() { println!("f1"); }
- pub fn common() -> usize { return 0_usize; }
+ pub fn common() -> usize { return 0; }
}
mod circ2 {
pub use circ1::f1;
pub fn f2() { println!("f2"); }
- pub fn common() -> usize { return 1_usize; }
+ pub fn common() -> usize { return 1; }
}
mod test {
// except according to those terms.
fn main() {
- (return)[0_usize]; //~ ERROR the type of this value must be known in this context
+ (return)[0]; //~ ERROR the type of this value must be known in this context
}
}
fn function<T:ToOpt + Clone>(counter: usize, t: T) {
- if counter > 0_usize {
- function(counter - 1_usize, t.to_option());
+ if counter > 0 {
+ function(counter - 1, t.to_option());
// FIXME(#4287) Error message should be here. It should be
// a type error to instantiate `test` at a type other than T.
}
}
fn main() {
- function(22_usize, 22_usize);
+ function(22, 22);
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// error-pattern: illegal recursive type
-
-
type x = Vec<x>;
+//~^ ERROR unsupported cyclic reference
fn main() { let b: x = Vec::new(); }
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// this has to be separate to internal-unstable.rs because these tests
+// have error messages pointing deep into the internals of the
+// cross-crate macros, and hence need to use error-pattern instead of
+// the // ~ form.
+
+// aux-build:internal_unstable.rs
+// error-pattern:use of unstable library feature 'function'
+// error-pattern:use of unstable library feature 'struct_field'
+// error-pattern:compilation successful
+#![feature(rustc_attrs)]
+
+#[macro_use]
+extern crate internal_unstable;
+
+#[rustc_error]
+fn main() {
+ call_unstable_noallow!();
+
+ construct_unstable_noallow!(0);
+}
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:internal_unstable.rs
+
+#![feature(rustc_attrs)]
+#![allow(dead_code)]
+
+extern crate internal_unstable;
+
+
+thread_local!(static FOO: () = ());
+thread_local!(static BAR: () = internal_unstable::unstable()); //~ WARN use of unstable
+
+#[rustc_error]
+fn main() {} //~ ERROR
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:internal_unstable.rs
+
+#![feature(rustc_attrs, allow_internal_unstable)]
+
+#[macro_use]
+extern crate internal_unstable;
+
+macro_rules! foo {
+ ($e: expr, $f: expr) => {{
+ $e;
+ $f;
+ internal_unstable::unstable(); //~ WARN use of unstable
+ }}
+}
+
+#[allow_internal_unstable]
+macro_rules! bar {
+ ($e: expr) => {{
+ foo!($e,
+ internal_unstable::unstable());
+ internal_unstable::unstable();
+ }}
+}
+
+#[rustc_error]
+fn main() { //~ ERROR
+ // ok, the instability is contained.
+ call_unstable_allow!();
+ construct_unstable_allow!(0);
+
+ // bad.
+ pass_through_allow!(internal_unstable::unstable()); //~ WARN use of unstable
+
+ pass_through_noallow!(internal_unstable::unstable()); //~ WARN use of unstable
+
+
+
+ println!("{:?}", internal_unstable::unstable()); //~ WARN use of unstable
+
+ bar!(internal_unstable::unstable()); //~ WARN use of unstable
+}
// except according to those terms.
fn blah() -> i32 { //~ ERROR not all control paths return a value
- 1i32
+ 1
; //~ HELP consider removing this semicolon:
}
{
let cont_iter = cont.iter();
//~^ ERROR cannot infer an appropriate lifetime for autoref due to conflicting requirements
- let result = cont_iter.fold(Some(0u16), |state, val| {
+ let result = cont_iter.fold(Some(0), |state, val| {
state.map_or(None, |mask| {
let bit = 1 << val;
if mask & bit == 0 {Some(mask|bit)} else {None}
}
fn main() {
- check((3_usize, 5_usize));
+ check((3, 5));
//~^ ERROR mismatched types
//~| expected `&_`
-//~| found `(usize, usize)`
+//~| found `(_, _)`
//~| expected &-ptr
//~| found tuple
}
// The expected arm type `Option<T>` has one type parameter, while
// the actual arm `Result<T, E>` has two. typeck should not be
// tricked into looking up a non-existing second type parameter.
- let _x: usize = match Some(1_usize) {
+ let _x: usize = match Some(1) {
Ok(u) => u,
//~^ ERROR mismatched types
- //~| expected `core::option::Option<usize>`
+ //~| expected `core::option::Option<_>`
//~| found `core::result::Result<_, _>`
//~| expected enum `core::option::Option`
//~| found enum `core::result::Result`
Err(e) => panic!(e)
//~^ ERROR mismatched types
- //~| expected `core::option::Option<usize>`
+ //~| expected `core::option::Option<_>`
//~| found `core::result::Result<_, _>`
//~| expected enum `core::option::Option`
//~| found enum `core::result::Result`
//~| expected u8
//~| found array of 1 elements
- let local = [0u8];
+ let local = [0];
let _v = &local as *mut u8;
//~^ ERROR mismatched types
//~| expected `*mut u8`
- //~| found `&[u8; 1]`
+ //~| found `&[_; 1]`
//~| expected u8,
//~| found array of 1 elements
}
struct List<'a, T: ListItem<'a>> {
//~^ ERROR the parameter type `T` may not live long enough
-//~^^ HELP consider adding an explicit lifetime bound
-//~^^^ NOTE ...so that the reference type `&'a [T]` does not outlive the data it points at
+//~^^ NOTE ...so that the reference type `&'a [T]` does not outlive the data it points at
slice: &'a [T]
}
-
+//~^ HELP consider adding an explicit lifetime bound
impl<'a, T: ListItem<'a>> Collection for List<'a, T> {
fn len(&self) -> usize {
0
}
fn main() {
- let x = 1_usize;
+ let x = 1;
let y: Foo;
// `x { ... }` should not be interpreted as a struct literal here
fn main() {
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
- (|| Box::new(*[0_usize].as_slice()))();
- //~^ ERROR the trait `core::marker::Sized` is not implemented for the type `[usize]`
+ (|| Box::new(*[0].as_slice()))();
+ //~^ ERROR the trait `core::marker::Sized` is not implemented for the type `[_]`
}
const A3: usize = 1;
fn main() {
- match 1_usize {
+ match 1 {
A1 => {} //~ ERROR: static variables cannot be referenced in a pattern
A2 => {} //~ ERROR: static variables cannot be referenced in a pattern
A3 => {}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-pub static X: usize = 1_usize;
+pub static X: usize = 1;
fn main() {
- match 1_usize {
+ match 1 {
self::X => { },
//~^ ERROR static variables cannot be referenced in a pattern, use a `const` instead
_ => { },
AbstractRenderer
//~^ ERROR: the trait `core::marker::Sized` is not implemented
{
- match 0_usize {
+ match 0 {
_ => unimplemented!()
}
}
}
fn main() {
- let f = Foo::Variant(42_usize); //~ ERROR uses it like a function
+ let f = Foo::Variant(42); //~ ERROR uses it like a function
}
use std::any::Any;
use std::any::TypeId;
+use std::marker::MarkerTrait;
-pub trait Pt {}
-pub trait Rt {}
+pub trait Pt : MarkerTrait {}
+pub trait Rt : MarkerTrait {}
trait Private<P: Pt, R: Rt> {
fn call(&self, p: P, r: R);
}
-pub trait Public: Private<
+pub trait Public: Private< //~ ERROR private trait in exported type parameter bound
<Self as Public>::P,
-//~^ ERROR illegal recursive type; insert an enum or struct in the cycle, if this is desired
<Self as Public>::R
-//~^ ERROR unsupported cyclic reference between types/traits detected
> {
type P;
type R;
}
fn main() {
- let s = &mut 1_usize;
+ let s = &mut 1;
MyPtr(s).poke(s);
//~^ ERROR cannot borrow `*s` as mutable more than once at a time
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
fn main() {
- let mut y = 1_usize;
+ let mut y = 1;
let c = RefCell::new(vec![]);
c.push(Box::new(|| y = 0));
c.push(Box::new(|| y = 0));
}
fn ufcs() {
- let mut y = 1_usize;
+ let mut y = 1;
let c = RefCell::new(vec![]);
Push::push(&c, Box::new(|| y = 0));
#[inline(never)]
fn foo(b: &Bar) {
- b.foo(&0usize)
+ b.foo(&0)
//~^ ERROR the trait `Foo` is not implemented for the type `Bar`
}
fn main() {
if let Some(homura) = Some("madoka") { //~ ERROR missing an else clause
//~| expected `()`
- //~| found `i32`
+ //~| found `_`
//~| expected ()
- //~| found i32
- 765i32
+ //~| found integral variable
+ 765
};
}
}
fn mut_ptr() -> *mut T {
- unsafe { 0u8 as *mut T }
+ unsafe { 0 as *mut T }
}
fn const_ptr() -> *const T {
- unsafe { 0u8 as *const T }
+ unsafe { 0 as *const T }
}
pub fn main() {
fn fail_len(v: Vec<isize> ) -> usize {
let mut i = 3;
panic!();
- for x in &v { i += 1_usize; }
+ for x in &v { i += 1; }
//~^ ERROR: unreachable statement
return i;
}
+++ /dev/null
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// ignore-tidy-linelength
-
-use std::cmp::PartialEq;
-
-trait Hahaha: PartialEq + PartialEq {
- //~^ ERROR trait `PartialEq` already appears in the list of bounds
-}
-
-struct Lol(isize);
-
-impl Hahaha for Lol { }
-
-impl PartialEq for Lol {
- fn eq(&self, other: &Lol) -> bool { **self != **other }
- fn ne(&self, other: &Lol) -> bool { **self == **other }
-}
-
-fn main() {
- if Lol(2) == Lol(4) {
- println!("2 == 4");
- } else {
- println!("2 != 4");
- }
-}
fn bar(int_param: usize) {}
fn main() {
- let foo: [u8; 4] = [1u8; 4_usize];
+ let foo: [u8; 4] = [1; 4];
bar(foo);
//~^ ERROR mismatched types
//~| expected `usize`
impl CtxtFn for usize {
fn f8(self, i: usize) -> usize {
- i * 4_usize
+ i * 4
}
fn f9(i: usize) -> usize {
- i * 4_usize
+ i * 4
}
}
impl OtherTrait for usize {
fn f9(i: usize) -> usize {
- i * 8_usize
+ i * 8
}
}
_ => ()
}
- match &Some(42i32) {
+ match &Some(42) {
Some(x) => (),
//~^ ERROR mismatched types
- //~| expected `&core::option::Option<i32>`
+ //~| expected `&core::option::Option<_>`
//~| found `core::option::Option<_>`
//~| expected &-ptr
//~| found enum `core::option::Option`
None => ()
//~^ ERROR mismatched types
- //~| expected `&core::option::Option<i32>`
+ //~| expected `&core::option::Option<_>`
//~| found `core::option::Option<_>`
//~| expected &-ptr
//~| found enum `core::option::Option`
fn bar<F:FnOnce() + Send>(_: F) { }
fn main() {
- let x = Rc::new(3_usize);
+ let x = Rc::new(3);
bar(move|| foo(x));
//~^ ERROR `core::marker::Send` is not implemented
}
fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool {
//~^ HELP: consider using an explicit lifetime parameter as shown: fn check<'r, I: Iterator<Item = usize>, T: Itble<'r, usize, I>>(cont: &'r T)
let cont_iter = cont.iter(); //~ ERROR: cannot infer
- let result = cont_iter.fold(Some(0u16), |state, val| {
+ let result = cont_iter.fold(Some(0), |state, val| {
state.map_or(None, |mask| {
let bit = 1 << val;
if mask & bit == 0 {Some(mask|bit)} else {None}
fn main() {
field_read(Foo { x: 1, b: false, marker: std::marker::NoCopy });
field_match_in_patterns(XYZ::Z);
- field_match_in_let(Bar { x: 42_usize, b: true, _guard: () });
+ field_match_in_let(Bar { x: 42, b: true, _guard: () });
let _ = Baz { x: 0 };
}
//
// regression test for #8005
-macro_rules! test { () => { fn foo() -> i32 { 1i32; } } }
+macro_rules! test { () => { fn foo() -> i32 { 1; } } }
//~^ ERROR not all control paths return a value
//~^^ HELP consider removing this semicolon
extern crate macro_non_reexport_2;
fn main() {
- assert_eq!(reexported!(), 3_usize); //~ ERROR macro undefined
+ assert_eq!(reexported!(), 3); //~ ERROR macro undefined
}
extern crate macro_reexport_1;
fn main() {
- assert_eq!(reexported!(), 3_usize); //~ ERROR macro undefined
+ assert_eq!(reexported!(), 3); //~ ERROR macro undefined
}
//~| found `Foo`
//~| expected &-ptr
//~| found struct `Foo`
- Foo::bar(&42i32); //~ ERROR mismatched types
+ Foo::bar(&42); //~ ERROR mismatched types
//~| expected `&Foo`
- //~| found `&i32`
+ //~| found `&_`
//~| expected struct `Foo`
- //~| found i32
+ //~| found integral variable
}
// except according to those terms.
fn main() {
- let foo = &mut 1i32;
+ let foo = &mut 1;
// (separate lines to ensure the spans are accurate)
let &_ //~ ERROR mismatched types
- //~| expected `&mut i32`
+ //~| expected `&mut _`
//~| found `&_`
//~| values differ in mutability
= foo;
let &mut _ = foo;
- let bar = &1i32;
+ let bar = &1;
let &_ = bar;
let &mut _ //~ ERROR mismatched types
- //~| expected `&i32`
+ //~| expected `&_`
//~| found `&mut _`
//~| values differ in mutability
= bar;
}
fn main() {
- let nyan : cat = cat(52_usize, 99);
+ let nyan : cat = cat(52, 99);
nyan.eat();
}
}
fn main() {
- let nyan : cat = cat(52_usize, 99);
+ let nyan : cat = cat(52, 99);
nyan.how_hungry = 0; //~ ERROR cannot assign
}
Foo { first: true, second: None } => (),
Foo { first: true, second: Some(_) } => (),
Foo { first: false, second: None } => (),
- Foo { first: false, second: Some([1_usize, 2_usize, 3_usize, 4_usize]) } => ()
+ Foo { first: false, second: Some([1, 2, 3, 4]) } => ()
}
}
enum blah { a(isize, isize, usize), b(isize, isize), }
-fn main() { match blah::a(1, 1, 2_usize) { blah::a(_, x, y) | blah::b(x, y) => { } } }
+fn main() { match blah::a(1, 1, 2) { blah::a(_, x, y) | blah::b(x, y) => { } } }
}
fn main() {
- let nyan : kitties::cat = kitties::cat(52_usize, 99);
+ let nyan : kitties::cat = kitties::cat(52, 99);
nyan.nap();
}
use cci_class::kitties::cat;
fn main() {
- let nyan : cat = cat(52_usize, 99);
- assert!((nyan.meows == 52_usize));
+ let nyan : cat = cat(52, 99);
+ assert!((nyan.meows == 52));
//~^ ERROR field `meows` of struct `cci_class::kitties::cat` is private
}
//~^ ERROR the trait `core::num::Int` is not implemented for the type `f32`
// Unsized type.
- let arr: &[_] = &[1u32, 2, 3];
+ let arr: &[_] = &[1, 2, 3];
let range = *arr..;
//~^ ERROR the trait `core::marker::Sized` is not implemented
}
impl dog {
pub fn chase_cat(&mut self) {
let p: &'static mut usize = &mut self.cats_chased; //~ ERROR cannot infer
- *p += 1_usize;
+ *p += 1;
}
pub fn chase_cat_2(&mut self) {
let p: &mut usize = &mut self.cats_chased;
- *p += 1_usize;
+ *p += 1;
}
}
fn dog() -> dog {
dog {
- cats_chased: 0_usize
+ cats_chased: 0
}
}
pub fn chase_cat(&mut self) {
let _f = || {
let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer
- *p = 3_usize;
+ *p = 3;
};
}
}
}
fn build() {
- let x = ast::num(3_usize);
- let y = ast::num(4_usize);
+ let x = ast::num(3);
+ let y = ast::num(4);
let z = ast::add(&x, &y);
compute(&z);
}
// except according to those terms.
fn main() {
- let a0 = 0u8;
- let f = 1u8;
+ let a0 = 0;
+ let f = 1;
let mut a1 = &a0;
match (&a1,) {
(&ref b0,) => {
fn main() {
// Unboxed closure case
{
- let mut x = 0_usize;
+ let mut x = 0;
let mut f = || &mut x; //~ ERROR cannot infer
let x = f();
let y = f();
}
fn main() {
- let ctxt = ctxt { v: 22_usize };
+ let ctxt = ctxt { v: 22 };
let hc = has_ctxt { c: &ctxt };
- assert_eq!(get_v(box hc as Box<get_ctxt>), 22_usize);
+ assert_eq!(get_v(box hc as Box<get_ctxt>), 22);
}
let pt = PointF {
//~^ ERROR structure constructor specifies a structure of type
//~| expected f32
- //~| found i32
- x: 1i32,
- y: 2i32,
+ //~| found integral variable
+ x: 1,
+ y: 2,
};
let pt2 = Point::<f32> {
//~^ ERROR structure constructor specifies a structure of type
//~| expected f32
- //~| found i32
- x: 3i32,
- y: 4i32,
+ //~| found integral variable
+ x: 3,
+ y: 4,
};
let pair = PairF {
//~^ ERROR structure constructor specifies a structure of type
//~| expected f32
- //~| found i32
- x: 5i32,
- y: 6i32,
+ //~| found integral variable
+ x: 5,
+ y: 6,
};
let pair2 = PairF::<i32> {
//~^ ERROR structure constructor specifies a structure of type
//~| expected f32
- //~| found i32
- x: 7i32,
- y: 8i32,
+ //~| found integral variable
+ x: 7,
+ y: 8,
};
let pt3 = PointF::<i32> {
//~^ ERROR wrong number of type arguments
//~| ERROR structure constructor specifies a structure of type
- x: 9i32,
- y: 10i32,
+ x: 9,
+ y: 10,
};
}
fn f() -> isize { return g(); }
-fn g() -> usize { return 0_usize; }
+fn g() -> usize { return 0; }
fn main() { let y = f(); }
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test case where an associated type is referenced from within the
+// supertrait definition, and the impl makes the wrong
+// associations. Issue #20220.
+
+use std::vec::IntoIter;
+
+pub trait Foo: Iterator<Item=<Self as Foo>::Key> {
+ type Key;
+}
+
+impl Foo for IntoIter<i32> { //~ ERROR type mismatch
+ type Key = u32;
+}
+
+fn main() {
+}
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// A variant of traits-issue-23003 in which an infinite series of
+// types are required. This currently creates an overflow. This test
+// is included to ensure that some controlled failure, at least,
+// results -- but it might be that we should adjust the rules somewhat
+// to make this legal. -nmatsakis
+
+use std::marker::PhantomData;
+
+trait Async {
+ type Cancel;
+}
+
+struct Receipt<A:Async> {
+ marker: PhantomData<A>,
+}
+
+struct Complete<B> {
+ core: Option<B>,
+}
+
+impl<B> Async for Complete<B> {
+ type Cancel = Receipt<Complete<Option<B>>>;
+}
+
+fn foo(r: Receipt<Complete<()>>) { }
+//~^ ERROR overflow
+
+fn main() { }
}
fn a() {
- test(22_i32, std::default::Default::default()); //~ ERROR type annotations required
+ test(22, std::default::Default::default()); //~ ERROR type annotations required
}
fn main() {}
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test a case of a trait which extends the same supertrait twice, but
+// with difference type parameters. Test then that when we don't give
+// enough information to pick between these, no selection is made. In
+// this particular case, the two choices are i64/u64 -- so when we use
+// an integer literal, we wind up falling this literal back to i32.
+// See also `run-pass/trait-repeated-supertrait.rs`.
+
+trait CompareTo<T> {
+ fn same_as(&self, t: T) -> bool;
+}
+
+trait CompareToInts : CompareTo<i64> + CompareTo<u64> {
+}
+
+impl CompareTo<i64> for i64 {
+ fn same_as(&self, t: i64) -> bool { *self == t }
+}
+
+impl CompareTo<u64> for i64 {
+ fn same_as(&self, t: u64) -> bool { *self == (t as i64) }
+}
+
+impl CompareToInts for i64 { }
+
+fn with_obj(c: &CompareToInts) -> bool {
+ c.same_as(22) //~ ERROR `CompareTo<i32>` is not implemented
+}
+
+fn with_trait<C:CompareToInts>(c: &C) -> bool {
+ c.same_as(22) //~ ERROR `CompareTo<i32>` is not implemented
+}
+
+fn with_ufcs1<C:CompareToInts>(c: &C) -> bool {
+ CompareToInts::same_as(c, 22) //~ ERROR `CompareTo<i32>` is not implemented
+}
+
+fn with_ufcs2<C:CompareToInts>(c: &C) -> bool {
+ CompareTo::same_as(c, 22) //~ ERROR `CompareTo<i32>` is not implemented
+}
+
+fn main() {
+ assert_eq!(22_i64.same_as(22), true); //~ ERROR `CompareTo<i32>` is not implemented
+}
struct Point(i32, i32);
fn main() {
- let origin = Point(0i32, 0i32);
+ let origin = Point(0, 0);
origin.0;
origin.1;
origin.2;
//~^ ERROR attempted out-of-bounds tuple index `2` on type `Point`
- let tuple = (0i32, 0i32);
+ let tuple = (0, 0);
tuple.0;
tuple.1;
tuple.2;
- //~^ ERROR attempted out-of-bounds tuple index `2` on type `(i32, i32)`
+ //~^ ERROR attempted out-of-bounds tuple index `2` on type `(_, _)`
}
// Checking that the compiler reports multiple type errors at once
-fn main() { let a: bool = 1i32; let b: i32 = true; }
+fn main() { let a: bool = 1; let b: i32 = true; }
//~^ ERROR mismatched types
//~| expected `bool`
-//~| found `i32`
+//~| found `_`
//~| expected bool
-//~| found i32
+//~| found integral variable
//~| ERROR mismatched types
//~| expected `i32`
//~| found `bool`
impl<T: Int> BrokenAdd for T {}
pub fn main() {
- let foo: u8 = 0u8;
+ let foo: u8 = 0;
let x: u8 = foo.broken_add("hello darkness my old friend".to_string());
println!("{}", x);
}
static TEST3: _ = "test";
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
-static TEST4: _ = 145u16;
+static TEST4: _ = 145;
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
static TEST5: (_, _) = (1, 2);
static FN_TEST3: _ = "test";
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
- static FN_TEST4: _ = 145u16;
+ static FN_TEST4: _ = 145;
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
static FN_TEST5: (_, _) = (1, 2);
fn main() {
// By-ref cases
{
- let x = Box::new(0_usize);
+ let x = Box::new(0);
let f = to_fn(|| drop(x)); //~ ERROR cannot move
}
{
- let x = Box::new(0_usize);
+ let x = Box::new(0);
let f = to_fn_mut(|| drop(x)); //~ ERROR cannot move
}
{
- let x = Box::new(0_usize);
+ let x = Box::new(0);
let f = to_fn_once(|| drop(x)); // OK -- FnOnce
}
// By-value cases
{
- let x = Box::new(0_usize);
+ let x = Box::new(0);
let f = to_fn(move || drop(x)); //~ ERROR cannot move
}
{
- let x = Box::new(0_usize);
+ let x = Box::new(0);
let f = to_fn_mut(move || drop(x)); //~ ERROR cannot move
}
{
- let x = Box::new(0_usize);
+ let x = Box::new(0);
let f = to_fn_once(move || drop(x)); // this one is ok
}
}
fn set(x: &mut usize) { *x = 0; }
fn main() {
- let x = 0_usize;
+ let x = 0;
move || x = 1; //~ ERROR cannot assign
move || set(&mut x); //~ ERROR cannot borrow
move || x = 1; //~ ERROR cannot assign
// reference cannot escape the region of that variable.
fn main() {
let _f = {
- let x = 0_usize;
+ let x = 0;
|| x //~ ERROR `x` does not live long enough
};
}
// cause borrow conflicts.
fn main() {
- let mut x = 0_usize;
+ let mut x = 0;
let f = || x += 1;
let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed
}
fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f }
fn a() {
- let n = 0u8;
+ let n = 0;
let mut f = to_fn_mut(|| { //~ ERROR closure cannot assign
n += 1;
});
}
fn b() {
- let mut n = 0u8;
+ let mut n = 0;
let mut f = to_fn_mut(|| {
n += 1; // OK
});
}
fn c() {
- let n = 0u8;
+ let n = 0;
let mut f = to_fn_mut(move || {
// If we just did a straight-forward desugaring, this would
// compile, but we do something a bit more subtle, and hence
}
fn d() {
- let mut n = 0u8;
+ let mut n = 0;
let mut f = to_fn_mut(move || {
n += 1; // OK
});
}
fn e() {
- let n = 0u8;
+ let n = 0;
let mut f = to_fn(move || {
n += 1; //~ ERROR cannot assign
});
}
fn f() {
- let mut n = 0u8;
+ let mut n = 0;
let mut f = to_fn(move || {
n += 1; //~ ERROR cannot assign
});
}
fn main() {
- let mut counter = 0_u32;
+ let mut counter = 0;
call(|| {
counter += 1;
//~^ ERROR cannot assign to data in a captured outer variable in an `Fn` closure
enum foo { a(Box<foo>, isize), b(usize), }
-fn main() { match foo::b(1_usize) { foo::b(_) | foo::a(box _, 1) => { } foo::a(_, 1) => { } } }
+fn main() { match foo::b(1) { foo::b(_) | foo::a(box _, 1) => { } foo::a(_, 1) => { } } }
fn f(p: *const u8) {
- *p = 0u8; //~ ERROR dereference of unsafe pointer requires unsafe function or block
+ *p = 0; //~ ERROR dereference of unsafe pointer requires unsafe function or block
return;
}
+++ /dev/null
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test that bounds are sized-compatible.
-
-trait T : Sized {}
-fn f<Y: ?Sized + T>() {
-//~^ERROR incompatible bounds on `Y`, bound `T` does not allow unsized type
-}
-
-pub fn main() {
-}
fn main() {
{
- let a = AffineU32(1_u32);
+ let a = AffineU32(1);
let x = foo(&a);
drop(a); //~ ERROR cannot move out of `a`
drop(x);
}
{
- let a = AffineU32(1_u32);
+ let a = AffineU32(1);
let x = bar(&a);
drop(a); //~ ERROR cannot move out of `a`
drop(x);
}
{
- let a = AffineU32(1_u32);
+ let a = AffineU32(1);
let x = baz(&a);
drop(a); //~ ERROR cannot move out of `a`
drop(x);
}
fn call_it<B:TraitB>(b: B) -> isize {
- let y = 4_usize;
+ let y = 4;
b.gimme_an_a(y) //~ ERROR the trait `TraitA` is not implemented
}
}
fn main() {
- assoc_struct(Struct { b: -1i32, b1: 0i64 });
- assoc_local(1i32);
- assoc_arg::<i32>(2i64);
- assoc_return_value(3i32);
- assoc_tuple((4i32, 5i64));
- assoc_enum(Enum::Variant1(6i32, 7i64));
- assoc_enum(Enum::Variant2(8i64, 9i32));
+ assoc_struct(Struct { b: -1, b1: 0 });
+ assoc_local(1);
+ assoc_arg::<i32>(2);
+ assoc_return_value(3);
+ assoc_tuple((4, 5));
+ assoc_enum(Enum::Variant1(6, 7));
+ assoc_enum(Enum::Variant2(8, 9));
}
fn zzz() { () }
next: Val {
val: box UniqueNode {
next: Empty,
- value: 1_u16,
+ value: 1,
}
},
- value: 0_u16,
+ value: 0,
};
let unique_unique: Box<UniqueNode<u32>> = box UniqueNode {
fn main() {
- let vi8x16 = i8x16(0i8, 1i8, 2i8, 3i8, 4i8, 5i8, 6i8, 7i8,
- 8i8, 9i8, 10i8, 11i8, 12i8, 13i8, 14i8, 15i8);
-
- let vi16x8 = i16x8(16i16, 17i16, 18i16, 19i16, 20i16, 21i16, 22i16, 23i16);
- let vi32x4 = i32x4(24i32, 25i32, 26i32, 27i32);
- let vi64x2 = i64x2(28i64, 29i64);
-
- let vu8x16 = u8x16(30u8, 31u8, 32u8, 33u8, 34u8, 35u8, 36u8, 37u8,
- 38u8, 39u8, 40u8, 41u8, 42u8, 43u8, 44u8, 45u8);
- let vu16x8 = u16x8(46u16, 47u16, 48u16, 49u16, 50u16, 51u16, 52u16, 53u16);
- let vu32x4 = u32x4(54u32, 55u32, 56u32, 57u32);
- let vu64x2 = u64x2(58u64, 59u64);
+ let vi8x16 = i8x16(0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15);
+
+ let vi16x8 = i16x8(16, 17, 18, 19, 20, 21, 22, 23);
+ let vi32x4 = i32x4(24, 25, 26, 27);
+ let vi64x2 = i64x2(28, 29);
+
+ let vu8x16 = u8x16(30, 31, 32, 33, 34, 35, 36, 37,
+ 38, 39, 40, 41, 42, 43, 44, 45);
+ let vu16x8 = u16x8(46, 47, 48, 49, 50, 51, 52, 53);
+ let vu32x4 = u32x4(54, 55, 56, 57);
+ let vu64x2 = u64x2(58, 59);
let vf32x4 = f32x4(60.5f32, 61.5f32, 62.5f32, 63.5f32);
let vf64x2 = f64x2(64.5f64, 65.5f64);
}
fn main() {
- let nyan = cat(0us);
+ let nyan = cat(0);
}
// except according to those terms.
fn main() {
- let __isize = 0xff_ffff_ffff_ffff_ffff__isize;
+ let __isize = 0xff_ffff_ffff_ffff_ffff;
//~^ ERROR int literal is too large
}
1e+; //~ ERROR: expected at least one digit in exponent
0x539.0; //~ ERROR: hexadecimal float literal is not supported
99999999999999999999999999999999; //~ ERROR: int literal is too large
- 99999999999999999999999999999999u32; //~ ERROR: int literal is too large
+ 99999999999999999999999999999999; //~ ERROR: int literal is too large
0x; //~ ERROR: no valid digits
0xu32; //~ ERROR: no valid digits
0ou32; //~ ERROR: no valid digits
}
fn make_gc() -> @get_ctxt {
- let ctxt = ctxt { v: 22us };
+ let ctxt = ctxt { v: 22 };
let hc = has_ctxt { c: &ctxt };
return @hc as @get_ctxt;
//~^ ERROR source contains reference
fn a() -> uint {
- 1usize
+ 1
}
const FOO: usize = ((5 as usize) - (4 as usize) as usize);
let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]);
- let _: [(); (1usize as usize)] = ([(() as ())] as [(); 1]);
+ let _: [(); (1 as usize)] = ([(() as ())] as [(); 1]);
let _ =
(((&((([(1 as i32), (2 as i32), (3 as i32)] as [i32; 3])) as [i32; 3])
as &[i32; 3]) as *const _ as *const [i32; 3]) as
- *const [i32; (3usize as usize)] as *const [i32; 3]);
+ *const [i32; (3 as usize)] as *const [i32; 3]);
const FOO: usize = 5 - 4;
let _: [(); FOO] = [()];
- let _ : [(); 1usize] = [()];
+ let _ : [(); 1] = [()];
- let _ = &([1,2,3]) as *const _ as *const [i32; 3usize];
+ let _ = &([1,2,3]) as *const _ as *const [i32; 3];
format!("test");
}
}
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
- if data == 1_usize {
+ if data == 1 {
data
} else {
- count(data - 1_usize) + count(data - 1_usize)
+ count(data - 1) + count(data - 1)
}
}
}
fn main() {
- for _ in 0..10_usize {
+ for _ in 0..10 {
task::spawn(move|| {
- let result = count(5_usize);
+ let result = count(5);
println!("result = %?", result);
panic!();
});
// error-pattern:Number is odd
fn even(x: uint) -> bool {
- if x < 2_usize {
+ if x < 2 {
return false;
- } else if x == 2_usize { return true; } else { return even(x - 2_usize); }
+ } else if x == 2 { return true; } else { return even(x - 2); }
}
fn foo(x: uint) {
}
}
-fn main() { foo(3_usize); }
+fn main() { foo(3); }
digraph block {
N0[label="entry"];
N1[label="exit"];
- N2[label="expr 2usize"];
- N3[label="expr 0usize"];
- N4[label="expr 20usize"];
- N5[label="expr [2usize, 0usize, 20usize]"];
+ N2[label="expr 2"];
+ N3[label="expr 0"];
+ N4[label="expr 20"];
+ N5[label="expr [2, 0, 20]"];
N6[label="local v"];
- N7[label="stmt let v = [2usize, 0usize, 20usize];"];
+ N7[label="stmt let v = [2, 0, 20];"];
N8[label="expr v"];
- N9[label="expr 20usize"];
- N10[label="expr v[20usize]"];
- N11[label="stmt v[20usize];"];
- N12[label="block { let v = [2usize, 0usize, 20usize]; v[20usize]; }"];
+ N9[label="expr 20"];
+ N10[label="expr v[20]"];
+ N11[label="stmt v[20];"];
+ N12[label="block { let v = [2, 0, 20]; v[20]; }"];
N0 -> N2;
N2 -> N3;
N3 -> N4;
// except according to those terms.
pub fn expr_index_20() {
- let v = [2_usize, 0_usize, 20_usize];
- v[20_usize];
+ let v = [2, 0, 20];
+ v[20];
}
// buglink test - see issue #1337.
fn test_alias<I: Iterator>(i: Option<<I as Iterator>::Item>) {
- let s = sub_struct{ field2: 45u32, };
+ let s = sub_struct{ field2: 45, };
// import tests
fn foo(x: &Float) {}
let _: Option<u8> = from_i32(45);
- let x = 42_usize;
+ let x = 42;
myflate::deflate_bytes(&[]);
- let x = (3, 4_usize);
+ let x = (3, 4);
let y = x.1;
}
pub fn dummy() {
// force the vtable to be created
- let _x = &1_usize as &Foo;
+ let _x = &1 as &Foo;
}
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
let _m: Vec<syntax::ast::TokenTree> = quote_matcher!(cx, $($foo:tt,)* bar);
let _n: syntax::ast::Attribute = quote_attr!(cx, #![cfg(foo, bar = "baz")]);
+
+ let _o: Option<P<syntax::ast::Item>> = quote_item!(cx, fn foo<T: ?Sized>() {});
}
fn main() {
struct RawT {struct_: sty, cname: Option<String>, hash: uint}
fn mk_raw_ty(st: sty, cname: Option<String>) -> RawT {
- return RawT {struct_: st, cname: cname, hash: 0_usize};
+ return RawT {struct_: st, cname: cname, hash: 0};
}
pub fn main() { mk_raw_ty(sty::ty_nil, None::<String>); }
fn main() {
let x = get(22);
- assert_eq!(22_usize, x);
+ assert_eq!(22, x);
}
pub fn main() {
let a = 42;
- assert!(foo2(a) == 42_usize);
+ assert!(foo2(a) == 42);
let a = Bar;
assert!(foo2(a) == 43);
pub fn main() {
let node: Node<i32> = Node { key: 1, value: Some(22) };
- assert_eq!(foo(&node), Some(22_u32));
+ assert_eq!(foo(&node), Some(22));
let node: Node<u32> = Node { key: 1, value: Some(22) };
- assert_eq!(foo(&node), Some(22_i32));
+ assert_eq!(foo(&node), Some(22));
}
pub fn main() {
let node: Node<i32> = Node(1, Some(22));
- assert_eq!(foo(&node), Some(22_u32));
+ assert_eq!(foo(&node), Some(22));
let node: Node<u32> = Node(1, Some(22));
- assert_eq!(foo(&node), Some(22_i32));
+ assert_eq!(foo(&node), Some(22));
}
}
pub fn main() {
- let z: uint = bar(2, 4_usize);
+ let z: uint = bar(2, 4);
}
enum CLike { A, B, C }
pub fn main() {
- let a = &Plus(@Minus(@Val(3_usize), @Val(10_usize)), @Plus(@Val(22_usize), @Val(5_usize)));
+ let a = &Plus(@Minus(@Val(3), @Val(10)), @Plus(@Val(22), @Val(5)));
test_rbml(a);
- let a = &Spanned {lo: 0_usize, hi: 5_usize, node: 22_usize};
+ let a = &Spanned {lo: 0, hi: 5, node: 22};
test_rbml(a);
- let a = &Point {x: 3_usize, y: 5_usize};
+ let a = &Point {x: 3, y: 5};
test_rbml(a);
- let a = &Top(22_usize);
+ let a = &Top(22);
test_rbml(a);
- let a = &Bottom(222_usize);
+ let a = &Bottom(222);
test_rbml(a);
let a = &A;
}
impl double for uint {
- fn double(self: Box<uint>) -> uint { *self * 2_usize }
+ fn double(self: Box<uint>) -> uint { *self * 2 }
}
pub fn main() {
- let x: Box<_> = box() (box 3_usize as Box<double>);
- assert_eq!(x.double(), 6_usize);
+ let x: Box<_> = box() (box 3 as Box<double>);
+ assert_eq!(x.double(), 6);
}
}
impl double for Box<uint> {
- fn double(self) -> uint { *self * 2_usize }
+ fn double(self) -> uint { *self * 2 }
}
pub fn main() {
- let x: Box<_> = box 3_usize;
- assert_eq!(x.double(), 6_usize);
+ let x: Box<_> = box 3;
+ assert_eq!(x.double(), 6);
}
}
impl double for Box<uint> {
- fn double(self: Box<Box<uint>>) -> uint { **self * 2_usize }
+ fn double(self: Box<Box<uint>>) -> uint { **self * 2 }
}
pub fn main() {
- let x: Box<Box<Box<Box<Box<_>>>>> = box box box box box 3_usize;
- assert_eq!(x.double(), 6_usize);
+ let x: Box<Box<Box<Box<Box<_>>>>> = box box box box box 3;
+ assert_eq!(x.double(), 6);
}
}
impl double for uint {
- fn double(self: Box<uint>) -> uint { *self * 2_usize }
+ fn double(self: Box<uint>) -> uint { *self * 2 }
}
pub fn main() {
- let x: Box<Box<_>> = box box 3_usize;
- assert_eq!(x.double(), 6_usize);
+ let x: Box<Box<_>> = box box 3;
+ assert_eq!(x.double(), 6);
}
}
impl double for uint {
- fn double(self: Box<uint>) -> uint { *self * 2_usize }
+ fn double(self: Box<uint>) -> uint { *self * 2 }
}
pub fn main() {
- let x: Box<_> = box 3_usize;
- assert_eq!(x.double(), 6_usize);
+ let x: Box<_> = box 3;
+ assert_eq!(x.double(), 6);
}
}
pub fn main() {
- let x: Box<_> = box 3_usize;
+ let x: Box<_> = box 3;
assert_eq!(x.foo(), "box 3".to_string());
}
// except according to those terms.
pub fn main() {
- assert_eq!(0xffffffffu32, (-1 as u32));
- assert_eq!(4294967295u32, (-1 as u32));
- assert_eq!(0xffffffffffffffffu64, (-1 as u64));
- assert_eq!(18446744073709551615u64, (-1 as u64));
+ assert_eq!(0xffffffff, (-1 as u32));
+ assert_eq!(4294967295, (-1 as u32));
+ assert_eq!(0xffffffffffffffff, (-1 as u64));
+ assert_eq!(18446744073709551615, (-1 as u64));
- assert_eq!(-2147483648i32 - 1i32, 2147483647i32);
+ assert_eq!(-2147483648 - 1, 2147483647);
}
}
pub fn main() {
- let x = asBlock(|| 22_usize);
- assert_eq!(x, 22_usize);
+ let x = asBlock(|| 22);
+ assert_eq!(x, 22);
}
fn iter_vec<T, F>(v: Vec<T> , mut f: F) where F: FnMut(&T) { for x in &v { f(x); } }
pub fn main() {
- let v = vec![1i32, 2, 3, 4, 5, 6, 7];
- let mut odds = 0i32;
+ let v = vec![1, 2, 3, 4, 5, 6, 7];
+ let mut odds = 0;
iter_vec(v, |i| {
if *i % 2 == 1 {
odds += 1;
fn iter_vec<T, F>(v: Vec<T>, mut f: F) where F: FnMut(&T) { for x in &v { f(x); } }
pub fn main() {
- let v = vec![1i32, 2, 3, 4, 5];
+ let v = vec![1, 2, 3, 4, 5];
let mut sum = 0;
iter_vec(v.clone(), |i| {
iter_vec(v.clone(), |j| {
// the closures are in scope. Issue #6801.
fn a() -> i32 {
- let mut x = 3i32;
+ let mut x = 3;
x += 1;
let c1 = || x * 4;
let c2 = || x * 5;
}
fn b() -> i32 {
- let mut x = 3i32;
+ let mut x = 3;
x += 1;
let c1 = || get(&x);
let c2 = || get(&x);
}
fn c() -> i32 {
- let mut x = 3i32;
+ let mut x = 3;
x += 1;
let c1 = || x * 5;
let c2 = || get(&x);
fn iter_ints<F>(x: &Ints, mut f: F) -> bool where F: FnMut(&int) -> bool {
let l = x.values.len();
- (0_usize..l).all(|i| f(&x.values[i]))
+ (0..l).all(|i| f(&x.values[i]))
}
pub fn main() {
}
fn main() {
- let mut sum = 0_usize;
- let elems = [ 1_usize, 2, 3, 4, 5 ];
+ let mut sum = 0;
+ let elems = [ 1, 2, 3, 4, 5 ];
each(&elems, |val: &uint| sum += *val);
assert_eq!(sum, 15);
}
assert_eq!(u, 'Q' as u32);
assert_eq!(i as u8, 'Q' as u8);
assert_eq!(i as u8 as i8, 'Q' as u8 as i8);
- assert_eq!(0x51u8 as char, 'Q');
+ assert_eq!(0x51 as char, 'Q');
assert_eq!(0 as u32, false as u32);
}
use cci_borrow_lib::foo;
pub fn main() {
- let p: Box<_> = box 22_usize;
+ let p: Box<_> = box 22;
let r = foo(&*p);
println!("r={}", r);
- assert_eq!(r, 22_usize);
+ assert_eq!(r, 22);
}
//let bt0 = sys::frame_address();
//println!("%?", bt0);
- 3_usize.to(10_usize, |i| {
+ 3.to(10, |i| {
println!("{}", i);
//let bt1 = sys::frame_address();
extern crate cci_iter_lib;
pub fn main() {
- //let bt0 = sys::rusti::frame_address(1u32);
+ //let bt0 = sys::rusti::frame_address(1);
//println!("%?", bt0);
cci_iter_lib::iter(&[1, 2, 3], |i| {
println!("{}", *i);
- //assert!(bt0 == sys::rusti::frame_address(2u32));
+ //assert!(bt0 == sys::rusti::frame_address(2));
})
}
// actually working.
//let bt0 = sys::frame_address();
//println!("%?", bt0);
- iter(vec!(1_usize, 2_usize, 3_usize), |i| {
+ iter(vec!(1, 2, 3), |i| {
println!("{}", i);
//let bt1 = sys::frame_address();
}
pub fn main() {
- let nyan: Box<ToString> = box cat(0_usize, 2, "nyan".to_string()) as Box<ToString>;
+ let nyan: Box<ToString> = box cat(0, 2, "nyan".to_string()) as Box<ToString>;
print_out(nyan, "nyan".to_string());
}
impl cat {
fn meow(&mut self) {
println!("Meow");
- self.meows += 1_usize;
- if self.meows % 5_usize == 0_usize {
+ self.meows += 1;
+ if self.meows % 5 == 0 {
self.how_hungry += 1;
}
}
pub fn main() {
- let mut nyan = cat(0_usize, 2, "nyan".to_string());
+ let mut nyan = cat(0, 2, "nyan".to_string());
let mut nyan: &mut noisy = &mut nyan;
nyan.speak();
}
fn cat(done: extern fn(uint)) -> cat {
cat {
- meows: 0_usize,
+ meows: 0,
done: done
}
}
pub fn cat(in_name: String) -> cat {
cat {
name: in_name,
- meows: 0_usize
+ meows: 0
}
}
}
use cci_class_2::kitties::cat;
pub fn main() {
- let nyan : cat = cat(52_usize, 99);
- let kitty = cat(1000_usize, 2);
+ let nyan : cat = cat(52, 99);
+ let kitty = cat(1000, 2);
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
nyan.speak();
use cci_class_3::kitties::cat;
pub fn main() {
- let mut nyan : cat = cat(52_usize, 99);
- let kitty = cat(1000_usize, 2);
+ let mut nyan : cat = cat(52, 99);
+ let kitty = cat(1000, 2);
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
nyan.speak();
- assert_eq!(nyan.meow_count(), 53_usize);
+ assert_eq!(nyan.meow_count(), 53);
}
}
impl cat {
- pub fn speak(&mut self) { self.meows += 1_usize; }
+ pub fn speak(&mut self) { self.meows += 1; }
pub fn meow_count(&mut self) -> uint { self.meows }
}
}
pub fn main() {
- let mut nyan: cat = cat(52_usize, 99);
- let kitty = cat(1000_usize, 2);
+ let mut nyan: cat = cat(52, 99);
+ let kitty = cat(1000, 2);
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
nyan.speak();
- assert_eq!(nyan.meow_count(), 53_usize);
+ assert_eq!(nyan.meow_count(), 53);
}
}
pub fn main() {
- let mut nyan : cat<int> = cat::<int>(52_usize, 99, vec!(9));
- let mut kitty = cat(1000_usize, 2, vec!("tabby".to_string()));
+ let mut nyan : cat<int> = cat::<int>(52, 99, vec!(9));
+ let mut kitty = cat(1000, 2, vec!("tabby".to_string()));
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
nyan.speak(vec!(1,2,3));
- assert_eq!(nyan.meow_count(), 55_usize);
+ assert_eq!(nyan.meow_count(), 55);
kitty.speak(vec!("meow".to_string(), "mew".to_string(), "purr".to_string(), "chirp".to_string()));
- assert_eq!(kitty.meow_count(), 1004_usize);
+ assert_eq!(kitty.meow_count(), 1004);
}
impl cat {
fn meow(&mut self) {
println!("Meow");
- self.meows += 1_usize;
- if self.meows % 5_usize == 0_usize {
+ self.meows += 1;
+ if self.meows % 5 == 0 {
self.how_hungry += 1;
}
}
}
pub fn main() {
- let nyan: Box<ToString> = box cat(0_usize, 2, "nyan".to_string()) as Box<ToString>;
+ let nyan: Box<ToString> = box cat(0, 2, "nyan".to_string()) as Box<ToString>;
print_out(nyan, "nyan".to_string());
}
}
impl<U> cat<U> {
- pub fn speak(&mut self) { self.meows += 1_usize; }
+ pub fn speak(&mut self) { self.meows += 1; }
pub fn meow_count(&mut self) -> uint { self.meows }
}
pub fn main() {
- let _nyan : cat<int> = cat::<int>(52_usize, 99);
- // let mut kitty = cat(1000_usize, 2);
+ let _nyan : cat<int> = cat::<int>(52, 99);
+ // let mut kitty = cat(1000, 2);
}
use cci_class::kitties::cat;
pub fn main() {
- let nyan : cat = cat(52_usize, 99);
- let kitty = cat(1000_usize, 2);
+ let nyan : cat = cat(52, 99);
+ let kitty = cat(1000, 2);
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
}
}
pub fn main() {
- let mut nyan : cat = cat(52_usize, 99);
- let kitty = cat(1000_usize, 2);
+ let mut nyan : cat = cat(52, 99);
+ let kitty = cat(1000, 2);
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
nyan.speak();
}
pub fn main() {
- let nyan : cat = cat(52_usize, 99);
- let kitty = cat(1000_usize, 2);
+ let nyan : cat = cat(52, 99);
+ let kitty = cat(1000, 2);
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
}
}
pub fn main() {
- let mut the_vec = vec!(1_usize, 2, 3, 100);
+ let mut the_vec = vec!(1, 2, 3, 100);
assert_eq!(the_vec.clone(), bar(&mut the_vec));
assert_eq!(the_vec.clone(), bip(&the_vec));
}
assert_eq!(concat!("qux", "quux",).to_string(), "quxquux".to_string());
assert_eq!(
- concat!(1, 2, 3_usize, 4f32, 4.0, 'a', true),
+ concat!(1, 2, 3, 4f32, 4.0, 'a', true),
"12344.0atrue"
);
assert!(match "12344.0atrue" {
- concat!(1, 2, 3_usize, 4f32, 4.0, 'a', true) => true,
+ concat!(1, 2, 3, 4f32, 4.0, 'a', true) => true,
_ => false
})
}
assert_eq!(BLOCK_FN(300), 300);
assert_eq!(BLOCK_ENUM_CONSTRUCTOR(200), Some(200));
// FIXME #13972
- // assert_eq!(BLOCK_UNSAFE_SAFE_PTR as *const isize as usize, 0xdeadbeef_us);
- // assert_eq!(BLOCK_UNSAFE_SAFE_PTR_2 as *const isize as usize, 0xdeadbeef_us);
+ // assert_eq!(BLOCK_UNSAFE_SAFE_PTR as *const isize as usize, 0xdeadbeef);
+ // assert_eq!(BLOCK_UNSAFE_SAFE_PTR_2 as *const isize as usize, 0xdeadbeef);
}
foo("hi".to_string());
foo(~[1, 2, 3]);
foo(F{field: 42});
- foo((1, 2_usize));
+ foo((1, 2));
foo(@1);*/
foo(Box::new(1));
}
// except according to those terms.
fn check_expr() {
- let _: & uint = &1_usize;
- let _: & & uint = &&1_usize;
- let _: & & & uint = &&&1_usize;
- let _: & & & uint = & &&1_usize;
- let _: & & & & uint = &&&&1_usize;
- let _: & & & & uint = & &&&1_usize;
- let _: & & & & & uint = &&&&&1_usize;
+ let _: & uint = &1;
+ let _: & & uint = &&1;
+ let _: & & & uint = &&&1;
+ let _: & & & uint = & &&1;
+ let _: & & & & uint = &&&&1;
+ let _: & & & & uint = & &&&1;
+ let _: & & & & & uint = &&&&&1;
}
fn check_ty() {
- let _: &uint = & 1_usize;
- let _: &&uint = & & 1_usize;
- let _: &&&uint = & & & 1_usize;
- let _: & &&uint = & & & 1_usize;
- let _: &&&&uint = & & & & 1_usize;
- let _: & &&&uint = & & & & 1_usize;
- let _: &&&&&uint = & & & & & 1_usize;
+ let _: &uint = & 1;
+ let _: &&uint = & & 1;
+ let _: &&&uint = & & & 1;
+ let _: & &&uint = & & & 1;
+ let _: &&&&uint = & & & & 1;
+ let _: & &&&uint = & & & & 1;
+ let _: &&&&&uint = & & & & & 1;
}
fn check_pat() {
let (sender, receiver) = channel();
{
- let v = Foo::NestedVariant(box 42_usize, SendOnDrop { sender: sender.clone() }, sender);
+ let v = Foo::NestedVariant(box 42, SendOnDrop { sender: sender.clone() }, sender);
}
assert_eq!(receiver.recv().unwrap(), Message::DestructorRan);
assert_eq!(receiver.recv().unwrap(), Message::Dropped);
let (sender, receiver) = channel();
let t = {
thread::spawn(move|| {
- let mut v = Foo::NestedVariant(box 42usize, SendOnDrop {
+ let mut v = Foo::NestedVariant(box 42, SendOnDrop {
sender: sender.clone()
}, sender.clone());
- v = Foo::NestedVariant(box 42_usize,
+ v = Foo::NestedVariant(box 42,
SendOnDrop { sender: sender.clone() },
sender.clone());
v = Foo::SimpleVariant(sender.clone());
pub fn main() {
unsafe {
- assert_eq!(22_u8, rust_dbg_extern_identity_u8(22_u8));
+ assert_eq!(22, rust_dbg_extern_identity_u8(22));
}
}
pub fn main() {
unsafe {
- assert_eq!(22_u32, rust_dbg_extern_identity_u32(22_u32));
+ assert_eq!(22, rust_dbg_extern_identity_u32(22));
}
}
pub fn main() {
unsafe {
- assert_eq!(22_u64, rust_dbg_extern_identity_u64(22_u64));
+ assert_eq!(22, rust_dbg_extern_identity_u64(22));
}
}
pub fn main() {
let len = strlen("Rust".to_string());
- assert_eq!(len, 4_usize);
+ assert_eq!(len, 4);
}
-pub fn main() { let mut x: i32 = -400_i32; x = 0_i32 - x; assert!((x == 400_i32)); }
+pub fn main() { let mut x: i32 = -400; x = 0 - x; assert!((x == 400)); }
pub fn main() {
- let mut x: i8 = -12i8;
- let y: i8 = -12i8;
- x = x + 1i8;
- x = x - 1i8;
+ let mut x: i8 = -12;
+ let y: i8 = -12;
+ x = x + 1;
+ x = x - 1;
assert_eq!(x, y);
}
// except according to those terms.
fn even(x: uint) -> bool {
- if x < 2_usize {
+ if x < 2 {
return false;
- } else if x == 2_usize { return true; } else { return even(x - 2_usize); }
+ } else if x == 2 { return true; } else { return even(x - 2); }
}
fn foo(x: uint) {
}
}
-pub fn main() { foo(2_usize); }
+pub fn main() { foo(2); }
#[cfg(target_arch = "x86")]
pub fn main() {
unsafe {
- assert_eq!(::rusti::pref_align_of::<u64>(), 8_usize);
- assert_eq!(::rusti::min_align_of::<u64>(), 4_usize);
+ assert_eq!(::rusti::pref_align_of::<u64>(), 8);
+ assert_eq!(::rusti::min_align_of::<u64>(), 4);
}
}
#[cfg(any(target_arch = "x86_64", target_arch = "arm", target_arch = "aarch64"))]
pub fn main() {
unsafe {
- assert_eq!(::rusti::pref_align_of::<u64>(), 8_usize);
- assert_eq!(::rusti::min_align_of::<u64>(), 8_usize);
+ assert_eq!(::rusti::pref_align_of::<u64>(), 8);
+ assert_eq!(::rusti::min_align_of::<u64>(), 8);
}
}
}
#[cfg(target_arch = "x86_64")]
pub fn main() {
unsafe {
- assert_eq!(::rusti::pref_align_of::<u64>(), 8u);
- assert_eq!(::rusti::min_align_of::<u64>(), 8u);
+ assert_eq!(::rusti::pref_align_of::<u64>(), 8);
+ assert_eq!(::rusti::min_align_of::<u64>(), 8);
}
}
}
#[cfg(target_arch = "x86")]
pub fn main() {
unsafe {
- assert_eq!(::rusti::pref_align_of::<u64>(), 8_usize);
- assert_eq!(::rusti::min_align_of::<u64>(), 8_usize);
+ assert_eq!(::rusti::pref_align_of::<u64>(), 8);
+ assert_eq!(::rusti::min_align_of::<u64>(), 8);
}
}
#[cfg(target_arch = "x86_64")]
pub fn main() {
unsafe {
- assert_eq!(::rusti::pref_align_of::<u64>(), 8_usize);
- assert_eq!(::rusti::min_align_of::<u64>(), 8_usize);
+ assert_eq!(::rusti::pref_align_of::<u64>(), 8);
+ assert_eq!(::rusti::min_align_of::<u64>(), 8);
}
}
}
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
pub fn main() {
unsafe {
- assert_eq!(::rusti::pref_align_of::<u64>(), 8_usize);
- assert_eq!(::rusti::min_align_of::<u64>(), 8_usize);
+ assert_eq!(::rusti::pref_align_of::<u64>(), 8);
+ assert_eq!(::rusti::min_align_of::<u64>(), 8);
}
}
}
unsafe {
use rusti::*;
- assert_eq!(ctpop8(0u8), 0u8);
- assert_eq!(ctpop16(0u16), 0u16);
- assert_eq!(ctpop32(0u32), 0u32);
- assert_eq!(ctpop64(0u64), 0u64);
-
- assert_eq!(ctpop8(1u8), 1u8);
- assert_eq!(ctpop16(1u16), 1u16);
- assert_eq!(ctpop32(1u32), 1u32);
- assert_eq!(ctpop64(1u64), 1u64);
-
- assert_eq!(ctpop8(10u8), 2u8);
- assert_eq!(ctpop16(10u16), 2u16);
- assert_eq!(ctpop32(10u32), 2u32);
- assert_eq!(ctpop64(10u64), 2u64);
-
- assert_eq!(ctpop8(100u8), 3u8);
- assert_eq!(ctpop16(100u16), 3u16);
- assert_eq!(ctpop32(100u32), 3u32);
- assert_eq!(ctpop64(100u64), 3u64);
-
- assert_eq!(ctpop8(-1u8), 8u8);
- assert_eq!(ctpop16(-1u16), 16u16);
- assert_eq!(ctpop32(-1u32), 32u32);
- assert_eq!(ctpop64(-1u64), 64u64);
-
- assert_eq!(ctlz8(0u8), 8u8);
- assert_eq!(ctlz16(0u16), 16u16);
- assert_eq!(ctlz32(0u32), 32u32);
- assert_eq!(ctlz64(0u64), 64u64);
-
- assert_eq!(ctlz8(1u8), 7u8);
- assert_eq!(ctlz16(1u16), 15u16);
- assert_eq!(ctlz32(1u32), 31u32);
- assert_eq!(ctlz64(1u64), 63u64);
-
- assert_eq!(ctlz8(10u8), 4u8);
- assert_eq!(ctlz16(10u16), 12u16);
- assert_eq!(ctlz32(10u32), 28u32);
- assert_eq!(ctlz64(10u64), 60u64);
-
- assert_eq!(ctlz8(100u8), 1u8);
- assert_eq!(ctlz16(100u16), 9u16);
- assert_eq!(ctlz32(100u32), 25u32);
- assert_eq!(ctlz64(100u64), 57u64);
-
- assert_eq!(cttz8(-1u8), 0u8);
- assert_eq!(cttz16(-1u16), 0u16);
- assert_eq!(cttz32(-1u32), 0u32);
- assert_eq!(cttz64(-1u64), 0u64);
-
- assert_eq!(cttz8(0u8), 8u8);
- assert_eq!(cttz16(0u16), 16u16);
- assert_eq!(cttz32(0u32), 32u32);
- assert_eq!(cttz64(0u64), 64u64);
-
- assert_eq!(cttz8(1u8), 0u8);
- assert_eq!(cttz16(1u16), 0u16);
- assert_eq!(cttz32(1u32), 0u32);
- assert_eq!(cttz64(1u64), 0u64);
-
- assert_eq!(cttz8(10u8), 1u8);
- assert_eq!(cttz16(10u16), 1u16);
- assert_eq!(cttz32(10u32), 1u32);
- assert_eq!(cttz64(10u64), 1u64);
-
- assert_eq!(cttz8(100u8), 2u8);
- assert_eq!(cttz16(100u16), 2u16);
- assert_eq!(cttz32(100u32), 2u32);
- assert_eq!(cttz64(100u64), 2u64);
-
- assert_eq!(cttz8(-1u8), 0u8);
- assert_eq!(cttz16(-1u16), 0u16);
- assert_eq!(cttz32(-1u32), 0u32);
- assert_eq!(cttz64(-1u64), 0u64);
-
- assert_eq!(bswap16(0x0A0Bu16), 0x0B0Au16);
- assert_eq!(bswap32(0x0ABBCC0Du32), 0x0DCCBB0Au32);
- assert_eq!(bswap64(0x0122334455667708u64), 0x0877665544332201u64);
+ assert_eq!(ctpop8(0), 0);
+ assert_eq!(ctpop16(0), 0);
+ assert_eq!(ctpop32(0), 0);
+ assert_eq!(ctpop64(0), 0);
+
+ assert_eq!(ctpop8(1), 1);
+ assert_eq!(ctpop16(1), 1);
+ assert_eq!(ctpop32(1), 1);
+ assert_eq!(ctpop64(1), 1);
+
+ assert_eq!(ctpop8(10), 2);
+ assert_eq!(ctpop16(10), 2);
+ assert_eq!(ctpop32(10), 2);
+ assert_eq!(ctpop64(10), 2);
+
+ assert_eq!(ctpop8(100), 3);
+ assert_eq!(ctpop16(100), 3);
+ assert_eq!(ctpop32(100), 3);
+ assert_eq!(ctpop64(100), 3);
+
+ assert_eq!(ctpop8(-1), 8);
+ assert_eq!(ctpop16(-1), 16);
+ assert_eq!(ctpop32(-1), 32);
+ assert_eq!(ctpop64(-1), 64);
+
+ assert_eq!(ctlz8(0), 8);
+ assert_eq!(ctlz16(0), 16);
+ assert_eq!(ctlz32(0), 32);
+ assert_eq!(ctlz64(0), 64);
+
+ assert_eq!(ctlz8(1), 7);
+ assert_eq!(ctlz16(1), 15);
+ assert_eq!(ctlz32(1), 31);
+ assert_eq!(ctlz64(1), 63);
+
+ assert_eq!(ctlz8(10), 4);
+ assert_eq!(ctlz16(10), 12);
+ assert_eq!(ctlz32(10), 28);
+ assert_eq!(ctlz64(10), 60);
+
+ assert_eq!(ctlz8(100), 1);
+ assert_eq!(ctlz16(100), 9);
+ assert_eq!(ctlz32(100), 25);
+ assert_eq!(ctlz64(100), 57);
+
+ assert_eq!(cttz8(-1), 0);
+ assert_eq!(cttz16(-1), 0);
+ assert_eq!(cttz32(-1), 0);
+ assert_eq!(cttz64(-1), 0);
+
+ assert_eq!(cttz8(0), 8);
+ assert_eq!(cttz16(0), 16);
+ assert_eq!(cttz32(0), 32);
+ assert_eq!(cttz64(0), 64);
+
+ assert_eq!(cttz8(1), 0);
+ assert_eq!(cttz16(1), 0);
+ assert_eq!(cttz32(1), 0);
+ assert_eq!(cttz64(1), 0);
+
+ assert_eq!(cttz8(10), 1);
+ assert_eq!(cttz16(10), 1);
+ assert_eq!(cttz32(10), 1);
+ assert_eq!(cttz64(10), 1);
+
+ assert_eq!(cttz8(100), 2);
+ assert_eq!(cttz16(100), 2);
+ assert_eq!(cttz32(100), 2);
+ assert_eq!(cttz64(100), 2);
+
+ assert_eq!(cttz8(-1), 0);
+ assert_eq!(cttz16(-1), 0);
+ assert_eq!(cttz32(-1), 0);
+ assert_eq!(cttz64(-1), 0);
+
+ assert_eq!(bswap16(0x0A0B), 0x0B0A);
+ assert_eq!(bswap32(0x0ABBCC0D), 0x0DCCBB0A);
+ assert_eq!(bswap64(0x0122334455667708), 0x0877665544332201);
}
}
assert_approx_eq!(sqrtf32(64f32), 8f32);
assert_approx_eq!(sqrtf64(64f64), 8f64);
- assert_approx_eq!(powif32(25f32, -2i32), 0.0016f32);
- assert_approx_eq!(powif64(23.2f64, 2i32), 538.24f64);
+ assert_approx_eq!(powif32(25f32, -2), 0.0016f32);
+ assert_approx_eq!(powif64(23.2f64, 2), 538.24f64);
assert_approx_eq!(sinf32(0f32), 0f32);
assert_approx_eq!(sinf64(f64::consts::PI / 2f64), 1f64);
pub fn main() {
let x: X<int> = X {
a: 12345678,
- b: 9u8,
+ b: 9,
c: true,
- d: 10u8,
- e: 11u16,
- f: 12u8,
- g: 13u8
+ d: 10,
+ e: 11,
+ f: 12,
+ g: 13
};
bar(x);
}
fn bar<T>(x: X<T>) {
- assert_eq!(x.b, 9u8);
+ assert_eq!(x.b, 9);
assert_eq!(x.c, true);
- assert_eq!(x.d, 10u8);
- assert_eq!(x.e, 11u16);
- assert_eq!(x.f, 12u8);
- assert_eq!(x.g, 13u8);
+ assert_eq!(x.d, 10);
+ assert_eq!(x.e, 11);
+ assert_eq!(x.f, 12);
+ assert_eq!(x.g, 13);
}
fn main() {
// Generate sieve of Eratosthenes for n up to 1e6
- let n = 1000000_usize;
+ let n = 1000000;
let mut sieve = BitVec::from_elem(n+1, true);
let limit: uint = (n as f32).sqrt() as uint;
for i in 2..limit+1 {
use std::thunk::Thunk;
pub fn main() {
- let mut x = 1i32;
+ let mut x = 1;
let _thunk = Thunk::new(move|| { x = 2; });
}
}
fn main() {
- let arr = [(1, 1_usize), (2, 2), (3, 3)];
+ let arr = [(1, 1), (2, 2), (3, 3)];
let v1: Vec<&_> = arr.iter().collect();
let v2: Vec<_> = arr.iter().map(copy).collect();
}
fn match_on_upvar() {
- let mut foo: Option<Box<_>> = Some(box 8i32);
+ let mut foo: Option<Box<_>> = Some(box 8);
let f = move|| {
match foo {
None => {},
use std::iter::AdditiveIterator;
fn main() {
let x: [u64; 3] = [1, 2, 3];
- assert_eq!(6, (0_usize..3).map(|i| x[i]).sum());
+ assert_eq!(6, (0..3).map(|i| x[i]).sum());
}
}
fn main() {
- let m = Mat::new(vec!(1_usize, 2, 3, 4, 5, 6), 3);
+ let m = Mat::new(vec!(1, 2, 3, 4, 5, 6), 3);
let r = m.row(1);
assert!(r.index(&2) == &6);
assert!(r[2] == 6);
- assert!(r[2_usize] == 6_usize);
+ assert!(r[2] == 6);
assert!(6 == r[2]);
let e = r[2];
struct Bar<'a> { m: marker::PhantomData<&'a ()> }
impl<'a> i::Foo<'a, uint> for Bar<'a> {
- fn foo(&self) -> uint { 5_usize }
+ fn foo(&self) -> uint { 5 }
}
pub fn main() {
#[allow(unused_must_use)]
fn main() {
- (0_usize..10).map(uint_to_foo);
+ (0..10).map(uint_to_foo);
}
}
pub fn main() {
- fn box_1() -> Box<[i8; 1]> { Box::new( [1i8; 1] ) }
- fn box_2() -> Box<[i8; 2]> { Box::new( [1i8; 2] ) }
- fn box_3() -> Box<[i8; 3]> { Box::new( [1i8; 3] ) }
- fn box_4() -> Box<[i8; 4]> { Box::new( [1i8; 4] ) }
+ fn box_1() -> Box<[i8; 1]> { Box::new( [1; 1] ) }
+ fn box_2() -> Box<[i8; 2]> { Box::new( [1; 2] ) }
+ fn box_3() -> Box<[i8; 3]> { Box::new( [1; 3] ) }
+ fn box_4() -> Box<[i8; 4]> { Box::new( [1; 4] ) }
foo(box_1, box_2, box_3, box_4);
}
}
pub fn main() {
- fn box_1() -> Box<[i8; 1]> { Box::new( [1i8] ) }
- fn box_2() -> Box<[i8; 20]> { Box::new( [1i8; 20] ) }
- fn box_3() -> Box<[i8; 300]> { Box::new( [1i8; 300] ) }
- fn box_4() -> Box<[i8; 4000]> { Box::new( [1i8; 4000] ) }
+ fn box_1() -> Box<[i8; 1]> { Box::new( [1] ) }
+ fn box_2() -> Box<[i8; 20]> { Box::new( [1; 20] ) }
+ fn box_3() -> Box<[i8; 300]> { Box::new( [1; 300] ) }
+ fn box_4() -> Box<[i8; 4000]> { Box::new( [1; 4000] ) }
foo(box_1, box_2, box_3, box_4);
}
use std::fmt;
fn main() {
- let a: &fmt::Debug = &1_i32;
+ let a: &fmt::Debug = &1;
format!("{:?}", a);
}
use m::{START, END};
fn main() {
- match 42u32 {
+ match 42 {
m::START...m::END => {},
- 0u32...m::END => {},
- m::START...59u32 => {},
+ 0...m::END => {},
+ m::START...59 => {},
_ => {},
}
}
let mut i = lo;
while i < hi {
it(i);
- i += 1_usize;
+ i += 1;
}
}
pub fn main() {
- let range: 'static ||uint|| = |a| range(0_usize, 1000_usize, a);
+ let range: 'static ||uint|| = |a| range(0, 1000, a);
let filt: 'static ||v: uint|| = |a| filter(
range,
- |&&n: uint| n % 3_usize != 0_usize && n % 5_usize != 0_usize,
+ |&&n: uint| n % 3 != 0 && n % 5 != 0,
a);
- let sum = foldl(filt, 0_usize, |accum, &&n: uint| accum + n );
+ let sum = foldl(filt, 0, |accum, &&n: uint| accum + n );
println!("{}", sum);
}
}
fn main() {
- let xs = vec![1u8, 2, 3, 4, 5];
+ let xs = vec![1, 2, 3, 4, 5];
assert_eq!(xs.into_iter().digit_sum(), 15);
}
}
pub fn main() {
- f(C(1_usize));
+ f(C(1));
}
// the position of this function is significant! - if it comes before methods
// then it works, if it comes after it then it doesn't!
fn to_bools(bitv: Storage) -> Vec<bool> {
- (0_usize..8).map(|i| {
+ (0..8).map(|i| {
let w = i / 64;
let b = i % 64;
- let x = 1u64 & (bitv.storage[w] >> b);
- x == 1u64
+ let x = 1 & (bitv.storage[w] >> b);
+ x == 1
}).collect()
}
let bools = vec!(false, false, true, false, false, true, true, false);
let bools2 = to_bools(Storage{storage: vec!(0b01100100)});
- for i in 0_usize..8 {
+ for i in 0..8 {
println!("{} => {} vs {}", i, bools[i], bools2[i]);
}
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
let callback: SamplesFn = Box::new(move |buffer| {
- for i in 0_usize..buffer.len() {
+ for i in 0..buffer.len() {
println!("{}: {}", i, buffer[i])
}
});
pub fn main() {
let i: uint = 0;
- assert!(i <= 0xFFFF_FFFF_usize);
+ assert!(i <= 0xFFFF_FFFF);
let i: int = 0;
- assert!(i >= -0x8000_0000__isize);
- assert!(i <= 0x7FFF_FFFF__isize);
+ assert!(i >= -0x8000_0000);
+ assert!(i <= 0x7FFF_FFFF);
}
assert_eq!(unsafe { NUM_DROPS }, 3);
{ let _x = FooBar::_Foo(Foo); }
assert_eq!(unsafe { NUM_DROPS }, 5);
- { let _x = FooBar::_Bar(42_usize); }
+ { let _x = FooBar::_Bar(42); }
assert_eq!(unsafe { NUM_DROPS }, 6);
{ let _ = Foo; }
assert_eq!(unsafe { NUM_DROPS }, 9);
{ let _ = FooBar::_Foo(Foo); }
assert_eq!(unsafe { NUM_DROPS }, 11);
- { let _ = FooBar::_Bar(42_usize); }
+ { let _ = FooBar::_Bar(42); }
assert_eq!(unsafe { NUM_DROPS }, 12);
}
struct signature<'a> { pattern : &'a [u32] }
static test1: signature<'static> = signature {
- pattern: &[0x243f6a88u32,0x85a308d3u32,0x13198a2eu32,0x03707344u32,0xa4093822u32,0x299f31d0u32]
+ pattern: &[0x243f6a88,0x85a308d3,0x13198a2e,0x03707344,0xa4093822,0x299f31d0]
};
pub fn main() {
- let test: &[u32] = &[0x243f6a88u32,0x85a308d3u32,0x13198a2eu32,
- 0x03707344u32,0xa4093822u32,0x299f31d0u32];
+ let test: &[u32] = &[0x243f6a88,0x85a308d3,0x13198a2e,
+ 0x03707344,0xa4093822,0x299f31d0];
println!("{}",test==test1.pattern);
}
struct X { pub x: uint }
impl Default for X {
fn default() -> X {
- X { x: 42_usize }
+ X { x: 42 }
}
}
extern crate issue2170lib;
pub fn main() {
- // let _ = issue2170lib::rsrc(2i32);
+ // let _ = issue2170lib::rsrc(2);
}
fn producer(tx: &Sender<Vec<u8>>) {
tx.send(
- vec!(1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u8, 9u8, 10u8, 11u8, 12u8,
- 13u8)).unwrap();
+ vec!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13)).unwrap();
}
pub fn main() {
fn foo() -> Box<FnMut() -> isize + 'static> {
let k: Box<_> = box 22;
let _u = A {a: k.clone()};
- // FIXME(#16640) suffix in `22_isize` suffix shouldn't be necessary
- let result = || 22_isize;
+ // FIXME(#16640) suffix in `22` suffix shouldn't be necessary
+ let result = || 22;
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
Box::new(result)
}
pub fn main() {
assert!(overly_complicated!(f, x, Option<uint>, { return Some(x); },
- Some(8_usize), Some(y), y) == 8_usize)
+ Some(8), Some(y), y) == 8)
}
}
pub fn main() {
- assert_eq!(1_usize, f(Some('x')));
- assert_eq!(2_usize, f(Some('y')));
- assert_eq!(3_usize, f(None));
+ assert_eq!(1, f(Some('x')));
+ assert_eq!(2, f(Some('y')));
+ assert_eq!(3, f(None));
assert_eq!(1, match Some('x') {
Some(char_x!()) => 1,
None => return (),
Some(num) => num as u32
};
- assert_eq!(f, 1234u32);
+ assert_eq!(f, 1234);
println!("{}", f)
}
}
fn main() {
- let mut buf = [0_u8; 6];
+ let mut buf = [0; 6];
{
let mut writer: &mut [_] = &mut buf;
x.foo(&x);
- assert!(method_self_arg1::get_count() == 2u64*3*3*3*5*5*5*7*7*7);
+ assert!(method_self_arg1::get_count() == 2*3*3*3*5*5*5*7*7*7);
}
x.run_trait();
- assert!(method_self_arg2::get_count() == 2u64*2*3*3*5*5*7*7*11*11*13*13*17);
+ assert!(method_self_arg2::get_count() == 2*2*3*3*5*5*7*7*11*11*13*13*17);
}
x.baz();
- unsafe { assert!(COUNT == 2u64*2*3*3*5*5*7*7*11*11*13*13*17); }
+ unsafe { assert!(COUNT == 2*2*3*3*5*5*7*7*11*11*13*13*17); }
}
x.foo(&x);
- unsafe { assert!(COUNT == 2_usize*3*3*3*5*5*5*7*7*7); }
+ unsafe { assert!(COUNT == 2*3*3*3*5*5*5*7*7*7); }
}
check_fancy!($e, $T, |ptr| assert!(*ptr == $e));
}};
($e:expr, $T:ty, |$v:ident| $chk:expr) => {{
- assert!(E::Nothing::<$T>((), ((), ()), [23i8; 0]).is_none());
+ assert!(E::Nothing::<$T>((), ((), ()), [23; 0]).is_none());
let e = $e;
let t_ = E::Thing::<$T>(23, e);
match t_.get_ref() {
}
fn main() {
- let x = 22_i32;
+ let x = 22;
let x1: &SomeTrait<SomeType=i32> = &x;
let y = get_int(x1);
assert_eq!(x, y);
}
pub fn main() {
- let mut x = 22_usize;
+ let mut x = 22;
let obj = &mut x as &mut Foo;
do_it_mut(obj);
- do_it_imm(obj, 23_usize);
+ do_it_imm(obj, 23);
do_it_mut(obj);
}
box BarStruct{ x: 2 } as Box<FooTrait>
);
- for i in 0_usize..foos.len() {
+ for i in 0..foos.len() {
assert_eq!(i, foos[i].foo());
}
}
pub fn main() {
assert_eq!(or_alt(blah::c), 0);
- assert_eq!(or_alt(blah::a(10, 100, 0_usize)), 110);
+ assert_eq!(or_alt(blah::a(10, 100, 0)), 110);
assert_eq!(or_alt(blah::b(20, 200)), 220);
}
fn main() {
// ICE trigger
- (G(PhantomData))(1_i32);
+ (G(PhantomData))(1);
}
assert_eq!(mem::size_of::<[Foo; 10]>(), 90);
- for i in 0_usize..10 {
+ for i in 0..10 {
assert_eq!(foos[i], Foo { bar: 1, baz: 2});
}
pub fn bar(_offset: uint) { }
}
-pub fn main() { foo::bar(0_usize); }
+pub fn main() { foo::bar(0); }
}
pub fn main() {
- let mut nyan : cat = cat(52_usize, 99);
- assert_eq!(nyan.meow_count(), 52_usize);
+ let mut nyan : cat = cat(52, 99);
+ assert_eq!(nyan.meow_count(), 52);
}
#![feature(box_syntax)]
fn sums_to(v: Vec<int> , sum: int) -> bool {
- let mut i = 0_usize;
+ let mut i = 0;
let mut sum0 = 0;
while i < v.len() {
sum0 += v[i];
- i += 1_usize;
+ i += 1;
}
return sum0 == sum;
}
fn sums_to_using_uniq(v: Vec<int> , sum: int) -> bool {
- let mut i = 0_usize;
+ let mut i = 0;
let mut sum0: Box<_> = box 0;
while i < v.len() {
*sum0 += v[i];
- i += 1_usize;
+ i += 1;
}
return *sum0 == sum;
}
fn sums_to_using_rec(v: Vec<int> , sum: int) -> bool {
- let mut i = 0_usize;
+ let mut i = 0;
let mut sum0 = F {f: 0};
while i < v.len() {
sum0.f += v[i];
- i += 1_usize;
+ i += 1;
}
return sum0.f == sum;
}
struct F<T> { f: T }
fn sums_to_using_uniq_rec(v: Vec<int> , sum: int) -> bool {
- let mut i = 0_usize;
+ let mut i = 0;
let mut sum0 = F::<Box<_>> {f: box 0};
while i < v.len() {
*sum0.f += v[i];
- i += 1_usize;
+ i += 1;
}
return *sum0.f == sum;
}
let x = ..1+3;
assert!(x == (..4));
- let a = &[0i32, 1, 2, 3, 4, 5, 6];
+ let a = &[0, 1, 2, 3, 4, 5, 6];
let x = &a[1+1..2+2];
assert!(x == &a[2..4]);
let x = &a[..1+2];
// from pairs of rows (where each pair of rows is equally sized),
// and the elements of the triangle match their row-pair index.
unsafe fn sanity_check(ascend: &[*mut u8]) {
- for i in 0_usize..COUNT / 2 {
+ for i in 0..COUNT / 2 {
let (p0, p1, size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i));
- for j in 0_usize..size {
+ for j in 0..size {
assert_eq!(*p0.offset(j as int), i as u8);
assert_eq!(*p1.offset(j as int), i as u8);
}
// that at least two rows will be allocated near each other, so
// that we trigger the bug (a buffer overrun) in an observable
// way.)
- for i in 0_usize..COUNT / 2 {
+ for i in 0..COUNT / 2 {
let size = idx_to_size(i);
ascend[2*i] = allocate(size, ALIGN);
ascend[2*i+1] = allocate(size, ALIGN);
}
// Initialize each pair of rows to distinct value.
- for i in 0_usize..COUNT / 2 {
+ for i in 0..COUNT / 2 {
let (p0, p1, size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i));
for j in 0..size {
*p0.offset(j as int) = i as u8;
test_3(ascend); // triangle -> square
test_4(ascend); // square -> triangle
- for i in 0_usize..COUNT / 2 {
+ for i in 0..COUNT / 2 {
let size = idx_to_size(i);
deallocate(ascend[2*i], size, ALIGN);
deallocate(ascend[2*i+1], size, ALIGN);
// rows as we go.
unsafe fn test_1(ascend: &mut [*mut u8]) {
let new_size = idx_to_size(COUNT-1);
- for i in 0_usize..COUNT / 2 {
+ for i in 0..COUNT / 2 {
let (p0, p1, old_size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i));
assert!(old_size < new_size);
// Test 2: turn the square back into a triangle, top to bottom.
unsafe fn test_2(ascend: &mut [*mut u8]) {
let old_size = idx_to_size(COUNT-1);
- for i in 0_usize..COUNT / 2 {
+ for i in 0..COUNT / 2 {
let (p0, p1, new_size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i));
assert!(new_size < old_size);
// Test 3: turn triangle into a square, bottom to top.
unsafe fn test_3(ascend: &mut [*mut u8]) {
let new_size = idx_to_size(COUNT-1);
- for i in (0_usize..COUNT / 2).rev() {
+ for i in (0..COUNT / 2).rev() {
let (p0, p1, old_size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i));
assert!(old_size < new_size);
// Test 4: turn the square back into a triangle, bottom to top.
unsafe fn test_4(ascend: &mut [*mut u8]) {
let old_size = idx_to_size(COUNT-1);
- for i in (0_usize..COUNT / 2).rev() {
+ for i in (0..COUNT / 2).rev() {
let (p0, p1, new_size) = (ascend[2*i], ascend[2*i+1], idx_to_size(i));
assert!(new_size < old_size);
#[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "aarch64"))]
mod m {
- pub fn align() -> uint { 4_usize }
- pub fn size() -> uint { 8_usize }
+ pub fn align() -> uint { 4 }
+ pub fn size() -> uint { 8 }
}
#[cfg(target_arch = "x86_64")]
mod m {
- pub fn align() -> uint { 4_usize }
- pub fn size() -> uint { 8_usize }
+ pub fn align() -> uint { 4 }
+ pub fn size() -> uint { 8 }
}
pub fn main() {
unsafe {
- let x = Outer {c8: 22u8, t: Inner {c64: 44u32}};
+ let x = Outer {c8: 22, t: Inner {c64: 44}};
// Send it through the shape code
let y = format!("{:?}", x);
mod m {
#[cfg(target_arch = "x86")]
pub mod m {
- pub fn align() -> uint { 4_usize }
- pub fn size() -> uint { 12_usize }
+ pub fn align() -> uint { 4 }
+ pub fn size() -> uint { 12 }
}
#[cfg(any(target_arch = "x86_64", target_arch = "arm", target_arch = "aarch64"))]
pub mod m {
- pub fn align() -> uint { 8_usize }
- pub fn size() -> uint { 16_usize }
+ pub fn align() -> uint { 8 }
+ pub fn size() -> uint { 16 }
}
}
mod m {
#[cfg(target_arch = "x86_64")]
pub mod m {
- pub fn align() -> uint { 8u }
- pub fn size() -> uint { 16u }
+ pub fn align() -> uint { 8 }
+ pub fn size() -> uint { 16 }
}
}
mod m {
#[cfg(target_arch = "x86")]
pub mod m {
- pub fn align() -> uint { 8_usize }
- pub fn size() -> uint { 16_usize }
+ pub fn align() -> uint { 8 }
+ pub fn size() -> uint { 16 }
}
#[cfg(target_arch = "x86_64")]
pub mod m {
- pub fn align() -> uint { 8_usize }
- pub fn size() -> uint { 16_usize }
+ pub fn align() -> uint { 8 }
+ pub fn size() -> uint { 16 }
}
}
mod m {
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
pub mod m {
- pub fn align() -> uint { 8_usize }
- pub fn size() -> uint { 16_usize }
+ pub fn align() -> uint { 8 }
+ pub fn size() -> uint { 16 }
}
}
pub fn main() {
unsafe {
- let x = Outer {c8: 22u8, t: Inner {c64: 44u64}};
+ let x = Outer {c8: 22, t: Inner {c64: 44}};
let y = format!("{:?}", x);
}
pub fn main() {
- assert_eq!(m(t3::c(T2 {x: t1::a(10), y: 5}, 4_usize)), 10);
- assert_eq!(m(t3::c(T2 {x: t1::b(10_usize), y: 5}, 4_usize)), 19);
+ assert_eq!(m(t3::c(T2 {x: t1::a(10), y: 5}, 4)), 10);
+ assert_eq!(m(t3::c(T2 {x: t1::b(10), y: 5}, 4)), 19);
}
}
pub fn main() {
- let p: Box<_> = box 22_usize;
+ let p: Box<_> = box 22;
let r = foo(&*p);
println!("r={}", r);
- assert_eq!(r, 22_usize);
+ assert_eq!(r, 22);
}
}
pub fn main() {
- let p: Box<_> = box 3_usize;
+ let p: Box<_> = box 3;
let r = foo(&*p);
- assert_eq!(r, 3_usize);
+ assert_eq!(r, 3);
}
}
pub fn main() {
- let mut i = 3i32;
+ let mut i = 3;
assert_eq!(i, 3);
{
let cl = || i += 1;
fn bar(x: &uint) -> uint { *x }
pub fn main() {
- let p: Box<_> = box 3_usize;
+ let p: Box<_> = box 3;
assert_eq!(bar(foo(&*p)), 3);
}
}
pub fn main() {
- let x = 3_usize;
- assert_eq!(parameterized(&x), 3_usize);
+ let x = 3;
+ assert_eq!(parameterized(&x), 3);
}
// This version does not yet work (associated type issues)...
#[cfg(cannot_use_this_yet)]
fn foo<'a>(map: RefCell<HashMap<&'static str, &'a [u8]>>) {
- let one = [1_usize];
+ let one = [1];
assert_eq!(map.borrow().get("one"), Some(&one[..]));
}
// ... and this version does not work (the lifetime of `one` is
// supposed to match the lifetime `'a`) ...
fn foo<'a>(map: RefCell<HashMap<&'static str, &'a [u8]>>) {
- let one = [1_usize];
+ let one = [1];
assert_eq!(map.borrow().get("one"), Some(&one.as_slice()));
}
}
fn main() {
- let zer = [0u8];
- let one = [1u8];
- let two = [2u8];
+ let zer = [0];
+ let one = [1];
+ let two = [2];
let mut map = HashMap::new();
map.insert("zero", &zer[..]);
map.insert("one", &one[..]);
}
fn main() {
- let w = E { f: &10u8 };
+ let w = E { f: &10 };
let o = extension(&w);
- assert_eq!(o.n(), 10u8);
+ assert_eq!(o.n(), 10);
}
let fromp = CString::new(test_file.as_vec()).unwrap();
let modebuf = CString::new(b"w+b").unwrap();
let ostream = libc::fopen(fromp.as_ptr(), modebuf.as_ptr());
- assert!((ostream as uint != 0_usize));
+ assert!((ostream as uint != 0));
let s = "hello".to_string();
let buf = CString::new(b"hello").unwrap();
let write_len = libc::fwrite(buf.as_ptr() as *mut _,
fn my_err(s: String) -> ! { println!("{}", s); panic!(); }
fn okay(i: uint) -> int {
- if i == 3_usize {
+ if i == 3 {
my_err("I don't like three".to_string());
} else {
return 42;
}
}
-pub fn main() { okay(4_usize); }
+pub fn main() { okay(4); }
};
let me = &*args[0];
- let x: &[u8] = &[1u8];
+ let x: &[u8] = &[1];
pass(Command::new(me).arg(x).output().unwrap());
- let x: &[u8] = &[2u8];
+ let x: &[u8] = &[2];
pass(Command::new(me).arg(x).output().unwrap());
- let x: &[u8] = &[3u8];
+ let x: &[u8] = &[3];
pass(Command::new(me).arg(x).output().unwrap());
- let x: &[u8] = &[4u8];
+ let x: &[u8] = &[4];
pass(Command::new(me).arg(x).output().unwrap());
- let x: &[u8] = &[5u8];
+ let x: &[u8] = &[5];
pass(Command::new(me).arg(x).output().unwrap());
0
fn test<F>(f: F) -> uint where F: FnOnce(uint) -> uint {
- return f(22_usize);
+ return f(22);
}
pub fn main() {
- let y = test(|x| 4_usize * x);
- assert_eq!(y, 88_usize);
+ let y = test(|x| 4 * x);
+ assert_eq!(y, 88);
}
}
fn foo(p: &Panolpy) {
- assert_eq!(22_i32 >> p.i8, 11_i32);
- assert_eq!(22_i32 >> p.i16, 11_i32);
- assert_eq!(22_i32 >> p.i32, 11_i32);
- assert_eq!(22_i32 >> p.i64, 11_i32);
- assert_eq!(22_i32 >> p.isize, 11_i32);
+ assert_eq!(22 >> p.i8, 11);
+ assert_eq!(22 >> p.i16, 11);
+ assert_eq!(22 >> p.i32, 11);
+ assert_eq!(22 >> p.i64, 11);
+ assert_eq!(22 >> p.isize, 11);
- assert_eq!(22_i32 >> p.u8, 11_i32);
- assert_eq!(22_i32 >> p.u16, 11_i32);
- assert_eq!(22_i32 >> p.u32, 11_i32);
- assert_eq!(22_i32 >> p.u64, 11_i32);
- assert_eq!(22_i32 >> p.usize, 11_i32);
+ assert_eq!(22 >> p.u8, 11);
+ assert_eq!(22 >> p.u16, 11);
+ assert_eq!(22 >> p.u32, 11);
+ assert_eq!(22 >> p.u64, 11);
+ assert_eq!(22 >> p.usize, 11);
}
fn main() {
pub fn main() {
check!(Option<u8>, 2,
None, "None",
- Some(129u8), "Some(129)");
+ Some(129), "Some(129)");
check!(Option<i16>, 4,
None, "None",
- Some(-20000i16), "Some(-20000)");
+ Some(-20000), "Some(-20000)");
check!(Either<u8, i8>, 2,
- Either::Left(132u8), "Left(132)",
- Either::Right(-32i8), "Right(-32)");
+ Either::Left(132), "Left(132)",
+ Either::Right(-32), "Right(-32)");
check!(Either<u8, i16>, 4,
- Either::Left(132u8), "Left(132)",
- Either::Right(-20000i16), "Right(-20000)");
+ Either::Left(132), "Left(132)",
+ Either::Right(-20000), "Right(-20000)");
}
impl Foo for uint {
fn foo() -> uint {
- 5_usize
+ 5
}
}
}
// Make sure we properly handle repeated self-appends.
let mut a: String = "A".to_string();
let mut i = 20;
- let mut expected_len = 1_usize;
+ let mut expected_len = 1;
while i > 0 {
println!("{}", a.len());
assert_eq!(a.len(), expected_len);
a = format!("{}{}", a, a);
i -= 1;
- expected_len *= 2_usize;
+ expected_len *= 2;
}
}
fn test1() {
unsafe {
- let q = Quad { a: 0xaaaa_aaaa_aaaa_aaaa_u64,
- b: 0xbbbb_bbbb_bbbb_bbbb_u64,
- c: 0xcccc_cccc_cccc_cccc_u64,
- d: 0xdddd_dddd_dddd_dddd_u64 };
+ let q = Quad { a: 0xaaaa_aaaa_aaaa_aaaa,
+ b: 0xbbbb_bbbb_bbbb_bbbb,
+ c: 0xcccc_cccc_cccc_cccc,
+ d: 0xdddd_dddd_dddd_dddd };
let qq = rustrt::rust_dbg_abi_1(q);
println!("a: {:x}", qq.a as uint);
println!("b: {:x}", qq.b as uint);
println!("c: {:x}", qq.c as uint);
println!("d: {:x}", qq.d as uint);
- assert_eq!(qq.a, q.c + 1u64);
- assert_eq!(qq.b, q.d - 1u64);
- assert_eq!(qq.c, q.a + 1u64);
- assert_eq!(qq.d, q.b - 1u64);
+ assert_eq!(qq.a, q.c + 1);
+ assert_eq!(qq.b, q.d - 1);
+ assert_eq!(qq.c, q.a + 1);
+ assert_eq!(qq.d, q.b - 1);
}
}
fn test2() {
unsafe {
let f = Floats { a: 1.234567890e-15_f64,
- b: 0b_1010_1010_u8,
+ b: 0b_1010_1010,
c: 1.0987654321e-15_f64 };
let ff = rustrt::rust_dbg_abi_2(f);
println!("a: {}", ff.a as f64);
println!("b: {}", ff.b as uint);
println!("c: {}", ff.c as f64);
assert_eq!(ff.a, f.c + 1.0f64);
- assert_eq!(ff.b, 0xff_u8);
+ assert_eq!(ff.b, 0xff);
assert_eq!(ff.c, f.a - 1.0f64);
}
}
pub fn main() {
assert_eq!(line!(), 25);
- assert!((column!() == 4u32));
+ assert!((column!() == 4));
assert_eq!(indirect_line!(), 27);
assert!((file!().ends_with("syntax-extension-source-utils.rs")));
assert_eq!(stringify!((2*3) + 5).to_string(), "( 2 * 3 ) + 5".to_string());
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// ignore-linux #7340 fails on 32-bit Linux
-// ignore-macos #7340 fails on 32-bit macos
-
use std::mem;
enum Tag<A> {
}
fn mk_rec() -> Rec {
- return Rec { c8:0u8, t:Tag::Tag2(0u64) };
+ return Rec { c8:0, t:Tag::Tag2(0) };
}
-fn is_8_byte_aligned(u: &Tag<u64>) -> bool {
+fn is_u64_aligned(u: &Tag<u64>) -> bool {
let p: uint = unsafe { mem::transmute(u) };
- return (p & 7_usize) == 0_usize;
+ let u64_align = std::mem::min_align_of::<u64>();
+ return (p & (u64_align - 1)) == 0;
}
pub fn main() {
let x = mk_rec();
- assert!(is_8_byte_aligned(&x.t));
+ assert!(is_u64_aligned(&x.t));
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// ignore-linux #7340 fails on 32-bit Linux
-// ignore-macos #7340 fails on 32-bit macos
-
use std::mem;
enum Tag<A,B> {
}
fn mk_rec<A,B>(a: A, b: B) -> Rec<A,B> {
- Rec { chA:0u8, tA:Tag::VarA(a), chB:1u8, tB:Tag::VarB(b) }
+ Rec { chA:0, tA:Tag::VarA(a), chB:1, tB:Tag::VarB(b) }
}
fn is_aligned<A>(amnt: uint, u: &A) -> bool {
let p: uint = unsafe { mem::transmute(u) };
- return (p & (amnt-1_usize)) == 0_usize;
+ return (p & (amnt-1)) == 0;
}
fn variant_data_is_aligned<A,B>(amnt: uint, u: &Tag<A,B>) -> bool {
}
pub fn main() {
+ let u64_align = std::mem::min_align_of::<u64>();
let x = mk_rec(22u64, 23u64);
- assert!(is_aligned(8_usize, &x.tA));
- assert!(variant_data_is_aligned(8_usize, &x.tA));
- assert!(is_aligned(8_usize, &x.tB));
- assert!(variant_data_is_aligned(8_usize, &x.tB));
+ assert!(is_aligned(u64_align, &x.tA));
+ assert!(variant_data_is_aligned(u64_align, &x.tA));
+ assert!(is_aligned(u64_align, &x.tB));
+ assert!(variant_data_is_aligned(u64_align, &x.tB));
let x = mk_rec(22u64, 23u32);
- assert!(is_aligned(8_usize, &x.tA));
- assert!(variant_data_is_aligned(8_usize, &x.tA));
- assert!(is_aligned(8_usize, &x.tB));
- assert!(variant_data_is_aligned(4_usize, &x.tB));
+ assert!(is_aligned(u64_align, &x.tA));
+ assert!(variant_data_is_aligned(u64_align, &x.tA));
+ assert!(is_aligned(u64_align, &x.tB));
+ assert!(variant_data_is_aligned(4, &x.tB));
let x = mk_rec(22u32, 23u64);
- assert!(is_aligned(8_usize, &x.tA));
- assert!(variant_data_is_aligned(4_usize, &x.tA));
- assert!(is_aligned(8_usize, &x.tB));
- assert!(variant_data_is_aligned(8_usize, &x.tB));
+ assert!(is_aligned(u64_align, &x.tA));
+ assert!(variant_data_is_aligned(4, &x.tA));
+ assert!(is_aligned(u64_align, &x.tB));
+ assert!(variant_data_is_aligned(u64_align, &x.tB));
let x = mk_rec(22u32, 23u32);
- assert!(is_aligned(4_usize, &x.tA));
- assert!(variant_data_is_aligned(4_usize, &x.tA));
- assert!(is_aligned(4_usize, &x.tB));
- assert!(variant_data_is_aligned(4_usize, &x.tB));
+ assert!(is_aligned(4, &x.tA));
+ assert!(variant_data_is_aligned(4, &x.tA));
+ assert!(is_aligned(4, &x.tB));
+ assert!(variant_data_is_aligned(4, &x.tB));
let x = mk_rec(22f64, 23f64);
- assert!(is_aligned(8_usize, &x.tA));
- assert!(variant_data_is_aligned(8_usize, &x.tA));
- assert!(is_aligned(8_usize, &x.tB));
- assert!(variant_data_is_aligned(8_usize, &x.tB));
+ assert!(is_aligned(u64_align, &x.tA));
+ assert!(variant_data_is_aligned(u64_align, &x.tA));
+ assert!(is_aligned(u64_align, &x.tB));
+ assert!(variant_data_is_aligned(u64_align, &x.tB));
}
}
pub fn main() {
- let x = t_rec {c8: 22u8, t: a_tag::a_tag_var(44u64)};
+ let x = t_rec {c8: 22, t: a_tag::a_tag_var(44)};
let y = format!("{:?}", x);
println!("y = {:?}", y);
assert_eq!(y, "t_rec { c8: 22, t: a_tag_var(44) }".to_string());
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// ignore-linux #7340 fails on 32-bit Linux
-// ignore-macos #7340 fails on 32-bit macos
-
use std::mem;
enum Tag {
}
fn mk_rec() -> Rec {
- return Rec { c8:0u8, t:Tag::TagInner(0u64) };
+ return Rec { c8:0, t:Tag::TagInner(0) };
}
-fn is_8_byte_aligned(u: &Tag) -> bool {
+fn is_u64_aligned(u: &Tag) -> bool {
let p: uint = unsafe { mem::transmute(u) };
- return (p & 7_usize) == 0_usize;
+ let u64_align = std::mem::min_align_of::<u64>();
+ return (p & (u64_align - 1)) == 0;
}
pub fn main() {
let x = mk_rec();
- assert!(is_8_byte_aligned(&x.t));
+ assert!(is_u64_aligned(&x.t));
}
struct R {val0: int, val1: u8, val2: char}
let (tx, rx) = channel();
- let r0: R = R {val0: 0, val1: 1u8, val2: '2'};
+ let r0: R = R {val0: 0, val1: 1, val2: '2'};
tx.send(r0).unwrap();
let mut r1: R;
r1 = rx.recv().unwrap();
assert_eq!(r1.val0, 0);
- assert_eq!(r1.val1, 1u8);
+ assert_eq!(r1.val1, 1);
assert_eq!(r1.val2, '2');
}
let (tx, rx) = channel();
tx.send(t::tag1).unwrap();
tx.send(t::tag2(10)).unwrap();
- tx.send(t::tag3(10, 11u8, 'A')).unwrap();
+ tx.send(t::tag3(10, 11, 'A')).unwrap();
let mut t1: t;
t1 = rx.recv().unwrap();
assert_eq!(t1, t::tag1);
t1 = rx.recv().unwrap();
assert_eq!(t1, t::tag2(10));
t1 = rx.recv().unwrap();
- assert_eq!(t1, t::tag3(10, 11u8, 'A'));
+ assert_eq!(t1, t::tag3(10, 11, 'A'));
}
fn test_chan() {
let addr = rx.recv().unwrap();
let (tx, rx) = channel();
- for _ in 0_usize..1000 {
+ for _ in 0..1000 {
let tx = tx.clone();
Builder::new().stack_size(64 * 1024).spawn(move|| {
match TcpStream::connect(addr) {
// Wait for all clients to exit, but don't wait for the server to exit. The
// server just runs infinitely.
drop(tx);
- for _ in 0_usize..1000 {
+ for _ in 0..1000 {
rx.recv().unwrap();
}
unsafe { libc::exit(0) }
}
pub fn main () {
- assert_eq!(f::<f64, int>(0, 2_usize), 2_usize);
- assert_eq!(f::<uint, int>(0, 2_usize), 2_usize);
+ assert_eq!(f::<f64, int>(0, 2), 2);
+ assert_eq!(f::<uint, int>(0, 2), 2);
}
pub fn main() {
let a = box() () as Box<Trait<u8, u8>>;
- assert_eq!(a.method(Type::Constant((1u8, 2u8))), 0);
+ assert_eq!(a.method(Type::Constant((1, 2))), 0);
}
}
fn main() {
- let w = E { f: &10u8 };
+ let w = E { f: &10 };
let o = extension(&w);
- assert_eq!(o.n(), 10u8);
+ assert_eq!(o.n(), 10);
}
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test case where an associated type is referenced from within the
+// supertrait definition. Issue #20220.
+
+use std::vec::IntoIter;
+
+pub trait Foo: Iterator<Item=<Self as Foo>::Key> {
+ type Key;
+}
+
+impl Foo for IntoIter<i32> {
+ type Key = i32;
+}
+
+fn sum_foo<F:Foo<Key=i32>>(f: F) -> i32 {
+ f.fold(0, |a,b| a + b)
+}
+
+fn main() {
+ let x = sum_foo(vec![11, 10, 1].into_iter());
+ assert_eq!(x, 22);
+}
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test stack overflow triggered by evaluating the implications. To be
+// WF, the type `Receipt<Complete>` would require that `<Complete as
+// Async>::Cancel` be WF. This normalizes to `Receipt<Complete>`
+// again, leading to an infinite cycle. Issue #23003.
+
+#![allow(dead_code)]
+#![allow(unused_variables)]
+
+use std::marker::PhantomData;
+
+trait Async {
+ type Cancel;
+}
+
+struct Receipt<A:Async> {
+ marker: PhantomData<A>,
+}
+
+struct Complete {
+ core: Option<()>,
+}
+
+impl Async for Complete {
+ type Cancel = Receipt<Complete>;
+}
+
+fn foo(r: Receipt<Complete>) { }
+
+fn main() { }
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test a case of a trait which extends the same supertrait twice, but
+// with difference type parameters. Test that we can invoke the
+// various methods in various ways successfully.
+// See also `compile-fail/trait-repeated-supertrait-ambig.rs`.
+
+trait CompareTo<T> {
+ fn same_as(&self, t: T) -> bool;
+}
+
+trait CompareToInts : CompareTo<i64> + CompareTo<u64> {
+}
+
+impl CompareTo<i64> for i64 {
+ fn same_as(&self, t: i64) -> bool { *self == t }
+}
+
+impl CompareTo<u64> for i64 {
+ fn same_as(&self, t: u64) -> bool { *self == (t as i64) }
+}
+
+impl CompareToInts for i64 { }
+
+fn with_obj(c: &CompareToInts) -> bool {
+ c.same_as(22_i64) && c.same_as(22_u64)
+}
+
+fn with_trait<C:CompareToInts>(c: &C) -> bool {
+ c.same_as(22_i64) && c.same_as(22_u64)
+}
+
+fn with_ufcs1<C:CompareToInts>(c: &C) -> bool {
+ CompareToInts::same_as(c, 22_i64) && CompareToInts::same_as(c, 22_u64)
+}
+
+fn with_ufcs2<C:CompareToInts>(c: &C) -> bool {
+ CompareTo::same_as(c, 22_i64) && CompareTo::same_as(c, 22_u64)
+}
+
+fn main() {
+ assert_eq!(22_i64.same_as(22_i64), true);
+ assert_eq!(22_i64.same_as(22_u64), true);
+ assert_eq!(with_trait(&22), true);
+ assert_eq!(with_obj(&22), true);
+ assert_eq!(with_ufcs1(&22), true);
+ assert_eq!(with_ufcs2(&22), true);
+}
fn range_<F>(lo: uint, hi: uint, mut it: F) where F: FnMut(uint) {
let mut lo_ = lo;
- while lo_ < hi { it(lo_); lo_ += 1_usize; }
+ while lo_ < hi { it(lo_); lo_ += 1; }
}
fn create_index<T>(_index: Vec<S<T>> , _hash_fn: extern fn(T) -> uint) {
- range_(0_usize, 256_usize, |_i| {
+ range_(0, 256, |_i| {
let _bucket: Vec<T> = Vec::new();
})
}
pub fn main() {
- let x: Vec<_> = (0_usize..5).collect();
+ let x: Vec<_> = (0..5).collect();
let expected: &[uint] = &[0,1,2,3,4];
assert_eq!(x, expected);
- let x = (0_usize..5).collect::<Vec<_>>();
+ let x = (0..5).collect::<Vec<_>>();
assert_eq!(x, expected);
let y: _ = "hello";
assert_eq!(y.len(), 5);
- let ptr = &5_usize;
+ let ptr = &5;
let ptr2 = ptr as *const _;
assert_eq!(ptr as *const uint as uint, ptr2 as uint);
pub fn main() {
- let mut word: u32 = 200000u32;
- word = word - 1u32;
- assert_eq!(word, 199999u32);
+ let mut word: u32 = 200000;
+ word = word - 1;
+ assert_eq!(word, 199999);
}
// These constants were chosen because they aren't used anywhere
// in the rest of the generated code so they're easily grep-able.
pub fn main() {
- let mut x: u8 = 19u8; // 0x13
+ let mut x: u8 = 19; // 0x13
- let mut y: u8 = 35u8; // 0x23
+ let mut y: u8 = 35; // 0x23
- x = x + 7u8; // 0x7
+ x = x + 7; // 0x7
- y = y - 9u8; // 0x9
+ y = y - 9; // 0x9
assert_eq!(x, y);
}
pub fn main() {
- let mut x: u8 = 12u8;
- let y: u8 = 12u8;
- x = x + 1u8;
- x = x - 1u8;
+ let mut x: u8 = 12;
+ let y: u8 = 12;
+ x = x + 1;
+ x = x - 1;
assert_eq!(x, y);
- // x = 14u8;
- // x = x + 1u8;
+ // x = 14;
+ // x = x + 1;
}
}
fn main() {
- let a: &Foo = &22_i32;
+ let a: &Foo = &22;
assert_eq!(Foo::test(a), 22);
}
//
// error: internal compiler error: get_unique_type_id_of_type() -
// unexpected type: closure,
-// ty_closure(syntax::ast::DefId{krate: 0u32, node: 66u32},
-// ReScope(63u32))
+// ty_closure(syntax::ast::DefId{krate: 0, node: 66},
+// ReScope(63))
//
// This is a regression test for issue #17021.
//
}
pub fn main() {
- let mut a = 7_usize;
+ let mut a = 7;
let b = &mut a;
replace_map(b, |x: uint| x * 2);
- assert_eq!(*b, 14_usize);
+ assert_eq!(*b, 14);
}
enum bar { u(Box<Foo>), w(int), }
pub fn main() {
- assert!(match bar::u(box Foo{a: 10, b: 40_usize}) {
+ assert!(match bar::u(box Foo{a: 10, b: 40}) {
bar::u(box Foo{a: a, b: b}) => { a + (b as int) }
_ => { 66 }
} == 50);
pub fn main() {
let (tx, rx) = channel();
- let n = 100_usize;
- let mut expected = 0_usize;
- let _t = (0_usize..n).map(|i| {
+ let n = 100;
+ let mut expected = 0;
+ let _t = (0..n).map(|i| {
expected += i;
let tx = tx.clone();
thread::spawn(move|| {
})
}).collect::<Vec<_>>();
- let mut actual = 0_usize;
- for _ in 0_usize..n {
+ let mut actual = 0;
+ for _ in 0..n {
let j = rx.recv().unwrap();
actual += *j;
}
f: [T; 3]
}
- let data: Box<_> = box Foo_{f: [1i32, 2, 3] };
+ let data: Box<Foo_<i32>> = box Foo_{f: [1, 2, 3] };
let x: &Foo<i32> = mem::transmute(raw::Slice { len: 3, data: &*data });
assert!(x.f.len() == 3);
assert!(x.f[0] == 1);
- assert!(x.f[1] == 2);
- assert!(x.f[2] == 3);
struct Baz_ {
f1: uint,
let s: String = chs.iter().cloned().collect();
let schs: Vec<char> = s.chars().collect();
- assert!(s.len() == 10_usize);
- assert!(s.chars().count() == 4_usize);
- assert!(schs.len() == 4_usize);
+ assert!(s.len() == 10);
+ assert!(s.chars().count() == 4);
+ assert!(schs.len() == 4);
assert!(schs.iter().cloned().collect::<String>() == s);
- assert!(s.char_at(0_usize) == 'e');
- assert!(s.char_at(1_usize) == 'é');
+ assert!(s.char_at(0) == 'e');
+ assert!(s.char_at(1) == 'é');
assert!((str::from_utf8(s.as_bytes()).is_ok()));
// invalid prefix
- assert!((!str::from_utf8(&[0x80_u8]).is_ok()));
+ assert!((!str::from_utf8(&[0x80]).is_ok()));
// invalid 2 byte prefix
- assert!((!str::from_utf8(&[0xc0_u8]).is_ok()));
- assert!((!str::from_utf8(&[0xc0_u8, 0x10_u8]).is_ok()));
+ assert!((!str::from_utf8(&[0xc0]).is_ok()));
+ assert!((!str::from_utf8(&[0xc0, 0x10]).is_ok()));
// invalid 3 byte prefix
- assert!((!str::from_utf8(&[0xe0_u8]).is_ok()));
- assert!((!str::from_utf8(&[0xe0_u8, 0x10_u8]).is_ok()));
- assert!((!str::from_utf8(&[0xe0_u8, 0xff_u8, 0x10_u8]).is_ok()));
+ assert!((!str::from_utf8(&[0xe0]).is_ok()));
+ assert!((!str::from_utf8(&[0xe0, 0x10]).is_ok()));
+ assert!((!str::from_utf8(&[0xe0, 0xff, 0x10]).is_ok()));
// invalid 4 byte prefix
- assert!((!str::from_utf8(&[0xf0_u8]).is_ok()));
- assert!((!str::from_utf8(&[0xf0_u8, 0x10_u8]).is_ok()));
- assert!((!str::from_utf8(&[0xf0_u8, 0xff_u8, 0x10_u8]).is_ok()));
- assert!((!str::from_utf8(&[0xf0_u8, 0xff_u8, 0xff_u8, 0x10_u8]).is_ok()));
+ assert!((!str::from_utf8(&[0xf0]).is_ok()));
+ assert!((!str::from_utf8(&[0xf0, 0x10]).is_ok()));
+ assert!((!str::from_utf8(&[0xf0, 0xff, 0x10]).is_ok()));
+ assert!((!str::from_utf8(&[0xf0, 0xff, 0xff, 0x10]).is_ok()));
}
assert_eq!(x[2], 3);
assert_eq!(x[3], 4);
- assert_eq!(size_of::<[u8; 4]>(), 4_usize);
+ assert_eq!(size_of::<[u8; 4]>(), 4);
// FIXME #10183
// FIXME #18069
//if cfg!(target_pointer_width = "64") {
- // assert_eq!(size_of::<[u8; (1 << 32)]>(), (1_usize << 32));
+ // assert_eq!(size_of::<[u8; (1 << 32)]>(), (1 << 32));
//}
}
fn p() -> bool { true }
let _a = (assert!((true)) == (assert!(p())));
let _c = (assert!((p())) == ());
- let _b: bool = (println!("{}", 0) == (return 0_usize));
+ let _b: bool = (println!("{}", 0) == (return 0));
}
fn angrydome() {
}
fn main() {
- let x = 42u32;
+ let x = 42;
foo1(&x);
foo2(&x);
unsafe {
#[cfg(windows)]
pub fn main() {
unsafe {
- let expected = 1234_usize;
+ let expected = 1234;
kernel32::SetLastError(expected);
let actual = kernel32::GetLastError();
println!("actual = {}", actual);
#[cfg(windows)]
pub fn main() {
let heap = unsafe { kernel32::GetProcessHeap() };
- let mem = unsafe { kernel32::HeapAlloc(heap, 0u32, 100u32) };
- assert!(mem != 0_usize);
- let res = unsafe { kernel32::HeapFree(heap, 0u32, mem) };
- assert!(res != 0u8);
+ let mem = unsafe { kernel32::HeapAlloc(heap, 0, 100) };
+ assert!(mem != 0);
+ let res = unsafe { kernel32::HeapFree(heap, 0, mem) };
+ assert!(res != 0);
}
#[cfg(not(windows))]