<del> // 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. /*! * High-level text containers. * * Ropes are a high-level representation of text that offers * much better performance than strings for common operations, * and generally reduce memory allocations and copies, while only * entailing a small degradation of less common operations. * * More precisely, where a string is represented as a memory buffer, * a rope is a tree structure whose leaves are slices of immutable * strings. Therefore, concatenation, appending, prepending, substrings, * etc. are operations that require only trivial tree manipulation, * generally without having to copy memory. In addition, the tree * structure of ropes makes them suitable as a form of index to speed-up * access to Unicode characters by index in long chunks of text. * * The following operations are algorithmically faster in ropes: * * * extracting a subrope is logarithmic (linear in strings); * * appending/prepending is near-constant time (linear in strings); * * concatenation is near-constant time (linear in strings); * * char length is constant-time (linear in strings); * * access to a character by index is logarithmic (linear in strings); */ #[allow(missing_doc)]; use std::uint; use std::vec; use std::str; /// The type of ropes. pub type Rope = node::Root; /* Section: Creating a rope */ /// Create an empty rope pub fn empty() -> Rope { return node::Empty; } /** * Adopt a string as a rope. * * # Arguments * * * str - A valid string. * * # Return value * * A rope representing the same string as `str`. Depending of the length * of `str`, this rope may be empty, flat or complex. * * # Performance notes * * * this operation does not copy the string; * * the function runs in linear time. */ pub fn of_str(str: @~str) -> Rope { return of_substr(str, 0u, str.len()); } /** * As `of_str` but for a substring. * * # Arguments * * byte_offset - The offset of `str` at which the rope starts. * * byte_len - The number of bytes of `str` to use. * * # Return value * * A rope representing the same string as `str.slice(byte_offset, * byte_offset + byte_len)`.  Depending on `byte_len`, this rope may * be empty, flat or complex. * * # Performance note * * This operation does not copy the substring. * * # Safety notes * * * this function does _not_ check the validity of the substring; * * this function fails if `byte_offset` or `byte_len` do not match `str`. */ pub fn of_substr(str: @~str, byte_offset: uint, byte_len: uint) -> Rope { if byte_len == 0u { return node::Empty; } if byte_offset + byte_len  > str.len() { fail!(); } return node::Content(node::of_substr(str, byte_offset, byte_len)); } /* Section: Adding things to a rope */ /** * Add one char to the end of the rope * * # Performance note * * * this function executes in near-constant time */ pub fn append_char(rope: Rope, char: char) -> Rope { return append_str(rope, @str::from_chars([char])); } /** * Add one string to the end of the rope * * # Performance note * * * this function executes in near-linear time */ pub fn append_str(rope: Rope, str: @~str) -> Rope { return append_rope(rope, of_str(str)) } /** * Add one char to the beginning of the rope * * # Performance note * * this function executes in near-constant time */ pub fn prepend_char(rope: Rope, char: char) -> Rope { return prepend_str(rope, @str::from_chars([char])); } /** * Add one string to the beginning of the rope * * # Performance note * * this function executes in near-linear time */ pub fn prepend_str(rope: Rope, str: @~str) -> Rope { return append_rope(of_str(str), rope) } /// Concatenate two ropes pub fn append_rope(left: Rope, right: Rope) -> Rope { match (left) { node::Empty => return right, node::Content(left_content) => { match (right) { node::Empty => return left, node::Content(right_content) => { return node::Content(node::concat2(left_content, right_content)); } } } } } /** * Concatenate many ropes. * * If the ropes are balanced initially and have the same height, the resulting * rope remains balanced. However, this function does not take any further * measure to ensure that the result is balanced. */ pub fn concat(v: ~[Rope]) -> Rope { //Copy `v` into a mut vector let mut len = v.len(); if len == 0u { return node::Empty; } let mut ropes = vec::from_elem(len, v[0]); for uint::range(1u, len) |i| { ropes[i] = v[i]; } //Merge progresively while len > 1u { for uint::range(0u, len/2u) |i| { ropes[i] = append_rope(ropes[2u*i], ropes[2u*i+1u]); } if len%2u != 0u { ropes[len/2u] = ropes[len - 1u]; len = len/2u + 1u; } else { len = len/2u; } } //Return final rope return ropes[0]; } /* Section: Keeping ropes healthy */ /** * Balance a rope. * * # Return value * * A copy of the rope in which small nodes have been grouped in memory, * and with a reduced height. * * If you perform numerous rope concatenations, it is generally a good idea * to rebalance your rope at some point, before using it for other purposes. */ pub fn bal(rope:Rope) -> Rope { match (rope) { node::Empty => return rope, node::Content(x) => match (node::bal(x)) { None    => rope, Some(y) => node::Content(y) } } } /* Section: Transforming ropes */ /** * Extract a subrope from a rope. * * # Performance note * * * on a balanced rope, this operation takes algorithmic time; * * this operation does not involve any copying * * # Safety note * * * this function fails if char_offset/char_len do not represent *   valid positions in rope */ pub fn sub_chars(rope: Rope, char_offset: uint, char_len: uint) -> Rope { if char_len == 0u { return node::Empty; } match (rope) { node::Empty => fail!(), node::Content(node) => if char_len > node::char_len(node) { fail!() } else { return node::Content(node::sub_chars(node, char_offset, char_len)) } } } /** * Extract a subrope from a rope. * * # Performance note * * * on a balanced rope, this operation takes algorithmic time; * * this operation does not involve any copying * * # Safety note * * * this function fails if byte_offset/byte_len do not represent *   valid positions in rope */ pub fn sub_bytes(rope: Rope, byte_offset: uint, byte_len: uint) -> Rope { if byte_len == 0u { return node::Empty; } match (rope) { node::Empty => fail!(), node::Content(node) =>if byte_len > node::byte_len(node) { fail!() } else { return node::Content(node::sub_bytes(node, byte_offset, byte_len)) } } } /* Section: Comparing ropes */ /** * Compare two ropes by Unicode lexicographical order. * * This function compares only the contents of the rope, not their structure. * * # Return value * * A negative value if `left < right`, 0 if eq(left, right) or a positive * value if `left > right` */ pub fn cmp(left: Rope, right: Rope) -> int { match ((left, right)) { (node::Empty, node::Empty) => return 0, (node::Empty, _)     => return -1, (_, node::Empty)     => return  1, (node::Content(a), node::Content(b)) => { return node::cmp(a, b); } } } /** * Returns `true` if both ropes have the same content (regardless of * their structure), `false` otherwise */ pub fn eq(left: Rope, right: Rope) -> bool { return cmp(left, right) == 0; } /** * # Arguments * * * left - an arbitrary rope * * right - an arbitrary rope * * # Return value * * `true` if `left <= right` in lexicographical order (regardless of their * structure), `false` otherwise */ pub fn le(left: Rope, right: Rope) -> bool { return cmp(left, right) <= 0; } /** * # Arguments * * * left - an arbitrary rope * * right - an arbitrary rope * * # Return value * * `true` if `left < right` in lexicographical order (regardless of their * structure), `false` otherwise */ pub fn lt(left: Rope, right: Rope) -> bool { return cmp(left, right) < 0; } /** * # Arguments * * * left - an arbitrary rope * * right - an arbitrary rope * * # Return value * *  `true` if `left >= right` in lexicographical order (regardless of their * structure), `false` otherwise */ pub fn ge(left: Rope, right: Rope) -> bool { return cmp(left, right) >= 0; } /** * # Arguments * * * left - an arbitrary rope * * right - an arbitrary rope * * # Return value * * `true` if `left > right` in lexicographical order (regardless of their * structure), `false` otherwise */ pub fn gt(left: Rope, right: Rope) -> bool { return cmp(left, right) > 0; } /* Section: Iterating */ /** * Loop through a rope, char by char * * While other mechanisms are available, this is generally the best manner * of looping through the contents of a rope char by char. If you prefer a * loop that iterates through the contents string by string (e.g. to print * the contents of the rope or output it to the system), however, * you should rather use `traverse_components`. * * # Arguments * * * rope - A rope to traverse. It may be empty. * * it - A block to execute with each consecutive character of the rope. *        Return `true` to continue, `false` to stop. * * # Return value * * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ pub fn loop_chars(rope: Rope, it: &fn(c: char) -> bool) -> bool { match (rope) { node::Empty => return true, node::Content(x) => return node::loop_chars(x, it) } } /** * Loop through a rope, char by char, until the end. * * # Arguments * * rope - A rope to traverse. It may be empty * * it - A block to execute with each consecutive character of the rope. */ pub fn iter_chars(rope: Rope, it: &fn(char)) { do loop_chars(rope) |x| { it(x); true }; } /** * Loop through a rope, string by string * * While other mechanisms are available, this is generally the best manner of * looping through the contents of a rope string by string, which may be * useful e.g. to print strings as you see them (without having to copy their * contents into a new string), to send them to then network, to write them to * a file, etc.. If you prefer a loop that iterates through the contents * char by char (e.g. to search for a char), however, you should rather * use `traverse`. * * # Arguments * * * rope - A rope to traverse. It may be empty * * it - A block to execute with each consecutive string component of the *        rope. Return `true` to continue, `false` to stop * * # Return value * * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ pub fn loop_leaves(rope: Rope, it: &fn(node::Leaf) -> bool) -> bool{ match (rope) { node::Empty => return true, node::Content(x) => return node::loop_leaves(x, it) } } pub mod iterator { pub mod leaf { use rope::{Rope, node}; pub fn start(rope: Rope) -> node::leaf_iterator::T { match (rope) { node::Empty      => return node::leaf_iterator::empty(), node::Content(x) => return node::leaf_iterator::start(x) } } pub fn next(it: &mut node::leaf_iterator::T) -> Option<node::Leaf> { return node::leaf_iterator::next(it); } } pub mod char { use rope::{Rope, node}; pub fn start(rope: Rope) -> node::char_iterator::T { match (rope) { node::Empty      => return node::char_iterator::empty(), node::Content(x) => return node::char_iterator::start(x) } } pub fn next(it: &mut node::char_iterator::T) -> Option<char> { return node::char_iterator::next(it) } } } /* Section: Rope properties */ /** * Returns the height of the rope. * * The height of the rope is a bound on the number of operations which * must be performed during a character access before finding the leaf in * which a character is contained. * * # Performance note * * Constant time. */ pub fn height(rope: Rope) -> uint { match (rope) { node::Empty      => return 0u, node::Content(x) => return node::height(x) } } /** * The number of character in the rope * * # Performance note * * Constant time. */ pub fn char_len(rope: Rope) -> uint { match (rope) { node::Empty            => return 0u, node::Content(x)       => return node::char_len(x) } } /** * The number of bytes in the rope * * # Performance note * * Constant time. */ pub fn byte_len(rope: Rope) -> uint { match (rope) { node::Empty            => return 0u, node::Content(x)       => return node::byte_len(x) } } /** * The character at position `pos` * * # Arguments * * * pos - A position in the rope * * # Safety notes * * The function will fail if `pos` is not a valid position in the rope. * * # Performance note * * This function executes in a time proportional to the height of the * rope + the (bounded) length of the largest leaf. */ pub fn char_at(rope: Rope, pos: uint) -> char { match (rope) { node::Empty => fail!(), node::Content(x) => return node::char_at(x, pos) } } /* Section: Implementation */ pub mod node { use rope::node; use std::cast; use std::uint; use std::vec; /// Implementation of type `rope` pub enum Root { /// An empty rope Empty, /// A non-empty rope Content(@Node), } /** * A text component in a rope. * * This is actually a slice in a rope, so as to ensure maximal sharing. * * # Fields * * * byte_offset = The number of bytes skipped in `content` * * byte_len - The number of bytes of `content` to use * * char_len - The number of chars in the leaf. * * content - Contents of the leaf. * *     Note that we can have `char_len < content.char_len()`, if *     this leaf is only a subset of the string. Also note that the *     string can be shared between several ropes, e.g. for indexing *     purposes. */ pub struct Leaf { byte_offset: uint, byte_len: uint, char_len: uint, content: @~str, } /** * A node obtained from the concatenation of two other nodes * * # Fields * * * left - The node containing the beginning of the text. * * right - The node containing the end of the text. * * char_len - The number of chars contained in all leaves of this node. * * byte_len - The number of bytes in the subrope. * *     Used to pre-allocate the correct amount of storage for *     serialization. * * * height - Height of the subrope. * *     Used for rebalancing and to allocate stacks for traversals. */ pub struct Concat { //FIXME (#2744): Perhaps a `vec` instead of `left`/`right` left: @Node, right: @Node, char_len: uint, byte_len: uint, height: uint, } pub enum Node { /// A leaf consisting in a `str` Leaf(Leaf), /// The concatenation of two ropes Concat(Concat), } /** * The maximal number of chars that _should_ be permitted in a single node * * This is not a strict value */ pub static HINT_MAX_LEAF_CHAR_LEN: uint = 256u; /** * The maximal height that _should_ be permitted in a tree. * * This is not a strict value */ pub static HINT_MAX_NODE_HEIGHT:   uint = 16u; /** * Adopt a string as a node. * * If the string is longer than `max_leaf_char_len`, it is * logically split between as many leaves as necessary. Regardless, * the string itself is not copied. * * Performance note: The complexity of this function is linear in * the length of `str`. */ pub fn of_str(str: @~str) -> @Node { return of_substr(str, 0u, str.len()); } /** * Adopt a slice of a string as a node. * * If the slice is longer than `max_leaf_char_len`, it is logically split * between as many leaves as necessary. Regardless, the string itself * is not copied * * # Arguments * * * byte_start - The byte offset where the slice of `str` starts. * * byte_len   - The number of bytes from `str` to use. * * # Safety note * * Behavior is undefined if `byte_start` or `byte_len` do not represent * valid positions in `str` */ pub fn of_substr(str: @~str, byte_start: uint, byte_len: uint) -> @Node { return of_substr_unsafer(str, byte_start, byte_len, str.slice(byte_start, byte_start + byte_len).char_len()); } /** * Adopt a slice of a string as a node. * * If the slice is longer than `max_leaf_char_len`, it is logically split * between as many leaves as necessary. Regardless, the string itself * is not copied * * # Arguments * * * byte_start - The byte offset where the slice of `str` starts. * * byte_len - The number of bytes from `str` to use. * * char_len - The number of chars in `str` in the interval *              [byte_start, byte_start+byte_len) * * # Safety notes * * * Behavior is undefined if `byte_start` or `byte_len` do not represent *   valid positions in `str` * * Behavior is undefined if `char_len` does not accurately represent the *   number of chars between byte_start and byte_start+byte_len */ pub fn of_substr_unsafer(str: @~str, byte_start: uint, byte_len: uint, char_len: uint) -> @Node { assert!((byte_start + byte_len <= str.len())); let candidate = @Leaf(Leaf { byte_offset: byte_start, byte_len: byte_len, char_len: char_len, content: str, }); if char_len <= HINT_MAX_LEAF_CHAR_LEN { return candidate; } else { //Firstly, split `str` in slices of HINT_MAX_LEAF_CHAR_LEN let mut leaves = uint::div_ceil(char_len, HINT_MAX_LEAF_CHAR_LEN); //Number of leaves let mut nodes  = vec::from_elem(leaves, candidate); let mut i = 0u; let mut offset = byte_start; let first_leaf_char_len = if char_len%HINT_MAX_LEAF_CHAR_LEN == 0u { HINT_MAX_LEAF_CHAR_LEN } else { char_len%HINT_MAX_LEAF_CHAR_LEN }; while i < leaves { let chunk_char_len: uint = if i == 0u  { first_leaf_char_len } else { HINT_MAX_LEAF_CHAR_LEN }; let chunk_byte_len = str.slice_from(offset).slice_chars(0, chunk_char_len).len(); nodes[i] = @Leaf(Leaf { byte_offset: offset, byte_len: chunk_byte_len, char_len: chunk_char_len, content: str, }); offset += chunk_byte_len; i      += 1u; } //Then, build a tree from these slices by collapsing them while leaves > 1u { i = 0u; while i < leaves - 1u {//Concat nodes 0 with 1, 2 with 3 etc. nodes[i/2u] = concat2(nodes[i], nodes[i + 1u]); i += 2u; } if i == leaves - 1u { //And don't forget the last node if it is in even position nodes[i/2u] = nodes[i]; } leaves = uint::div_ceil(leaves, 2u); } return nodes[0u]; } } pub fn byte_len(node: @Node) -> uint { //FIXME (#2744): Could we do this without the pattern-matching? match (*node) { Leaf(y) => y.byte_len, Concat(ref y) => y.byte_len } } pub fn char_len(node: @Node) -> uint { match (*node) { Leaf(y) => y.char_len, Concat(ref y) => y.char_len } } /** * Concatenate a forest of nodes into one tree. * * # Arguments * * * forest - The forest. This vector is progressively rewritten during *            execution and should be discarded as meaningless afterwards. */ pub fn tree_from_forest_destructive(forest: &mut [@Node]) -> @Node { let mut i; let mut len = forest.len(); while len > 1u { i = 0u; while i < len - 1u {//Concat nodes 0 with 1, 2 with 3 etc. let mut left  = forest[i]; let mut right = forest[i+1u]; let left_len = char_len(left); let right_len= char_len(right); let mut left_height= height(left); let mut right_height=height(right); if left_len + right_len > HINT_MAX_LEAF_CHAR_LEN { if left_len <= HINT_MAX_LEAF_CHAR_LEN { left = flatten(left); left_height = height(left); } if right_len <= HINT_MAX_LEAF_CHAR_LEN { right = flatten(right); right_height = height(right); } } if left_height >= HINT_MAX_NODE_HEIGHT { left = of_substr_unsafer(@serialize_node(left), 0u,byte_len(left), left_len); } if right_height >= HINT_MAX_NODE_HEIGHT { right = of_substr_unsafer(@serialize_node(right), 0u,byte_len(right), right_len); } forest[i/2u] = concat2(left, right); i += 2u; } if i == len - 1u { //And don't forget the last node if it is in even position forest[i/2u] = forest[i]; } len = uint::div_ceil(len, 2u); } return forest[0]; } pub fn serialize_node(node: @Node) -> ~str { unsafe { let mut buf = vec::from_elem(byte_len(node), 0); let mut offset = 0u;//Current position in the buffer let mut it = leaf_iterator::start(node); loop { match leaf_iterator::next(&mut it) { None => break, Some(x) => { //FIXME (#2744): Replace with memcpy or something similar let local_buf: ~[u8] = cast::transmute(copy *x.content); let mut i = x.byte_offset; while i < x.byte_len { buf[offset] = local_buf[i]; offset += 1u; i      += 1u; } cast::forget(local_buf); } } } return cast::transmute(buf); } } /** * Replace a subtree by a single leaf with the same contents. * * * Performance note * * This function executes in linear time. */ pub fn flatten(node: @Node) -> @Node { match (*node) { Leaf(_) => node, Concat(ref x) => { @Leaf(Leaf { byte_offset: 0u, byte_len: x.byte_len, char_len: x.char_len, content: @serialize_node(node), }) } } } /** * Balance a node. * * # Algorithm * * * if the node height is smaller than `HINT_MAX_NODE_HEIGHT`, do nothing * * otherwise, gather all leaves as a forest, rebuild a balanced node, *   concatenating small leaves along the way * * # Return value * * * `None` if no transformation happened * * `Some(x)` otherwise, in which case `x` has the same contents *    as `node` bot lower height and/or fragmentation. */ pub fn bal(node: @Node) -> Option<@Node> { if height(node) < HINT_MAX_NODE_HEIGHT { return None; } //1. Gather all leaves as a forest let mut forest = ~[]; let mut it = leaf_iterator::start(node); loop { match leaf_iterator::next(&mut it) { None    => break, Some(x) => forest.push(@Leaf(x)) } } //2. Rebuild tree from forest let root = @*tree_from_forest_destructive(forest); return Some(root); } /** * Compute the subnode of a node. * * # Arguments * * * node        - A node * * byte_offset - A byte offset in `node` * * byte_len    - The number of bytes to return * * # Performance notes * * * this function performs no copying; * * this function executes in a time proportional to the height of `node` * * # Safety notes * * This function fails if `byte_offset` or `byte_len` do not represent * valid positions in `node`. */ pub fn sub_bytes(node: @Node, byte_offset: uint, byte_len: uint) -> @Node { let mut node        = node; let mut byte_offset = byte_offset; loop { if byte_offset == 0u && byte_len == node::byte_len(node) { return node; } match (*node) { node::Leaf(x) => { let char_len = x.content.slice(byte_offset, byte_offset + byte_len).char_len(); return @Leaf(Leaf { byte_offset: byte_offset, byte_len: byte_len, char_len: char_len, content: x.content, }); } node::Concat(ref x) => { let left_len: uint = node::byte_len(x.left); if byte_offset <= left_len { if byte_offset + byte_len <= left_len { //Case 1: Everything fits in x.left, tail-call node = x.left; } else { //Case 2: A (non-empty, possibly full) suffix //of x.left and a (non-empty, possibly full) prefix //of x.right let left_result  = sub_bytes(x.left, byte_offset, left_len); let right_result = sub_bytes(x.right, 0u, left_len - byte_offset); return concat2(left_result, right_result); } } else { //Case 3: Everything fits in x.right byte_offset -= left_len; node = x.right; } } } }; } /** * Compute the subnode of a node. * * # Arguments * * * node        - A node * * char_offset - A char offset in `node` * * char_len    - The number of chars to return * * # Performance notes * * * this function performs no copying; * * this function executes in a time proportional to the height of `node` * * # Safety notes * * This function fails if `char_offset` or `char_len` do not represent * valid positions in `node`. */ pub fn sub_chars(node: @Node, char_offset: uint, char_len: uint) -> @Node { let mut node        = node; let mut char_offset = char_offset; loop { match (*node) { node::Leaf(x) => { if char_offset == 0u && char_len == x.char_len { return node; } let byte_offset = x.content.slice_chars(0, char_offset).len(); let byte_len    = x.content.slice_from(byte_offset).slice_chars(0, char_len).len(); return @Leaf(Leaf { byte_offset: byte_offset, byte_len: byte_len, char_len: char_len, content: x.content, }); } node::Concat(ref x) => { if char_offset == 0u && char_len == x.char_len {return node;} let left_len : uint = node::char_len(x.left); if char_offset <= left_len { if char_offset + char_len <= left_len { //Case 1: Everything fits in x.left, tail call node        = x.left; } else { //Case 2: A (non-empty, possibly full) suffix //of x.left and a (non-empty, possibly full) prefix //of x.right let left_result  = sub_chars(x.left, char_offset, left_len); let right_result = sub_chars(x.right, 0u, left_len - char_offset); return concat2(left_result, right_result); } } else { //Case 3: Everything fits in x.right, tail call node = x.right; char_offset -= left_len; } } } }; } pub fn concat2(left: @Node, right: @Node) -> @Node { @Concat(Concat { left: left, right: right, char_len: char_len(left) + char_len(right), byte_len: byte_len(left) + byte_len(right), height: uint::max(height(left), height(right)) + 1u, }) } pub fn height(node: @Node) -> uint { match (*node) { Leaf(_) => 0u, Concat(ref x) => x.height, } } pub fn cmp(a: @Node, b: @Node) -> int { let mut ita = char_iterator::start(a); let mut itb = char_iterator::start(b); let mut result = 0; while result == 0 { match (char_iterator::next(&mut ita), char_iterator::next(&mut itb)) { (None, None) => break, (Some(chara), Some(charb)) => { result = chara.cmp(&charb) as int; } (Some(_), _) => { result = 1; } (_, Some(_)) => { result = -1; } } } return result; } pub fn loop_chars(node: @Node, it: &fn(c: char) -> bool) -> bool { return loop_leaves(node,|leaf| { leaf.content.slice(leaf.byte_offset, leaf.byte_len).iter().all(|c| it(c)) }); } /** * Loop through a node, leaf by leaf * * # Arguments * * * rope - A node to traverse. * * it - A block to execute with each consecutive leaf of the node. *        Return `true` to continue, `false` to stop * * # Arguments * * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ pub fn loop_leaves(node: @Node, it: &fn(Leaf) -> bool) -> bool{ let mut current = node; loop { match (*current) { Leaf(x) => return it(x), Concat(ref x) => if loop_leaves(x.left, |l| it(l)) { //non tail call current = x.right;       //tail call } else { return false; } } }; } /** * # Arguments * * * pos - A position in the rope * * # Return value * * The character at position `pos` * * # Safety notes * * The function will fail if `pos` is not a valid position in the rope. * * Performance note: This function executes in a time * proportional to the height of the rope + the (bounded) * length of the largest leaf. */ pub fn char_at(mut node: @Node, mut pos: uint) -> char { loop { match *node { Leaf(x) => return x.content.char_at(pos), Concat(Concat {left, right, _}) => { let left_len = char_len(left); node = if left_len > pos { left } else { pos -= left_len; right }; } } }; } pub mod leaf_iterator { use rope::node::{Concat, Leaf, Node, height}; use std::vec; pub struct T { stack: ~[@Node], stackpos: int, } pub fn empty() -> T { let stack : ~[@Node] = ~[]; T { stack: stack, stackpos: -1 } } pub fn start(node: @Node) -> T { let stack = vec::from_elem(height(node)+1u, node); T { stack: stack, stackpos:  0, } } pub fn next(it: &mut T) -> Option<Leaf> { if it.stackpos < 0 { return None; } loop { let current = it.stack[it.stackpos]; it.stackpos -= 1; match (*current) { Concat(ref x) => { it.stackpos += 1; it.stack[it.stackpos] = x.right; it.stackpos += 1; it.stack[it.stackpos] = x.left; } Leaf(x) => return Some(x) } }; } } pub mod char_iterator { use rope::node::{Leaf, Node}; use rope::node::leaf_iterator; pub struct T { leaf_iterator: leaf_iterator::T, leaf:  Option<Leaf>, leaf_byte_pos: uint, } pub fn start(node: @Node) -> T { T { leaf_iterator: leaf_iterator::start(node), leaf: None, leaf_byte_pos: 0u, } } pub fn empty() -> T { T { leaf_iterator: leaf_iterator::empty(), leaf: None, leaf_byte_pos: 0u, } } pub fn next(it: &mut T) -> Option<char> { loop { match get_current_or_next_leaf(it) { None => return None, Some(_) => { let next_char = get_next_char_in_leaf(it); match next_char { None => loop, Some(_) => return next_char } } } }; } pub fn get_current_or_next_leaf(it: &mut T) -> Option<Leaf> { match it.leaf { Some(_) => return it.leaf, None => { let next = leaf_iterator::next(&mut it.leaf_iterator); match next { None => return None, Some(_) => { it.leaf          = next; it.leaf_byte_pos = 0u; return next; } } } } } pub fn get_next_char_in_leaf(it: &mut T) -> Option<char> { match copy it.leaf { None => return None, Some(aleaf) => { if it.leaf_byte_pos >= aleaf.byte_len { //We are actually past the end of the leaf it.leaf = None; return None } else { let range = aleaf.content.char_range_at((*it).leaf_byte_pos + aleaf.byte_offset); let ch = range.ch; let next = range.next; (*it).leaf_byte_pos = next - aleaf.byte_offset; return Some(ch) } } } } } } #[cfg(test)] mod tests { use rope::*; use std::uint; use std::vec; //Utility function, used for sanity check fn rope_to_string(r: Rope) -> ~str { match (r) { node::Empty => return ~"", node::Content(x) => { let mut str = ~""; fn aux(str: &mut ~str, node: @node::Node) { match (*node) { node::Leaf(x) => { str.push_str(x.content.slice(x.byte_offset, x.byte_offset + x.byte_len)); } node::Concat(ref x) => { aux(str, x.left); aux(str, x.right); } } } aux(&mut str, x); return str } } } #[test] fn trivial() { assert_eq!(char_len(empty()), 0u); assert_eq!(byte_len(empty()), 0u); } #[test] fn of_string1() { let sample = @~"0123456789ABCDE"; let r      = of_str(sample); assert_eq!(char_len(r), sample.char_len()); assert!(rope_to_string(r) == *sample); } #[test] fn of_string2() { let buf = @ mut ~"1234567890"; let mut i = 0; while i < 10 { let a = copy *buf; let b = copy *buf; *buf = a + b; i+=1; } let sample = @copy *buf; let r      = of_str(sample); assert_eq!(char_len(r), sample.char_len()); assert!(rope_to_string(r) == *sample); let mut string_iter = 0u; let string_len = sample.len(); let mut rope_iter = iterator::char::start(r); let mut equal = true; while equal { match (node::char_iterator::next(&mut rope_iter)) { None => { if string_iter < string_len { equal = false; } break; } Some(c) => { let range = sample.char_range_at(string_iter); string_iter = range.next; if range.ch != c { equal = false; break; } } } } assert!(equal); } #[test] fn iter1() { let buf = @ mut ~"1234567890"; let mut i = 0; while i < 10 { let a = copy *buf; let b = copy *buf; *buf = a + b; i+=1; } let sample = @copy *buf; let r      = of_str(sample); let mut len = 0u; let mut it  = iterator::char::start(r); loop { match (node::char_iterator::next(&mut it)) { None => break, Some(_) => len += 1u } } assert_eq!(len, sample.char_len()); } #[test] fn bal1() { let init = @~"1234567890"; let buf  = @mut copy *init; let mut i = 0; while i < 8 { let a = copy *buf; let b = copy *buf; *buf = a + b; i+=1; } let sample = @copy *buf; let r1     = of_str(sample); let mut r2 = of_str(init); i = 0; while i < 8 { r2 = append_rope(r2, r2); i+= 1;} assert!(eq(r1, r2)); let r3 = bal(r2); assert_eq!(char_len(r1), char_len(r3)); assert!(eq(r1, r3)); } #[test] #[ignore] fn char_at1() { //Generate a large rope let mut r = of_str(@~"123456789"); for uint::range(0u, 10u) |_i| { r = append_rope(r, r); } //Copy it in the slowest possible way let mut r2 = empty(); for uint::range(0u, char_len(r)) |i| { r2 = append_char(r2, char_at(r, i)); } assert!(eq(r, r2)); let mut r3 = empty(); for uint::range(0u, char_len(r)) |i| { r3 = prepend_char(r3, char_at(r, char_len(r) - i - 1u)); } assert!(eq(r, r3)); //Additional sanity checks let balr = bal(r); let bal2 = bal(r2); let bal3 = bal(r3); assert!(eq(r, balr)); assert!(eq(r, bal2)); assert!(eq(r, bal3)); assert!(eq(r2, r3)); assert!(eq(bal2, bal3)); } #[test] fn concat1() { //Generate a reasonable rope let chunk = of_str(@~"123456789"); let mut r = empty(); for uint::range(0u, 10u) |_i| { r = append_rope(r, chunk); } //Same rope, obtained with rope::concat let r2 = concat(vec::from_elem(10u, chunk)); assert!(eq(r, r2)); } } </del>


} else { match self.try_coercion_cast(fcx) { Ok(()) => { <del> self.trivial_cast_lint(fcx); debug!(" -> CoercionCast"); fcx.typeck_results.borrow_mut().set_coercion_cast(self.expr.hir_id.local_id); </del> <ins> if self.expr_ty.is_unsafe_ptr() && self.cast_ty.is_unsafe_ptr() { // When casting a raw pointer to another raw pointer, we cannot convert the cast into // a coercion because the pointee types might only differ in regions, which HIR typeck // cannot distinguish. This would cause us to erroneously discard a cast which will // lead to a borrowck error like #113257. // We still did a coercion above to unify inference variables for `ptr as _` casts. // This does cause us to miss some trivial casts in the trival cast lint. debug!(" -> PointerCast"); } else { self.trivial_cast_lint(fcx); debug!(" -> CoercionCast"); fcx.typeck_results .borrow_mut() .set_coercion_cast(self.expr.hir_id.local_id); } </ins> } Err(_) => { match self.do_check(fcx) {


//! } //! //! // This function wants to log its parameter out prior to doing work with it. <del> //! fn do_work<T: Show>(value: &T) { </del> <ins> //! fn do_work<T: Show+'static>(value: &T) { </ins> //!     log(value); //!     // ...do some other work //! }


None => return DummyResult::any(sp), }; // The file will be added to the code map by the parser <del> let file = cx.resolve_path(file, sp); </del> <ins> let file = match cx.resolve_path(file, sp) { Ok(f) => f, Err(mut err) => { err.emit(); return DummyResult::any(sp); }, }; </ins> let directory_ownership = DirectoryOwnership::Owned { relative: None }; let p = parse::new_sub_parser_from_file(cx.parse_sess(), &file, directory_ownership, None, sp);


ARCH=$1 LIB_ARCH=$2 APT_ARCH=$3 <ins> MANUFACTURER=$4 </ins> BINUTILS=2.28.1 GCC=6.5.0 <del> # Choose correct target based on the $ARCH case "$ARCH" in x86_64) TARGET=x86_64-pc-solaris2.10 ;; sparcv9) TARGET=sparcv9-sun-solaris2.10 ;; *) printf 'ERROR: unknown architecture: %sn' "$ARCH" exit 1 esac </del> <ins> TARGET=${ARCH}-${MANUFACTURER}-solaris2.10 </ins> # First up, build binutils mkdir binutils


let diagnostic = &sess.span_diagnostic; 'outer: for attr in attrs_iter { <del> if attr.path != "deprecated" { continue </del> <ins> if !attr.check_name("deprecated") { continue; </ins> } <del> mark_used(attr); </del> if depr.is_some() { span_err!(diagnostic, item_sp, E0550, "multiple deprecated attributes"); break } <del> depr = if let Some(metas) = attr.meta_item_list() { let get = |meta: &MetaItem, item: &mut Option<Symbol>| { if item.is_some() { handle_errors(sess, meta.span, AttrError::MultipleItem(meta.name())); return false } if let Some(v) = meta.value_str() { *item = Some(v); true } else { if let Some(lit) = meta.name_value_literal() { handle_errors( sess, lit.span, AttrError::UnsupportedLiteral( "literal in `deprecated`  value must be a string", lit.node.is_bytestr() ), ); } else { span_err!(diagnostic, meta.span, E0551, "incorrect meta item"); </del> <ins> let meta = attr.meta().unwrap(); depr = match &meta.node { MetaItemKind::Word => Some(Deprecation { since: None, note: None }), MetaItemKind::NameValue(..) => { meta.value_str().map(|note| { Deprecation { since: None, note: Some(note) } }) } MetaItemKind::List(list) => { let get = |meta: &MetaItem, item: &mut Option<Symbol>| { if item.is_some() { handle_errors(sess, meta.span, AttrError::MultipleItem(meta.name())); return false </ins> } <ins> if let Some(v) = meta.value_str() { *item = Some(v); true } else { if let Some(lit) = meta.name_value_literal() { handle_errors( sess, lit.span, AttrError::UnsupportedLiteral( "literal in `deprecated`  value must be a string", lit.node.is_bytestr() ), ); } else { span_err!(diagnostic, meta.span, E0551, "incorrect meta item"); } </ins> <del> false } }; </del> <ins> false } }; </ins> <del> let mut since = None; let mut note = None; for meta in metas { match &meta.node { NestedMetaItemKind::MetaItem(mi) => { match &*mi.name().as_str() { "since" => if !get(mi, &mut since) { continue 'outer }, "note" => if !get(mi, &mut note) { continue 'outer }, _ => { handle_errors( sess, meta.span, AttrError::UnknownMetaItem(mi.name(), &["since", "note"]), ); continue 'outer </del> <ins> let mut since = None; let mut note = None; for meta in list { match &meta.node { NestedMetaItemKind::MetaItem(mi) => { match &*mi.name().as_str() { "since" => if !get(mi, &mut since) { continue 'outer }, "note" => if !get(mi, &mut note) { continue 'outer }, _ => { handle_errors( sess, meta.span, AttrError::UnknownMetaItem(mi.name(), &["since", "note"]), ); continue 'outer } </ins> } } <del> } NestedMetaItemKind::Literal(lit) => { handle_errors( sess, lit.span, AttrError::UnsupportedLiteral( "item in `deprecated` must be a key/value pair", false, ), ); continue 'outer </del> <ins> NestedMetaItemKind::Literal(lit) => { handle_errors( sess, lit.span, AttrError::UnsupportedLiteral( "item in `deprecated` must be a key/value pair", false, ), ); continue 'outer } </ins> } } <del> } Some(Deprecation {since: since, note: note}) } else { Some(Deprecation{since: None, note: None}) } </del> <ins> Some(Deprecation { since, note }) } }; </ins> } depr


<ins> #![crate_type = "lib"] #![feature(unnamed_fields)] #![allow(unused, incomplete_features)] enum K { M { _ : struct { field: u8 }, //~^ error: unnamed fields are not allowed outside of structs or unions //~| error: anonymous structs are not allowed outside of unnamed struct or union fields } } </ins>


<ins> error[E0080]: it is undefined behavior to use this value --> $DIR/issue-79690.rs:29:1 | LL | const G: Fat = unsafe { Transmute { t: FOO }.u }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered read of part of a pointer at .1.<deref>.size.foo | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. </ins>


&format!("comparison of `{}`", cx.ty_to_string(rhs_t))[], StrEqFnLangItem); <del> callee::trans_lang_call(cx, did, &[lhs, rhs], None, debug_loc) </del> <ins> let t = ty::mk_str_slice(cx.tcx(), cx.tcx().mk_region(ty::ReStatic), ast::MutImmutable); // The comparison function gets the slices by value, so we have to make copies here. Even // if the function doesn't write through the pointer, things like lifetime intrinsics // require that we do this properly let lhs_arg = alloc_ty(cx, t, "lhs"); let rhs_arg = alloc_ty(cx, t, "rhs"); memcpy_ty(cx, lhs_arg, lhs, t); memcpy_ty(cx, rhs_arg, rhs, t); let res = callee::trans_lang_call(cx, did, &[lhs_arg, rhs_arg], None, debug_loc); call_lifetime_end(res.bcx, lhs_arg); call_lifetime_end(res.bcx, rhs_arg); res </ins> } let _icx = push_ctxt("compare_values");


<ins> // Regression test for ICE #130012 // Checks that we do not ICE while reporting // lifetime mistmatch error trait Fun { type Assoc; } trait MyTrait: for<'a> Fun<Assoc = &'a ()> {} //~^ ERROR binding for associated type `Assoc` references lifetime `'a`, which does not appear in the trait input types //~| ERROR binding for associated type `Assoc` references lifetime `'a`, which does not appear in the trait input types //~| ERROR binding for associated type `Assoc` references lifetime `'a`, which does not appear in the trait input types impl<F: for<'b> Fun<Assoc = &'b ()>> MyTrait for F {} //~^ ERROR binding for associated type `Assoc` references lifetime `'b`, which does not appear in the trait input types //~| ERROR mismatched types fn main() {} </ins>


<ins> #![allow(unused)] fn main() { let _foo = b'hello0'; //~^ ERROR character literal may only contain one codepoint //~| HELP if you meant to write a byte string literal, use double quotes let _bar = 'hello'; //~^ ERROR character literal may only contain one codepoint //~| HELP if you meant to write a `str` literal, use double quotes } </ins>


pub fn prepend(&mut self, line: usize, string: &str, style: Style) { self.ensure_lines(line); <del> let string_len = string.len(); </del> <ins> let string_len = string.chars().count(); </ins> // Push the old content over to make room for new content for _ in 0..string_len {


return None; } } <del> Some(i) </del> <ins> if lines.is_empty() { None } else { Some(lines[0][..i].into()) } </ins> } let data_s = data.as_str();


<ins> #![feature(prelude_import)] #![no_std] //@ check-pass //@ aux-build: another-proc-macro.rs //@ compile-flags: -Zunpretty=expanded #![feature(derive_smart_pointer)] #[prelude_import] use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; #[macro_use] extern crate another_proc_macro; use another_proc_macro::{pointee, AnotherMacro}; #[repr(transparent)] pub struct Ptr<'a, #[pointee] T: ?Sized> { data: &'a mut T, } #[automatically_derived] impl<'a, T: ?Sized + ::core::marker::Unsize<__S>, __S: ?Sized> ::core::ops::DispatchFromDyn<Ptr<'a, __S>> for Ptr<'a, T> { } #[automatically_derived] impl<'a, T: ?Sized + ::core::marker::Unsize<__S>, __S: ?Sized> ::core::ops::CoerceUnsized<Ptr<'a, __S>> for Ptr<'a, T> { } const _: () = { const POINTEE_MACRO_ATTR_DERIVED: () = (); }; #[pointee] struct MyStruct; const _: () = { const ANOTHER_MACRO_DERIVED: () = (); }; fn main() {} </ins>


<ins> error[E0277]: expected a `std::ops::Fn<()>` closure, found `fn() {foo}` --> $DIR/fn-traits.rs:24:10 | LL | fn call(f: impl Fn()) { |                 ---- required by this bound in `call` ... LL |     call(foo); |          ^^^ expected an `Fn<()>` closure, found `fn() {foo}` | = help: the trait `std::ops::Fn<()>` is not implemented for `fn() {foo}` = note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ } = note: `#[target_feature]` functions do not implement the `Fn` traits error[E0277]: expected a `std::ops::FnMut<()>` closure, found `fn() {foo}` --> $DIR/fn-traits.rs:25:14 | LL | fn call_mut(f: impl FnMut()) { |                     ------- required by this bound in `call_mut` ... LL |     call_mut(foo); |              ^^^ expected an `FnMut<()>` closure, found `fn() {foo}` | = help: the trait `std::ops::FnMut<()>` is not implemented for `fn() {foo}` = note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ } = note: `#[target_feature]` functions do not implement the `Fn` traits error[E0277]: expected a `std::ops::FnOnce<()>` closure, found `fn() {foo}` --> $DIR/fn-traits.rs:26:15 | LL | fn call_once(f: impl FnOnce()) { |                      -------- required by this bound in `call_once` ... LL |     call_once(foo); |               ^^^ expected an `FnOnce<()>` closure, found `fn() {foo}` | = help: the trait `std::ops::FnOnce<()>` is not implemented for `fn() {foo}` = note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ } = note: `#[target_feature]` functions do not implement the `Fn` traits error[E0277]: expected a `std::ops::Fn<()>` closure, found `unsafe fn() {foo_unsafe}` --> $DIR/fn-traits.rs:28:10 | LL | fn call(f: impl Fn()) { |                 ---- required by this bound in `call` ... LL |     call(foo_unsafe); |          ^^^^^^^^^^ expected an `Fn<()>` closure, found `unsafe fn() {foo_unsafe}` | = help: the trait `std::ops::Fn<()>` is not implemented for `unsafe fn() {foo_unsafe}` = note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ } = note: `#[target_feature]` functions do not implement the `Fn` traits error[E0277]: expected a `std::ops::FnMut<()>` closure, found `unsafe fn() {foo_unsafe}` --> $DIR/fn-traits.rs:30:14 | LL | fn call_mut(f: impl FnMut()) { |                     ------- required by this bound in `call_mut` ... LL |     call_mut(foo_unsafe); |              ^^^^^^^^^^ expected an `FnMut<()>` closure, found `unsafe fn() {foo_unsafe}` | = help: the trait `std::ops::FnMut<()>` is not implemented for `unsafe fn() {foo_unsafe}` = note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ } = note: `#[target_feature]` functions do not implement the `Fn` traits error[E0277]: expected a `std::ops::FnOnce<()>` closure, found `unsafe fn() {foo_unsafe}` --> $DIR/fn-traits.rs:32:15 | LL | fn call_once(f: impl FnOnce()) { |                      -------- required by this bound in `call_once` ... LL |     call_once(foo_unsafe); |               ^^^^^^^^^^ expected an `FnOnce<()>` closure, found `unsafe fn() {foo_unsafe}` | = help: the trait `std::ops::FnOnce<()>` is not implemented for `unsafe fn() {foo_unsafe}` = note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ } = note: `#[target_feature]` functions do not implement the `Fn` traits error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0277`. </ins>


} alloc0 (static: FOO, size: 8, align: 8) { <del> ╾───────alloc3────────╼                         │ ╾──────╼ </del> <ins> ╾───────alloc9────────╼                         │ ╾──────╼ </ins> } <del> alloc3 (size: 180, align: 1) { </del> <ins> alloc9 (size: 180, align: 1) { </ins> 0x00 │ ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab │ ................ 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾──alloc4── │ ............╾─── 0x20 │ ──────────╼ 01 ef cd ab 00 00 00 00 00 00 00 00 │ ───╼............


<del> use crate::spec::{LinkerFlavor, PanicStrategy, Target, TargetResult}; </del> <ins> use crate::spec::{LinkerFlavor, Target, TargetResult}; </ins> pub fn target() -> TargetResult { let mut base = super::windows_uwp_msvc_base::opts(); base.max_atomic_width = Some(64); base.has_elf_tls = true; <del> // FIXME: this shouldn't be panic=abort, it should be panic=unwind base.panic_strategy = PanicStrategy::Abort; </del> Ok(Target { llvm_target: "aarch64-pc-windows-msvc".to_string(), target_endian: "little".to_string(),


COPY host-x86_64/dist-x86_64-linux/build-binutils.sh /tmp/ RUN ./build-binutils.sh <del> # libssh2 (a dependency of Cargo) requires cmake 2.8.11 or higher but CentOS # only has 2.6.4, so build our own COPY host-x86_64/dist-x86_64-linux/build-cmake.sh /tmp/ RUN ./build-cmake.sh # Need a newer version of gcc than centos has to compile LLVM nowadays </del> <ins> # Need at least GCC 5.1 to compile LLVM nowadays </ins> COPY host-x86_64/dist-x86_64-linux/build-gcc.sh /tmp/ <del> RUN ./build-gcc.sh </del> <ins> RUN ./build-gcc.sh && apt-get remove -y gcc g++ </ins> <del> # CentOS 5.5 has Python 2.4 by default, but LLVM needs 2.7+ </del> <ins> # Debian 6 has Python 2.6 by default, but LLVM needs 2.7+ </ins> COPY host-x86_64/dist-x86_64-linux/build-python.sh /tmp/ RUN ./build-python.sh <del> # Now build LLVM+Clang 7, afterwards configuring further compilations to use the </del> <ins> # LLVM needs cmake 3.4.3 or higher, and is planning to raise to 3.13.4. COPY host-x86_64/dist-x86_64-linux/build-cmake.sh /tmp/ RUN ./build-cmake.sh # Now build LLVM+Clang, afterwards configuring further compilations to use the </ins> # clang/clang++ compilers. <del> COPY host-x86_64/dist-x86_64-linux/build-clang.sh host-x86_64/dist-x86_64-linux/llvm-project-centos.patch /tmp/ </del> <ins> COPY host-x86_64/dist-x86_64-linux/build-clang.sh /tmp/ </ins> RUN ./build-clang.sh ENV CC=clang CXX=clang++ <del> # Apparently CentOS 5.5 desn't have `git` in yum, but we're gonna need it for # cloning, so download and build it here. COPY host-x86_64/dist-x86_64-linux/build-git.sh /tmp/ RUN ./build-git.sh # for sanitizers, we need kernel headers files newer than the ones CentOS ships # with so we install newer ones here COPY host-x86_64/dist-x86_64-linux/build-headers.sh /tmp/ RUN ./build-headers.sh # OpenSSL requires a more recent version of perl # with so we install newer ones here COPY host-x86_64/dist-x86_64-linux/build-perl.sh /tmp/ RUN ./build-perl.sh </del> COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh


LL | fn test_many_bounds_where<X>(x: X) where X: Sized, X: Sized, X: Debug { |                                                            ^^^^^^^^^^ <del> error: aborting due to 6 previous errors </del> <ins> error[E0277]: the size for values of type `Self` cannot be known at compilation time --> $DIR/bound-suggestions.rs:44:46 | LL |     const SIZE: usize = core::mem::size_of::<Self>(); |                                              ^^^^ doesn't have a size known at compile-time | ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of<T>() -> usize { |                      - required by this bound in `std::mem::size_of` | help: consider further restricting `Self` | LL | trait Foo<T>: Sized { |             ^^^^^^^ error[E0277]: the size for values of type `Self` cannot be known at compilation time --> $DIR/bound-suggestions.rs:49:46 | LL |     const SIZE: usize = core::mem::size_of::<Self>(); |                                              ^^^^ doesn't have a size known at compile-time | ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of<T>() -> usize { |                      - required by this bound in `std::mem::size_of` | help: consider further restricting `Self` | LL | trait Bar: std::fmt::Display + Sized { |                              ^^^^^^^ error[E0277]: the size for values of type `Self` cannot be known at compilation time --> $DIR/bound-suggestions.rs:54:46 | LL |     const SIZE: usize = core::mem::size_of::<Self>(); |                                              ^^^^ doesn't have a size known at compile-time | ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of<T>() -> usize { |                      - required by this bound in `std::mem::size_of` | help: consider further restricting `Self` | LL | trait Baz: Sized where Self: std::fmt::Display { |          ^^^^^^^ error[E0277]: the size for values of type `Self` cannot be known at compilation time --> $DIR/bound-suggestions.rs:59:46 | LL |     const SIZE: usize = core::mem::size_of::<Self>(); |                                              ^^^^ doesn't have a size known at compile-time | ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of<T>() -> usize { |                      - required by this bound in `std::mem::size_of` | help: consider further restricting `Self` | LL | trait Qux<T>: Sized where Self: std::fmt::Display { |             ^^^^^^^ error[E0277]: the size for values of type `Self` cannot be known at compilation time --> $DIR/bound-suggestions.rs:64:46 | LL |     const SIZE: usize = core::mem::size_of::<Self>(); |                                              ^^^^ doesn't have a size known at compile-time | ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | LL | pub const fn size_of<T>() -> usize { |                      - required by this bound in `std::mem::size_of` | help: consider further restricting `Self` | LL | trait Bat<T>: std::fmt::Display + Sized { |                                 ^^^^^^^ error: aborting due to 11 previous errors </ins> For more information about this error, try `rustc --explain E0277`.


// EMIT_MIR casts.roundtrip.InstSimplify.diff pub fn roundtrip(x: *const u8) -> *const u8 { // CHECK-LABEL: fn roundtrip( <del> // CHECK: _3 = _1; // CHECK: _2 = move _3 as *mut u8 (PtrToPtr); // CHECK: _0 = move _2 as *const u8 (PointerCoercion(MutToConstPointer)); </del> <ins> // CHECK: _4 = _1; // CHECK: _3 = move _4 as *mut u8 (PtrToPtr); // CHECK: _2 = move _3 as *const u8 (PointerCoercion(MutToConstPointer)); </ins> x as *mut u8 as *const u8 }


.suggestion = convert it to a `{$msg_code}` hir_analysis_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)` <ins> hir_analysis_missing_parentheses_in_range = can't call method `{$method_name}` on type `{$ty_str}` hir_analysis_add_missing_parentheses_in_range = you must surround the range in parentheses to call its `{$func_name}` function </ins>


if instance.def.is_inline(cx.tcx) { attributes::inline(lldecl, attributes::InlineAttr::Hint); } <del> attributes::from_fn_attrs(cx, lldecl, instance.def.def_id()); </del> <ins> attributes::from_fn_attrs(cx, lldecl, Some(instance.def.def_id())); </ins> cx.instances.borrow_mut().insert(instance, lldecl); }


<ins> error: attribute must be of the form `#[deprecated]` or `#[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason)]` or `#[deprecated = "reason"]` --> $DIR/invalid-literal.rs:1:1 | LL | #[deprecated = b"test"] //~ ERROR attribute must be of the form | ^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error </ins>


} #[test] <ins> #[allow(deprecated)] </ins> fn stream_smoke_test_ip6() { let server_ip = next_test_ip6(); let client_ip = next_test_ip6();


use rustc_ast as ast; use rustc_attr as attr; use rustc_data_structures::fingerprint::Fingerprint; <del> use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; </del> <ins> use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet}; </ins> use rustc_data_structures::intern::{Interned, WithStableHash}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::tagged_ptr::CopyTaggedPtr;


/// any methods, but instead is used to gate access to data. /// /// FIXME. Better documentation needed here! <del> pub trait MarkerTrait : PhantomFn<Self> { } </del> <ins> pub trait MarkerTrait : PhantomFn<Self,Self> { } //                                    ~~~~~ <-- FIXME(#22806)? // // Marker trait has been made invariant so as to avoid inf recursion, // but we should ideally solve the underlying problem. That's a bit // complicated. </ins> impl<T:?Sized> MarkerTrait for T { } /// `PhantomFn` is a marker trait for use with traits that contain


/// Parses an enum declaration. fn parse_item_enum(&mut self) -> PResult<'a, ItemInfo> { <ins> if self.token.is_keyword(kw::Struct) { let mut err = self.struct_span_err( self.prev_token.span.to(self.token.span), "`enum` and `struct` are mutually exclusive", ); err.span_suggestion( self.prev_token.span.to(self.token.span), "replace `enum struct` with", "enum", Applicability::MachineApplicable, ); if self.look_ahead(1, |t| t.is_ident()) { self.bump(); err.emit(); } else { return Err(err); } } </ins> let id = self.parse_ident()?; let mut generics = self.parse_generics()?; generics.where_clause = self.parse_where_clause()?;


<del> use core::task::{Context, Poll, RawWaker, RawWakerVTable, Waker}; </del> <ins> use core::task::{Poll, RawWaker, RawWakerVTable, Waker}; </ins> #[test] fn poll_const() {


f.debug_tuple("Drain") .field(&self.after_tail) .field(&self.after_head) <del> .field(&self.iter) </del> <ins> .field(&self.ring) .field(&self.tail) .field(&self.head) </ins> .finish() } }


<ins> error: index out of bounds: the len is 3 but the index is 4 --> $DIR/array-literal-index-oob.rs:2:7 | LL |     &{[1, 2, 3][4]}; |       ^^^^^^^^^^^^ | = note: #[deny(const_err)] on by default error: this expression will panic at runtime --> $DIR/array-literal-index-oob.rs:2:5 | LL |     &{[1, 2, 3][4]}; |     ^^^^^^^^^^^^^^^ index out of bounds: the len is 3 but the index is 4 error: reaching this expression at runtime will panic or abort --> $DIR/array-literal-index-oob.rs:2:7 | LL |     &{[1, 2, 3][4]}; |     --^^^^^^^^^^^^- |       | |       index out of bounds: the len is 3 but the index is 4 error: aborting due to 3 previous errors </ins>


crate_lint: CrateLint, ) -> PartialRes { tracing::debug!( <del> "smart_resolve_path_fragment(id={:?},qself={:?},path={:?}", </del> <ins> "smart_resolve_path_fragment(id={:?}, qself={:?}, path={:?})", </ins> id, qself, path


} } } <ins> #[allow(improper_ctypes)] mod unknown_layout { mod a { extern "C" { pub fn generic(l: Link<u32>); } pub struct Link<T> { pub item: T, pub next: *const Link<T>, } } mod b { extern "C" { pub fn generic(l: Link<u32>); } pub struct Link<T> { pub item: T, pub next: *const Link<T>, } } } </ins>


