let _ = write!(&mut w, "{}", args); let msg = str::from_utf8(&w.buf[0..w.pos]).unwrap_or("aborted"); let msg = if msg.is_empty() {"aborted"} else {msg}; <del> // Give some context to the message let hash = msg.bytes().fold(0, |accum, val| accum + (val as uint) ); let quote = match hash % 10 { 0 => " It was from the artists and poets that the pertinent answers came, and I know that panic would have broken loose had they been able to compare notes. As it was, lacking their original letters, I half suspected the compiler of having asked leading questions, or of having edited the correspondence in corroboration of what he had latently resolved to see.", 1 => " There are not many persons who know what wonders are opened to them in the stories and visions of their youth; for when as children we listen and dream, we think but half-formed thoughts, and when as men we try to remember, we are dulled and prosaic with the poison of life. But some of us awake in the night with strange phantasms of enchanted hills and gardens, of fountains that sing in the sun, of golden cliffs overhanging murmuring seas, of plains that stretch down to sleeping cities of bronze and stone, and of shadowy companies of heroes that ride caparisoned white horses along the edges of thick forests; and then we know that we have looked back through the ivory gates into that world of wonder which was ours before we were wise and unhappy.", 2 => " Instead of the poems I had hoped for, there came only a shuddering blackness and ineffable loneliness; and I saw at last a fearful truth which no one had ever dared to breathe before — the unwhisperable secret of secrets — The fact that this city of stone and stridor is not a sentient perpetuation of Old New York as London is of Old London and Paris of Old Paris, but that it is in fact quite dead, its sprawling body imperfectly embalmed and infested with queer animate things which have nothing to do with it as it was in life.", 3 => " The ocean ate the last of the land and poured into the smoking gulf, thereby giving up all it had ever conquered. From the new-flooded lands it flowed again, uncovering death and decay; and from its ancient and immemorial bed it trickled loathsomely, uncovering nighted secrets of the years when Time was young and the gods unborn. Above the waves rose weedy remembered spires. The moon laid pale lilies of light on dead London, and Paris stood up from its damp grave to be sanctified with star-dust. Then rose spires and monoliths that were weedy but not remembered; terrible spires and monoliths of lands that men never knew were lands...", 4 => " There was a night when winds from unknown spaces whirled us irresistibly into limitless vacuum beyond all thought and entity. Perceptions of the most maddeningly untransmissible sort thronged upon us; perceptions of infinity which at the time convulsed us with joy, yet which are now partly lost to my memory and partly incapable of presentation to others.", _ => "You've met with a terrible fate, haven't you?" }; rterrln!("{}", ""); rterrln!("{}", quote); rterrln!("{}", ""); </del> rterrln!("fatal runtime error: {}", msg); unsafe { intrinsics::abort(); } }


"libstd/sync/spsc_queue.rs", # BSD "libstd/sync/mpmc_bounded_queue.rs", # BSD "libsync/mpsc_intrusive.rs", # BSD <ins> "test/bench/shootout-binarytrees.rs", # BSD </ins> "test/bench/shootout-fannkuch-redux.rs", # BSD "test/bench/shootout-meteor.rs", # BSD "test/bench/shootout-regex-dna.rs", # BSD


<del> // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. </del> <ins> // The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ </ins> // <del> // 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. </del> <ins> // contributed by the Rust Project Developers // Copyright (c) 2012-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // - Redistributions of source code must retain the above copyright //   notice, this list of conditions and the following disclaimer. // // - Redistributions in binary form must reproduce the above copyright //   notice, this list of conditions and the following disclaimer in //   the documentation and/or other materials provided with the //   distribution. // // - Neither the name of "The Computer Language Benchmarks Game" nor //   the name of "The Computer Language Shootout Benchmarks" nor the //   names of its contributors may be used to endorse or promote //   products derived from this software without specific prior //   written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED // OF THE POSSIBILITY OF SUCH DAMAGE. </ins> extern crate sync; extern crate arena;