let (bounds, lifetime_bound) = self.with_dyn_type_scope(true, |this| { let bounds = this.arena.alloc_from_iter(bounds.iter().filter_map(|bound| match bound { <del> GenericBound::Trait( ty, TraitBoundModifiers { polarity: BoundPolarity::Positive | BoundPolarity::Negative(_), constness, }, ) => Some(this.lower_poly_trait_ref(ty, itctx, *constness)), // We can safely ignore constness here, since AST validation // will take care of invalid modifier combinations. GenericBound::Trait( _, TraitBoundModifiers { polarity: BoundPolarity::Maybe(_), .. }, ) => None, </del> <ins> // We can safely ignore constness here since AST validation // takes care of rejecting invalid modifier combinations and // const trait bounds in trait object types. GenericBound::Trait(ty, modifiers) => match modifiers.polarity { BoundPolarity::Positive | BoundPolarity::Negative(_) => { Some(this.lower_poly_trait_ref( ty, itctx, // Still, don't pass along the constness here; we don't want to // synthesize any host effect args, it'd only cause problems. ast::BoundConstness::Never, )) } BoundPolarity::Maybe(_) => None, }, </ins> GenericBound::Outlives(lifetime) => { if lifetime_bound.is_none() { lifetime_bound = Some(this.lower_lifetime(lifetime));


// list. let argv = ARGV.load(Ordering::Relaxed); let argc = if argv.is_null() { 0 } else { ARGC.load(Ordering::Relaxed) }; <del> (0..argc) .map(|i| { let cstr = CStr::from_ptr(*argv.offset(i) as *const libc::c_char); OsStringExt::from_vec(cstr.to_bytes().to_vec()) }) .collect() </del> <ins> let mut args = Vec::with_capacity(argc as usize); for i in 0..argc { let ptr = *argv.offset(i) as *const libc::c_char; // Some C commandline parsers (e.g. GLib and Qt) are replacing already // handled arguments in `argv` with `NULL` and move them to the end. That // means that `argc` might be bigger than the actual number of non-`NULL` // pointers in `argv` at this point. // // To handle this we simply stop iterating at the first `NULL` argument. // // `argv` is also guaranteed to be `NULL`-terminated so any non-`NULL` arguments // after the first `NULL` can safely be ignored. if ptr.is_null() { break; } let cstr = CStr::from_ptr(ptr); args.push(OsStringExt::from_vec(cstr.to_bytes().to_vec())); } args </ins> } } }


<ins> running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s </ins>


pub use adt::*; pub use assoc::*; pub use generics::*; <del> use hir::OpaqueTyOrigin; </del> use rustc_ast as ast; use rustc_ast::node_id::NodeMap; use rustc_attr as attr;


} /// Derive macro generating impls of traits related to smart pointers. <del> #[rustc_builtin_macro] </del> <ins> #[rustc_builtin_macro(SmartPointer, attributes(pointee))] </ins> #[allow_internal_unstable(dispatch_from_dyn, coerce_unsized, unsize)] #[unstable(feature = "derive_smart_pointer", issue = "123430")] pub macro SmartPointer($item:item) {


use FfiResult::*; if def.repr.transparent() { <del> // Can assume that only one field is not a ZST, so only check </del> <ins> // Can assume that at most one field is not a ZST, so only check </ins> // that field's type for FFI-safety. if let Some(field) = transparent_newtype_field(self.cx.tcx, variant) { self.check_field_type_for_ffi(cache, field, substs) } else { <del> bug!("malformed transparent type"); </del> <ins> // All fields are ZSTs; this means that the type should behave // like (), which is FFI-unsafe FfiUnsafe { ty, reason: "this struct contains only zero-sized fields".into(), help: None, } </ins> } } else { // We can't completely trust repr(C) markings; make sure the fields are


/// /// Additionally, `f32` can represent some special values: /// <del> /// - −0.0: IEEE 754 floating point numbers have a bit that indicates their sign, so −0.0 is a ///   possible value. For comparison −0.0 = +0.0, but floating point operations can carry </del> <ins> /// - −0.0: IEEE 754 floating-point numbers have a bit that indicates their sign, so −0.0 is a ///   possible value. For comparison −0.0 = +0.0, but floating-point operations can carry </ins> ///   the sign bit through arithmetic operations. This means −0.0 × +0.0 produces −0.0 and ///   a negative number rounded to a value smaller than a float can represent also produces −0.0. /// - [∞](#associatedconstant.INFINITY) and


impl<'tcx> OpaqueTypeExpander<'tcx> { fn expand_opaque_ty(&mut self, def_id: DefId, substs: SubstsRef<'tcx>) -> Option<Ty<'tcx>> { <del> if self.found_recursion { </del> <ins> if self.found_any_recursion { </ins> return None; } let substs = substs.fold_with(self);


/// Options for rendering Markdown in the main body of documentation. pub(crate) fn opts() -> Options { <del> Options::ENABLE_TABLES | Options::ENABLE_FOOTNOTES | Options::ENABLE_STRIKETHROUGH </del> <ins> Options::ENABLE_TABLES | Options::ENABLE_FOOTNOTES | Options::ENABLE_STRIKETHROUGH | Options::ENABLE_TASKLISTS </ins> } /// A subset of [`opts()`] used for rendering summaries.


- env: IMAGE=dist-x86_64-linux DEPLOY_ALT=1 - env: > RUST_CHECK_TARGET=dist <del> RUST_CONFIGURE_ARGS="--enable-extended" </del> <ins> RUST_CONFIGURE_ARGS="--enable-extended --enable-profiler" </ins> SRC=. DEPLOY_ALT=1 RUSTC_RETRY_LINKER_ON_SEGFAULT=1


# https://github.com/puppeteer/puppeteer/issues/375 # # We also specify the version in case we need to update it to go around cache limitations. <del> RUN npm install -g browser-ui-test@0.2.12 --unsafe-perm=true </del> <ins> RUN npm install -g browser-ui-test@0.2.14 --unsafe-perm=true </ins> ENV RUST_CONFIGURE_ARGS  --build=x86_64-unknown-linux-gnu


use libc::{mmap, mprotect}; use libc::{MAP_ANON, MAP_FAILED, MAP_FIXED, MAP_PRIVATE, PROT_NONE, PROT_READ, PROT_WRITE}; <ins> use crate::io; </ins> use crate::ops::Range; use crate::sync::atomic::{AtomicUsize, Ordering}; use crate::sys::os;


} } <del> clean::ExternCrateItem(..) | clean::ImportItem(_) => { if i.visibility != Some(hir::Public) { return None } } </del> clean::StructFieldItem(..) => { if i.visibility != Some(hir::Public) { return Some(clean::Item {


RelateOutputImplTypes(span) => span, MatchExpressionArm(match_span, _) => match_span, IfExpression(span) => span, <ins> IfExpressionWithNoElse(span) => span </ins> } } }


<ins> pub trait Ice { fn f(&self, _: ()); } impl Ice for () { fn f(&self, _: ()) {} } fn main() { ().f::<()>(()); //~^ ERROR this associated function takes 0 generic arguments but 1 generic argument was supplied } </ins>


kind_name, tcx.item_path_str(variant.did), field_names); <del> if let Some((span, _)) = inexistent_fields.last() { </del> <ins> if let Some((span, ident)) = inexistent_fields.last() { </ins> err.span_label(*span, format!("{} `{}` does not have {} field{}", kind_name, tcx.item_path_str(variant.did), t, plural)); <ins> if plural == "" { let input = unmentioned_fields.iter().map(|field| &field.name); let suggested_name = find_best_match_for_name(input, &ident.name.as_str(), None); if let Some(suggested_name) = suggested_name { err.span_suggestion(*span, "did you mean", suggested_name.to_string()); // we don't want to throw `E0027` in case we have thrown `E0026` for them unmentioned_fields.retain(|&x| x.as_str() != suggested_name.as_str()); } } </ins> } if tcx.sess.teach(&err.get_code().unwrap()) { err.note(


<ins> // 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 transitive analysis for associated types. Collected types // should be normalized and new obligations generated. trait Foo { type A; fn foo(&self) {} } impl Foo for usize { type A = usize; } struct Bar<T: Foo> { inner: T::A } fn is_send<T: Send>() {} fn main() { is_send::<Bar<usize>>(); } </ins>


fn to_radians(self) -> f64 { num::Float::to_radians(self) } #[inline] <del> fn ldexp(x: f64, exp: int) -> f64 { unsafe { cmath::ldexp(x, exp as c_int) } </del> <ins> fn ldexp(self, exp: isize) -> f64 { unsafe { cmath::ldexp(self, exp as c_int) } </ins> } /// Breaks the number into a normalized fraction and a base-2 exponent,


<ins> error[E0599]: no method named `b` found for reference `&Self` in the current scope --> $DIR/issue-117794.rs:5:14 | LL |         self.b(|| 0) |              ^ help: there is a method with a similar name: `a` error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0599`. </ins>


assert_eq!("ΑΣ''Α".to_lowercase(), "ασ''α"); // https://github.com/rust-lang/rust/issues/124714 <ins> // input lengths around the boundary of the chunk size used by the ascii prefix optimization assert_eq!("abcdefghijklmnoΣ".to_lowercase(), "abcdefghijklmnoς"); </ins> assert_eq!("abcdefghijklmnopΣ".to_lowercase(), "abcdefghijklmnopς"); <ins> assert_eq!("abcdefghijklmnopqΣ".to_lowercase(), "abcdefghijklmnopqς"); </ins> // a really long string that has it's lowercase form // even longer. this tests that implementations don't assume


<ins> // check-pass // revisions: new old //[new] compile-flags: -Znext-solver //! This test checks that we can successfully infer //! the hidden type of `FooImpl` to be `Foo<i32, {closure}>` //! and `ImplT` to be `i32`. This test used to fail, because //! we were unable to make the connection that the closure //! argument is the same as the first argument of `Foo`. #![feature(type_alias_impl_trait)] use std::fmt::Debug; use std::marker::PhantomData; struct Foo<T: Debug, F: FnOnce(T)> { f: F, _phantom: PhantomData<T>, } type ImplT = impl Debug; type FooImpl = Foo<ImplT, impl FnOnce(ImplT)>; fn bar() -> FooImpl { Foo::<i32, _> { f: |_| (), _phantom: PhantomData } } fn main() {} </ins>


/// A Terminal that knows how many colors it supports, with a reference to its /// parsed Terminfo database record. pub struct TerminfoTerminal<T> { <del> num_colors: u16, </del> <ins> num_colors: u32, </ins> out: T, ti: TermInfo, }


#[must_use] #[inline] pub const fn from_waker(waker: &'a Waker) -> Self { <del> Context { waker, _marker: PhantomData } </del> <ins> Context { waker, _marker: PhantomData, _marker2: PhantomData } </ins> } /// Returns a reference to the [`Waker`] for the current task.


let err = Ty::new_error(self.tcx, guar); self.write_ty(hir_id, err); self.write_ty(pat.hir_id, err); <del> let mut visitor = V { tcx: self.tcx, pat_hir_ids: vec![] }; </del> <ins> let mut visitor = V { pat_hir_ids: vec![] }; </ins> hir::intravisit::walk_pat(&mut visitor, pat); // Mark all the subpatterns as `{type error}` as well. This allows errors for specific // subpatterns to be silenced.


/// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] <del> pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result<u64> </del> <ins> pub fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> Result<u64> </ins> where R: Read, W: Write,


pub fn is_dir(&self) -> bool { self.0.is_dir() } /// Test whether this file type represents a regular file. <ins> /// The result is  mutually exclusive to the results of /// [`is_dir`] and [`is_symlink`]; only zero or one of these /// tests may pass. /// /// [`is_dir`]: struct.FileType.html#method.is_dir /// [`is_symlink`]: struct.FileType.html#method.is_symlink </ins> /// /// # Examples ///


Abi::Rust ))); let llfn = declare::define_internal_fn(cx, name, rust_fn_ty); <ins> attributes::from_fn_attrs(cx, llfn, None); </ins> let bx = Builder::new_block(cx, llfn, "entry-block"); codegen(bx); llfn


<ins> #![deny(rustdoc::broken_intra_doc_links)] // Test intra-doc links on trait implementations with generics // regression test for issue #92662 use std::marker::PhantomData; pub trait Bar<T> { fn bar(&self); } pub struct Foo<U>(PhantomData<U>); impl<T, U> Bar<T> for Foo<U> { fn bar(&self) {} } // @has generic_trait_impl/fn.main.html '//a[@href="struct.Foo.html#method.bar"]' 'Foo::bar' /// link to [`Foo::bar`] pub fn main() {} </ins>


<ins> // edition:2018 trait T { async fn foo() {} //~ ERROR trait fns cannot be declared `async` async fn bar(&self) {} //~ ERROR trait fns cannot be declared `async` } fn main() {} </ins>


<ins> error: cannot capture late-bound lifetime in constant --> $DIR/escaping_bound_vars.rs:11:35 | LL |     (): Test<{ 1 + (<() as Elide(&())>::call) }>, |                                  -^ |                                  | |                                  lifetime defined here error: aborting due to previous error </ins>


fn print_poly_trait_ref(&mut self, t: &ast::PolyTraitRef) -> IoResult<()> { if !t.bound_lifetimes.is_empty() { try!(word(&mut self.s, "for<")); <ins> let mut comma = false; </ins> for lifetime_def in t.bound_lifetimes.iter() { <ins> if comma { try!(self.word_space(",")) } </ins> try!(self.print_lifetime_def(lifetime_def)); <ins> comma = true; </ins> } try!(word(&mut self.s, ">")); }


} } <ins> /// Constructs a new locked handle to the standard error of the current /// process. /// /// This handle is not buffered. /// /// ### Note: Windows Portability Consideration /// When operating in a console, the Windows implementation of this stream does not support /// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return /// an error. /// /// # Example /// /// ```no_run /// #![feature(stdio_locked)] /// use std::io::{self, Write}; /// /// fn main() -> io::Result<()> { ///     let mut handle = io::stderr_locked(); /// ///     handle.write_all(b"hello world")?; /// ///     Ok(()) /// } /// ``` #[unstable(feature = "stdio_locked", issue = "none")] pub fn stderr_locked() -> StderrLock<'static> { stderr().into_locked() } </ins> impl Stderr { /// Locks this handle to the standard error stream, returning a writable /// guard.


if let Some(err) = self.finalize_import(import) { errors = true; <ins> if let SingleImport { source, ref result, .. } = import.subclass { if source.name == "self" { // Silence `unresolved import` error if E0429 is already emitted match result.value_ns.get() { Err(Determined) => continue, _ => {}, } } } </ins> // If the error is a single failed import then create a "fake" import // resolution for it so that later resolve stages won't complain. self.import_dummy_binding(import);


<ins> fn main() { let abs: i32 = 3i32.checked_abs(); //~^ ERROR mismatched types } </ins>


<ins> error[E0308]: mismatched types --> $DIR/issue-73553-misinterp-range-literal.rs:12:10 | LL |     demo(tell(1)..tell(10)); |          ^^^^^^^^^^^^^^^^^ |          | |          expected reference, found struct `std::ops::Range` |          help: consider borrowing here: `&(tell(1)..tell(10))` | = note: expected reference `&std::ops::Range<usize>` found struct `std::ops::Range<usize>` error[E0308]: mismatched types --> $DIR/issue-73553-misinterp-range-literal.rs:14:10 | LL |     demo(1..10); |          ^^^^^ |          | |          expected reference, found struct `std::ops::Range` |          help: consider borrowing here: `&(1..10)` | = note: expected reference `&std::ops::Range<usize>` found struct `std::ops::Range<{integer}>` error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. </ins>


#![feature(unsafe_cell_raw_get)] #![feature(unwind_attributes)] #![feature(vec_into_raw_parts)] <ins> #![feature(vec_spare_capacity)] </ins> #![feature(wake_trait)] // NB: the above list is sorted to minimize merge conflicts. #![default_lib_allocator]


cx.span_lint(UNUSED_COMPARISONS, e.span, "comparison is useless due to type limits"); } <ins> if is_shift_binop(binop) { let opt_ty_bits = match ty::get(ty::expr_ty(cx.tcx, &**l)).sty { ty::ty_int(t) => Some(int_ty_bits(t)), ty::ty_uint(t) => Some(uint_ty_bits(t)), _ => None }; if let Some(bits) = opt_ty_bits { let exceeding = if let ast::ExprLit(ref lit) = r.node { if let ast::LitInt(shift, _) = lit.node { shift > bits } else { false } } else { match eval_const_expr_partial(cx.tcx, &**r) { Ok(const_int(shift)) => { shift as u64 > bits }, Ok(const_uint(shift)) => { shift > bits }, _ => { false } } }; if exceeding { cx.span_lint(EXCEEDING_BITSHIFTS, e.span, "bitshift exceeds the type's number of bits"); } }; } </ins> }, ast::ExprLit(ref lit) => { match ty::get(ty::expr_ty(cx.tcx, e)).sty {


ty = it.type_(), path = relpath ); if parentlen == 0 { <del> // There is no sidebar-items.js beyond the crate root path // FIXME maybe dynamic crate loading can be merged here </del> <ins> write!( buffer, "<script defer src="{}sidebar-items{}.js"></script>", relpath, cx.shared.resource_suffix ); </ins> } else { <del> write!(buffer, "<script defer src="{path}sidebar-items.js"></script>", path = relpath); </del> <ins> write!(buffer, "<script defer src="{}sidebar-items.js"></script>", relpath); </ins> } // Closes sidebar-elems div. buffer.write_str("</div>"); }


Ok(Some((d, path))) => (path.trim(), Some(d)), Ok(None) => (link.trim(), None), Err((err_msg, relative_range)) => { <del> let disambiguator_range = (no_backticks_range.start + relative_range.start) ..(no_backticks_range.start + relative_range.end); disambiguator_error(self.cx, &item, dox, disambiguator_range, &err_msg); </del> <ins> if !should_ignore_link_with_disambiguators(link) { // Only report error if we would not have ignored this link. // See issue #83859. let disambiguator_range = (no_backticks_range.start + relative_range.start) ..(no_backticks_range.start + relative_range.end); disambiguator_error(self.cx, &item, dox, disambiguator_range, &err_msg); } </ins> return None; } }; <del> if path_str.contains(|ch: char| !(ch.is_alphanumeric() || ":_<>, !*&;".contains(ch))) { </del> <ins> if should_ignore_link(path_str) { </ins> return None; }


if self.filename { match self.path.filename() { None => ~"", <del> Some(v) => from_utf8_with_replacement(v) </del> <ins> Some(v) => str::from_utf8_lossy(v) </ins> } } else { <del> from_utf8_with_replacement(self.path.as_vec()) </del> <ins> str::from_utf8_lossy(self.path.as_vec()) </ins> } } }


/// and surrogates as `u` followed by four hexadecimal digits. /// Example: `"au{D800}"` for a slice with code points [U+0061, U+D800] impl fmt::Debug for Wtf8 { <del> fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { </del> <ins> fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { fn write_str_escaped(f: &mut fmt::Formatter, s: &str) -> fmt::Result { use fmt::Write; for c in s.chars().flat_map(|c| c.escape_default()) { try!(f.write_char(c)) } Ok(()) } </ins> try!(formatter.write_str(""")); let mut pos = 0; loop { match self.next_surrogate(pos) { None => break, Some((surrogate_pos, surrogate)) => { <del> try!(formatter.write_str(unsafe { // the data in this slice is valid UTF-8, transmute to &str mem::transmute(&self.bytes[pos .. surrogate_pos]) })); </del> <ins> try!(write_str_escaped( formatter, unsafe { str::from_utf8_unchecked( &self.bytes[pos .. surrogate_pos] )}, )); </ins> try!(write!(formatter, "u{{{:X}}}", surrogate)); pos = surrogate_pos + 3; } } } <del> try!(formatter.write_str(unsafe { // the data in this slice is valid UTF-8, transmute to &str mem::transmute(&self.bytes[pos..]) })); </del> <ins> try!(write_str_escaped( formatter, unsafe { str::from_utf8_unchecked(&self.bytes[pos..]) }, )); </ins> formatter.write_str(""") } }


pub type LPBOOL = *mut BOOL; pub type LPBYTE = *mut BYTE; <ins> pub type LPCCH = *const CHAR; </ins> pub type LPCSTR = *const CHAR; <ins> pub type LPCWCH = *const WCHAR; </ins> pub type LPCWSTR = *const WCHAR; <ins> pub type LPCVOID = *const c_void; </ins> pub type LPDWORD = *mut DWORD; pub type LPHANDLE = *mut HANDLE; pub type LPOVERLAPPED = *mut OVERLAPPED; pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION; pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; pub type LPSTARTUPINFO = *mut STARTUPINFO; <ins> pub type LPSTR = *mut CHAR; </ins> pub type LPVOID = *mut c_void; <del> pub type LPCVOID = *const c_void; </del> pub type LPWCH = *mut WCHAR; pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; pub type LPWSADATA = *mut WSADATA;


ENV NO_DOWNLOAD_CI_LLVM 1 ENV EXTERNAL_LLVM 1 <del> # This is not the latest LLVM version, so some components required by tests may # be missing. ENV IS_NOT_LATEST_LLVM 1 </del> # Using llvm-link-shared due to libffi issues -- see #34486 ENV RUST_CONFIGURE_ARGS  --build=x86_64-unknown-linux-gnu


fn super_ascribe_user_ty(&mut self, place: & $($mutability)? Place<'tcx>, <del> _variance: $(& $mutability)? ty::Variance, </del> <ins> variance: $(& $mutability)? ty::Variance, </ins> user_ty: & $($mutability)? UserTypeProjection, location: Location) { self.visit_place( place, <del> PlaceContext::NonUse(NonUseContext::AscribeUserTy), </del> <ins> PlaceContext::NonUse(NonUseContext::AscribeUserTy($(* &$mutability *)? variance)), </ins> location ); self.visit_user_type_projection(user_ty);


# "alternate" deployment, see .travis.yml for more info - MSYS_BITS: 64 <del> RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-extended </del> <ins> RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-extended --enable-profiler </ins> SCRIPT: python x.py dist DEPLOY_ALT: 1


/// Ending a storage live range. StorageDead, /// User type annotation assertions for NLL. <del> AscribeUserTy, </del> <ins> AscribeUserTy(ty::Variance), </ins> /// The data of a user variable, for debug info. VarDebugInfo, }


version = "0.1.0" dependencies = [ "serde", <ins> "serde_json", </ins> "toml", ]


visit.visit_block(body); } <ins> fcx.require_type_is_sized(ret_ty, decl.output.span, traits::ReturnType); </ins> check_block_with_expected(&fcx, body, ExpectHasType(ret_ty));


<ins> error: expected a pattern, found an expression --> $DIR/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs:2:31 | LL |     let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes; |                               ^^^^^^^^^^^^^^^^^^ arbitrary expressions are not allowed in patterns error[E0412]: cannot find type `T` in this scope --> $DIR/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs:2:55 | LL |     let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes; |                                                       ^ not found in this scope error[E0109]: type and const arguments are not allowed on builtin type `str` --> $DIR/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs:2:15 | LL |     let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes; |         ---   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  ^ type and const arguments not allowed |         | |         not allowed on builtin type `str` | help: primitive type `str` doesn't have generic parameters | LL -     let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes; LL +     let str::as_bytes; | error[E0533]: expected unit struct, unit variant or constant, found associated function `str<, T>::as_bytes` --> $DIR/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs:2:9 | LL |     let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes; |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a unit struct, unit variant or constant error: aborting due to 4 previous errors Some errors have detailed explanations: E0109, E0412, E0533. For more information about an error, try `rustc --explain E0109`. </ins>


pat: &'tcx hir::Pat<'tcx>, ty: Ty<'tcx>, ) { <del> struct V<'tcx> { tcx: TyCtxt<'tcx>, </del> <ins> struct V { </ins> pat_hir_ids: Vec<hir::HirId>, } <del> impl<'tcx> Visitor<'tcx> for V<'tcx> { type NestedFilter = rustc_middle::hir::nested_filter::All; fn nested_visit_map(&mut self) -> Self::Map { self.tcx.hir() } </del> <ins> impl<'tcx> Visitor<'tcx> for V { </ins> fn visit_pat(&mut self, p: &'tcx hir::Pat<'tcx>) { self.pat_hir_ids.push(p.hir_id); hir::intravisit::walk_pat(self, p);


<ins> // check-pass #![deny(improper_ctypes_definitions)] #[repr(C)] pub struct Wrap<T>(T); #[repr(transparent)] pub struct TransparentWrap<T>(T); pub extern "C" fn f() -> Wrap<()> { todo!() } const _: extern "C" fn() -> Wrap<()> = f; pub extern "C" fn ff() -> Wrap<Wrap<()>> { todo!() } const _: extern "C" fn() -> Wrap<Wrap<()>> = ff; pub extern "C" fn g() -> TransparentWrap<()> { todo!() } const _: extern "C" fn() -> TransparentWrap<()> = g; pub extern "C" fn gg() -> TransparentWrap<TransparentWrap<()>> { todo!() } const _: extern "C" fn() -> TransparentWrap<TransparentWrap<()>> = gg; fn main() {} </ins>


param_span: Span, }, } <ins> #[derive(Diagnostic)] pub(crate) enum LateBoundInApit { #[diag(hir_analysis_late_bound_type_in_apit)] Type { #[primary_span] span: Span, #[label] param_span: Span, }, #[diag(hir_analysis_late_bound_const_in_apit)] Const { #[primary_span] span: Span, #[label] param_span: Span, }, #[diag(hir_analysis_late_bound_lifetime_in_apit)] Lifetime { #[primary_span] span: Span, #[label] param_span: Span, }, } </ins>


euv::AddrOf | euv::RefBinding | euv::AutoRef | <del> euv::ForLoop => { </del> <ins> euv::ForLoop | euv::MatchDiscriminant => { </ins> format!("cannot borrow {} as mutable", descr) } euv::ClosureInvocation => {


let mir_opaque_ty = tcx.mir_borrowck(owner_def_id).concrete_opaque_types.get(&def_id).copied(); if let Some(mir_opaque_ty) = mir_opaque_ty { <ins> if mir_opaque_ty.references_error() { return mir_opaque_ty.ty; } </ins> let scope = tcx.local_def_id_to_hir_id(owner_def_id); debug!(?scope); let mut locator = RpitConstraintChecker { def_id, tcx, found: mir_opaque_ty };


<del> Subproject commit df4109151b6870cdb6d170326d1c099746990ea8 </del> <ins> Subproject commit c8f51fc5a772a125f3b3ad7fe46609a4638ca509 </ins>


[dependencies] toml = "0.5" serde = { version = "1.0", features = ["derive"] } <del> serde_json = "1.0" reqwest = "0.9" </del>


.ok() .expect("Failed to read line"); <del> println!("You guessed: {}", input); </del> <ins> println!("You guessed: {}", guess); </ins> } ```


// option. This file may not be copied, modified, or distributed // except according to those terms. <ins> // min-llvm-version 3.9 </ins> use std::ops::Deref; fn main() {


<ins> // check-pass #![feature(exhaustive_patterns)] enum Void {} fn main() { let a: Option<Void> = None; let None = a; } </ins>


use lint::{LateContext, LintContext, LintArray}; use lint::{LintPass, LateLintPass}; <ins> use syntax::abi::Abi; </ins> use syntax::ast; use syntax::attr; use syntax_pos::Span;


fn stability(&self, def: DefId) -> Option<attr::Stability>; fn deprecation(&self, def: DefId) -> Option<attr::Deprecation>; fn visibility(&self, def: DefId) -> ty::Visibility; <del> fn visible_parent_map<'a>(&'a self) -> ::std::cell::RefMut<'a, DefIdMap<DefId>>; </del> <ins> fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap<DefId>>; </ins> fn item_generics_cloned(&self, def: DefId) -> ty::Generics; fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute>; fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>;


<ins> pub struct Stuff { inner: *mut (), } pub struct Wrap<T>(T); fn fun<T>(t: T) -> Wrap<T> { todo!() } pub trait Trait<'de> { fn do_stuff(_: Wrap<&'de mut Self>); } impl<'a> Trait<'a> for () { fn do_stuff(_: Wrap<&'a mut Self>) {} } fn fun2(t: &mut Stuff) -> () { let Stuff { inner, .. } = t; Trait::do_stuff({ fun(&mut *inner) }); //~^ ERROR the trait bound `*mut (): Trait<'_>` is not satisfied } fn main() {} </ins>


// a missing surrogate can be produced (and also because of the UTF-8 validation above), // write the missing surrogate out now. // Buffering it would mean we have to lie about the number of bytes written. <del> let first_char_remaining = utf16[written]; if first_char_remaining >= 0xDCEE && first_char_remaining <= 0xDFFF { </del> <ins> let first_code_unit_remaining = utf16[written]; if first_code_unit_remaining >= 0xDCEE && first_code_unit_remaining <= 0xDFFF { </ins> // low surrogate // We just hope this works, and give up otherwise let _ = write_u16s(handle, &utf16[written..written + 1]);


rustc_middle = { path = "../rustc_middle", optional = true } rustc_span = { path = "../rustc_span", optional = true } tracing = "0.1" <ins> scoped-tls = "1.0" </ins> [features] default = [


/// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] <ins> #[inline] </ins> pub fn kind(&self) -> ErrorKind { match self.repr { Repr::Os(code) => sys::decode_error_kind(code),


&self, obligation: &PredicateObligation<'tcx>, err: &mut DiagnosticBuilder<'_>, <del> trait_ref: &ty::Binder<'tcx, ty::TraitRef<'tcx>>, </del> <ins> poly_trait_ref: &ty::Binder<'tcx, ty::TraitRef<'tcx>>, </ins> has_custom_message: bool, ) -> bool { let span = obligation.cause.span;


/// assert_eq!(err.kind(), ErrorKind::WriteZero); /// assert_eq!(recovered_writer.buffer(), b"t be actually written"); /// ``` <del> #[unstable(feature = "io_into_inner_error_parts", issue = "79704")] </del> <ins> #[stable(feature = "io_into_inner_error_parts", since = "1.55.0")] </ins> pub fn into_parts(self) -> (Error, W) { (self.1, self.0) }


StorageDead(_4);                 // scope 1 at $DIR/simple.rs:6:18: 6:19 StorageDead(_6);                 // scope 1 at $DIR/simple.rs:6:19: 6:20 StorageDead(_3);                 // scope 1 at $DIR/simple.rs:6:19: 6:20 <del> -         _0 = _2;                         // scope 1 at $DIR/simple.rs:7:5: 7:8 -         StorageDead(_2);                 // scope 0 at $DIR/simple.rs:8:1: 8:2 +         nop;                             // scope 1 at $DIR/simple.rs:7:5: 7:8 +         nop;                             // scope 0 at $DIR/simple.rs:8:1: 8:2 </del> <ins> _0 = _2;                         // scope 1 at $DIR/simple.rs:7:5: 7:8 StorageDead(_2);                 // scope 0 at $DIR/simple.rs:8:1: 8:2 </ins> return;                          // scope 0 at $DIR/simple.rs:8:2: 8:2 } }


<ins> #[derive(Debug)] struct Foo { #[cfg(all())] field: fn(($),), //~ ERROR expected pattern, found `$` //~^ ERROR expected pattern, found `$` } fn main() {} </ins>


fn make_final_bounds( &self, ty_to_bounds: FxHashMap<Type, FxHashSet<GenericBound>>, <del> ty_to_fn: FxHashMap<Type, (Option<PolyTrait>, Option<Type>)>, </del> <ins> ty_to_fn: FxHashMap<Type, (PolyTrait, Option<Type>)>, </ins> lifetime_to_bounds: FxHashMap<Lifetime, FxHashSet<GenericBound>>, ) -> Vec<WherePredicate> { ty_to_bounds .into_iter() .flat_map(|(ty, mut bounds)| { <del> if let Some(data) = ty_to_fn.get(&ty) { let (poly_trait, output) = (data.0.as_ref().unwrap().clone(), data.1.as_ref().cloned().map(Box::new)); </del> <ins> if let Some((ref poly_trait, ref output)) = ty_to_fn.get(&ty) { </ins> let mut new_path = poly_trait.trait_.clone(); let last_segment = new_path.segments.pop().expect("segments were empty");


<del> Subproject commit 50ef22af522f2545295090cc1ad3e4bd4aa8632c </del> <ins> Subproject commit b8f617897a66953b9026c02f7a8f93a2e9611f63 </ins>


"regex-syntax", "semver", "serde", <del> "smallvec 0.6.10", </del> <ins> "smallvec 1.0.0", </ins> "toml", "unicode-normalization", "url 2.1.0",


panic!("dist: Error calling canonicalize path `{}`: {}", llvm_dylib_path.display(), e); }); <del> builder.install(&llvm_dylib_path, &dst_libdir1, 0o644); builder.install(&llvm_dylib_path, &dst_libdir2, 0o644); </del> <ins> builder.install(&llvm_dylib_path, dst_libdir, 0o644); </ins> } } <ins> /// Maybe add libLLVM.so to the target lib-dir for linking. pub fn maybe_install_llvm_target(builder: &Builder<'_>, target: Interned<String>, sysroot: &Path) { let dst_libdir = sysroot.join("lib/rustlib").join(&*target).join("lib"); maybe_install_llvm(builder, target, &dst_libdir); } /// Maybe add libLLVM.so to the runtime lib-dir for rustc itself. pub fn maybe_install_llvm_runtime(builder: &Builder<'_>, target: Interned<String>, sysroot: &Path) { let dst_libdir = sysroot.join(builder.sysroot_libdir_relative(Compiler { stage: 1, host: target })); maybe_install_llvm(builder, target, &dst_libdir); } </ins> #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct LlvmTools { pub target: Interned<String>,


h2, h3, h4 { border-bottom: 1px solid; } <del> .impl, .method, .type:not(.container-rustdoc), .associatedconstant, .associatedtype { </del> <ins> .impl, .impl-items .method, .impl-items .type, .impl-items .associatedconstant, .impl-items .associatedtype { </ins> flex-basis: 100%; font-weight: 600; margin-top: 16px;


<ins> error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:16:16 | LL |     take_range(std::ops::Range { start: 0, end: 1 }); |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |                | |                expected reference, found struct `std::ops::Range` |                help: consider borrowing here: `&std::ops::Range { start: 0, end: 1 }` | = note: expected type `&_` found type `std::ops::Range<{integer}>` error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:21:16 | LL |     take_range(::std::ops::Range { start: 0, end: 1 }); |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |                | |                expected reference, found struct `std::ops::Range` |                help: consider borrowing here: `&::std::ops::Range { start: 0, end: 1 }` | = note: expected type `&_` found type `std::ops::Range<{integer}>` error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:26:16 | LL |     take_range(std::ops::RangeFrom { start: 1 }); |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |                | |                expected reference, found struct `std::ops::RangeFrom` |                help: consider borrowing here: `&std::ops::RangeFrom { start: 1 }` | = note: expected type `&_` found type `std::ops::RangeFrom<{integer}>` error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:31:16 | LL |     take_range(::std::ops::RangeFrom { start: 1 }); |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |                | |                expected reference, found struct `std::ops::RangeFrom` |                help: consider borrowing here: `&::std::ops::RangeFrom { start: 1 }` | = note: expected type `&_` found type `std::ops::RangeFrom<{integer}>` error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:36:16 | LL |     take_range(std::ops::RangeFull {}); |                ^^^^^^^^^^^^^^^^^^^^^^ |                | |                expected reference, found struct `std::ops::RangeFull` |                help: consider borrowing here: `&std::ops::RangeFull {}` | = note: expected type `&_` found type `std::ops::RangeFull` error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:41:16 | LL |     take_range(::std::ops::RangeFull {}); |                ^^^^^^^^^^^^^^^^^^^^^^^^ |                | |                expected reference, found struct `std::ops::RangeFull` |                help: consider borrowing here: `&::std::ops::RangeFull {}` | = note: expected type `&_` found type `std::ops::RangeFull` error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:46:16 | LL |     take_range(std::ops::RangeInclusive::new(0, 1)); |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |                | |                expected reference, found struct `std::ops::RangeInclusive` |                help: consider borrowing here: `&std::ops::RangeInclusive::new(0, 1)` | = note: expected type `&_` found type `std::ops::RangeInclusive<{integer}>` error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:51:16 | LL |     take_range(::std::ops::RangeInclusive::new(0, 1)); |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |                | |                expected reference, found struct `std::ops::RangeInclusive` |                help: consider borrowing here: `&::std::ops::RangeInclusive::new(0, 1)` | = note: expected type `&_` found type `std::ops::RangeInclusive<{integer}>` error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:56:16 | LL |     take_range(std::ops::RangeTo { end: 5 }); |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |                | |                expected reference, found struct `std::ops::RangeTo` |                help: consider borrowing here: `&std::ops::RangeTo { end: 5 }` | = note: expected type `&_` found type `std::ops::RangeTo<{integer}>` error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:61:16 | LL |     take_range(::std::ops::RangeTo { end: 5 }); |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |                | |                expected reference, found struct `std::ops::RangeTo` |                help: consider borrowing here: `&::std::ops::RangeTo { end: 5 }` | = note: expected type `&_` found type `std::ops::RangeTo<{integer}>` error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:66:16 | LL |     take_range(std::ops::RangeToInclusive { end: 5 }); |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |                | |                expected reference, found struct `std::ops::RangeToInclusive` |                help: consider borrowing here: `&std::ops::RangeToInclusive { end: 5 }` | = note: expected type `&_` found type `std::ops::RangeToInclusive<{integer}>` error[E0308]: mismatched types --> $DIR/issue-54505-no-literals.rs:71:16 | LL |     take_range(::std::ops::RangeToInclusive { end: 5 }); |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |                | |                expected reference, found struct `std::ops::RangeToInclusive` |                help: consider borrowing here: `&::std::ops::RangeToInclusive { end: 5 }` | = note: expected type `&_` found type `std::ops::RangeToInclusive<{integer}>` error: aborting due to 12 previous errors For more information about this error, try `rustc --explain E0308`. </ins>


// integer literal, push to vector expression ast::LitIntUnsuffixed(v) => { if v > 0xFF { <del> cx.span_err(expr.span, "too large integer literal in bytes!") </del> <ins> cx.span_err(expr.span, "too large integer literal in bytes!"); err = true; </ins> } else if v < 0 { <del> cx.span_err(expr.span, "negative integer literal in bytes!") </del> <ins> cx.span_err(expr.span, "negative integer literal in bytes!"); err = true; </ins> } else { bytes.push(cx.expr_u8(expr.span, v as u8)); }


<ins> #![feature(const_generics)] #![allow(incomplete_features)] struct Test(); fn pass() { println!("Hello, world!"); } impl Test { pub fn call_me(&self) { self.test::<pass>(); } fn test<const FN: fn()>(&self) { //~^ ERROR: using function pointers as const generic parameters is forbidden FN(); } } fn main() { let x = Test(); x.call_me() } </ins>


_ => self.is_free(), } } <ins> pub fn is_var(self) -> bool { matches!(self.kind(), ty::ReVar(_)) } </ins> } /// Type utilities


<ins> error: higher-ranked subtype error --> $DIR/issue-30906.rs:15:5 | LL |     test(Compose(f, |_| {})); |     ^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error </ins>


fn expect_aborted(status: ExitStatus) { dbg!(status); let signal = status.signal().expect("expected child process to die of signal"); <ins> #[cfg(not(target_os = "android"))] </ins> assert!(signal == libc::SIGABRT || signal == libc::SIGILL || signal == libc::SIGTRAP); <ins> #[cfg(target_os = "android")] { // Android signals an abort() call with SIGSEGV at address 0xdeadbaad // See e.g. https://groups.google.com/g/android-ndk/c/laW1CJc7Icc assert!(signal == libc::SIGSEGV); // Additional checks performed: // 1. Find last tombstone (similar to coredump but in text format) from the //    same executable (path) as we are (must be because of usage of fork): //    This ensures that we look into the correct tombstone. // 2. Cause of crash is a SIGSEGV with address 0xdeadbaad. // 3. libc::abort call is in one of top two functions on callstack. // The last two steps distinguish between a normal SIGSEGV and one caused // by libc::abort. let this_exe = std::env::current_exe().unwrap().into_os_string().into_string().unwrap(); let exe_string = format!(">>> {this_exe} <<<"); let tombstone = (0..100) .map(|n| format!("/data/tombstones/tombstone_{n:02}")) .filter(|f| std::path::Path::new(&f).exists()) .map(|f| std::fs::read_to_string(&f).expect("Cannot read tombstone file")) .filter(|f| f.contains(&exe_string)) .last() .expect("no tombstone found"); println!("Content of tombstone:n{tombstone}"); assert!( tombstone.contains("signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad") ); let abort_on_top = tombstone .lines() .skip_while(|l| !l.contains("backtrace:")) .skip(1) .take_while(|l| l.starts_with("    #")) .take(2) .any(|f| f.contains("/system/lib/libc.so (abort")); assert!(abort_on_top); } </ins> } fn main() {


use crate::TargetSelection; use crate::{t, VERSION}; <ins> use std::env::consts::EXE_SUFFIX; </ins> use std::fmt::Write as _; <del> use std::path::{Path, PathBuf}; </del> <ins> use std::fs::File; use std::path::{Path, PathBuf, MAIN_SEPARATOR}; </ins> use std::process::Command; use std::str::FromStr; use std::{


<ins> // Regression test for #89469, where an extra non_snake_case warning was // reported for a shorthand field binding. // check-pass #![deny(non_snake_case)] #[allow(non_snake_case)] struct Entry { A: u16, a: u16 } fn foo() -> Entry {todo!()} pub fn f() { let Entry { A, a } = foo(); let _ = (A, a); } fn main() {} </ins>


<ins> error[E0283]: type annotations needed --> $DIR/issue-80816.rs:49:38 | LL |     let guard: Guard<Arc<usize>> = s.load(); |                                      ^^^^ | note: multiple `impl`s satisfying `ArcSwapAny<Arc<usize>>: Access<_>` found --> $DIR/issue-80816.rs:35:1 | LL | impl<T> Access<T> for ArcSwapAny<T> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... LL | impl<T> Access<T> for ArcSwapAny<Arc<T>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required for `Arc<ArcSwapAny<Arc<usize>>>` to implement `Access<_>` --> $DIR/issue-80816.rs:31:45 | LL | impl<T, A: Access<T>, P: Deref<Target = A>> Access<T> for P { |                                             ^^^^^^^^^     ^ help: try using a fully qualified path to specify the expected types | LL |     let guard: Guard<Arc<usize>> = <Arc<ArcSwapAny<Arc<usize>>> as Access<T>>::load(&s); |                                    ++++++++++++++++++++++++++++++++++++++++++++++++++ ~ error: aborting due to previous error For more information about this error, try `rustc --explain E0283`. </ins>


pub use self::stdio::set_output_capture; #[stable(feature = "rust1", since = "1.0.0")] pub use self::stdio::{stderr, stdin, stdout, Stderr, Stdin, Stdout}; <ins> #[unstable(feature = "stdio_locked", issue = "none")] pub use self::stdio::{stderr_locked, stdin_locked, stdout_locked}; </ins> #[stable(feature = "rust1", since = "1.0.0")] pub use self::stdio::{StderrLock, StdinLock, StdoutLock}; #[unstable(feature = "print_internals", issue = "none")]


} } } <del> hir::ItemKind::Macro(ref macro_def) => { self.update_reachability_from_macro(item.def_id, macro_def); } </del> // Visit everything, but foreign items have their own levels. hir::ItemKind::ForeignMod { items, .. } => { for foreign_item in items {


}).peekable(); if let doctree::Plain = s.struct_type { if fields.peek().is_some() {  write!(w, "
Fields
")?;   write!(w, "
 Fields
")?;  for (field, ty) in fields { let id = derive_id(format!("{}.{}", ItemType::StructField,


<ins> // Regression test for #84632: Recursion limit is ignored // for builtin macros that eagerly expands. #![recursion_limit = "15"] macro_rules! a { () => (""); (A) => (concat!("", a!())); (A, $($A:ident),*) => (concat!("", a!($($A),*))) //~^ ERROR recursion limit reached //~| HELP consider adding } fn main() { a!(A, A, A, A, A); a!(A, A, A, A, A, A, A, A, A, A, A); } </ins>


if let hir::Node::Pat(parent_pat) = cx.tcx.hir().get(cx.tcx.hir().get_parent_node(hid)) { if let PatKind::Struct(_, field_pats, _) = &parent_pat.kind { <del> for field in field_pats.iter() { if field.ident != ident { // Only check if a new name has been introduced, to avoid warning // on both the struct definition and this pattern. self.check_snake_case(cx, "variable", &ident); } </del> <ins> if field_pats .iter() .any(|field| !field.is_shorthand && field.pat.hir_id == p.hir_id) { // Only check if a new name has been introduced, to avoid warning // on both the struct definition and this pattern. self.check_snake_case(cx, "variable", &ident); </ins> } return; }