rustup toolchain install --profile minimal nightly-${TOOLCHAIN} # Sanity check to see if the nightly exists echo nightly-${TOOLCHAIN} > rust-toolchain <del> echo "=> Uninstalling all old nighlies" </del> <ins> echo "=> Uninstalling all old nightlies" </ins> for nightly in $(rustup toolchain list | grep nightly | grep -v $TOOLCHAIN | grep -v nightly-x86_64); do rustup toolchain uninstall $nightly done


} } <del> (&ty::ty_param(ref a_p), &ty::ty_param(ref b_p)) if a_p.idx == b_p.idx => { </del> <ins> (&ty::ty_param(ref a_p), &ty::ty_param(ref b_p)) if a_p.idx == b_p.idx && a_p.space == b_p.space => { </ins> Ok(a) }


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::num::Num; trait BrokenAdd: Num { fn broken_add<T>(&self, rhs: T) -> Self { *self + rhs //~ ERROR mismatched types } } impl<T: Num> BrokenAdd for T {} pub fn main() { let foo: u8 = 0u8; let x: u8 = foo.broken_add("hello darkness my old friend".to_string()); println!("{}", x); } </ins>


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. trait Tr<T> { fn op(T) -> Self; } // these compile as if Self: Tr<U>, even tho only Self: Tr<Self or T> trait A:    Tr<Self> { fn test<U>(u: U) -> Self { Tr::op(u)   //~ ERROR expected Tr<U>, but found Tr<Self> } } trait B<T>: Tr<T> { fn test<U>(u: U) -> Self { Tr::op(u)   //~ ERROR expected Tr<U>, but found Tr<T> } } impl<T> Tr<T> for T { fn op(t: T) -> T { t } } impl<T> A for T {} fn main() { std::io::println(A::test((&7306634593706211700, 8))); } </ins>


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. trait Tr { fn test<X>(u: X) -> Self { u   //~ ERROR mismatched types } } fn main() {} </ins>


CFG_LIBDIR_RELATIVE=bin fi <ins> if [ "$CFG_OSTYPE" = "pc-mingw32" ] || [ "$CFG_OSTYPE" = "w64-mingw32" ] then CFG_LD_PATH_VAR=PATH CFG_OLD_LD_PATH_VAR=$PATH elif [ "$CFG_OSTYPE" = "Darwin" ] then CFG_LD_PATH_VAR=DYLD_LIBRARY_PATH CFG_OLD_LD_PATH_VAR=$DYLD_LIBRARY_PATH else CFG_LD_PATH_VAR=LD_LIBRARY_PATH CFG_OLD_LD_PATH_VAR=$LD_LIBRARY_PATH fi </ins> flag uninstall "only uninstall from the installation prefix" opt verify 1 "verify that the installed binaries run correctly" valopt prefix "/usr/local" "set installation prefix"


if [ -z "${CFG_UNINSTALL}" ] then msg "verifying platform can run binaries" <ins> export $CFG_LD_PATH_VAR="${CFG_SRC_DIR}/lib":$CFG_OLD_LD_PATH_VAR </ins> "${CFG_SRC_DIR}/bin/rustc" --version > /dev/null if [ $? -ne 0 ] then err "can't execute rustc binary on this platform" fi <ins> export $CFG_LD_PATH_VAR=$CFG_OLD_LD_PATH_VAR </ins> fi fi


done < "${CFG_SRC_DIR}/${CFG_LIBDIR_RELATIVE}/rustlib/manifest.in" # Sanity check: can we run the installed binaries? <ins> # # As with the verification above, make sure the right LD_LIBRARY_PATH-equivalent # is in place. Try first without this variable, and if that fails try again with # the variable. If the second time tries, print a hopefully helpful message to # add something to the appropriate environment variable. </ins> if [ -z "${CFG_DISABLE_VERIFY}" ] then msg "verifying installed binaries are executable" <del> "${CFG_PREFIX}/bin/rustc" --version > /dev/null </del> <ins> "${CFG_PREFIX}/bin/rustc" --version 2> /dev/null 1> /dev/null </ins> if [ $? -ne 0 ] then <del> ERR="can't execute installed rustc binary. " ERR="${ERR}installation may be broken. " ERR="${ERR}if this is expected then rerun install.sh with `--disable-verify` " ERR="${ERR}or `make install` with `--disable-verify-install`" err "${ERR}" </del> <ins> export $CFG_LD_PATH_VAR="${CFG_PREFIX}/lib":$CFG_OLD_LD_PATH_VAR "${CFG_PREFIX}/bin/rustc" --version > /dev/null if [ $? -ne 0 ] then ERR="can't execute installed rustc binary. " ERR="${ERR}installation may be broken. " ERR="${ERR}if this is expected then rerun install.sh with `--disable-verify` " ERR="${ERR}or `make install` with `--disable-verify-install`" err "${ERR}" else echo echo "    please ensure '${CFG_PREFIX}/lib' is added to ${CFG_LD_PATH_VAR}" echo fi </ins> fi fi


TTNonterminal(Span, Ident) } <del> /// Matchers are nodes defined-by and recognized-by the main rust parser and /// language, but they're only ever found inside syntax-extension invocations; /// indeed, the only thing that ever _activates_ the rules in the rust parser /// for parsing a matcher is a matcher looking for the 'matchers' nonterminal /// itself. Matchers represent a small sub-language for pattern-matching /// token-trees, and are thus primarily used by the macro-defining extension /// itself. /// /// MatchTok /// -------- /// ///     A matcher that matches a single token, denoted by the token itself. So ///     long as there's no $ involved. /// /// /// MatchSeq /// -------- /// ///     A matcher that matches a sequence of sub-matchers, denoted various ///     possible ways: /// ///             $(M)*       zero or more Ms ///             $(M)+       one or more Ms ///             $(M),+      one or more comma-separated Ms ///             $(A B C);*  zero or more semi-separated 'A B C' seqs /// /// /// MatchNonterminal /// ----------------- /// ///     A matcher that matches one of a few interesting named rust ///     nonterminals, such as types, expressions, items, or raw token-trees. A ///     black-box matcher on expr, for example, binds an expr to a given ident, ///     and that ident can re-occur as an interpolation in the RHS of a ///     macro-by-example rule. For example: /// ///        $foo:expr   =>     1 + $foo    // interpolate an expr ///        $foo:tt     =>     $foo        // interpolate a token-tree ///        $foo:tt     =>     bar! $foo   // only other valid interpolation ///                                       // is in arg position for another ///                                       // macro /// /// As a final, horrifying aside, note that macro-by-example's input is /// also matched by one of these matchers. Holy self-referential! It is matched /// by a MatchSeq, specifically this one: /// ///                   $( $lhs:matchers => $rhs:tt );+ /// /// If you understand that, you have closed the loop and understand the whole /// macro system. Congratulations. </del> <ins> // Matchers are nodes defined-by and recognized-by the main rust parser and // language, but they're only ever found inside syntax-extension invocations; // indeed, the only thing that ever _activates_ the rules in the rust parser // for parsing a matcher is a matcher looking for the 'matchers' nonterminal // itself. Matchers represent a small sub-language for pattern-matching // token-trees, and are thus primarily used by the macro-defining extension // itself. // // MatchTok // -------- // //     A matcher that matches a single token, denoted by the token itself. So //     long as there's no $ involved. // // // MatchSeq // -------- // //     A matcher that matches a sequence of sub-matchers, denoted various //     possible ways: // //             $(M)*       zero or more Ms //             $(M)+       one or more Ms //             $(M),+      one or more comma-separated Ms //             $(A B C);*  zero or more semi-separated 'A B C' seqs // // // MatchNonterminal // ----------------- // //     A matcher that matches one of a few interesting named rust //     nonterminals, such as types, expressions, items, or raw token-trees. A //     black-box matcher on expr, for example, binds an expr to a given ident, //     and that ident can re-occur as an interpolation in the RHS of a //     macro-by-example rule. For example: // //        $foo:expr   =>     1 + $foo    // interpolate an expr //        $foo:tt     =>     $foo        // interpolate a token-tree //        $foo:tt     =>     bar! $foo   // only other valid interpolation //                                       // is in arg position for another //                                       // macro // // As a final, horrifying aside, note that macro-by-example's input is // also matched by one of these matchers. Holy self-referential! It is matched // by a MatchSeq, specifically this one: // //                   $( $lhs:matchers => $rhs:tt );+ // // If you understand that, you have closed the loop and understand the whole // macro system. Congratulations. </ins> pub type Matcher = Spanned<Matcher_>; #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]


<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. // error-pattern: too big for the current architecture #[cfg(target_pointer_width = "32")] fn main() { let x = [0usize; 0xffff_ffff]; } #[cfg(target_pointer_width = "64")] fn main() { let x = [0usize; 0xffff_ffff_ffff_ffff]; } </ins>


<del> Subproject commit 2751bdcef125468ea2ee006c11992cd1405aebe5 </del> <ins> Subproject commit 34fca48ed284525b2f124bf93c51af36d6685492 </ins>


<del> Subproject commit 388750b081c0893c275044d37203f97709e058ba </del> <ins> Subproject commit e3f3af69dce71cd37a785bccb7e58449197d940c </ins>


<del> Subproject commit d43038932adeb16ada80e206d4c073d851298101 </del> <ins> Subproject commit ee7c676fd6e287459cb407337652412c990686c0 </ins>


<del> Subproject commit 07e0df2f006e59d171c6bf3cafa9d61dbeb520d8 </del> <ins> Subproject commit c954202c1e1720cba5628f99543cc01188c7d6fc </ins>


<del> Subproject commit b123ab4754127d822ffb38349ce0fbf561f1b2fd </del> <ins> Subproject commit 08bb147d51e815b96e8db7ba4cf870f201c11ff8 </ins>


**Source:** https://github.com/rust-lang/rust-analyzer/blob/master/crates/rust-analyzer/src/config.rs[config.rs] <del> The <<_installation,Installation>> section contains details on configuration for some of the editors. </del> <ins> The <<installation,Installation>> section contains details on configuration for some of the editors. </ins> In general `rust-analyzer` is configured via LSP messages, which means that it's up to the editor to decide on the exact format and location of configuration files. Some clients, such as <<vs-code,VS Code>> or <<coc-rust-analyzer,COC plugin in Vim>> provide `rust-analyzer` specific configuration UIs. Others may require you to know a bit more about the interaction with `rust-analyzer`.


let stability_index = time(time_passes, "stability index", (), |_| stability::Index::build(krate)); <ins> time(time_passes, "static item recursion checking", (), |_| middle::check_static_recursion::check_crate(&sess, krate, &def_map, &ast_map)); </ins> let ty_cx = ty::mk_ctxt(sess, type_arena, def_map,


pub mod borrowck; pub mod cfg; pub mod check_const; <ins> pub mod check_static_recursion; </ins> pub mod check_loop; pub mod check_match; pub mod check_rvalues;


// except according to those terms. <del> use driver::session::Session; </del> use middle::def::*; <del> use middle::resolve; </del> use middle::ty; use middle::typeck; use util::ppaux; use syntax::ast::*; <del> use syntax::{ast_util, ast_map}; </del> <ins> use syntax::ast_util; </ins> use syntax::visit::Visitor; use syntax::visit;


match it.node { ItemStatic(_, _, ref ex) => { v.inside_const(|v| v.visit_expr(&**ex)); <del> check_item_recursion(&v.tcx.sess, &v.tcx.map, &v.tcx.def_map, it); </del> } ItemEnum(ref enum_definition, _) => { for var in (*enum_definition).variants.iter() {


} visit::walk_expr(v, e); } <del> struct CheckItemRecursionVisitor<'a, 'ast: 'a> { root_it: &'a Item, sess: &'a Session, ast_map: &'a ast_map::Map<'ast>, def_map: &'a resolve::DefMap, idstack: Vec<NodeId> } // Make sure a const item doesn't recursively refer to itself // FIXME: Should use the dependency graph when it's available (#1356) pub fn check_item_recursion<'a>(sess: &'a Session, ast_map: &'a ast_map::Map, def_map: &'a resolve::DefMap, it: &'a Item) { let mut visitor = CheckItemRecursionVisitor { root_it: it, sess: sess, ast_map: ast_map, def_map: def_map, idstack: Vec::new() }; visitor.visit_item(it); } impl<'a, 'ast, 'v> Visitor<'v> for CheckItemRecursionVisitor<'a, 'ast> { fn visit_item(&mut self, it: &Item) { if self.idstack.iter().any(|x| x == &(it.id)) { self.sess.span_fatal(self.root_it.span, "recursive constant"); } self.idstack.push(it.id); visit::walk_item(self, it); self.idstack.pop(); } fn visit_expr(&mut self, e: &Expr) { match e.node { ExprPath(..) => { match self.def_map.borrow().find(&e.id) { Some(&DefStatic(def_id, _)) if ast_util::is_local(def_id) => { self.visit_item(&*self.ast_map.expect_item(def_id.node)); } _ => () } }, _ => () } visit::walk_expr(self, e); } } </del>


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // This compiler pass detects static items that refer to themselves // recursively. use driver::session::Session; use middle::resolve; use middle::def::DefStatic; use syntax::ast::{Crate, Expr, ExprPath, Item, ItemStatic, NodeId}; use syntax::{ast_util, ast_map}; use syntax::visit::Visitor; use syntax::visit; struct CheckCrateVisitor<'a, 'ast: 'a> { sess: &'a Session, def_map: &'a resolve::DefMap, ast_map: &'a ast_map::Map<'ast> } impl<'v, 'a, 'ast> Visitor<'v> for CheckCrateVisitor<'a, 'ast> { fn visit_item(&mut self, i: &Item) { check_item(self, i); } } pub fn check_crate<'ast>(sess: &Session, krate: &Crate, def_map: &resolve::DefMap, ast_map: &ast_map::Map<'ast>) { let mut visitor = CheckCrateVisitor { sess: sess, def_map: def_map, ast_map: ast_map }; visit::walk_crate(&mut visitor, krate); sess.abort_if_errors(); } fn check_item(v: &mut CheckCrateVisitor, it: &Item) { match it.node { ItemStatic(_, _, ref ex) => { check_item_recursion(v.sess, v.ast_map, v.def_map, it); visit::walk_expr(v, &**ex) }, _ => visit::walk_item(v, it) } } struct CheckItemRecursionVisitor<'a, 'ast: 'a> { root_it: &'a Item, sess: &'a Session, ast_map: &'a ast_map::Map<'ast>, def_map: &'a resolve::DefMap, idstack: Vec<NodeId> } // Make sure a const item doesn't recursively refer to itself // FIXME: Should use the dependency graph when it's available (#1356) pub fn check_item_recursion<'a>(sess: &'a Session, ast_map: &'a ast_map::Map, def_map: &'a resolve::DefMap, it: &'a Item) { let mut visitor = CheckItemRecursionVisitor { root_it: it, sess: sess, ast_map: ast_map, def_map: def_map, idstack: Vec::new() }; visitor.visit_item(it); } impl<'a, 'ast, 'v> Visitor<'v> for CheckItemRecursionVisitor<'a, 'ast> { fn visit_item(&mut self, it: &Item) { if self.idstack.iter().any(|x| x == &(it.id)) { self.sess.span_err(self.root_it.span, "recursive constant"); return; } self.idstack.push(it.id); visit::walk_item(self, it); self.idstack.pop(); } fn visit_expr(&mut self, e: &Expr) { match e.node { ExprPath(..) => { match self.def_map.borrow().find(&e.id) { Some(&DefStatic(def_id, _)) if ast_util::is_local(def_id) => { self.visit_item(&*self.ast_map.expect_item(def_id.node)); } _ => () } }, _ => () } visit::walk_expr(self, e); } } </ins>


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. static FOO: uint = FOO; //~ ERROR recursive constant fn main() { let _x: [u8, ..FOO]; // caused stack overflow prior to fix let _y: uint = 1 + { static BAR: uint = BAR; //~ ERROR recursive constant let _z: [u8, ..BAR]; // caused stack overflow prior to fix 1 }; } </ins>


euv::AutoRef(..) | euv::ClosureInvocation(..) | euv::ForLoop(..) | <del> euv::RefBinding(..) => { </del> <ins> euv::RefBinding(..) | euv::MatchDiscriminant(..) => { </ins> format!("previous borrow of `{}` occurs here", self.bccx.loan_path_to_string(&*old_loan.loan_path)) }


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


BorrowViolation(euv::OverloadedOperator) | BorrowViolation(euv::AddrOf) | BorrowViolation(euv::AutoRef) | <del> BorrowViolation(euv::RefBinding) => { </del> <ins> BorrowViolation(euv::RefBinding) | BorrowViolation(euv::MatchDiscriminant) => { </ins> "cannot borrow data mutably" }


OverloadedOperator, ClosureInvocation, ForLoop, <ins> MatchDiscriminant </ins> } #[deriving(PartialEq,Show)]


} ast::ExprMatch(ref discr, ref arms) => { <del> // treatment of the discriminant is handled while // walking the arms: self.walk_expr(&**discr); </del> let discr_cmt = return_if_err!(self.mc.cat_expr(&**discr)); <ins> self.borrow_expr(&**discr, ty::ReEmpty, ty::ImmBorrow, MatchDiscriminant); // treatment of the discriminant is handled while walking the arms. </ins> for arm in arms.iter() { self.walk_arm(discr_cmt.clone(), arm); }


ref s => { tcx.sess.span_bug( span, <del> format!("ty_region() invoked on in appropriate ty: {:?}", </del> <ins> format!("ty_region() invoked on an inappropriate ty: {:?}", </ins> s).as_slice()); } }


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn foo(_s: i16) { } fn bar(_s: u32) { } fn main() { foo(1*(1 as int)); //~^ ERROR: mismatched types: expected `i16`, found `int` (expected `i16`, found `int`) bar(1*(1 as uint)); //~^ ERROR: mismatched types: expected `u32`, found `uint` (expected `u32`, found `uint`) } </ins>


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. struct X(int); enum Enum { Variant1, Variant2 } impl Drop for X { fn drop(&mut self) {} } impl Drop for Enum { fn drop(&mut self) {} } fn main() { let foo = X(1i); drop(foo); match foo { //~ ERROR use of moved value X(1i) => (), _ => unreachable!() } let e = Variant2; drop(e); match e { //~ ERROR use of moved value Variant1 => unreachable!(), Variant2 => () } } </ins>


<del> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn foo(_s: i16) { } fn bar(_s: u32) { } fn main() { foo(1*(1 as int)); //~^ ERROR: mismatched types: expected `i16`, found `int` (expected `i16`, found `int`) bar(1*(1 as uint)); //~^ ERROR: mismatched types: expected `u32`, found `uint` (expected `u32`, found `uint`) } </del>


{ let parent = self.get_parent(id); let parent = match self.find_entry(id) { <del> Some(EntryForeignItem(..)) | Some(EntryVariant(..)) => { // Anonymous extern items, enum variants and struct ctors // go in the parent scope. </del> <ins> Some(EntryForeignItem(..)) => { // Anonymous extern items go in the parent scope. </ins> self.get_parent(parent) } // But tuple struct ctors don't have names, so use the path of its


prim_ty_to_ty(tcx, base_segments, prim_ty) } _ => { <ins> let node = def.def_id().node; </ins> span_err!(tcx.sess, span, E0248, <del> "found value name used as a type: {:?}", *def); </del> <ins> "found value `{}` used as a type", tcx.map.path_to_string(node)); </ins> return this.tcx().types.err; } }


Bar } <del> fn foo(x: Foo::Bar) {} //~ERROR found value name used as a type </del> <ins> fn foo(x: Foo::Bar) {} //~ERROR found value `Foo::Bar` used as a type </ins> fn main() {}


<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. use foo::MyEnum::Result; use foo::NoResult; // Through a re-export mod foo { pub use self::MyEnum::NoResult; enum MyEnum { Result, NoResult } fn new() -> NoResult<MyEnum, String> { //~^ ERROR: found value `foo::MyEnum::NoResult` used as a type unimplemented!() } } mod bar { use foo::MyEnum::Result; use foo; fn new() -> Result<foo::MyEnum, String> { //~^ ERROR: found value `foo::MyEnum::Result` used as a type unimplemented!() } } fn new() -> Result<foo::MyEnum, String> { //~^ ERROR: found value `foo::MyEnum::Result` used as a type unimplemented!() } fn newer() -> NoResult<foo::MyEnum, String> { //~^ ERROR: found value `foo::MyEnum::NoResult` used as a type unimplemented!() } fn main() { let _ = new(); } </ins>


#[rustc_move_fragments] pub fn test_match_partial(p: Lonely<D, D>) { //~^ ERROR                 parent_of_fragments: `$(local p)` <del> //~| ERROR                  assigned_leaf_path: `($(local p) as Zero)` </del> <ins> //~| ERROR                  assigned_leaf_path: `($(local p) as Lonely::Zero)` </ins> match p { Zero(..) => {} _ => {}


#[rustc_move_fragments] pub fn test_match_full(p: Lonely<D, D>) { //~^ ERROR                 parent_of_fragments: `$(local p)` <del> //~| ERROR                  assigned_leaf_path: `($(local p) as Zero)` //~| ERROR                  assigned_leaf_path: `($(local p) as One)` //~| ERROR                  assigned_leaf_path: `($(local p) as Two)` </del> <ins> //~| ERROR                  assigned_leaf_path: `($(local p) as Lonely::Zero)` //~| ERROR                  assigned_leaf_path: `($(local p) as Lonely::One)` //~| ERROR                  assigned_leaf_path: `($(local p) as Lonely::Two)` </ins> match p { Zero(..) => {} One(..) => {}


#[rustc_move_fragments] pub fn test_match_bind_one(p: Lonely<D, D>) { //~^ ERROR                 parent_of_fragments: `$(local p)` <del> //~| ERROR                  assigned_leaf_path: `($(local p) as Zero)` //~| ERROR                 parent_of_fragments: `($(local p) as One)` //~| ERROR                     moved_leaf_path: `($(local p) as One).#0` //~| ERROR                  assigned_leaf_path: `($(local p) as Two)` </del> <ins> //~| ERROR                  assigned_leaf_path: `($(local p) as Lonely::Zero)` //~| ERROR                 parent_of_fragments: `($(local p) as Lonely::One)` //~| ERROR                     moved_leaf_path: `($(local p) as Lonely::One).#0` //~| ERROR                  assigned_leaf_path: `($(local p) as Lonely::Two)` </ins> //~| ERROR                  assigned_leaf_path: `$(local data)` match p { Zero(..) => {}


#[rustc_move_fragments] pub fn test_match_bind_many(p: Lonely<D, D>) { //~^ ERROR                 parent_of_fragments: `$(local p)` <del> //~| ERROR                  assigned_leaf_path: `($(local p) as Zero)` //~| ERROR                 parent_of_fragments: `($(local p) as One)` //~| ERROR                     moved_leaf_path: `($(local p) as One).#0` </del> <ins> //~| ERROR                  assigned_leaf_path: `($(local p) as Lonely::Zero)` //~| ERROR                 parent_of_fragments: `($(local p) as Lonely::One)` //~| ERROR                     moved_leaf_path: `($(local p) as Lonely::One).#0` </ins> //~| ERROR                  assigned_leaf_path: `$(local data)` <del> //~| ERROR                 parent_of_fragments: `($(local p) as Two)` //~| ERROR                     moved_leaf_path: `($(local p) as Two).#0` //~| ERROR                     moved_leaf_path: `($(local p) as Two).#1` </del> <ins> //~| ERROR                 parent_of_fragments: `($(local p) as Lonely::Two)` //~| ERROR                     moved_leaf_path: `($(local p) as Lonely::Two).#0` //~| ERROR                     moved_leaf_path: `($(local p) as Lonely::Two).#1` </ins> //~| ERROR                  assigned_leaf_path: `$(local left)` //~| ERROR                  assigned_leaf_path: `$(local right)` match p {


<del> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT </del> <ins> // Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT </ins> // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. //


#[rustc_move_fragments] pub fn test_match_bind_and_underscore(p: Lonely<D, D>) { //~^ ERROR                 parent_of_fragments: `$(local p)` <del> //~| ERROR                  assigned_leaf_path: `($(local p) as Zero)` //~| ERROR                  assigned_leaf_path: `($(local p) as One)` //~| ERROR                 parent_of_fragments: `($(local p) as Two)` //~| ERROR                     moved_leaf_path: `($(local p) as Two).#0` //~| ERROR                    unmoved_fragment: `($(local p) as Two).#1` </del> <ins> //~| ERROR                  assigned_leaf_path: `($(local p) as Lonely::Zero)` //~| ERROR                  assigned_leaf_path: `($(local p) as Lonely::One)` //~| ERROR                 parent_of_fragments: `($(local p) as Lonely::Two)` //~| ERROR                     moved_leaf_path: `($(local p) as Lonely::Two).#0` //~| ERROR                    unmoved_fragment: `($(local p) as Lonely::Two).#1` </ins> //~| ERROR                  assigned_leaf_path: `$(local left)` match p {


impl<'a> Writer for &'a mut Writer+'a { #[inline] <del> fn write(&mut self, buf: &[u8]) -> IoResult<()> { self.write(buf) } </del> <ins> fn write(&mut self, buf: &[u8]) -> IoResult<()> { (**self).write(buf) } </ins> #[inline] <del> fn flush(&mut self) -> IoResult<()> { self.flush() } </del> <ins> fn flush(&mut self) -> IoResult<()> { (**self).flush() } </ins> } /// A `RefWriter` is a struct implementing `Writer` which contains a reference


It generally helps our diagnosis to include your specific OS (for example: Mac OS X 10.8.3, Windows 7, Ubuntu 12.04) and your hardware architecture (for example: i686, x86_64). <del> It's also helpful to copy/paste the output of re-running the erroneous rustc command with the `-v` flag. Finally, if you can run the offending command under gdb, pasting a stack trace can be useful; to do so, you will need to set a breakpoint on `rust_fail`. </del> <ins> It's also helpful to provide the exact version and host by copying the output of re-running the erroneous rustc command with the `--version=verbose` flag, which will produce something like this: ```{ignore} rustc 0.12.0 (ba4081a5a 2014-10-07 13:44:41 -0700) binary: rustc commit-hash: ba4081a5a8573875fed17545846f6f6902c8ba8d commit-date: 2014-10-07 13:44:41 -0700 host: i686-apple-darwin release: 0.12.0 ``` Finally, if you can run the offending command under gdb, pasting a stack trace can be useful; to do so, you will need to set a breakpoint on `rust_fail`. </ins> # I submitted a bug, but nobody has commented on it!


# Some less critical tests that are not prone to breakage. # Not run as part of the normal test suite, but tested by bors on checkin. <del> check-secondary: check-lexer check-pretty </del> <ins> check-secondary: check-build-compiletest check-lexer check-pretty </ins> # check + check-secondary. <del> check-all: check check-secondary </del> <ins> # # Issue #17883: build check-secondary first so hidden dependencies in # e.g. building compiletest are exercised (resolve those by adding # deps to rules that need them; not by putting `check` first here). check-all: check-secondary check </ins> # Pretty-printing tests. check-pretty: check-stage2-T-$(CFG_BUILD)-H-$(CFG_BUILD)-pretty-exec <ins> define DEF_CHECK_BUILD_COMPILETEST_FOR_STAGE check-stage$(1)-build-compiletest: 	$$(HBIN$(1)_H_$(CFG_BUILD))/compiletest$$(X_$(CFG_BUILD)) endef $(foreach stage,$(STAGES),  $(eval $(call DEF_CHECK_BUILD_COMPILETEST_FOR_STAGE,$(stage)))) check-build-compiletest:  check-stage1-build-compiletest  check-stage2-build-compiletest </ins> .PHONY: cleantmptestlogs cleantestlibs cleantmptestlogs:


PRETTY_DEPS_pretty-rfail = $(RFAIL_TESTS) PRETTY_DEPS_pretty-bench = $(BENCH_TESTS) PRETTY_DEPS_pretty-pretty = $(PRETTY_TESTS) <ins> # The stage- and host-specific dependencies are for e.g. macro_crate_test which pulls in # external crates. PRETTY_DEPS$(1)_H_$(3)_pretty-rpass = PRETTY_DEPS$(1)_H_$(3)_pretty-rpass-full = $$(HLIB$(1)_H_$(3))/stamp.syntax $$(HLIB$(1)_H_$(3))/stamp.rustc PRETTY_DEPS$(1)_H_$(3)_pretty-rfail = PRETTY_DEPS$(1)_H_$(3)_pretty-bench = PRETTY_DEPS$(1)_H_$(3)_pretty-pretty = </ins> PRETTY_DIRNAME_pretty-rpass = run-pass PRETTY_DIRNAME_pretty-rpass-full = run-pass-fulldeps PRETTY_DIRNAME_pretty-rfail = run-fail


$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)):  $$(TEST_SREQ$(1)_T_$(2)_H_$(3))  <del> $$(PRETTY_DEPS_$(4)) </del> <ins> $$(PRETTY_DEPS_$(4))  $$(PRETTY_DEPS$(1)_H_$(3)_$(4)) </ins> @$$(call E, run pretty-rpass [$(2)]: $$<) $$(Q)$$(call CFG_RUN_CTEST_$(2),$(1),$$<,$(3))  $$(PRETTY_ARGS$(1)-T-$(2)-H-$(3)-$(4))


impl fmt::Show for Duration { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { <del> let days = self.num_days(); let secs = self.secs - days * SECS_PER_DAY; </del> <ins> // technically speaking, negative duration is not valid ISO 8601, // but we need to print it anyway. let (abs, sign) = if self.secs < 0 { (-self, "-") } else { (*self, "") }; let days = abs.secs / SECS_PER_DAY; let secs = abs.secs - days * SECS_PER_DAY; </ins> let hasdate = days != 0; <del> let hastime = (secs != 0 || self.nanos != 0) || !hasdate; </del> <ins> let hastime = (secs != 0 || abs.nanos != 0) || !hasdate; try!(write!(f, "{}P", sign)); </ins> <del> try!(write!(f, "P")); </del> if hasdate { <del> // technically speaking the negative part is not the valid ISO 8601, // but we need to print it anyway. </del> try!(write!(f, "{}D", days)); } if hastime { <del> if self.nanos == 0 { </del> <ins> if abs.nanos == 0 { </ins> try!(write!(f, "T{}S", secs)); <del> } else if self.nanos % NANOS_PER_MILLI == 0 { try!(write!(f, "T{}.{:03}S", secs, self.nanos / NANOS_PER_MILLI)); } else if self.nanos % NANOS_PER_MICRO == 0 { try!(write!(f, "T{}.{:06}S", secs, self.nanos / NANOS_PER_MICRO)); </del> <ins> } else if abs.nanos % NANOS_PER_MILLI == 0 { try!(write!(f, "T{}.{:03}S", secs, abs.nanos / NANOS_PER_MILLI)); } else if abs.nanos % NANOS_PER_MICRO == 0 { try!(write!(f, "T{}.{:06}S", secs, abs.nanos / NANOS_PER_MICRO)); </ins> } else { <del> try!(write!(f, "T{}.{:09}S", secs, self.nanos)); </del> <ins> try!(write!(f, "T{}.{:09}S", secs, abs.nanos)); </ins> } } Ok(())


let d: Duration = Zero::zero(); assert_eq!(d.to_string(), "PT0S".to_string()); assert_eq!(Duration::days(42).to_string(), "P42D".to_string()); <del> assert_eq!(Duration::days(-42).to_string(), "P-42D".to_string()); </del> <ins> assert_eq!(Duration::days(-42).to_string(), "-P42D".to_string()); </ins> assert_eq!(Duration::seconds(42).to_string(), "PT42S".to_string()); assert_eq!(Duration::milliseconds(42).to_string(), "PT0.042S".to_string()); assert_eq!(Duration::microseconds(42).to_string(), "PT0.000042S".to_string()); assert_eq!(Duration::nanoseconds(42).to_string(), "PT0.000000042S".to_string()); assert_eq!((Duration::days(7) + Duration::milliseconds(6543)).to_string(), "P7DT6.543S".to_string()); <ins> assert_eq!(Duration::seconds(-86401).to_string(), "-P1DT1S".to_string()); assert_eq!(Duration::nanoseconds(-1).to_string(), "-PT0.000000001S".to_string()); </ins> // the format specifier should have no effect on `Duration` assert_eq!(format!("{:30}", Duration::days(1) + Duration::milliseconds(2345)),


return found def make_win_dist(dist_root, target_triple): <del> # Ask gcc where it keeps its' stuff </del> <ins> # Ask gcc where it keeps its stuff </ins> gcc_out = subprocess.check_output(["gcc.exe", "-print-search-dirs"]) bin_path = os.environ["PATH"].split(os.pathsep) lib_path = []


else: rustc_dlls.append("libgcc_s_seh-1.dll") <del> target_libs = ["crtbegin.o", "crtend.o", "crt2.o", "dllcrt2.o", "libadvapi32.a", "libcrypt32.a", "libgcc.a", "libgcc_eh.a", "libgcc_s.a", "libimagehlp.a", "libiphlpapi.a", "libkernel32.a", "libm.a", "libmingw32.a", "libmingwex.a", "libmsvcrt.a", "libpsapi.a", "libshell32.a", "libstdc++.a", "libuser32.a", "libws2_32.a", "libiconv.a", "libmoldname.a"] </del> <ins> target_libs = [ # MinGW libs "crtbegin.o", "crtend.o", "crt2.o", "dllcrt2.o", "libgcc.a", "libgcc_eh.a", "libgcc_s.a", "libm.a", "libmingw32.a", "libmingwex.a", "libstdc++.a", "libiconv.a", "libmoldname.a", # Windows import libs "libadvapi32.a", "libbcrypt.a", "libcomctl32.a", "libcomdlg32.a", "libcrypt32.a", "libctl3d32.a", "libgdi32.a", "libimagehlp.a", "libiphlpapi.a", "libkernel32.a", "libmsvcrt.a", "libodbc32.a", "libole32.a", "liboleaut32.a", "libopengl32.a", "libpsapi.a", "librpcrt4.a", "libsetupapi.a", "libshell32.a", "libuser32.a", "libuuid.a", "libwinhttp.a", "libwinmm.a", "libwinspool.a", "libws2_32.a", "libwsock32.a", ] </ins> # Find mingw artifacts we want to bundle target_tools = find_files(target_tools, bin_path)


shutil.copy(src, dist_bin_dir) # Copy platform tools to platform-specific bin directory <del> target_bin_dir = os.path.join(dist_root, "bin", "rustlib", target_triple, "gcc", "bin") </del> <ins> target_bin_dir = os.path.join(dist_root, "bin", "rustlib", target_triple, "bin") </ins> if not os.path.exists(target_bin_dir): os.makedirs(target_bin_dir) for src in target_tools: shutil.copy(src, target_bin_dir) # Copy platform libs to platform-spcific lib directory <del> target_lib_dir = os.path.join(dist_root, "bin", "rustlib", target_triple, "gcc", "lib") </del> <ins> target_lib_dir = os.path.join(dist_root, "bin", "rustlib", target_triple, "lib") </ins> if not os.path.exists(target_lib_dir): os.makedirs(target_lib_dir) for src in target_libs:


cmd.arg(obj_filename.with_extension("metadata.o")); } <del> // Rust does its' own LTO cmd.arg("-fno-lto"); </del> if t.options.is_like_osx { // The dead_strip option to the linker specifies that functions and data // unreachable by the entry point will be removed. This is quite useful


trans: &CrateTranslation, outputs: &OutputFilenames) { let old_path = os::getenv("PATH").unwrap_or_else(||String::new()); <del> let mut new_path = os::split_paths(old_path.as_slice()); new_path.extend(sess.host_filesearch().get_tools_search_paths().into_iter()); </del> <ins> let mut new_path = sess.host_filesearch().get_tools_search_paths(); new_path.extend(os::split_paths(old_path.as_slice()).into_iter()); </ins> os::setenv("PATH", os::join_paths(new_path.as_slice()).unwrap()); time(sess.time_passes(), "linking", (), |_|


p.push(find_libdir(self.sysroot)); p.push(rustlibdir()); p.push(self.triple); <del> let mut p1 = p.clone(); p1.push("bin"); let mut p2 = p.clone(); p2.push("gcc"); p2.push("bin"); vec![p1, p2] </del> <ins> p.push("bin"); vec![p] </ins> } }


unsafe { let ccx = cx.fcx.ccx; let ty = val_ty(fn_); <del> let retty = if ty.kind() == llvm::Integer { </del> <ins> let retty = if ty.kind() == llvm::Function { </ins> ty.return_type() } else { ccx.int_type()


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // error-pattern:stop // #18576 // Make sure that an calling extern function pointer in an unreachable // context doesn't cause an LLVM assertion #[allow(unreachable_code)] fn main() { panic!("stop"); let pointer = other; pointer(); } extern fn other() {} </ins>


use common::{CodegenCx, val_ty}; use declare; use monomorphize::Instance; <ins> use syntax_pos::Span; use syntax_pos::symbol::LocalInternedString; </ins> use type_::Type; use type_of::LayoutLlvmExt; <del> use rustc::ty; </del> <ins> use rustc::ty::{self, Ty}; </ins> use rustc::ty::layout::{Align, LayoutOf}; <del> use rustc::hir::{self, CodegenFnAttrFlags}; </del> <ins> use rustc::hir::{self, CodegenFnAttrs, CodegenFnAttrFlags}; </ins> use std::ffi::{CStr, CString};


let ty = instance.ty(cx.tcx); let sym = cx.tcx.symbol_name(instance).as_str(); <ins> debug!("get_static: sym={} instance={:?}", sym, instance); </ins> let g = if let Some(id) = cx.tcx.hir.as_local_node_id(def_id) { let llty = cx.layout_of(ty).llvm_type(cx);


hir_map::NodeForeignItem(&hir::ForeignItem { ref attrs, span, node: hir::ForeignItemKind::Static(..), .. }) => { <del> let g = if let Some(linkage) = cx.tcx.codegen_fn_attrs(def_id).linkage { // If this is a static with a linkage specified, then we need to handle // it a little specially. The typesystem prevents things like &T and // extern "C" fn() from being non-null, so we can't just declare a // static and call it a day. Some linkages (like weak) will make it such // that the static actually has a null value. let llty2 = match ty.sty { ty::TyRawPtr(ref mt) => cx.layout_of(mt.ty).llvm_type(cx), _ => { cx.sess().span_fatal(span, "must have type `*const T` or `*mut T`"); } }; unsafe { // Declare a symbol `foo` with the desired linkage. let g1 = declare::declare_global(cx, &sym, llty2); llvm::LLVMRustSetLinkage(g1, base::linkage_to_llvm(linkage)); // Declare an internal global `extern_with_linkage_foo` which // is initialized with the address of `foo`.  If `foo` is // discarded during linking (for example, if `foo` has weak // linkage and there are no definitions), then // `extern_with_linkage_foo` will instead be initialized to // zero. let mut real_name = "_rust_extern_with_linkage_".to_string(); real_name.push_str(&sym); let g2 = declare::define_global(cx, &real_name, llty).unwrap_or_else(||{ cx.sess().span_fatal(span, &format!("symbol `{}` is already defined", &sym)) }); llvm::LLVMRustSetLinkage(g2, llvm::Linkage::InternalLinkage); llvm::LLVMSetInitializer(g2, g1); g2 } } else { // Generate an external declaration. declare::declare_global(cx, &sym, llty) }; (g, attrs) </del> <ins> let fn_attrs = cx.tcx.codegen_fn_attrs(def_id); (check_and_apply_linkage(cx, &fn_attrs, ty, sym, Some(span)), attrs) </ins> } item => bug!("get_static: expected static, found {:?}", item) }; <ins> debug!("get_static: sym={} attrs={:?}", sym, attrs); </ins> for attr in attrs { if attr.check_name("thread_local") { llvm::set_thread_local_mode(g, cx.tls_model);


g } else { // FIXME(nagisa): perhaps the map of externs could be offloaded to llvm somehow? <del> // FIXME(nagisa): investigate whether it can be changed into define_global let g = declare::declare_global(cx, &sym, cx.layout_of(ty).llvm_type(cx)); </del> <ins> debug!("get_static: sym={} item_attr={:?}", sym, cx.tcx.item_attrs(def_id)); let attrs = cx.tcx.codegen_fn_attrs(def_id); let g = check_and_apply_linkage(cx, &attrs, ty, sym, None); </ins> // Thread-local statics in some other crate need to *always* be linked // against in a thread-local fashion, so we need to be sure to apply the // thread-local attribute locally if it was present remotely. If we // don't do this then linker errors can be generated where the linker // complains that one object files has a thread local version of the // symbol and another one doesn't. <del> for attr in cx.tcx.get_attrs(def_id).iter() { if attr.check_name("thread_local") { llvm::set_thread_local_mode(g, cx.tls_model); } </del> <ins> if attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL) { llvm::set_thread_local_mode(g, cx.tls_model); </ins> } if cx.use_dll_storage_attrs && !cx.tcx.is_foreign_item(def_id) { // This item is external but not foreign, i.e. it originates from an external Rust // crate. Since we don't know whether this crate will be linked dynamically or


g } <ins> fn check_and_apply_linkage<'tcx>( cx: &CodegenCx<'_, 'tcx>, attrs: &CodegenFnAttrs, ty: Ty<'tcx>, sym: LocalInternedString, span: Option<Span> ) -> ValueRef { let llty = cx.layout_of(ty).llvm_type(cx); if let Some(linkage) = attrs.linkage { debug!("get_static: sym={} linkage={:?}", sym, linkage); // If this is a static with a linkage specified, then we need to handle // it a little specially. The typesystem prevents things like &T and // extern "C" fn() from being non-null, so we can't just declare a // static and call it a day. Some linkages (like weak) will make it such // that the static actually has a null value. let llty2 = match ty.sty { ty::TyRawPtr(ref mt) => cx.layout_of(mt.ty).llvm_type(cx), _ => { if span.is_some() { cx.sess().span_fatal(span.unwrap(), "must have type `*const T` or `*mut T`") } else { bug!("must have type `*const T` or `*mut T`") } } }; unsafe { // Declare a symbol `foo` with the desired linkage. let g1 = declare::declare_global(cx, &sym, llty2); llvm::LLVMRustSetLinkage(g1, base::linkage_to_llvm(linkage)); // Declare an internal global `extern_with_linkage_foo` which // is initialized with the address of `foo`.  If `foo` is // discarded during linking (for example, if `foo` has weak // linkage and there are no definitions), then // `extern_with_linkage_foo` will instead be initialized to // zero. let mut real_name = "_rust_extern_with_linkage_".to_string(); real_name.push_str(&sym); let g2 = declare::define_global(cx, &real_name, llty).unwrap_or_else(||{ if span.is_some() { cx.sess().span_fatal( span.unwrap(), &format!("symbol `{}` is already defined", &sym) ) } else { bug!("symbol `{}` is already defined", &sym) } }); llvm::LLVMRustSetLinkage(g2, llvm::Linkage::InternalLinkage); llvm::LLVMSetInitializer(g2, g1); g2 } } else { // Generate an external declaration. // FIXME(nagisa): investigate whether it can be changed into define_global declare::declare_global(cx, &sym, llty) } } </ins> pub fn codegen_static<'a, 'tcx>( cx: &CodegenCx<'a, 'tcx>, def_id: DefId,


<ins> // Copyright 2018 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. #![crate_type = "rlib"] #![feature(linkage)] pub fn foo<T>() -> *const() { extern { #[linkage = "extern_weak"] static FOO: *const(); } unsafe { FOO } } </ins>


<ins> // Copyright 2018 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 for issue #18804, #[linkage] does not propagate thorugh generic // functions. Failure results in a linker error. // ignore-asmjs no weak symbol support // ignore-emscripten no weak symbol support // aux-build:lib.rs extern crate lib; fn main() { lib::foo::<i32>(); } </ins>


<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. trait Tup { type T0; type T1; } impl Tup for isize { type T0 = f32; type T1 = (); } fn main() {} </ins>


clean::TypedefItem(ref t) => item_typedef(fmt, self.item, t), clean::MacroItem(ref m) => item_macro(fmt, self.item, m), clean::PrimitiveItem(ref p) => item_primitive(fmt, self.item, p), <ins> clean::StaticItem(ref i) => item_static(fmt, self.item, i), clean::ConstantItem(ref c) => item_constant(fmt, self.item, c), </ins> _ => Ok(()) } }


return s } <del> fn blank<'a>(s: Option<&'a str>) -> &'a str { match s { Some(s) => s, None => "" } } </del> fn shorter<'a>(s: Option<&'a str>) -> &'a str { match s { Some(s) => match s.find_str("nn") {


id = short, name = name)); }  struct Initializer<'a>(&'a str, Item<'a>); impl<'a> fmt::Show for Initializer<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let Initializer(s, item) = *self; if s.len() == 0 { return Ok(()); } try!(write!(f, " = ")); if s.contains("n") { match item.href() { Some(url) => { write!(f, "[definition]", url) } None => Ok(()), } } else { write!(f, "{}", s.as_slice()) } } }  match myitem.inner {  clean::StaticItem(ref s) | clean::ForeignStaticItem(ref s) => { try!(write!(w, "
 {}{}static {}{}: {}{}	 {}
 ", ConciseStability(&myitem.stability), VisSpace(myitem.visibility), MutableSpace(s.mutability), *myitem.name.as_ref().unwrap(), s.type_, Initializer(s.expr.as_slice(), Item { cx: cx, item: myitem }), Markdown(blank(myitem.doc_value())))); } clean::ConstantItem(ref s) => { try!(write!(w, "
 {}{}const {}: {}{}	 {}
 ", ConciseStability(&myitem.stability), VisSpace(myitem.visibility), *myitem.name.as_ref().unwrap(), s.type_, Initializer(s.expr.as_slice(), Item { cx: cx, item: myitem }), Markdown(blank(myitem.doc_value())))); }  clean::ViewItemItem(ref item) => { match item.inner { clean::ExternCrate(ref name, ref src, _) => {


write!(w, "
") }  struct Initializer<'a>(&'a str); impl<'a> fmt::Show for Initializer<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let Initializer(s) = *self; if s.len() == 0 { return Ok(()); } try!(write!(f, " = ")); write!(f, "{}", s.as_slice()) } } fn item_constant(w: &mut fmt::Formatter, it: &clean::Item, c: &clean::Constant) -> fmt::Result { try!(write!(w, "
{vis}const  {name}: {typ}{init}
", vis = VisSpace(it.visibility), name = it.name.as_ref().unwrap().as_slice(), typ = c.type_, init = Initializer(c.expr.as_slice()))); document(w, it) } fn item_static(w: &mut fmt::Formatter, it: &clean::Item, s: &clean::Static) -> fmt::Result { try!(write!(w, "
{vis}static {mutability} {name}: {typ}{init}
", vis = VisSpace(it.visibility), mutability = MutableSpace(s.mutability), name = it.name.as_ref().unwrap().as_slice(), typ = s.type_, init = Initializer(s.expr.as_slice()))); document(w, it) }  fn item_function(w: &mut fmt::Formatter, it: &clean::Item, f: &clean::Function) -> fmt::Result { try!(write!(w, "
{vis}{fn_style}fn


} } <del> /// Creates a `Vec<T>` directly from the raw constituents. </del> <ins> /// Creates a `Vec<T>` directly from the raw components of another vector. </ins> /// <del> /// This is highly unsafe: /// /// - if `ptr` is null, then `length` and `capacity` should be 0 /// - `ptr` must point to an allocation of size `capacity` /// - there must be `length` valid instances of type `T` at the ///   beginning of that allocation /// - `ptr` must be allocated by the default `Vec` allocator </del> <ins> /// This is highly unsafe, due to the number of invariants that aren't checked. </ins> /// /// # Example ///


use syntax::ast_util::{local_def}; use syntax::attr; use syntax::codemap::Span; <ins> use syntax::parse::token; </ins> use syntax::visit; use syntax::visit::Visitor;


} } <ins> fn reject_shadowing_type_parameters<'tcx>(tcx: &ty::ctxt<'tcx>, span: Span, generics: &ty::Generics<'tcx>) { let impl_params = generics.types.get_slice(subst::TypeSpace).iter() .map(|tp| tp.name).collect::<HashSet<_>>(); for method_param in generics.types.get_slice(subst::FnSpace).iter() { if impl_params.contains(&method_param.name) { tcx.sess.span_err( span, &*format!("type parameter `{}` shadows another type parameter of the same name", token::get_name(method_param.name))); } } } </ins> impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> { fn visit_item(&mut self, i: &ast::Item) { self.check_item_well_formed(i); visit::walk_item(self, i); } <ins> fn visit_fn(&mut self, fk: visit::FnKind<'v>, fd: &'v ast::FnDecl, b: &'v ast::Block, span: Span, id: ast::NodeId) { match fk { visit::FkFnBlock | visit::FkItemFn(..) => {} visit::FkMethod(..) => { match ty::impl_or_trait_item(self.ccx.tcx, local_def(id)) { ty::ImplOrTraitItem::MethodTraitItem(ty_method) => { reject_shadowing_type_parameters(self.ccx.tcx, span, &ty_method.generics) } _ => {} } } } visit::walk_fn(self, fk, fd, b, span) } fn visit_trait_item(&mut self, t: &'v ast::TraitItem) { match t { &ast::TraitItem::ProvidedMethod(_) | &ast::TraitItem::TypeTraitItem(_) => {}, &ast::TraitItem::RequiredMethod(ref method) => { match ty::impl_or_trait_item(self.ccx.tcx, local_def(method.id)) { ty::ImplOrTraitItem::MethodTraitItem(ty_method) => { reject_shadowing_type_parameters( self.ccx.tcx, method.span, &ty_method.generics) } _ => {} } } } visit::walk_trait_item(self, t) } </ins> } pub struct BoundsChecker<'cx,'tcx:'cx> {


self.ch == Some(c) } <del> fn error<T>(&self, reason: ErrorCode) -> Result<T, ParserError> { </del> <ins> fn error<U>(&self, reason: ErrorCode) -> Result<U, ParserError> { </ins> Err(SyntaxError(reason, self.line, self.col)) }


<ins> // Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Test that shadowed lifetimes generate an error. struct Foo<T>; impl<T> Foo<T> { fn shadow_in_method<T>(&self) {} //~^ ERROR type parameter `T` shadows another type parameter fn not_shadow_in_item<U>(&self) { struct Bar<T, U>; // not a shadow, separate item fn foo<T, U>() {} // same } } trait<T> Bar<T> { fn shadow_in_required<T>(&self); //~^ ERROR type parameter `T` shadows another type parameter fn shadow_in_provided<T>(&self) {} //~^ ERROR type parameter `T` shadows another type parameter fn not_shadow_in_required<U>(&self); fn not_shadow_in_provided<U>(&self) {} } fn main() {} </ins>


// aux-build:issue-13560-1.rs // aux-build:issue-13560-2.rs // aux-build:issue-13560-3.rs <ins> // ignore-pretty FIXME #19501 </ins> // ignore-stage1 // Regression test for issue #13560, the test itself is all in the dependent


match probe.kind { InherentImplCandidate(impl_def_id, ref substs) | ExtensionImplCandidate(impl_def_id, _, ref substs, _) => { <ins> let selcx = &mut traits::SelectionContext::new(self.infcx(), self.fcx); let cause = traits::ObligationCause::misc(self.span, self.fcx.body_id); </ins> // Check whether the impl imposes obligations we have to worry about. let impl_generics = ty::lookup_item_type(self.tcx(), impl_def_id).generics; let impl_bounds = impl_generics.to_bounds(self.tcx(), substs); <del> // FIXME(#20378) assoc type normalization here? // Erase any late-bound regions bound in the impl // which appear in the bounds. let impl_bounds = self.erase_late_bound_regions(&ty::Binder(impl_bounds)); </del> <ins> let traits::Normalized { value: impl_bounds, obligations: norm_obligations } = traits::normalize(selcx, cause.clone(), &impl_bounds); </ins> // Convert the bounds into obligations. let obligations = <del> traits::predicates_for_generics( self.tcx(), traits::ObligationCause::misc(self.span, self.fcx.body_id), &impl_bounds); </del> <ins> traits::predicates_for_generics(self.tcx(), cause.clone(), &impl_bounds); </ins> debug!("impl_obligations={}", obligations.repr(self.tcx())); // Evaluate those obligations to see if they might possibly hold. <del> let mut selcx = traits::SelectionContext::new(self.infcx(), self.fcx); obligations.all(|o| selcx.evaluate_obligation(o)) </del> <ins> obligations.all(|o| selcx.evaluate_obligation(o)) && norm_obligations.iter().all(|o| selcx.evaluate_obligation(o)) </ins> } ObjectCandidate(..) |


<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 that we handle projection types which wind up important for // resolving methods. This test was reduced from a larger example; the // call to `foo()` at the end was failing to resolve because the // winnowing stage of method resolution failed to handle an associated // type projection. #![feature(associated_types)] trait Hasher { type Output; fn finish(&self) -> Self::Output; } trait Hash<H: Hasher> { fn hash(&self, h: &mut H); } trait HashState { type Wut: Hasher; fn hasher(&self) -> Self::Wut; } struct SipHasher; impl Hasher for SipHasher { type Output = u64; fn finish(&self) -> u64 { 4 } } impl Hash<SipHasher> for int { fn hash(&self, h: &mut SipHasher) {} } struct SipState; impl HashState for SipState { type Wut = SipHasher; fn hasher(&self) -> SipHasher { SipHasher } } struct Map<S> { s: S, } impl<S> Map<S> where S: HashState, <S as HashState>::Wut: Hasher<Output=u64>, { fn foo<K>(&self, k: K) where K: Hash< <S as HashState>::Wut> {} } fn foo<K: Hash<SipHasher>>(map: &Map<SipState>) { map.foo(22); } fn main() {} </ins>


(_, "size_of") => { let tp_ty = *substs.types.get(FnSpace, 0); let lltp_ty = type_of::type_of(ccx, tp_ty); <del> C_uint(ccx, machine::llsize_of_real(ccx, lltp_ty)) </del> <ins> C_uint(ccx, machine::llsize_of_alloc(ccx, lltp_ty)) </ins> } (_, "min_align_of") => { let tp_ty = *substs.types.get(FnSpace, 0);


// Returns, as near as we can figure, the "real" size of a type. As in, the // bits in this number of bytes actually carry data related to the datum <del> // with the type. Not junk, padding, accidentally-damaged words, or // whatever. Rounds up to the nearest byte though, so if you have a 1-bit </del> <ins> // with the type. Not junk, accidentally-damaged words, or whatever. // Note that padding of the type will be included for structs, but not for the // other types (i.e. SIMD types). // Rounds up to the nearest byte though, so if you have a 1-bit </ins> // value, we return 1 here, not 0. Most of rustc works in bytes. Be warned // that LLVM *does* distinguish between e.g. a 1-bit value and an 8-bit value // at the codegen level! In general you should prefer `llbitsize_of_real`


<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. #![feature(simd)] #![allow(non_camel_case_types)] use std::mem; /// `T` should satisfy `size_of T (mod min_align_of T) === 0` to be stored at `Vec<T>` properly /// Please consult the issue #20460 fn check<T>() { assert_eq!(mem::size_of::<T>() % mem::min_align_of::<T>(), 0) } fn main() { check::<u8x2>(); check::<u8x3>(); check::<u8x4>(); check::<u8x5>(); check::<u8x6>(); check::<u8x7>(); check::<u8x8>(); check::<i16x2>(); check::<i16x3>(); check::<i16x4>(); check::<i16x5>(); check::<i16x6>(); check::<i16x7>(); check::<i16x8>(); check::<f32x2>(); check::<f32x3>(); check::<f32x4>(); check::<f32x5>(); check::<f32x6>(); check::<f32x7>(); check::<f32x8>(); } #[simd] struct u8x2(u8, u8); #[simd] struct u8x3(u8, u8, u8); #[simd] struct u8x4(u8, u8, u8, u8); #[simd] struct u8x5(u8, u8, u8, u8, u8); #[simd] struct u8x6(u8, u8, u8, u8, u8, u8); #[simd] struct u8x7(u8, u8, u8, u8, u8, u8, u8); #[simd] struct u8x8(u8, u8, u8, u8, u8, u8, u8, u8); #[simd] struct i16x2(i16, i16); #[simd] struct i16x3(i16, i16, i16); #[simd] struct i16x4(i16, i16, i16, i16); #[simd] struct i16x5(i16, i16, i16, i16, i16); #[simd] struct i16x6(i16, i16, i16, i16, i16, i16); #[simd] struct i16x7(i16, i16, i16, i16, i16, i16, i16); #[simd] struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); #[simd] struct f32x2(f32, f32); #[simd] struct f32x3(f32, f32, f32); #[simd] struct f32x4(f32, f32, f32, f32); #[simd] struct f32x5(f32, f32, f32, f32, f32); #[simd] struct f32x6(f32, f32, f32, f32, f32, f32); #[simd] struct f32x7(f32, f32, f32, f32, f32, f32, f32); #[simd] struct f32x8(f32, f32, f32, f32, f32, f32, f32, f32); </ins>


<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. trait T : Iterator<Item=Self::Item> //~^ ERROR unsupported cyclic reference between types/traits detected {} fn main() {} </ins>


<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. trait Foo {} impl<'a> Foo for Foo+'a {} //~^ ERROR the object type `Foo + 'a` automatically implements the trait `Foo` fn main() {} </ins>


<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. // ignore-tidy-linelength use std::ops::Add; fn main() { let x = &10 as //~^ ERROR the value of the associated type `Output` (from the trait `core::ops::Add`) must be specified &Add; //~^ ERROR the type parameter `RHS` must be explicitly specified in an object type because its default value `Self` references the type `Self` } </ins>


<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. extern crate libc; fn main() { let foo: *mut libc::c_void; let cb: &mut Fn() = unsafe { &mut *(foo as *mut Fn()) //~^ ERROR use of possibly uninitialized variable: `foo` }; } </ins>


use self::Arch::*; #[allow(non_camel_case_types)] <ins> #[derive(Copy)] </ins> pub enum Arch { Armv7, Armv7s,


"-Wl,-syslibroot".to_string(), get_sdk_root(sdk_name)] } <ins> fn target_cpu(arch: Arch) -> String { match arch { X86_64 => "x86-64", _ => "generic", }.to_string() } </ins> pub fn opts(arch: Arch) -> TargetOptions { TargetOptions { <ins> cpu: target_cpu(arch), </ins> dynamic_linking: false, executables: true, // Although there is an experimental implementation of LLVM which


pub fn target() -> Target { let mut base = super::apple_base::opts(); <ins> base.cpu = "x86-64".to_string(); </ins> base.eliminate_frame_pointer = false; base.pre_link_args.push("-m64".to_string());


pub fn target() -> Target { let mut base = super::windows_base::opts(); <ins> base.cpu = "x86-64".to_string(); </ins> // On Win64 unwinding is handled by the OS, so we can link libgcc statically. base.pre_link_args.push("-static-libgcc".to_string()); base.pre_link_args.push("-m64".to_string());


pub fn target() -> Target { let mut base = super::dragonfly_base::opts(); <ins> base.cpu = "x86-64".to_string(); </ins> base.pre_link_args.push("-m64".to_string()); Target {


pub fn target() -> Target { let mut base = super::freebsd_base::opts(); <ins> base.cpu = "x86-64".to_string(); </ins> base.pre_link_args.push("-m64".to_string()); Target {


pub fn target() -> Target { let mut base = super::linux_base::opts(); <ins> base.cpu = "x86-64".to_string(); </ins> base.pre_link_args.push("-m64".to_string()); Target {


ext::log_syntax::expand_syntax_ext)); syntax_expanders.insert(intern("derive"), Decorator(box ext::deriving::expand_meta_derive)); <ins> syntax_expanders.insert(intern("deriving"), Decorator(box ext::deriving::expand_deprecated_deriving)); </ins> if ecfg.enable_quotes { // Quasi-quoting expanders


pub mod generic; <ins> pub fn expand_deprecated_deriving(cx: &mut ExtCtxt, span: Span, _: &MetaItem, _: &Item, _: Box<FnMut(P<Item>)>) { cx.span_err(span, "`deriving` has been renamed to `derive`"); } </ins> pub fn expand_meta_derive(cx: &mut ExtCtxt, _span: Span, mitem: &MetaItem,


<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. #[deriving(Clone)] //~ ERROR `deriving` has been renamed to `derive` struct Foo; fn main() {} </ins>


use middle::infer::InferCtxt; use middle::ty::{self, ToPredicate, HasTypeFlags, ToPolyTraitRef, TraitRef, Ty}; use middle::ty::fold::TypeFoldable; <del> use std::collections::HashMap; </del> <ins> use util::nodemap::{FnvHashMap, FnvHashSet}; </ins> use std::fmt; use syntax::codemap::Span; use syntax::attr::{AttributeMethods, AttrMetaMethods};


(gen.name.as_str().to_string(), trait_ref.substs.types.get(param, i) .to_string()) <del> }).collect::<HashMap<String, String>>(); </del> <ins> }).collect::<FnvHashMap<String, String>>(); </ins> generic_map.insert("Self".to_string(), trait_ref.self_ty().to_string()); let parser = Parser::new(&istring);


"the trait `{}` cannot be made into an object", tcx.item_path_str(trait_def_id)); <ins> let mut reported_violations = FnvHashSet(); </ins> for violation in violations { <ins> if !reported_violations.insert(violation.clone()) { continue; } </ins> match violation { ObjectSafetyViolation::SizedSelf => { tcx.sess.fileline_note(


use std::rc::Rc; use syntax::ast; <del> #[derive(Debug)] </del> <ins> #[derive(Clone, Debug, PartialEq, Eq, Hash)] </ins> pub enum ObjectSafetyViolation<'tcx> { /// Self : Sized declared on the trait SizedSelf,


} } <ins> impl<'tcx> PartialEq for Method<'tcx> { #[inline] fn eq(&self, other: &Self) -> bool { self.def_id == other.def_id } } impl<'tcx> Eq for Method<'tcx> {} impl<'tcx> Hash for Method<'tcx> { #[inline] fn hash<H: Hasher>(&self, s: &mut H) { self.def_id.hash(s) } } </ins> #[derive(Clone, Copy, Debug)] pub struct AssociatedConst<'tcx> { pub name: Name,


<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. trait Array: Sized {} fn f<T: Array>(x: &T) { let _ = x //~^ ERROR `Array` cannot be made into an object //~| NOTE the trait cannot require that `Self : Sized` as &Array; //~^ ERROR `Array` cannot be made into an object //~| NOTE the trait cannot require that `Self : Sized` } fn main() {} </ins>


projection_ty: projection_ty, ty: ty_var }); <del> let obligation = Obligation::with_depth(cause, depth+1, projection.to_predicate()); </del> <ins> let obligation = Obligation::with_depth( cause, depth + 1, projection.to_predicate()); </ins> Normalized { value: ty_var, obligations: vec!(obligation)


obligations); if projected_ty.has_projection_types() { <del> let mut normalizer = AssociatedTypeNormalizer::new(selcx, cause, depth); </del> <ins> let mut normalizer = AssociatedTypeNormalizer::new(selcx, cause, depth+1); </ins> let normalized_ty = normalizer.fold(&projected_ty); debug!("normalize_projection_type: normalized_ty={:?} depth={}",


/// contexts around the same size. n_llvm_insns: Cell<usize>, <ins> /// Depth of the current type-of computation - used to bail out type_of_depth: Cell<usize>, </ins> trait_cache: RefCell<FnvHashMap<ty::PolyTraitRef<'tcx>, traits::Vtable<'tcx, ()>>>, }


unwind_resume_hooked: Cell::new(false), intrinsics: RefCell::new(FnvHashMap()), n_llvm_insns: Cell::new(0), <ins> type_of_depth: Cell::new(0), </ins> trait_cache: RefCell::new(FnvHashMap()), };


obj)) } <ins> pub fn enter_type_of(&self, ty: Ty<'tcx>) -> TypeOfDepthLock<'b, 'tcx> { let current_depth = self.local.type_of_depth.get(); debug!("enter_type_of({:?}) at depth {:?}", ty, current_depth); if current_depth > self.sess().recursion_limit.get() { self.sess().fatal( &format!("overflow representing the type `{}`", ty)) } self.local.type_of_depth.set(current_depth + 1); TypeOfDepthLock(self.local) } </ins> pub fn check_overflow(&self) -> bool { self.shared.check_overflow }


} } <ins> pub struct TypeOfDepthLock<'a, 'tcx: 'a>(&'a LocalCrateContext<'tcx>); impl<'a, 'tcx> Drop for TypeOfDepthLock<'a, 'tcx> { fn drop(&mut self) { self.0.type_of_depth.set(self.0.type_of_depth.get() - 1); } } </ins> /// Declare any llvm intrinsics that you might need fn declare_intrinsic(ccx: &CrateContext, key: &str) -> Option<ValueRef> { macro_rules! ifn {


} debug!("sizing_type_of {:?}", t); <ins> let _recursion_lock = cx.enter_type_of(t); </ins> let llsizingty = match t.sty { _ if !type_is_sized(cx.tcx(), t) => { Type::struct_(cx, &[Type::i8p(cx), Type::i8p(cx)], false)


<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. trait Foo { type A; } struct FooStruct; impl Foo for FooStruct { //~^ ERROR overflow evaluating the requirement `<FooStruct as Foo>::A` type A = <FooStruct as Foo>::A; } fn main() {} </ins>


<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. // error-pattern: overflow representing the type `S` trait Mirror { type It; } impl<T> Mirror for T { type It = Self; } struct S(Option<<S as Mirror>::It>); fn main() { let _s = S(None); } </ins>


<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. pub struct Outer<T: Trait>(T); pub struct Inner<'a> { value: &'a bool } pub trait Trait { type Error; fn ready(self) -> Self::Error; } impl<'a> Trait for Inner<'a> { type Error = Outer<Inner<'a>>; fn ready(self) -> Outer<Inner<'a>> { Outer(self) } } fn main() { let value = true; let inner = Inner { value: &value }; assert_eq!(inner.ready().0.value, &value); } </ins>


/// /// ``` /// let a = [1, 2, 3, 4, 5]; <del> /// assert!(a.iter().fold(0, |a, &b| a + b) == 15); </del> <ins> /// assert!(a.iter().fold(0, |acc, &item| acc + item) == 15); </ins> /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")]


/// instance, it will behave *as if* an instance of the type `T` were /// present for the purpose of various automatic analyses. /// <del> /// For example, embedding a `PhantomData<T>` will inform the compiler </del> <ins> /// # Examples /// /// When handling external resources over a foreign function interface, `PhantomData<T>` can /// prevent mismatches by enforcing types in the method implementations, although the struct /// doesn't actually contain values of the resource type. /// /// ``` /// # trait ResType { fn foo(&self); }; /// # struct ParamType; /// # mod foreign_lib { /// # pub fn new(_: usize) -> *mut () { 42 as *mut () } /// # pub fn do_stuff(_: *mut (), _: usize) {} /// # } /// # fn convert_params(_: ParamType) -> usize { 42 } /// use std::marker::PhantomData; /// use std::mem; /// /// struct ExternalResource<R> { ///    resource_handle: *mut (), ///    resource_type: PhantomData<R>, /// } /// /// impl<R: ResType> ExternalResource<R> { ///     fn new() -> ExternalResource<R> { ///         let size_of_res = mem::size_of::<R>(); ///         ExternalResource { ///             resource_handle: foreign_lib::new(size_of_res), ///             resource_type: PhantomData, ///         } ///     } /// ///     fn do_stuff(&self, param: ParamType) { ///         let foreign_params = convert_params(param); ///         foreign_lib::do_stuff(self.resource_handle, foreign_params); ///     } /// } /// ``` /// /// Another example: embedding a `PhantomData<T>` will inform the compiler </ins> /// that one or more instances of the type `T` could be dropped when /// instances of the type itself is dropped, though that may not be /// apparent from the other structure of the type itself. This is


/// The different kinds of types recognized by the compiler pub enum Ty_ { TyVec(P<Ty>), <del> /// A fixed length array (`[T, ..n]`) </del> <ins> /// A fixed length array (`[T; n]`) </ins> TyFixedLengthVec(P<Ty>, P<Expr>), /// A raw pointer (`*const T` or `*mut T`) TyPtr(MutTy),


debug!("(building reduced graph for external  crate) building type {}", final_ident); <ins> let modifiers = match new_parent.kind.get() { NormalModuleKind => modifiers, _ => modifiers & !DefModifiers::IMPORTABLE }; </ins> child_name_bindings.define_type(def, DUMMY_SP, modifiers); } DefStruct(def_id) => {


// option. This file may not be copied, modified, or distributed // except according to those terms. <ins> #![feature(associated_consts)] </ins> pub use self::sub::{Bar, Baz}; pub trait Trait { fn foo(&self); <ins> type Assoc; const CONST: u32; </ins> } struct Foo; impl Foo { pub fn new() {} <ins> pub const C: u32 = 0; </ins> } mod sub {


use use_from_trait_xc::Trait::foo; //~^ ERROR `foo` is not directly importable <ins> use use_from_trait_xc::Trait::Assoc; //~^ ERROR `Assoc` is not directly importable use use_from_trait_xc::Trait::CONST; //~^ ERROR `CONST` is not directly importable </ins> use use_from_trait_xc::Foo::new; //~^ ERROR `new` is not directly importable <ins> use use_from_trait_xc::Foo::C; //~^ ERROR unresolved import `use_from_trait_xc::Foo::C` </ins> use use_from_trait_xc::Bar::new as bnew; //~^ ERROR `bnew` is not directly importable


// option. This file may not be copied, modified, or distributed // except according to those terms. <ins> #![feature(associated_consts)] </ins> use Trait::foo; //~^ ERROR `foo` is not directly importable <ins> use Trait::Assoc; //~^ ERROR `Assoc` is not directly importable use Trait::C; //~^ ERROR `C` is not directly importable </ins> use Foo::new; //~^ ERROR unresolved import `Foo::new`. Not a module `Foo` <ins> use Foo::C2; //~^ ERROR unresolved import `Foo::C2`. Not a module `Foo` </ins> pub trait Trait { fn foo(); <ins> type Assoc; const C: u32; </ins> } struct Foo; impl Foo { fn new() {} <ins> const C2: u32 = 0; </ins> } fn main() {}


/// This function does not perform any I/O, it simply informs this object /// that some amount of its buffer, returned from `fill_buf`, has been /// consumed and should no longer be returned. <ins> /// /// This function is used to tell the buffer how many bytes you've consumed /// from the return value of `fill_buf`, and so may do odd things if /// `fill_buf` isn't called before calling this. /// /// The `amt` must be `<=` the number of bytes in the buffer returned by `fill_buf`. </ins> #[stable(feature = "rust1", since = "1.0.0")] fn consume(&mut self, amt: usize);


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. enum Foo { Bar } fn main() { Foo::Bar.a; //~^ ERROR: attempted access of field `a` on type `Foo`, but no field with that name was found } </ins>


} } <del> /// Returns the inner `T` of a `Some(T)`. </del> <ins> /// Moves the value `v` out of the `Option<T>` if the content of the `Option<T>` is a `Some(v)`. </ins> /// /// # Panics ///


<del> // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT </del> <ins> // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT </ins> // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. //


use std::num::wrapping::OverflowingOps; use std::cmp::Ordering; use std::collections::hash_map::Entry::Vacant; <del> use std::{i8, i16, i32, i64}; </del> <ins> use std::{i8, i16, i32, i64, u8, u16, u32, u64}; </ins> use std::rc::Rc; fn lookup_const<'a>(tcx: &'a ty::ctxt, e: &Expr) -> Option<&'a Expr> {


Ok(const_uint((!a).wrapping_add(1))) } <ins> fn const_uint_not(a: u64, opt_ety: Option<UintTy>) -> const_val { let mask = match opt_ety { Some(UintTy::U8) => u8::MAX as u64, Some(UintTy::U16) => u16::MAX as u64, Some(UintTy::U32) => u32::MAX as u64, None | Some(UintTy::U64) => u64::MAX, }; const_uint(!a & mask) } </ins> macro_rules! overflow_checking_body { ($a:ident, $b:ident, $ety:ident, $overflowing_op:ident, lhs: $to_8_lhs:ident $to_16_lhs:ident $to_32_lhs:ident,


ast::ExprUnary(ast::UnNot, ref inner) => { match try!(eval_const_expr_partial(tcx, &**inner, ety)) { const_int(i) => const_int(!i), <del> const_uint(i) => const_uint(!i), </del> <ins> const_uint(i) => const_uint_not(i, expr_uint_type), </ins> const_bool(b) => const_bool(!b), const_str(_) => signal!(e, NotOnString), const_float(_) => signal!(e, NotOnFloat),


<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. const U8_MAX_HALF: u8 = !0u8 / 2; const U16_MAX_HALF: u16 = !0u16 / 2; const U32_MAX_HALF: u32 = !0u32 / 2; const U64_MAX_HALF: u64 = !0u64 / 2; fn main() { assert_eq!(U8_MAX_HALF, 0x7f); assert_eq!(U16_MAX_HALF, 0x7fff); assert_eq!(U32_MAX_HALF, 0x7fff_ffff); assert_eq!(U64_MAX_HALF, 0x7fff_ffff_ffff_ffff); } </ins>


let mut where_predicates = where_predicates.into_iter().flat_map(|p| clean_predicate(*p, cx)).collect::<Vec<_>>(); <del> // Type parameters have a Sized bound by default unless removed with // ?Sized. Scan through the predicates and mark any type parameter with // a Sized bound, removing the bounds as we find them. </del> <ins> // In the surface language, all type parameters except `Self` have an // implicit `Sized` bound unless removed with `?Sized`. // However, in the list of where-predicates below, `Sized` appears like a // normal bound: It's either present (the type is sized) or // absent (the type is unsized) but never *maybe* (i.e. `?Sized`). </ins> // <del> // Note that associated types also have a sized bound by default, but we </del> <ins> // This is unsuitable for rendering. // Thus, as a first step remove all `Sized` bounds that should be implicit. // // Note that associated types also have an implicit `Sized` bound but we </ins> // don't actually know the set of associated types right here so that's <del> // handled in cleaning associated types </del> <ins> // handled when cleaning associated types. </ins> let mut sized_params = FxHashSet::default(); <del> where_predicates.retain(|pred| match *pred { WherePredicate::BoundPredicate { ty: Generic(ref g), ref bounds, .. } => { if bounds.iter().any(|b| b.is_sized_bound(cx)) { sized_params.insert(*g); false } else { true } </del> <ins> where_predicates.retain(|pred| { if let WherePredicate::BoundPredicate { ty: Generic(g), bounds, .. } = pred && *g != kw::SelfUpper && bounds.iter().any(|b| b.is_sized_bound(cx)) { sized_params.insert(*g); false } else { true </ins> } <del> _ => true, </del> }); <del> // Run through the type parameters again and insert a ?Sized // unbound for any we didn't find to be Sized. </del> <ins> // As a final step, go through the type parameters again and insert a // `?Sized` bound for each one we didn't find to be `Sized`. </ins> for tp in &stripped_params { <del> if matches!(tp.kind, types::GenericParamDefKind::Type { .. }) && !sized_params.contains(&tp.name) </del> <ins> if let types::GenericParamDefKind::Type { .. } = tp.kind && !sized_params.contains(&tp.name) </ins> { where_predicates.push(WherePredicate::BoundPredicate { ty: Type::Generic(tp.name),


<ins> #![crate_type = "lib"] pub trait U/*: ?Sized */ { fn modified(self) -> Self where Self: Sized { self } fn touch(&self)/* where Self: ?Sized */{} } pub trait S: Sized {} </ins>


fn touch(&self)
   No newline at end of file


<ins> #![crate_type = "lib"] #![crate_name = "usr"] // aux-crate:issue_24183=issue-24183.rs // edition: 2021 // @has usr/trait.U.html // @has - '//*[@class="item-decl"]' "pub trait U {" // @has - '//*[@id="method.modified"]'  // "fn modified(self) -> Self // where  //     Self: Sized" // @snapshot method_no_where_self_sized - '//*[@id="method.touch"]/*[@class="code-header"]' pub use issue_24183::U; // @has usr/trait.S.html // @has - '//*[@class="item-decl"]' 'pub trait S: Sized {' pub use issue_24183::S; </ins>


AutoTraitFinder { cx } } <ins> fn generate_for_trait( &mut self, ty: Ty<'tcx>, trait_def_id: DefId, param_env: ty::ParamEnv<'tcx>, param_env_def_id: DefId, f: &auto_trait::AutoTraitFinder<'tcx>, // If this is set, show only negative trait implementations, not positive ones. discard_positive_impl: bool, ) -> Option<Item> { let tcx = self.cx.tcx; let trait_ref = ty::TraitRef { def_id: trait_def_id, substs: tcx.mk_substs_trait(ty, &[]) }; if !self.cx.generated_synthetics.borrow_mut().insert((ty, trait_def_id)) { debug!("get_auto_trait_impl_for({:?}): already generated, aborting", trait_ref); return None; } let result = f.find_auto_trait_generics(ty, param_env, trait_def_id, |infcx, info| { let region_data = info.region_data; let names_map = tcx .generics_of(param_env_def_id) .params .iter() .filter_map(|param| match param.kind { ty::GenericParamDefKind::Lifetime => Some(param.name), _ => None, }) .map(|name| (name, Lifetime(name))) .collect(); let lifetime_predicates = Self::handle_lifetimes(&region_data, &names_map); let new_generics = self.param_env_to_generics( infcx.tcx, param_env_def_id, info.full_user_env, lifetime_predicates, info.vid_to_region, ); debug!( "find_auto_trait_generics(param_env_def_id={:?}, trait_def_id={:?}):  finished with {:?}", param_env_def_id, trait_def_id, new_generics ); new_generics }); let negative_polarity; let new_generics = match result { AutoTraitResult::PositiveImpl(new_generics) => { negative_polarity = false; if discard_positive_impl { return None; } new_generics } AutoTraitResult::NegativeImpl => { negative_polarity = true; // For negative impls, we use the generic params, but *not* the predicates, // from the original type. Otherwise, the displayed impl appears to be a // conditional negative impl, when it's really unconditional. // // For example, consider the struct Foo<T: Copy>(*mut T). Using // the original predicates in our impl would cause us to generate // `impl !Send for Foo<T: Copy>`, which makes it appear that Foo // implements Send where T is not copy. // // Instead, we generate `impl !Send for Foo<T>`, which better // expresses the fact that `Foo<T>` never implements `Send`, // regardless of the choice of `T`. let params = (tcx.generics_of(param_env_def_id), ty::GenericPredicates::default()) .clean(self.cx) .params; Generics { params, where_predicates: Vec::new() } } AutoTraitResult::ExplicitImpl => return None, }; Some(Item { source: Span::dummy(), name: None, attrs: Default::default(), visibility: Inherited, def_id: self.cx.next_def_id(param_env_def_id.krate), kind: box ImplItem(Impl { unsafety: hir::Unsafety::Normal, generics: new_generics, provided_trait_methods: Default::default(), trait_: Some(trait_ref.clean(self.cx).get_trait_type().unwrap()), for_: ty.clean(self.cx), items: Vec::new(), negative_polarity, synthetic: true, blanket_impl: None, }), }) } </ins> // FIXME(eddyb) figure out a better way to pass information about // parametrization of `ty` than `param_env_def_id`. crate fn get_auto_trait_impls(&mut self, ty: Ty<'tcx>, param_env_def_id: DefId) -> Vec<Item> {


debug!("get_auto_trait_impls({:?})", ty); let auto_traits: Vec<_> = self.cx.auto_traits.iter().cloned().collect(); <del> auto_traits </del> <ins> let mut auto_traits: Vec<Item> = auto_traits </ins> .into_iter() .filter_map(|trait_def_id| { <del> let trait_ref = ty::TraitRef { def_id: trait_def_id, substs: tcx.mk_substs_trait(ty, &[]) }; if !self.cx.generated_synthetics.borrow_mut().insert((ty, trait_def_id)) { debug!("get_auto_trait_impl_for({:?}): already generated, aborting", trait_ref); return None; } let result = f.find_auto_trait_generics(ty, param_env, trait_def_id, |infcx, info| { let region_data = info.region_data; let names_map = tcx .generics_of(param_env_def_id) .params .iter() .filter_map(|param| match param.kind { ty::GenericParamDefKind::Lifetime => Some(param.name), _ => None, }) .map(|name| (name, Lifetime(name))) .collect(); let lifetime_predicates = Self::handle_lifetimes(&region_data, &names_map); let new_generics = self.param_env_to_generics( infcx.tcx, param_env_def_id, info.full_user_env, lifetime_predicates, info.vid_to_region, ); debug!( "find_auto_trait_generics(param_env_def_id={:?}, trait_def_id={:?}):  finished with {:?}", param_env_def_id, trait_def_id, new_generics ); new_generics }); let negative_polarity; let new_generics = match result { AutoTraitResult::PositiveImpl(new_generics) => { negative_polarity = false; new_generics } AutoTraitResult::NegativeImpl => { negative_polarity = true; // For negative impls, we use the generic params, but *not* the predicates, // from the original type. Otherwise, the displayed impl appears to be a // conditional negative impl, when it's really unconditional. // // For example, consider the struct Foo<T: Copy>(*mut T). Using // the original predicates in our impl would cause us to generate // `impl !Send for Foo<T: Copy>`, which makes it appear that Foo // implements Send where T is not copy. // // Instead, we generate `impl !Send for Foo<T>`, which better // expresses the fact that `Foo<T>` never implements `Send`, // regardless of the choice of `T`. let params = (tcx.generics_of(param_env_def_id), ty::GenericPredicates::default()) .clean(self.cx) .params; Generics { params, where_predicates: Vec::new() } } AutoTraitResult::ExplicitImpl => return None, }; Some(Item { source: Span::dummy(), name: None, attrs: Default::default(), visibility: Inherited, def_id: self.cx.next_def_id(param_env_def_id.krate), kind: box ImplItem(Impl { unsafety: hir::Unsafety::Normal, generics: new_generics, provided_trait_methods: Default::default(), trait_: Some(trait_ref.clean(self.cx).get_trait_type().unwrap()), for_: ty.clean(self.cx), items: Vec::new(), negative_polarity, synthetic: true, blanket_impl: None, }), }) </del> <ins> self.generate_for_trait(ty, trait_def_id, param_env, param_env_def_id, &f, false) </ins> }) <del> .collect() </del> <ins> .collect(); // We are only interested in case the type *doesn't* implement the Sized trait. if !ty.is_sized(self.cx.tcx.at(rustc_span::DUMMY_SP), param_env) { // In case `#![no_core]` is used, `sized_trait` returns nothing. if let Some(item) = self.cx.tcx.lang_items().sized_trait().and_then(|sized_trait_did| { self.generate_for_trait(ty, sized_trait_did, param_env, param_env_def_id, &f, true) }) { auto_traits.push(item); } } auto_traits </ins> } fn get_lifetime(region: Region<'_>, names_map: &FxHashMap<Symbol, Lifetime>) -> Lifetime {


}; use crate::clean; <ins> use crate::clean::inline::build_external_trait; </ins> use crate::clean::{AttributesExt, MAX_DEF_IDX}; use crate::config::{Options as RustdocOptions, RenderOptions}; use crate::config::{OutputFormat, RenderInfo};


module_trait_cache: RefCell::new(FxHashMap::default()), cache: Cache::default(), }; <ins> // Small hack to force the Sized trait to be present. // // Note that in case of `#![no_core]`, the trait is not available. if let Some(sized_trait_did) = ctxt.tcx.lang_items().sized_trait() { let mut sized_trait = build_external_trait(&mut ctxt, sized_trait_did); sized_trait.is_auto = true; ctxt.external_traits.borrow_mut().insert(sized_trait_did, sized_trait); } </ins> debug!("crate: {:?}", tcx.hir().krate()); let mut krate = tcx.sess.time("clean_crate", || clean::krate(&mut ctxt));


<ins> #![crate_name = "foo"] // @has foo/struct.Bar.html // @!has - '//h3[@id="impl-Sized"]' pub struct Bar { a: u16, } // @has foo/struct.Foo.html // @!has - '//h3[@id="impl-Sized"]' pub struct Foo<T: ?Sized>(T); // @has foo/struct.Unsized.html // @has - '//h3[@id="impl-Sized"]/code' 'impl !Sized for Unsized' pub struct Unsized { data: [u8], } </ins>


// except according to those terms. // xfail-test <del> fn foo() -> &'a int { </del> <ins> fn foo<'a>() -> &'a int {  //~ ERROR unconstrained region </ins> return &x; } static x: int = 5;


BOOL_OPTIONS="" VAL_OPTIONS="" <del> opt debug 0 "debug mode" </del> <ins> opt debug 0 "debug mode; disables optimization unless `--enable-optimize` given" </ins> opt valgrind 0 "run tests with valgrind (memcheck by default)" opt helgrind 0 "run tests with helgrind instead of memcheck" opt valgrind-rpass 1 "run rpass-valgrind tests with valgrind"


<ins> # `char_error_internals` This feature is internal to the Rust compiler and is not intended for general use. ------------------------ </ins>


use convert::TryFrom; use fmt::{self, Write}; use slice; <del> use str::from_utf8_unchecked_mut; </del> <ins> use str::{from_utf8_unchecked_mut, FromStr}; </ins> use iter::FusedIterator; use mem::transmute;


} } <ins> /// An error which can be returned when parsing a char. #[stable(feature = "char_from_str", since = "1.19.0")] #[derive(Clone, Debug)] pub struct ParseCharError { kind: CharErrorKind, } impl ParseCharError { #[unstable(feature = "char_error_internals", reason = "this method should not be available publicly", issue = "0")] #[doc(hidden)] pub fn __description(&self) -> &str { match self.kind { CharErrorKind::EmptyString => { "cannot parse char from empty string" }, CharErrorKind::TooManyChars => "too many characters in string" } } } #[derive(Copy, Clone, Debug, PartialEq, Eq)] enum CharErrorKind { EmptyString, TooManyChars, } #[stable(feature = "char_from_str", since = "1.19.0")] impl fmt::Display for ParseCharError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.__description().fmt(f) } } #[stable(feature = "char_from_str", since = "1.19.0")] impl FromStr for char { type Err = ParseCharError; #[inline] fn from_str(s: &str) -> Result<Self, Self::Err> { let mut chars = s.chars(); match (chars.next(), chars.next()) { (None, _) => { Err(ParseCharError { kind: CharErrorKind::EmptyString }) }, (Some(c), None) => Ok(c), _ => { Err(ParseCharError { kind: CharErrorKind::TooManyChars }) } } } } </ins> #[unstable(feature = "try_from", issue = "33417")] impl TryFrom<u32> for char { type Error = CharTryFromError;


use std::{char,str}; use std::convert::TryFrom; <ins> use std::str::FromStr; </ins> #[test] fn test_convert() {


} #[test] <ins> fn test_from_str() { assert_eq!(char::from_str("a").unwrap(), 'a'); assert_eq!(char::try_from("a").unwrap(), 'a'); assert_eq!(char::from_str("0").unwrap(), '0'); assert_eq!(char::from_str("u{D7FF}").unwrap(), 'u{d7FF}'); assert!(char::from_str("").is_err()); assert!(char::from_str("abc").is_err()); } #[test] </ins> fn test_is_lowercase() { assert!('a'.is_lowercase()); assert!('ö'.is_lowercase());


} } <ins> #[stable(feature = "char_from_str", since = "1.19.0")] impl Error for char::ParseCharError { fn description(&self) -> &str { self.__description() } } </ins> // copied from any.rs impl Error + 'static { /// Returns true if the boxed type is the same as `T`


#![feature(cfg_target_thread_local)] #![feature(cfg_target_vendor)] #![feature(char_escape_debug)] <ins> #![feature(char_error_internals)] </ins> #![feature(char_internals)] #![feature(collections)] #![feature(collections_range)]


pub use core::char::{MAX, from_digit, from_u32, from_u32_unchecked}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::char::{EscapeDebug, EscapeDefault, EscapeUnicode}; <ins> #[stable(feature = "char_from_str", since = "1.19.0")] pub use core::char::ParseCharError; </ins> // unstable reexports #[unstable(feature = "try_from", issue = "33417")]


use types::os::arch::posix88::{uid_t}; pub type nlink_t = u16; <del> pub type blksize_t = i32; </del> <ins> pub type blksize_t = u32; </ins> pub type blkcnt_t = i64; pub type fflags_t = u32; #[repr(C)]


pub st_lspare: int32_t, pub st_birthtime: time_t, pub st_birthtime_nsec: c_long, <del> pub __unused: [uint8_t; 2], </del> <ins> pub __unused: [u8; 8], </ins> } #[repr(C)]


use types::os::arch::posix88::{uid_t}; pub type nlink_t = u16; <del> pub type blksize_t = i64; </del> <ins> pub type blksize_t = u32; </ins> pub type blkcnt_t = i64; pub type fflags_t = u32; #[repr(C)]


pub st_lspare: int32_t, pub st_birthtime: time_t, pub st_birthtime_nsec: c_long, <del> pub __unused: [uint8_t; 2], </del> } #[repr(C)]