<ins> //@ check-pass //! Tests that associated type projections normalize properly in the presence of HRTBs. //! Original issue: <https://github.com/rust-lang/rust/issues/30472> pub trait MyFrom<T> {} impl<T> MyFrom<T> for T {} pub trait MyInto<T> {} impl<T, U> MyInto<U> for T where U: MyFrom<T> {} pub trait A<'self_> { type T; } pub trait B: for<'self_> A<'self_> { // Originally caused the `type U = usize` example below to fail with a type mismatch error type U: for<'self_> MyFrom<<Self as A<'self_>>::T>; } pub struct M; impl<'self_> A<'self_> for M { type T = usize; } impl B for M { type U = usize; } fn main() {} </ins>


<ins> //@ check-pass //! Tests that a HRTB + FnOnce bound involving an associated type don't prevent //! a function pointer from implementing `Fn` traits. //! Test for <https://github.com/rust-lang/rust/issues/28994> trait LifetimeToType<'a> { type Out; } impl<'a> LifetimeToType<'a> for () { type Out = &'a (); } fn id<'a>(val: &'a ()) -> <() as LifetimeToType<'a>>::Out { val } fn assert_fn<F: for<'a> FnOnce(&'a ()) -> <() as LifetimeToType<'a>>::Out>(_func: F) { } fn main() { assert_fn(id); } </ins>


<ins> //@ check-pass //! Tests that HRTB impl selection covers type parameters not directly related //! to the trait. //! Test for <https://github.com/rust-lang/rust/issues/30867> #![crate_type = "lib"] trait Unary<T> {} impl<T, U, F: Fn(T) -> U> Unary<T> for F {} fn unary<F: for<'a> Unary<&'a T>, T>() {} pub fn test<F: for<'a> Fn(&'a i32) -> &'a i32>() { unary::<F, i32>() } </ins>


// These items live in the type namespace. ItemTy(..) => { <del> let parent_link = ModuleParentLink(parent, name); </del> let def = Def::TyAlias(self.ast_map.local_def_id(item.id)); <del> let module = self.new_module(parent_link, Some(def), false, is_public); self.define(parent, name, TypeNS, (module, sp)); </del> <ins> self.define(parent, name, TypeNS, (def, sp, modifiers)); </ins> parent }


} match def { <del> Def::Mod(_) | Def::ForeignMod(_) | Def::Enum(..) | Def::TyAlias(..) => { </del> <ins> Def::Mod(_) | Def::ForeignMod(_) | Def::Enum(..) => { </ins> debug!("(building reduced graph for external crate) building module {} {}", final_ident, is_public);


let module = self.new_module(parent_link, Some(def), true, is_public); self.try_define(new_parent, name, TypeNS, (module, DUMMY_SP)); } <del> Def::AssociatedTy(..) => { </del> <ins> Def::TyAlias(..) | Def::AssociatedTy(..) => { </ins> debug!("(building reduced graph for external crate) building type {}", final_ident); self.try_define(new_parent, name, TypeNS, (def, DUMMY_SP, modifiers));


target_module: Module<'b>, directive: &'b ImportDirective) -> ResolveResult<()> { <ins> if let Some(Def::Trait(_)) = target_module.def { self.resolver.session.span_err(directive.span, "items in traits are not importable."); } </ins> if module_.def_id() == target_module.def_id() { // This means we are trying to glob import a module into itself, and it is a no-go let msg = "Cannot glob-import a module into itself.".into();


<ins> // Copyright 2016 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. type Alias = (); use Alias::*; //~ ERROR Not a module use std::io::Result::*; //~ ERROR Not a module trait T {} use T::*; //~ ERROR items in traits are not importable fn main() {} </ins>


#[stable(feature = "rust1", since = "1.0.0")] pub trait Drop { /// A method called when the value goes out of scope. <ins> /// /// When this method has been called, `self` has not yet been deallocated. /// If it were, `self` would be a dangling reference. /// /// After this function is over, the memory of `self` will be deallocated. /// /// # Panics /// /// Given that a `panic!` will call `drop()` as it unwinds, any `panic!` in /// a `drop()` implementation will likely abort. </ins> #[stable(feature = "rust1", since = "1.0.0")] fn drop(&mut self); }


/// /// assert!(ecode.success()); /// ``` <ins> /// /// # Note /// /// Take note that there is no implementation of /// [`Drop`](../../core/ops/trait.Drop.html) for child processes, so if you /// do not ensure the `Child` has exited then it will continue to run, even /// after the `Child` handle to the child process has gone out of scope. /// /// Calling `wait` (or other functions that wrap around it) will make the /// parent process wait until the child has actually exited before continuing. </ins> #[stable(feature = "process", since = "1.0.0")] pub struct Child { handle: imp::Process,


use something::Foo; // error: unresolved import `something::Foo`. ``` <del> Please verify you didn't misspell the import name or the import does exist in the module from where you tried to import it. Example: </del> <ins> Paths in `use` statements are relative to the crate root. To import items relative to the current and parent modules, use the `self::` and `super::` prefixes, respectively. Also verify that you didn't misspell the import name and that the import exists in the module from where you tried to import it. Example: </ins> ```ignore <del> use something::Foo; // ok! </del> <ins> use self::something::Foo; // ok! </ins> mod something { pub struct Foo;


``` Or, if you tried to use a module from an external crate, you may have missed <del> the `extern crate` declaration: </del> <ins> the `extern crate` declaration (which is usually placed in the crate root): </ins> ```ignore extern crate homura; // Required to use the `homura` crate


// has anchors for the line numbers that we're linking to. } else if self.item.def_id.is_local() { self.cx.local_sources.get(&PathBuf::from(&self.item.source.filename)).map(|path| { <del> format!("{root}src/{krate}/{path}.html#{href}", </del> <ins> format!("{root}src/{krate}/{path}#{href}", </ins> root = self.cx.root_path, krate = self.cx.layout.krate, path = path,


} } <ins> fn increment_outstanding_references(&mut self, is_public: bool) { self.outstanding_references += 1; if is_public { self.pub_outstanding_references += 1; } } fn decrement_outstanding_references(&mut self, is_public: bool) { let decrement_references = |count: &mut _| { assert!(*count > 0); *count -= 1; }; decrement_references(&mut self.outstanding_references); if is_public { decrement_references(&mut self.pub_outstanding_references); } } </ins> fn report_conflicts<F: FnMut(&NameBinding, &NameBinding)>(&self, mut report: F) { let binding = match self.binding { Some(binding) => binding,


} pub fn increment_outstanding_references_for(&self, name: Name, ns: Namespace, is_public: bool) { <del> let mut resolutions = self.resolutions.borrow_mut(); let resolution = resolutions.entry((name, ns)).or_insert_with(Default::default); resolution.outstanding_references += 1; if is_public { resolution.pub_outstanding_references += 1; } } fn decrement_outstanding_references_for(&self, name: Name, ns: Namespace, is_public: bool) { let decrement_references = |count: &mut _| { assert!(*count > 0); *count -= 1; }; self.update_resolution(name, ns, |resolution| { decrement_references(&mut resolution.outstanding_references); if is_public { decrement_references(&mut resolution.pub_outstanding_references); } }) </del> <ins> self.resolutions.borrow_mut().entry((name, ns)).or_insert_with(Default::default) .increment_outstanding_references(is_public); </ins> } // Use `update` to mutate the resolution for the name.


// Temporarily count the directive as determined so that the resolution fails // (as opposed to being indeterminate) when it can only be defined by the directive. if !determined { <del> module_.decrement_outstanding_references_for(target, ns, directive.is_public) </del> <ins> module_.resolutions.borrow_mut().get_mut(&(target, ns)).unwrap() .decrement_outstanding_references(directive.is_public); </ins> } let result = self.resolver.resolve_name_in_module(target_module, source, ns, false, true);


self.report_conflict(target, ns, &directive.import(binding, None), old_binding); } } <del> module_.decrement_outstanding_references_for(target, ns, directive.is_public); </del> <ins> module_.update_resolution(target, ns, |resolution| { resolution.decrement_outstanding_references(directive.is_public); }) </ins> } match (&value_result, &type_result) {


<ins> // Copyright 2016 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(rustc_attrs)] #![allow(warnings)] mod foo { pub fn bar() {} } pub use foo::*; use b::bar; mod foobar { use super::*; } mod a { pub mod bar {} } mod b { pub use a::bar; } #[rustc_error] fn main() {} //~ ERROR compilation successful </ins>


* * # Safety note * <del> * This function fails if `c` is not a valid char </del> <ins> * This function returns none if `c` is not a valid char </ins> * * # Return value *


///    println!("{}", now.elapsed().as_secs()); /// } /// ``` <ins> /// /// # Underlying System calls /// Currently, the following system calls are being used to get the current time using `now()`: /// /// |  Platform |               System call                                            | /// |:---------:|:--------------------------------------------------------------------:| /// | Cloud ABI | [clock_time_get (Monotonic Clock)]                                   | /// | SGX       | [`insecure_time` usercall]. More information on [timekeeping in SGX] | /// | UNIX      | [clock_time_get (Monotonic Clock)]                                   | /// | Darwin    | [mach_absolute_time]                                                 | /// | VXWorks   | [clock_gettime (Monotonic Clock)]                                    | /// | WASI      | [__wasi_clock_time_get (Monotonic Clock)]                            | /// | Windows   | [QueryPerformanceCounter]                                            | /// /// [QueryPerformanceCounter]: https://docs.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter /// [`insecure_time` usercall]: https://edp.fortanix.com/docs/api/fortanix_sgx_abi/struct.Usercalls.html#method.insecure_time /// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode /// [__wasi_clock_time_get (Monotonic Clock)]: https://github.com/CraneStation/wasmtime/blob/master/docs/WASI-api.md#clock_time_get /// [clock_gettime (Monotonic Clock)]: https://linux.die.net/man/3/clock_gettime /// [mach_absolute_time]: https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/services/services.html /// [clock_time_get (Monotonic Clock)]: https://github.com/NuxiNL/cloudabi/blob/master/cloudabi.txt /// /// **Disclaimer:** These system calls might change over time. /// </ins> #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[stable(feature = "time2", since = "1.8.0")] pub struct Instant(time::Instant);


///    } /// } /// ``` <ins> /// /// # Underlying System calls /// Currently, the following system calls are being used to get the current time using `now()`: /// /// |  Platform |               System call                                            | /// |:---------:|:--------------------------------------------------------------------:| /// | Cloud ABI | [clock_time_get (Realtime Clock)]                                    | /// | SGX       | [`insecure_time` usercall]. More information on [timekeeping in SGX] | /// | UNIX      | [clock_gettime (Realtime Clock)]                                     | /// | DARWIN    | [gettimeofday]                                                       | /// | VXWorks   | [clock_gettime (Realtime Clock)]                                     | /// | WASI      | [__wasi_clock_time_get (Realtime Clock)]                             | /// | Windows   | [GetSystemTimeAsFileTime]                                            | /// /// [clock_time_get (Realtime Clock)]: https://github.com/NuxiNL/cloudabi/blob/master/cloudabi.txt /// [gettimeofday]: http://man7.org/linux/man-pages/man2/gettimeofday.2.html /// [clock_gettime (Realtime Clock)]: https://linux.die.net/man/3/clock_gettime /// [__wasi_clock_time_get (Realtime Clock)]: https://github.com/CraneStation/wasmtime/blob/master/docs/WASI-api.md#clock_time_get /// [GetSystemTimeAsFileTime]: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime /// /// **Disclaimer:** These system calls might change over time. /// </ins> #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[stable(feature = "time2", since = "1.8.0")] pub struct SystemTime(time::SystemTime);


ret }); <del> // Needs to go *after* expansion to be able to check the results // of macro expansion.  This runs before #[cfg] to try to catch as // much as possible (e.g. help the programmer avoid platform // specific differences) time(time_passes, "complete gated feature checking 1", || { sess.track_errors(|| { let features = syntax::feature_gate::check_crate(sess.codemap(), &sess.parse_sess.span_diagnostic, &krate, &attributes, sess.opts.unstable_features); *sess.features.borrow_mut() = features; }) })?; </del> // JBC: make CFG processing part of expansion to avoid this problem: // strip again, in case expansion added anything with a #[cfg].


"checking for inline asm in case the target doesn't support it", || no_asm::check_crate(sess, &krate)); <del> // One final feature gating of the true AST that gets compiled // later, to make sure we've got everything (e.g. configuration // can insert new attributes via `cfg_attr`) time(time_passes, "complete gated feature checking 2", || { </del> <ins> // Needs to go *after* expansion to be able to check the results of macro expansion. time(time_passes, "complete gated feature checking", || { </ins> sess.track_errors(|| { let features = syntax::feature_gate::check_crate(sess.codemap(), &sess.parse_sess.span_diagnostic,


// When we enter a module, record it, for the sake of `module!` pub fn expand_item(it: P<ast::Item>, fld: &mut MacroExpander) -> SmallVector<P<ast::Item>> { <del> let it = expand_item_multi_modifier(Annotatable::Item(it), fld); expand_annotatable(it, fld) </del> <ins> expand_annotatable(Annotatable::Item(it), fld) </ins> .into_iter().map(|i| i.expect_item()).collect() }


<ins> // Copyright 2016 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(rustc_attrs)] macro_rules! mac { {} => { #[cfg(attr)] mod m { #[lang_item] fn f() {} } } } mac! {} #[rustc_error] fn main() {} //~ ERROR compilation successful </ins>


libc::realloc(ptr as *mut libc::c_void, size as libc::size_t) as *mut u8 } else { let new_ptr = allocate(size, align); <del> ptr::copy(ptr, new_ptr, cmp::min(size, old_size)); deallocate(ptr, old_size, align); </del> <ins> if !new_ptr.is_null() { ptr::copy(ptr, new_ptr, cmp::min(size, old_size)); deallocate(ptr, old_size, align); } </ins> new_ptr } }


glob_importers: RefCell<Vec<(Module<'a>, &'a ImportDirective<'a>)>>, globs: RefCell<Vec<&'a ImportDirective<'a>>>, <ins> // Used to memoize the traits in this module for faster searches through all traits in scope. traits: RefCell<Option<Box<[&'a NameBinding<'a>]>>>, </ins> // Whether this module is populated. If not populated, any attempt to // access the children must be preceded with a // `populate_module_if_necessary` call.


prelude: RefCell::new(None), glob_importers: RefCell::new(Vec::new()), globs: RefCell::new((Vec::new())), <ins> traits: RefCell::new(None), </ins> populated: Cell::new(!external), arenas: arenas }


let mut search_module = self.current_module; loop { // Look for trait children. <del> let mut search_in_module = |module: Module<'a>| module.for_each_child(|_, ns, binding| { if ns != TypeNS { return } let trait_def_id = match binding.def() { Some(Def::Trait(trait_def_id)) => trait_def_id, Some(..) | None => return, }; if self.trait_item_map.contains_key(&(name, trait_def_id)) { add_trait_info(&mut found_traits, trait_def_id, name); let trait_name = self.get_trait_name(trait_def_id); self.record_use(trait_name, TypeNS, binding); </del> <ins> let mut search_in_module = |module: Module<'a>| { let mut traits = module.traits.borrow_mut(); if traits.is_none() { let mut collected_traits = Vec::new(); module.for_each_child(|_, ns, binding| { if ns != TypeNS { return } if let Some(Def::Trait(_)) = binding.def() { collected_traits.push(binding); } }); *traits = Some(collected_traits.into_boxed_slice()); </ins> } <del> }); </del> <ins> for binding in traits.as_ref().unwrap().iter() { let trait_def_id = binding.def().unwrap().def_id(); if self.trait_item_map.contains_key(&(name, trait_def_id)) { add_trait_info(&mut found_traits, trait_def_id, name); let trait_name = self.get_trait_name(trait_def_id); self.record_use(trait_name, TypeNS, binding); } } }; </ins> search_in_module(search_module); match search_module.parent_link {


<ins> // Copyright 2016 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.bar; //~ ERROR expected one of `::`, `;`, or `as`, found `.` </ins>


return os.path.join(self.bin_root(), '.cargo-stamp') def rustc_out_of_date(self): <del> if not os.path.exists(self.rustc_stamp()): </del> <ins> if not os.path.exists(self.rustc_stamp()) or self.clean: </ins> return True with open(self.rustc_stamp(), 'r') as f: return self.stage0_rustc_date() != f.read() def cargo_out_of_date(self): <del> if not os.path.exists(self.cargo_stamp()): </del> <ins> if not os.path.exists(self.cargo_stamp()) or self.clean: </ins> return True with open(self.cargo_stamp(), 'r') as f: return self.stage0_cargo_date() != f.read()


return '' def build_bootstrap(self): <ins> build_dir = os.path.join(self.build_dir, "bootstrap") if self.clean and os.path.exists(build_dir): shutil.rmtree(build_dir) </ins> env = os.environ.copy() <del> env["CARGO_TARGET_DIR"] = os.path.join(self.build_dir, "bootstrap") </del> <ins> env["CARGO_TARGET_DIR"] = build_dir </ins> env["RUSTC"] = self.rustc() env["LD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib") env["DYLD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib")


def main(): parser = argparse.ArgumentParser(description='Build rust') parser.add_argument('--config') <ins> parser.add_argument('--clean', action='store_true') </ins> parser.add_argument('-v', '--verbose', action='store_true') args = [a for a in sys.argv if a != '-h']


rb.rust_root = os.path.abspath(os.path.join(__file__, '../../..')) rb.build_dir = os.path.join(os.getcwd(), "build") rb.verbose = args.verbose <ins> rb.clean = args.clean </ins> try: with open(args.config or 'config.toml') as config:


asm!("xor %eax, %eax" : : <del> : "{eax}" </del> <ins> : "eax" </ins> ); # } } ```


# #![feature(asm)] # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] # fn main() { unsafe { <del> asm!("xor %eax, %eax" ::: "{eax}"); </del> <ins> asm!("xor %eax, %eax" ::: "eax"); </ins> # } } ```


# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] # fn main() { unsafe { // Put the value 0x200 in eax <del> asm!("mov $$0x200, %eax" : /* no outputs */ : /* no inputs */ : "{eax}"); </del> <ins> asm!("mov $$0x200, %eax" : /* no outputs */ : /* no inputs */ : "eax"); </ins> # } } ```


if OPTIONS.iter().any(|&opt| s == opt) { cx.span_warn(p.last_span, "expected a clobber, found an option"); <ins> } else if s.starts_with("{") || s.ends_with("}") { cx.span_err(p.last_span, "clobber should not be surrounded by braces"); </ins> } clobs.push(s); } }


<ins> // Copyright 2016 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-android // ignore-arm // ignore-aarch64 #![feature(asm, rustc_attrs)] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] #[rustc_error] pub fn main() { unsafe { // clobber formatted as register input/output asm!("xor %eax, %eax" : : : "{eax}"); //~^ ERROR clobber should not be surrounded by braces } } </ins>


use rustc_infer::infer; use rustc_infer::traits::{self, StatementAsExpression}; use rustc_middle::lint::in_external_macro; <del> use rustc_middle::ty::{self, Binder, DefIdTree, IsSuggestable, Ty}; </del> <ins> use rustc_middle::ty::{ self, suggest_constraining_type_params, Binder, DefIdTree, IsSuggestable, ToPredicate, Ty, }; </ins> use rustc_session::errors::ExprParenthesesNeeded; use rustc_span::symbol::sym; use rustc_span::Span;


&& !results.expr_adjustments(callee_expr).iter().any(|adj| matches!(adj.kind, ty::adjustment::Adjust::Deref(..))) // Check that we're in fact trying to clone into the expected type && self.can_coerce(*pointee_ty, expected_ty) <ins> && let trait_ref = ty::Binder::dummy(self.tcx.mk_trait_ref(clone_trait_did, [expected_ty])) </ins> // And the expected type doesn't implement `Clone` && !self.predicate_must_hold_considering_regions(&traits::Obligation::new( self.tcx, traits::ObligationCause::dummy(), self.param_env, <del> ty::Binder::dummy(self.tcx.mk_trait_ref( clone_trait_did, [expected_ty], )), </del> <ins> trait_ref, </ins> )) { diag.span_note(


"`{expected_ty}` does not implement `Clone`, so `{found_ty}` was cloned instead" ), ); <ins> let owner = self.tcx.hir().enclosing_body_owner(expr.hir_id); if let ty::Param(param) = expected_ty.kind() && let Some(generics) = self.tcx.hir().get_generics(owner) { suggest_constraining_type_params( self.tcx, generics, diag, vec![(param.name.as_str(), "Clone", Some(clone_trait_did))].into_iter(), ); } else { self.suggest_derive(diag, &[(trait_ref.to_predicate(self.tcx), None, None)]); } </ins> } }


self.suggest_derive(err, &preds); } <del> fn suggest_derive( </del> <ins> pub fn suggest_derive( </ins> &self, err: &mut Diagnostic, unsatisfied_predicates: &[(


<ins> // run-rustfix fn wat<T: Clone>(t: &T) -> T { t.clone() //~ ERROR E0308 } #[derive(Clone)] struct Foo; fn wut(t: &Foo) -> Foo { t.clone() //~ ERROR E0308 } fn main() { wat(&42); wut(&Foo); } </ins>


<ins> // run-rustfix fn wat<T>(t: &T) -> T { t.clone() //~ ERROR E0308 } struct Foo; fn wut(t: &Foo) -> Foo { t.clone() //~ ERROR E0308 } fn main() { wat(&42); wut(&Foo); } </ins>


<ins> error[E0308]: mismatched types --> $DIR/clone-on-unconstrained-borrowed-type-param.rs:3:5 | LL | fn wat<T>(t: &T) -> T { |        -            - expected `T` because of return type |        | |        this type parameter LL |     t.clone() |     ^^^^^^^^^ expected type parameter `T`, found `&T` | = note: expected type parameter `T` found reference `&T` note: `T` does not implement `Clone`, so `&T` was cloned instead --> $DIR/clone-on-unconstrained-borrowed-type-param.rs:3:5 | LL |     t.clone() |     ^ help: consider restricting type parameter `T` | LL | fn wat<T: Clone>(t: &T) -> T { |         +++++++ error[E0308]: mismatched types --> $DIR/clone-on-unconstrained-borrowed-type-param.rs:9:5 | LL | fn wut(t: &Foo) -> Foo { |                    --- expected `Foo` because of return type LL |     t.clone() |     ^^^^^^^^^ expected struct `Foo`, found `&Foo` | note: `Foo` does not implement `Clone`, so `&Foo` was cloned instead --> $DIR/clone-on-unconstrained-borrowed-type-param.rs:9:5 | LL |     t.clone() |     ^ help: consider annotating `Foo` with `#[derive(Clone)]` | LL | #[derive(Clone)] | error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. </ins>


| LL |     nc.clone() |     ^^ <ins> help: consider annotating `NotClone` with `#[derive(Clone)]` | LL | #[derive(Clone)] | </ins> error: aborting due to previous error


//!    in this case, if one uses the format string `{<arg>:<spec>.*}`, then the `<arg>` part refers //!    to the *value* to print, and the `precision` must come in the input preceding `<arg>`. //! <del> //! For example, these: </del> <ins> //! For example, the following calls all print the same thing `Hello x is 0.01000`: </ins> //! //! ``` <del> //! // Hello {arg 0 (x)} is {arg 1 (0.01) with precision specified inline (5)} </del> <ins> //! // Hello {arg 0 ("x")} is {arg 1 (0.01) with precision specified inline (5)} </ins> //! println!("Hello {0} is {1:.5}", "x", 0.01); //! <del> //! // Hello {arg 1 (x)} is {arg 2 (0.01) with precision specified in arg 0 (5)} </del> <ins> //! // Hello {arg 1 ("x")} is {arg 2 (0.01) with precision specified in arg 0 (5)} </ins> //! println!("Hello {1} is {2:.0$}", 5, "x", 0.01); //! <del> //! // Hello {arg 0 (x)} is {arg 2 (0.01) with precision specified in arg 1 (5)} </del> <ins> //! // Hello {arg 0 ("x")} is {arg 2 (0.01) with precision specified in arg 1 (5)} </ins> //! println!("Hello {0} is {2:.1$}", "x", 5, 0.01); //! <del> //! // Hello {next arg (x)} is {second of next two args (0.01) with precision </del> <ins> //! // Hello {next arg ("x")} is {second of next two args (0.01) with precision </ins> //! //                          specified in first of next two args (5)} //! println!("Hello {} is {:.*}",    "x", 5, 0.01); //! <del> //! // Hello {next arg (x)} is {arg 2 (0.01) with precision </del> <ins> //! // Hello {next arg ("x")} is {arg 2 (0.01) with precision </ins> //! //                          specified in its predecessor (5)} //! println!("Hello {} is {2:.*}",   "x", 5, 0.01); //! <del> //! // Hello {next arg (x)} is {arg "number" (0.01) with precision specified </del> <ins> //! // Hello {next arg ("x")} is {arg "number" (0.01) with precision specified </ins> //! //                          in arg "prec" (5)} //! println!("Hello {} is {number:.prec$}", "x", prec = 5, number = 0.01); //! ``` //! <del> //! All print the same thing: //! //! ```text //! Hello x is 0.01000 //! ``` //! </del> //! While these: //! //! ```


/// ``` #[stable(feature = "move_cell", since = "1.17.0")] pub fn into_inner(self) -> T { <del> unsafe { self.value.into_inner() } </del> <ins> self.value.into_inner() </ins> } }


// compiler statically verifies that it is not currently borrowed. // Therefore the following assertion is just a `debug_assert!`. debug_assert!(self.borrow.get() == UNUSED); <del> unsafe { self.value.into_inner() } </del> <ins> self.value.into_inner() </ins> } /// Replaces the wrapped value with a new one, returning the old value,


/// Unwraps the value. /// <del> /// # Safety /// /// This function is unsafe because this thread or another thread may currently be /// inspecting the inner value. /// </del> /// # Examples /// /// ```


/// /// let uc = UnsafeCell::new(5); /// <del> /// let five = unsafe { uc.into_inner() }; </del> <ins> /// let five = uc.into_inner(); </ins> /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] <del> pub unsafe fn into_inner(self) -> T { </del> <ins> pub fn into_inner(self) -> T { </ins> self.value } }


#[inline] #[stable(feature = "atomic_access", since = "1.15.0")] pub fn into_inner(self) -> bool { <del> unsafe { self.v.into_inner() != 0 } </del> <ins> self.v.into_inner() != 0 </ins> } /// Loads a value from the bool.


#[inline] #[stable(feature = "atomic_access", since = "1.15.0")] pub fn into_inner(self) -> *mut T { <del> unsafe { self.p.into_inner() } </del> <ins> self.p.into_inner() </ins> } /// Loads a value from the pointer.


#[inline] #[$stable_access] pub fn into_inner(self) -> $int_type { <del> unsafe { self.v.into_inner() } </del> <ins> self.v.into_inner() </ins> } /// Loads a value from the atomic integer.


let &(ref first_arm_pats, _) = &arms[0]; let first_pat = &first_arm_pats[0]; let span = first_pat.span; <del> span_err!(cx.tcx.sess, span, E0165, "irrefutable while-let pattern"); </del> <ins> struct_span_err!(cx.tcx.sess, span, E0165, "irrefutable while-let pattern") .span_label(span, &format!("irrefutable pattern")) .emit(); </ins> }, hir::MatchSource::ForLoopDesugar => {


tcx.sess.add_lint(lint::builtin::MATCH_OF_UNIT_VARIANT_VIA_PAREN_DOTDOT, pat.id, pat.span, msg); } else { <del> span_err!(tcx.sess, pat.span, E0164, "{}", msg); </del> <ins> struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg) .span_label(pat.span, &format!("not a tuple variant or struct")).emit(); </ins> on_error(); } };


.emit(); } Err(CopyImplementationError::HasDestructor) => { <del> span_err!(tcx.sess, span, E0184, </del> <ins> struct_span_err!(tcx.sess, span, E0184, </ins> "the trait `Copy` may not be implemented for this type;  <del> the type has a destructor"); </del> <ins> the type has a destructor") .span_label(span, &format!("Copy not allowed on types with destructors")) .emit(); </ins> } } });


fn bar(foo: Foo) -> u32 { match foo { Foo::B(i) => i, //~ ERROR E0164 <ins> //~| NOTE not a tuple variant or struct </ins> } }


fn main() { let irr = Irrefutable(0); while let Irrefutable(x) = irr { //~ ERROR E0165 <ins> //~| irrefutable pattern </ins> // ... } }


// except according to those terms. #[derive(Copy)] //~ ERROR E0184 <ins> //~| NOTE Copy not allowed on types with destructors //~| NOTE in this expansion of #[derive(Copy)] </ins> struct Foo; impl Drop for Foo {


let lifetime_j = &lifetimes[j]; if lifetime_i.lifetime.name == lifetime_j.lifetime.name { <del> span_err!(self.sess, lifetime_j.lifetime.span, E0263, "lifetime name `{}` declared twice in  the same scope", lifetime_j.lifetime.name); </del> <ins> struct_span_err!(self.sess, lifetime_j.lifetime.span, E0263, "lifetime name `{}` declared twice in the same scope", lifetime_j.lifetime.name) .span_label(lifetime_j.lifetime.span, &format!("declared twice")) .span_label(lifetime_i.lifetime.span, &format!("previous declaration here")) .emit(); </ins> } }


// option. This file may not be copied, modified, or distributed // except according to those terms. <del> fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) { } //~ ERROR E0263 </del> <ins> fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) { //~^ ERROR E0263 //~| NOTE declared twice //~| NOTE previous declaration here } </ins> fn main() {}


"tempfile", "thorin-dwp", "tracing", <ins> "windows 0.46.0", </ins> ] [[package]]


version = "0.30.1" default-features = false features = ["read_core", "elf", "macho", "pe", "unaligned", "archive", "write"] <ins> [target.'cfg(windows)'.dependencies.windows] version = "0.46.0" features = ["Win32_Globalization"] </ins>


if !prog.status.success() { let mut output = prog.stderr.clone(); output.extend_from_slice(&prog.stdout); <del> let escaped_output = escape_string(&output); </del> <ins> let escaped_output = escape_linker_output(&output, flavor); </ins> // FIXME: Add UI tests for this error. let err = errors::LinkingFailed { linker_path: &linker_path,


} } <ins> #[cfg(not(windows))] fn escape_linker_output(s: &[u8], _flavour: LinkerFlavor) -> String { escape_string(s) } /// If the output of the msvc linker is not UTF-8 and the host is Windows, /// then try to convert the string from the OEM encoding. #[cfg(windows)] fn escape_linker_output(s: &[u8], flavour: LinkerFlavor) -> String { // This only applies to the actual MSVC linker. if flavour != LinkerFlavor::Msvc(Lld::No) { return escape_string(s); } match str::from_utf8(s) { Ok(s) => return s.to_owned(), Err(_) => match win::locale_byte_str_to_string(s, win::oem_code_page()) { Some(s) => s, // The string is not UTF-8 and isn't valid for the OEM code page None => format!("Non-UTF-8 output: {}", s.escape_ascii()), }, } } /// Wrappers around the Windows API. #[cfg(windows)] mod win { use windows::Win32::Globalization::{ GetLocaleInfoEx, MultiByteToWideChar, CP_OEMCP, LOCALE_IUSEUTF8LEGACYOEMCP, LOCALE_NAME_SYSTEM_DEFAULT, LOCALE_RETURN_NUMBER, MB_ERR_INVALID_CHARS, }; /// Get the Windows system OEM code page. This is most notably the code page /// used for link.exe's output. pub fn oem_code_page() -> u32 { unsafe { let mut cp: u32 = 0; // We're using the `LOCALE_RETURN_NUMBER` flag to return a u32. // But the API requires us to pass the data as though it's a [u16] string. let len = std::mem::size_of::<u32>() / std::mem::size_of::<u16>(); let data = std::slice::from_raw_parts_mut(&mut cp as *mut u32 as *mut u16, len); let len_written = GetLocaleInfoEx( LOCALE_NAME_SYSTEM_DEFAULT, LOCALE_IUSEUTF8LEGACYOEMCP | LOCALE_RETURN_NUMBER, Some(data), ); if len_written as usize == len { cp } else { CP_OEMCP } } } /// Try to convert a multi-byte string to a UTF-8 string using the given code page /// The string does not need to be null terminated. /// /// This is implemented as a wrapper around `MultiByteToWideChar`. /// See <https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar> /// /// It will fail if the multi-byte string is longer than `i32::MAX` or if it contains /// any invalid bytes for the expected encoding. pub fn locale_byte_str_to_string(s: &[u8], code_page: u32) -> Option<String> { // `MultiByteToWideChar` requires a length to be a "positive integer". if s.len() > isize::MAX as usize { return None; } // Error if the string is not valid for the expected code page. let flags = MB_ERR_INVALID_CHARS; // Call MultiByteToWideChar twice. // First to calculate the length then to convert the string. let mut len = unsafe { MultiByteToWideChar(code_page, flags, s, None) }; if len > 0 { let mut utf16 = vec![0; len as usize]; len = unsafe { MultiByteToWideChar(code_page, flags, s, Some(&mut utf16)) }; if len > 0 { return utf16.get(..len as usize).map(String::from_utf16_lossy); } } None } } </ins> fn add_sanitizer_libraries(sess: &Session, crate_type: CrateType, linker: &mut dyn Linker) { // On macOS the runtimes are distributed as dylibs which should be linked to // both executables and dynamic shared objects. Everywhere else the runtimes


<ins> // build-fail // compile-flags:-C link-arg=märchenhaft // only-msvc // error-pattern:= note: LINK : fatal error LNK1181: // normalize-stderr-test "(s*|n)s*= note: .*n" -> "$1" pub fn main() {} </ins>


<ins> error: linking with `link.exe` failed: exit code: 1181 | = note: LINK : fatal error LNK1181: cannot open input file 'märchenhaft.obj' error: aborting due to previous error </ins>


linker_error.emit(); if sess.target.target.options.is_like_msvc && linker_not_found { <del> sess.note_without_error("the msvc targets depend on the msvc linker  but `link.exe` was not found"); sess.note_without_error("please ensure that VS 2013, VS 2015 or VS 2017  was installed with the Visual C++ option"); </del> <ins> sess.note_without_error( "the msvc targets depend on the msvc linker  but `link.exe` was not found", ); sess.note_without_error( "please ensure that VS 2013, VS 2015, VS 2017 or VS 2019  was installed with the Visual C++ option", ); </ins> } sess.abort_if_errors(); }


target_family: Some("windows".to_string()), is_like_windows: true, is_like_msvc: true, <ins> // set VSLANG to 1033 can prevent link.exe from using // language packs, and avoid generating Non-UTF-8 error // messages if a link error occurred. link_env: vec![("VSLANG".to_string(), "1033".to_string())], </ins> pre_link_args: args, crt_static_allows_dylibs: true, crt_static_respected: true,


<ins> // check-pass #![feature(coerce_unsized, unsize)] use std::marker::Unsize; use std::ops::CoerceUnsized; struct Foo<T: ?Sized>(Box<T>); impl<T> CoerceUnsized<Foo<dyn Baz>> for Foo<T> where T: Unsize<dyn Baz> {} struct Bar; trait Baz {} impl Baz for Bar {} fn main() { let foo = Foo(Box::new(Bar)); let foobar: Foo<Bar> = foo; } </ins>


impl<'a> CheckAttrVisitor<'a> { fn check_inline(&self, attr: &ast::Attribute, target: Target) { if target != Target::Fn { <del> span_err!(self.sess, attr.span, E0518, "attribute should be applied to function"); </del> <ins> struct_span_err!(self.sess, attr.span, E0518, "attribute should be applied to function") .span_label(attr.span, &format!("requires a function")) .emit(); </ins> } }


let mut conflicting_reprs = 0; for word in words { let name = match word.name() { Some(word) => word, None => continue, }; <del> let message = match &*name { </del> <ins> let (message, label) = match &*name { </ins> "C" => { conflicting_reprs += 1; if target != Target::Struct && target != Target::Union && target != Target::Enum { <del> "attribute should be applied to struct, enum or union" </del> <ins> ("attribute should be applied to struct, enum or union", "a struct, enum or union") </ins> } else { continue }


// can be used to modify another repr hint if target != Target::Struct && target != Target::Union { <del> "attribute should be applied to struct or union" </del> <ins> ("attribute should be applied to struct or union", "a struct or union") </ins> } else { continue }


"simd" => { conflicting_reprs += 1; if target != Target::Struct { <del> "attribute should be applied to struct" </del> <ins> ("attribute should be applied to struct", "a struct") </ins> } else { continue }


"isize" | "usize" => { conflicting_reprs += 1; if target != Target::Enum { <del> "attribute should be applied to enum" </del> <ins> ("attribute should be applied to enum", "an enum") </ins> } else { continue } } _ => continue, }; <del> span_err!(self.sess, attr.span, E0517, "{}", message); </del> <ins> struct_span_err!(self.sess, attr.span, E0517, "{}", message) .span_label(attr.span, &format!("requires {}", label)) .emit(); </ins> } if conflicting_reprs > 1 { span_warn!(self.sess, attr.span, E0566,


} } hir::TyTypeof(ref _e) => { <del> span_err!(tcx.sess, ast_ty.span, E0516, "`typeof` is a reserved keyword but unimplemented"); </del> <ins> struct_span_err!(tcx.sess, ast_ty.span, E0516, "`typeof` is a reserved keyword but unimplemented") .span_label(ast_ty.span, &format!("reserved keyword")) .emit(); </ins> tcx.types.err } hir::TyInfer => {


fn main() { let x: typeof(92) = 92; //~ ERROR E0516 <ins> //~| reserved keyword </ins> }


// except according to those terms. #[repr(C)] //~ ERROR E0517 <ins> //~| requires a struct, enum or union </ins> type Foo = u8; #[repr(packed)] //~ ERROR E0517 <ins> //~| requires a struct </ins> enum Foo2 {Bar, Baz} #[repr(u8)] //~ ERROR E0517 <ins> //~| requires an enum </ins> struct Foo3 {bar: bool, baz: bool} #[repr(C)] //~ ERROR E0517 <ins> //~| requires a struct, enum or union </ins> impl Foo3 { }


// except according to those terms. #[inline(always)] //~ ERROR E0518 <ins> //~| requires a function </ins> struct Foo; #[inline(never)] //~ ERROR E0518 <ins> //~| requires a function </ins> impl Foo { }


// If the resolution doesn't depend on glob definability, check privacy and return. if let Some(result) = self.try_result(&resolution, ns) { return result.and_then(|binding| { <del> if self.is_accessible(binding.vis) && !is_disallowed_private_import(binding) { </del> <ins> if self.is_accessible(binding.vis) && !is_disallowed_private_import(binding) || binding.is_extern_crate() { // c.f. issue #37020 </ins> Success(binding) } else { Failed(None)


<ins> // Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![allow(private_in_public)] mod foo { pub mod bar { extern crate core; } } mod baz { pub use foo::bar::core; } fn main() { baz::core::cell::Cell::new(0u32); } </ins>


let bindir_default = PathBuf::from("bin"); let libdir_default = PathBuf::from("lib"); let mandir_default = datadir_default.join("man"); <del> let prefix = build.config.prefix.as_ref().unwrap_or(&prefix_default); </del> <ins> let prefix = build.config.prefix.as_ref().map_or(prefix_default, |p| { fs::canonicalize(p).expect(&format!("could not canonicalize {}", p.display())) }); </ins> let sysconfdir = build.config.sysconfdir.as_ref().unwrap_or(&sysconfdir_default); let datadir = build.config.datadir.as_ref().unwrap_or(&datadir_default); let docdir = build.config.docdir.as_ref().unwrap_or(&docdir_default);


) fn mk_ident_interner() -> @ident_interner { <del> /* the indices here must correspond to the numbers in special_idents */ let init_vec = ~[@~"_", @~"anon", @~"drop", @~"", @~"unary", @~"!", @~"[]", @~"unary-", @~"__extensions__", @~"self", @~"item", @~"block", @~"stmt", @~"pat", @~"expr", @~"ty", @~"ident", @~"path", @~"tt", @~"matchers", @~"str", @~"TyVisitor", @~"arg", @~"descrim", @~"__rust_abi", @~"__rust_stack_shim", @~"TyDesc", @~"dtor", @~"main", @~"<opaque>", @~"blk", @~"static", @~"intrinsic", @~"__foreign_mod__"]; let rv = @ident_interner { interner: interner::mk_prefill::<@~str>(init_vec) }; /* having multiple interners will just confuse the serializer */ </del> unsafe { <del> assert task::local_data::local_data_get(interner_key!()).is_none() }; unsafe { task::local_data::local_data_set(interner_key!(), @rv) }; rv </del> <ins> match task::local_data::local_data_get(interner_key!()) { Some(interner) => *interner, None => { // the indices here must correspond to the numbers in // special_idents. let init_vec = ~[ @~"_", @~"anon", @~"drop", @~"", @~"unary", @~"!", @~"[]", @~"unary-", @~"__extensions__", @~"self", @~"item", @~"block", @~"stmt", @~"pat", @~"expr", @~"ty", @~"ident", @~"path", @~"tt", @~"matchers", @~"str", @~"TyVisitor", @~"arg", @~"descrim", @~"__rust_abi", @~"__rust_stack_shim", @~"TyDesc", @~"dtor", @~"main", @~"<opaque>", @~"blk", @~"static", @~"intrinsic", @~"__foreign_mod__" ]; let rv = @ident_interner { interner: interner::mk_prefill(init_vec) }; task::local_data::local_data_set(interner_key!(), @rv); rv } } } </ins> } /* for when we don't care about the contents; doesn't interact with TLD or


pub llvm_version_check: bool, pub llvm_static_stdcpp: bool, pub llvm_link_shared: bool, <ins> pub llvm_targets: Option<String>, </ins> // rust codegen options pub rust_optimize: bool,


release_debuginfo: Option<bool>, version_check: Option<bool>, static_libstdcpp: Option<bool>, <ins> targets: Option<String>, </ins> } #[derive(RustcDecodable)]


set(&mut config.llvm_release_debuginfo, llvm.release_debuginfo); set(&mut config.llvm_version_check, llvm.version_check); set(&mut config.llvm_static_stdcpp, llvm.static_libstdcpp); <ins> config.llvm_targets = llvm.targets.clone(); </ins> } if let Some(ref rust) = toml.rust {


# example. #ninja = false <ins> # LLVM targets to build support for. # Note: this is NOT related to Rust compilation targets. However, as Rust is # dependent on LLVM for code generation, turning targets off here WILL lead to # the resulting rustc being unable to compile for the disabled architectures. # Also worth pointing out is that, in case support for new targets are added to # LLVM, enabling them here doesn't mean Rust is automatically gaining said # support. You'll need to write a target specification at least, and most # likely, teach rustc about the C ABI of the target. Get in touch with the # Rust team and file an issue if you need assistance in porting! #targets = "X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc" </ins> # ============================================================================= # General build configuration options # =============================================================================


(true, true) => "RelWithDebInfo", }; <ins> // NOTE: remember to also update `config.toml.example` when changing the defaults! let llvm_targets = match build.config.llvm_targets { Some(ref s) => s, None => "X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc", }; </ins> cfg.target(target) .host(&build.config.build) .out_dir(&dst) .profile(profile) .define("LLVM_ENABLE_ASSERTIONS", assertions) <del> .define("LLVM_TARGETS_TO_BUILD", "X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc") </del> <ins> .define("LLVM_TARGETS_TO_BUILD", llvm_targets) </ins> .define("LLVM_INCLUDE_EXAMPLES", "OFF") .define("LLVM_INCLUDE_TESTS", "OFF") .define("LLVM_INCLUDE_DOCS", "OFF")


} } <del> #[derive(Copy, Clone)] </del> <ins> #[derive(Copy, Clone, PartialEq)] </ins> enum PathScope { Global, Lexical,


// // Such behavior is required for backward compatibility. // The same fallback is used when `a` resolves to nothing. <del> _ if self.primitive_type_table.primitive_types.contains_key(&path[0].name) => { </del> <ins> PathResult::Module(..) | PathResult::Failed(..) if scope == PathScope::Lexical && (ns == TypeNS || path.len() > 1) && self.primitive_type_table.primitive_types.contains_key(&path[0].name) => { </ins> PathResolution { base_def: Def::PrimTy(self.primitive_type_table.primitive_types[&path[0].name]), depth: segments.len() - 1,


<ins> // Copyright 2016 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 main() { // Make sure primitive type fallback doesn't work in value namespace std::mem::size_of(u16); //~^ ERROR unresolved name `u16` //~| ERROR this function takes 0 parameters but 1 parameter was supplied // Make sure primitive type fallback doesn't work with global paths let _: ::u8; //~^ ERROR type name `u8` is undefined or not in scope } </ins>


} contents.truncate(0); <del> t!(t!(File::open(file)).read_to_string(&mut contents)); </del> <ins> t!(t!(File::open(&file), &file).read_to_string(&mut contents)); </ins> for (i, line) in contents.lines().enumerate() { let mut err = |msg: &str| {


pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15; pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001; <ins> pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002; </ins> pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000; pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000; pub const PIPE_WAIT: DWORD = 0x00000000;


inner: Handle, } <del> pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> { </del> <ins> pub struct Pipes { pub ours: AnonPipe, pub theirs: AnonPipe, } /// Although this looks similar to `anon_pipe` in the Unix module it's actually /// subtly different. Here we'll return two pipes in the `Pipes` return value, /// but one is intended for "us" where as the other is intended for "someone /// else". /// /// Currently the only use case for this function is pipes for stdio on /// processes in the standard library, so "ours" is the one that'll stay in our /// process whereas "theirs" will be inherited to a child. /// /// The ours/theirs pipes are *not* specifically readable or writable. Each /// one only supports a read or a write, but which is which depends on the /// boolean flag given. If `ours_readable` is true then `ours` is readable where /// `theirs` is writable. Conversely if `ours_readable` is false then `ours` is /// writable where `theirs` is readable. /// /// Also note that the `ours` pipe is always a handle opened up in overlapped /// mode. This means that technically speaking it should only ever be used /// with `OVERLAPPED` instances, but also works out ok if it's only ever used /// once at a time (which we do indeed guarantee). pub fn anon_pipe(ours_readable: bool) -> io::Result<Pipes> { </ins> // Note that we specifically do *not* use `CreatePipe` here because // unfortunately the anonymous pipes returned do not support overlapped <del> // operations. // // Instead, we create a "hopefully unique" name and create a named pipe // which has overlapped operations enabled. </del> <ins> // operations. Instead, we create a "hopefully unique" name and create a // named pipe which has overlapped operations enabled. </ins> // <del> // Once we do this, we connect do it as usual via `CreateFileW`, and then we // return those reader/writer halves. </del> <ins> // Once we do this, we connect do it as usual via `CreateFileW`, and then // we return those reader/writer halves. Note that the `ours` pipe return // value is always the named pipe, whereas `theirs` is just the normal file. // This should hopefully shield us from child processes which assume their // stdout is a named pipe, which would indeed be odd! </ins> unsafe { <del> let reader; </del> <ins> let ours; </ins> let mut name; let mut tries = 0; let mut reject_remote_clients_flag = c::PIPE_REJECT_REMOTE_CLIENTS;


.encode_wide() .chain(Some(0)) .collect::<Vec<_>>(); <ins> let mut flags = c::FILE_FLAG_FIRST_PIPE_INSTANCE | c::FILE_FLAG_OVERLAPPED; if ours_readable { flags |= c::PIPE_ACCESS_INBOUND; } else { flags |= c::PIPE_ACCESS_OUTBOUND; } </ins> let handle = c::CreateNamedPipeW(wide_name.as_ptr(), <del> c::PIPE_ACCESS_INBOUND | c::FILE_FLAG_FIRST_PIPE_INSTANCE | c::FILE_FLAG_OVERLAPPED, </del> <ins> flags, </ins> c::PIPE_TYPE_BYTE | c::PIPE_READMODE_BYTE | c::PIPE_WAIT |


} return Err(err) } <del> reader = Handle::new(handle); </del> <ins> ours = Handle::new(handle); </ins> break } <del> // Connect to the named pipe we just created in write-only mode (also // overlapped for async I/O below). </del> <ins> // Connect to the named pipe we just created. This handle is going to be // returned in `theirs`, so if `ours` is readable we want this to be // writable, otherwise if `ours` is writable we want this to be // readable. // // Additionally we don't enable overlapped mode on this because most // client processes aren't enabled to work with that. </ins> let mut opts = OpenOptions::new(); <del> opts.write(true); opts.read(false); </del> <ins> opts.write(ours_readable); opts.read(!ours_readable); </ins> opts.share_mode(0); <del> opts.attributes(c::FILE_FLAG_OVERLAPPED); let writer = File::open(Path::new(&name), &opts)?; let writer = AnonPipe { inner: writer.into_handle() }; </del> <ins> let theirs = File::open(Path::new(&name), &opts)?; let theirs = AnonPipe { inner: theirs.into_handle() }; </ins> <del> Ok((AnonPipe { inner: reader }, AnonPipe { inner: writer.into_handle() })) </del> <ins> Ok(Pipes { ours: AnonPipe { inner: ours }, theirs: AnonPipe { inner: theirs.into_handle() }, }) </ins> } }


} Stdio::MakePipe => { <del> let (reader, writer) = pipe::anon_pipe()?; let (ours, theirs) = if stdio_id == c::STD_INPUT_HANDLE { (writer, reader) } else { (reader, writer) }; *pipe = Some(ours); </del> <ins> let ours_readable = stdio_id != c::STD_INPUT_HANDLE; let pipes = pipe::anon_pipe(ours_readable)?; *pipe = Some(pipes.ours); </ins> cvt(unsafe { <del> c::SetHandleInformation(theirs.handle().raw(), </del> <ins> c::SetHandleInformation(pipes.theirs.handle().raw(), </ins> c::HANDLE_FLAG_INHERIT, c::HANDLE_FLAG_INHERIT) })?; <del> Ok(theirs.into_handle()) </del> <ins> Ok(pipes.theirs.into_handle()) </ins> } Stdio::Handle(ref handle) => {


<ins> // Copyright 2017 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::env; use std::io::prelude::*; use std::process::Command; use std::thread; const THREADS: usize = 20; const WRITES: usize = 100; const WRITE_SIZE: usize = 1024 * 32; fn main() { let args = env::args().collect::<Vec<_>>(); if args.len() == 1 { parent(); } else { child(); } } fn parent() { let me = env::current_exe().unwrap(); let mut cmd = Command::new(me); cmd.arg("run-the-test"); let output = cmd.output().unwrap(); assert!(output.status.success()); assert_eq!(output.stderr.len(), 0); assert_eq!(output.stdout.len(), WRITES * THREADS * WRITE_SIZE); for byte in output.stdout.iter() { assert_eq!(*byte, b'a'); } } fn child() { let threads = (0..THREADS).map(|_| { thread::spawn(|| { let buf = [b'a'; WRITE_SIZE]; for _ in 0..WRITES { write_all(&buf); } }) }).collect::<Vec<_>>(); for thread in threads { thread.join().unwrap(); } } #[cfg(unix)] fn write_all(buf: &[u8]) { use std::fs::File; use std::mem; use std::os::unix::prelude::*; let mut file = unsafe { File::from_raw_fd(1) }; let res = file.write_all(buf); mem::forget(file); res.unwrap(); } #[cfg(windows)] fn write_all(buf: &[u8]) { use std::fs::File; use std::mem; use std::os::windows::raw::*; use std::os::windows::prelude::*; const STD_OUTPUT_HANDLE: u32 = (-11i32) as u32; extern "system" { fn GetStdHandle(handle: u32) -> HANDLE; } let mut file = unsafe { let handle = GetStdHandle(STD_OUTPUT_HANDLE); assert!(!handle.is_null()); File::from_raw_handle(handle) }; let res = file.write_all(buf); mem::forget(file); res.unwrap(); } </ins>


<ins> // check-pass use std::borrow::Borrow; trait TNode: Sized { type ConcreteElement: TElement<ConcreteNode = Self>; } trait TElement: Sized { type ConcreteNode: TNode<ConcreteElement = Self>; } trait DomTraversal<N: TNode> { type BorrowElement: Borrow<N::ConcreteElement>; } #[allow(dead_code)] fn recalc_style_at<E, D>() where E: TElement, D: DomTraversal<E::ConcreteNode>, { } fn main() {} </ins>


<ins> // check-pass pub trait Test { type Item; type Bundle: From<Self::Item>; } fn fails<T>() where T: Test<Item = String>, { } fn main() {} </ins>


<ins> // check-pass trait Foo { type FooT: Foo; } impl Foo for () { type FooT = (); } trait Bar<T: Foo> { type BarT: Bar<T::FooT>; } impl Bar<()> for () { type BarT = (); } #[allow(dead_code)] fn test<C: Bar<()>>() { } fn main() { } </ins>


<ins> // check-pass #![feature(associated_type_bounds)] #![feature(type_alias_impl_trait)] fn main() {} trait Bar { type Assoc; } trait Thing { type Out; fn func() -> Self::Out; } struct AssocIsCopy; impl Bar for AssocIsCopy { type Assoc = u8; } impl Thing for AssocIsCopy { type Out = impl Bar<Assoc: Copy>; fn func() -> Self::Out { AssocIsCopy } } </ins>


# Next, download the NetBSD libc and relevant header files mkdir netbsd <del> curl https://ftp.netbsd.org/pub/NetBSD/NetBSD-7.0/amd64/binary/sets/base.tgz |  </del> <ins> # originally from: # https://ftp.netbsd.org/pub/NetBSD/NetBSD-7.0/amd64/binary/sets/base.tgz curl https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-01-16-netbsd-base.tgz |  </ins> tar xzf - -C netbsd ./usr/include ./usr/lib ./lib <del> curl https://ftp.netbsd.org/pub/NetBSD/NetBSD-7.0/amd64/binary/sets/comp.tgz |  </del> <ins> # originally from: # https://ftp.netbsd.org/pub/NetBSD/NetBSD-7.0/amd64/binary/sets/comp.tgz curl https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-01-16-netbsd-comp.tgz |  </ins> tar xzf - -C netbsd ./usr/include ./usr/lib dst=/usr/local/x86_64-unknown-netbsd


# #   * `CFG_ENABLE_VALGRIND=1` - Run tests under valgrind #   * `VALGRIND_COMPILE=1` - Run the compiler itself under valgrind <del> #                            (may require `CFG_ENABLE_VALGRIND`) </del> <ins> #                            (requires `CFG_ENABLE_VALGRIND`) </ins> # #   * `NO_REBUILD=1` - Don't rebootstrap when testing std #                      (and possibly other crates)


# see https://blog.mozilla.org/jseward/2012/06/05/valgrind-now-supports-jemalloc-builds-directly/ ifdef CFG_VALGRIND CFG_VALGRIND += --error-exitcode=100  <del> --soname-synonyms=somalloc=NONE  </del> <ins> --fair-sched=try  </ins> --quiet  <ins> --soname-synonyms=somalloc=NONE  </ins> --suppressions=$(CFG_SRC_DIR)src/etc/x86.supp  $(OS_SUPP) ifdef CFG_ENABLE_HELGRIND


#![feature(box_into_raw_non_null)] #![feature(box_patterns)] #![feature(box_syntax)] <ins> #![feature(cfg_sanitize)] </ins> #![feature(cfg_target_has_atomic)] #![feature(coerce_unsized)] #![feature(const_generic_impls_guard)]


/// necessarily) at _exactly_ `MAX_REFCOUNT + 1` references. const MAX_REFCOUNT: usize = (isize::MAX) as usize; <ins> #[cfg(not(sanitize = "thread"))] macro_rules! acquire { ($x:expr) => { atomic::fence(Acquire) }; } // ThreadSanitizer does not support memory fences. To avoid false positive // reports in Arc / Weak implementation use atomic loads for synchronization // instead. #[cfg(sanitize = "thread")] macro_rules! acquire { ($x:expr) => { $x.load(Acquire) }; } </ins> /// A thread-safe reference-counting pointer. 'Arc' stands for 'Atomically /// Reference Counted'. ///


return Err(this); } <del> atomic::fence(Acquire); </del> <ins> acquire!(this.inner().strong); </ins> unsafe { let elem = ptr::read(&this.ptr.as_ref().data);


ptr::drop_in_place(&mut self.ptr.as_mut().data); if self.inner().weak.fetch_sub(1, Release) == 1 { <del> atomic::fence(Acquire); </del> <ins> acquire!(self.inner().weak); </ins> Global.dealloc(self.ptr.cast(), Layout::for_value(self.ptr.as_ref())) } }


// // [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html) // [2]: (https://github.com/rust-lang/rust/pull/41714) <del> atomic::fence(Acquire); </del> <ins> acquire!(self.inner().strong); </ins> unsafe { self.drop_slow();


let inner = if let Some(inner) = self.inner() { inner } else { return }; if inner.weak.fetch_sub(1, Release) == 1 { <del> atomic::fence(Acquire); </del> <ins> acquire!(inner.weak); </ins> unsafe { Global.dealloc(self.ptr.cast(), Layout::for_value(self.ptr.as_ref())) } } }


use common::{Codegen, DebugInfoLldb, DebugInfoGdb, Rustdoc, CodegenUnits}; use common::{Incremental, RunMake, Ui, MirOpt}; use errors::{self, ErrorKind, Error}; <ins> use filetime::FileTime; </ins> use json; use header::TestProps; use header;


} } <ins> fn check_mir_test_timestamp(&self, test_name: &str, output_file: &Path) { let t = |file| FileTime::from_last_modification_time(&fs::metadata(file).unwrap()); let source_file = &self.testpaths.file; let output_time = t(output_file); let source_time = t(source_file); if source_time > output_time { debug!("source file time: {:?} output file time: {:?}", source_time, output_time); panic!("test source file `{}` is newer than potentially stale output file `{}`.", source_file.display(), test_name); } } </ins> fn compare_mir_test_output(&self, test_name: &str, expected_content: &Vec<&str>) { let mut output_file = PathBuf::new(); output_file.push(self.get_mir_dump_dir()); output_file.push(test_name); debug!("comparing the contests of: {:?}", output_file); debug!("with: {:?}", expected_content); <ins> self.check_mir_test_timestamp(test_name, &output_file); </ins> let mut dumped_file = fs::File::open(output_file.clone()).unwrap(); let mut dumped_string = String::new();


{ debug!("note_issue_32330: terr={:?}", terr); match *terr { <del> TypeError::RegionsInsufficientlyPolymorphic(_, &Region::ReVar(vid)) | TypeError::RegionsOverlyPolymorphic(_, &Region::ReVar(vid)) => { match self.region_vars.var_origin(vid) { RegionVariableOrigin::EarlyBoundRegion(_, _, Some(Issue32330 { fn_def_id, region_name })) => { diag.note( &format!("lifetime parameter `{0}` declared on fn `{1}`  appears only in the return type,  but here is required to be higher-ranked,  which means that `{0}` must appear in both  argument and return types", region_name, self.tcx.item_path_str(fn_def_id))); diag.note( &format!("this error is the result of a recent bug fix;  for more information, see issue #33685  <https://github.com/rust-lang/rust/issues/33685>")); } _ => { } } </del> <ins> TypeError::RegionsInsufficientlyPolymorphic(_, _, Some(box Issue32330 { fn_def_id, region_name })) | TypeError::RegionsOverlyPolymorphic(_, _, Some(box Issue32330 { fn_def_id, region_name })) => { diag.note( &format!("lifetime parameter `{0}` declared on fn `{1}`  appears only in the return type,  but here is required to be higher-ranked,  which means that `{0}` must appear in both  argument and return types", region_name, self.tcx.item_path_str(fn_def_id))); diag.note( &format!("this error is the result of a recent bug fix;  for more information, see issue #33685  <https://github.com/rust-lang/rust/issues/33685>")); </ins> } <del> _ => { } </del> <ins> _ => {} </ins> } }


InferCtxt, LateBoundRegion, HigherRankedType, <ins> RegionVariableOrigin, </ins> SubregionOrigin, SkolemizationMap}; use super::combine::CombineFields;


skol_br, tainted_region); <ins> let issue_32330 = if let &ty::ReVar(vid) = tainted_region { match self.region_vars.var_origin(vid) { RegionVariableOrigin::EarlyBoundRegion(_, _, issue_32330) => { issue_32330.map(Box::new) } _ => None } } else { None }; </ins> if overly_polymorphic { debug!("Overly polymorphic!"); return Err(TypeError::RegionsOverlyPolymorphic(skol_br, <del> tainted_region)); </del> <ins> tainted_region, issue_32330)); </ins> } else { debug!("Not as polymorphic!"); return Err(TypeError::RegionsInsufficientlyPolymorphic(skol_br, <del> tainted_region)); </del> <ins> tainted_region, issue_32330)); </ins> } } }


RegionsDoesNotOutlive(&'tcx Region, &'tcx Region), RegionsNotSame(&'tcx Region, &'tcx Region), RegionsNoOverlap(&'tcx Region, &'tcx Region), <del> RegionsInsufficientlyPolymorphic(BoundRegion, &'tcx Region), RegionsOverlyPolymorphic(BoundRegion, &'tcx Region), </del> <ins> RegionsInsufficientlyPolymorphic(BoundRegion, &'tcx Region, Option<Box<ty::Issue32330>>), RegionsOverlyPolymorphic(BoundRegion, &'tcx Region, Option<Box<ty::Issue32330>>), </ins> Sorts(ExpectedFound<Ty<'tcx>>), IntMismatch(ExpectedFound<ty::IntVarValue>), FloatMismatch(ExpectedFound<ast::FloatTy>),


RegionsNoOverlap(..) => { write!(f, "lifetimes do not intersect") } <del> RegionsInsufficientlyPolymorphic(br, _) => { </del> <ins> RegionsInsufficientlyPolymorphic(br, _, _) => { </ins> write!(f, "expected bound lifetime parameter {},  found concrete lifetime", br) } <del> RegionsOverlyPolymorphic(br, _) => { </del> <ins> RegionsOverlyPolymorphic(br, _, _) => { </ins> write!(f, "expected concrete lifetime,  found bound lifetime parameter {}", br) }


self.note_and_explain_region(db, "...does not overlap ", region2, ""); } <del> RegionsInsufficientlyPolymorphic(_, conc_region) => { </del> <ins> RegionsInsufficientlyPolymorphic(_, conc_region, _) => { </ins> self.note_and_explain_region(db, "concrete lifetime that was found is ", conc_region, ""); } <del> RegionsOverlyPolymorphic(_, &ty::ReVar(_)) => { </del> <ins> RegionsOverlyPolymorphic(_, &ty::ReVar(_), _) => { </ins> // don't bother to print out the message below for // inference variables, it's not very illuminating. } <del> RegionsOverlyPolymorphic(_, conc_region) => { </del> <ins> RegionsOverlyPolymorphic(_, conc_region, _) => { </ins> self.note_and_explain_region(db, "expected concrete lifetime is ", conc_region, ""); }


RegionsNoOverlap(a, b) => { return tcx.lift(&(a, b)).map(|(a, b)| RegionsNoOverlap(a, b)) } <del> RegionsInsufficientlyPolymorphic(a, b) => { return tcx.lift(&b).map(|b| RegionsInsufficientlyPolymorphic(a, b)) </del> <ins> RegionsInsufficientlyPolymorphic(a, b, ref c) => { let c = c.clone(); return tcx.lift(&b).map(|b| RegionsInsufficientlyPolymorphic(a, b, c)) </ins> } <del> RegionsOverlyPolymorphic(a, b) => { return tcx.lift(&b).map(|b| RegionsOverlyPolymorphic(a, b)) </del> <ins> RegionsOverlyPolymorphic(a, b, ref c) => { let c = c.clone(); return tcx.lift(&b).map(|b| RegionsOverlyPolymorphic(a, b, c)) </ins> } IntMismatch(x) => IntMismatch(x), FloatMismatch(x) => FloatMismatch(x),


<ins> // Copyright 2017 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(closure_to_fn_coercion)] fn main() { let bar: fn(&mut u32) = |_| {}; //~ ERROR mismatched types //~| expected concrete lifetime, found bound lifetime parameter fn foo(x: Box<Fn(&i32)>) {} let bar = Box::new(|x: &i32| {}) as Box<Fn(_)>; foo(bar); //~ ERROR mismatched types //~| expected concrete lifetime, found bound lifetime parameter } </ins>


- [abi_sysv64](abi-sysv64.md) - [abi_unadjusted](abi-unadjusted.md) - [abi_vectorcall](abi-vectorcall.md) <ins> - [abi_x86_interrupt](abi-x86-interrupt.md) </ins> - [advanced_slice_patterns](advanced-slice-patterns.md) - [alloc_jemalloc](alloc-jemalloc.md) - [alloc_system](alloc-system.md)


<ins> # `abi_x86_interrupt` The tracking issue for this feature is: [#40180] [#40180]: https://github.com/rust-lang/rust/issues/40180 ------------------------ </ins>


/// # Examples /// /// ``` <del> /// #![feature(float_bits_conv)] </del> /// assert_ne!((1f32).to_bits(), 1f32 as u32); // to_bits() is not casting! /// assert_eq!((12.5f32).to_bits(), 0x41480000); /// /// ``` <del> #[unstable(feature = "float_bits_conv", reason = "recently added", issue = "40470")] </del> <ins> #[stable(feature = "float_bits_conv", since = "1.21.0")] </ins> #[inline] pub fn to_bits(self) -> u32 { unsafe { ::mem::transmute(self) }


/// # Examples /// /// ``` <del> /// #![feature(float_bits_conv)] </del> /// use std::f32; /// let v = f32::from_bits(0x41480000); /// let difference = (v - 12.5).abs();


/// let snan = 0x7F800001; /// assert_ne!(f32::from_bits(snan).to_bits(), snan); /// ``` <del> #[unstable(feature = "float_bits_conv", reason = "recently added", issue = "40470")] </del> <ins> #[stable(feature = "float_bits_conv", since = "1.21.0")] </ins> #[inline] pub fn from_bits(mut v: u32) -> Self { const EXP_MASK: u32   = 0x7F800000;


/// # Examples /// /// ``` <del> /// #![feature(float_bits_conv)] </del> /// assert!((1f64).to_bits() != 1f64 as u64); // to_bits() is not casting! /// assert_eq!((12.5f64).to_bits(), 0x4029000000000000); /// /// ``` <del> #[unstable(feature = "float_bits_conv", reason = "recently added", issue = "40470")] </del> <ins> #[stable(feature = "float_bits_conv", since = "1.21.0")] </ins> #[inline] pub fn to_bits(self) -> u64 { unsafe { ::mem::transmute(self) }


/// # Examples /// /// ``` <del> /// #![feature(float_bits_conv)] </del> /// use std::f64; /// let v = f64::from_bits(0x4029000000000000); /// let difference = (v - 12.5).abs();


/// let snan = 0x7FF0000000000001; /// assert_ne!(f64::from_bits(snan).to_bits(), snan); /// ``` <del> #[unstable(feature = "float_bits_conv", reason = "recently added", issue = "40470")] </del> <ins> #[stable(feature = "float_bits_conv", since = "1.21.0")] </ins> #[inline] pub fn from_bits(mut v: u64) -> Self { const EXP_MASK: u64   = 0x7FF0000000000000;


#![feature(unwind_attributes)] #![feature(vec_push_all)] #![cfg_attr(test, feature(update_panic_count))] <del> #![cfg_attr(test, feature(float_bits_conv))] </del> #![cfg_attr(not(stage0), default_lib_allocator)]


} impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedMut { <del> fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) { if let hir::ExprMatch(_, ref arms, _) = e.node { for a in arms { self.check_unused_mut_pat(cx, &a.pats) } } </del> <ins> fn check_arm(&mut self, cx: &LateContext, a: &hir::Arm) { self.check_unused_mut_pat(cx, &a.pats) </ins> } <del> fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) { if let hir::StmtDecl(ref d, _) = s.node { if let hir::DeclLocal(ref l) = d.node { self.check_unused_mut_pat(cx, slice::ref_slice(&l.pat)); } } </del> <ins> fn check_local(&mut self, cx: &LateContext, l: &hir::Local) { self.check_unused_mut_pat(cx, slice::ref_slice(&l.pat)); </ins> } fn check_fn(&mut self,


let mut a = 3; let mut b = vec![2]; } <ins> // make sure the lint attribute can be turned off on let statements #[deny(unused_mut)] fn bar() { #[allow(unused_mut)] let mut a = 3; let mut b = vec![2]; //~ ERROR: variable does not need to be mutable } </ins>


This flag will set which lints should be set to the [forbid level](lints/levels.html#forbid). <ins> ## `-Z`: set unstable options This flag will allow you to set unstable options of rustc. In order to set multiple options, the -Z flag can be used multiple times. For example: `rustc -Z verbose -Z time`. Specifying options with -Z is only available on nightly. To view all available options run: `rustc -Z help`. </ins> ## `--cap-lints`: set the most restrictive lint level This flag lets you 'cap' lints, for more, [see here](lints/levels.html#capping-lints).


} let message = "Usage: rustc [OPTIONS] INPUT"; let nightly_help = if nightly_options::is_nightly_build() { <del> "n    -Z help             Print internal options for debugging rustc" </del> <ins> "n    -Z help             Print unstable compiler options" </ins> } else { "" };


} fn describe_debug_flags() { <del> println!("nAvailable debug options:n"); </del> <ins> println!("nAvailable options:n"); </ins> print_flag_list("-Z", config::DB_OPTIONS); }


impl NonCamelCaseTypes { fn check_case(&self, cx: &LateContext, sort: &str, name: ast::Name, span: Span) { <ins> fn char_has_case(c: char) -> bool { c.is_lowercase() || c.is_uppercase() } </ins> fn is_camel_case(name: ast::Name) -> bool { let name = name.as_str(); if name.is_empty() {


// start with a non-lowercase letter rather than non-uppercase // ones (some scripts don't have a concept of upper/lowercase) <del> !name.is_empty() && !name.chars().next().unwrap().is_lowercase() && !name.contains('_') </del> <ins> !name.is_empty() && !name.chars().next().unwrap().is_lowercase() && !name.contains("__") && !name.chars().collect::<Vec<_>>().windows(2).any(|pair| { // contains a capitalisable character followed by, or preceded by, an underscore char_has_case(pair[0]) && pair[1] == '_' || char_has_case(pair[1]) && pair[0] == '_' }) </ins> } fn to_camel_case(s: &str) -> String { <del> s.split('_') .flat_map(|word| { </del> <ins> s.trim_matches('_') .split('_') .map(|word| { </ins> word.chars().enumerate().map(|(i, c)| if i == 0 { c.to_uppercase().collect::<String>() } else { c.to_lowercase().collect() }) <ins> .collect::<Vec<_>>() .concat() </ins> }) <ins> .filter(|x| !x.is_empty()) </ins> .collect::<Vec<_>>() <del> .concat() </del> <ins> .iter().fold((String::new(), None), |(acc, prev): (String, Option<&String>), next| { // separate two components with an underscore if their boundary cannot // be distinguished using a uppercase/lowercase case distinction let join = if let Some(prev) = prev { let l = prev.chars().last().unwrap(); let f = next.chars().next().unwrap(); !char_has_case(l) && !char_has_case(f) } else { false }; (acc + if join { "_" } else { "" } + next, Some(next)) }).0 </ins> } if !is_camel_case(name) {


type __ = isize; //~ ERROR type `__` should have a camel case name such as `CamelCase` <ins> struct X86_64; struct X86__64; //~ ERROR type `X86__64` should have a camel case name such as `X86_64` struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name such as `Abc123` struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name such as `A1B2C3` </ins> fn main() { }


// required. #[cfg(stage1)] #[cfg(stage2)] <ins> #[cfg(stage3)] </ins> pub impl<T: Owned> Chan<T> { fn send(&self, x: T) { chan_send(self, x) } fn try_send(&self, x: T) -> bool { chan_try_send(self, x) }


// Use an inherent impl so that imports are not required: #[cfg(stage1)] #[cfg(stage2)] <ins> #[cfg(stage3)] </ins> pub impl<T: Owned> Port<T> { fn recv(&self) -> T { port_recv(self) } fn try_recv(&self) -> Option<T> { port_try_recv(self) }


// Use an inherent impl so that imports are not required: #[cfg(stage1)] #[cfg(stage2)] <ins> #[cfg(stage3)] </ins> pub impl<T:Owned> PortSet<T> { fn recv(&self) -> T { port_set_recv(self) } fn try_recv(&self) -> Option<T> { port_set_try_recv(self) }


#[cfg(stage1)] #[cfg(stage2)] <ins> #[cfg(stage3)] </ins> pub impl<T: Owned> SharedChan<T> { fn send(&self, x: T) { shared_chan_send(self, x) } fn try_send(&self, x: T) -> bool { shared_chan_try_send(self, x) }


#[cfg(stage1)] #[cfg(stage2)] <ins> #[cfg(stage3)] </ins> impl Reader for @Reader { fn read(&self, bytes: &mut [u8], len: uint) -> uint { self.read(bytes, len)


#[cfg(stage1)] #[cfg(stage2)] <ins> #[cfg(stage3)] </ins> impl Writer for @Writer { fn write(&self, v: &[const u8]) { self.write(v) } fn seek(&self, a: int, b: SeekStyle) { self.seek(a, b) }


#[cfg(stage1)] #[cfg(stage2)] <ins> #[cfg(stage3)] </ins> fn mk_tests(cx: &TestCtxt) -> @ast::item { let ext_cx = cx.ext_cx;


// Allow these methods to be used without import: #[cfg(stage1)] #[cfg(stage2)] <ins> #[cfg(stage3)] </ins> pub impl<T:Owned,U:Owned> DuplexStream<T, U> { fn send(&self, x: T) { self.chan.send(x)


} #[stable(feature = "collection_debug", since = "1.17.0")] <del> impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Keys<'a, K, V> { </del> <ins> impl<'a, K: 'a + fmt::Debug, V: 'a> fmt::Debug for Keys<'a, K, V> { </ins> fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { <del> f.debug_list().entries(self.inner.clone()).finish() </del> <ins> f.debug_list().entries(self.clone()).finish() </ins> } }


} #[stable(feature = "collection_debug", since = "1.17.0")] <del> impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Values<'a, K, V> { </del> <ins> impl<'a, K: 'a, V: 'a + fmt::Debug> fmt::Debug for Values<'a, K, V> { </ins> fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { <del> f.debug_list().entries(self.inner.clone()).finish() </del> <ins> f.debug_list().entries(self.clone()).finish() </ins> } }


} #[stable(feature = "std_debug", since = "1.16.0")] <del> impl<'a, K: Debug, V: Debug> fmt::Debug for Keys<'a, K, V> { </del> <ins> impl<'a, K: Debug, V> fmt::Debug for Keys<'a, K, V> { </ins> fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list() .entries(self.clone())


} #[stable(feature = "std_debug", since = "1.16.0")] <del> impl<'a, K: Debug, V: Debug> fmt::Debug for Values<'a, K, V> { </del> <ins> impl<'a, K, V: Debug> fmt::Debug for Values<'a, K, V> { </ins> fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list() .entries(self.clone())


} } <ins> fn trace_macros_note(cx: &mut ExtCtxt, sp: Span, message: String) { let sp = sp.macro_backtrace().last().map(|trace| trace.call_site).unwrap_or(sp); let mut values: &mut Vec<String> = cx.expansions.entry(sp).or_insert_with(Vec::new); values.push(message); } </ins> /// Given `lhses` and `rhses`, this is the new macro we create fn generic_extension<'cx>(cx: &'cx mut ExtCtxt, sp: Span,


rhses: &[quoted::TokenTree]) -> Box<MacResult+'cx> { if cx.trace_macros() { <del> let sp = sp.macro_backtrace().last().map(|trace| trace.call_site).unwrap_or(sp); let mut values: &mut Vec<String> = cx.expansions.entry(sp).or_insert_with(Vec::new); values.push(format!("expands to `{}! {{ {} }}`", name, arg)); </del> <ins> trace_macros_note(cx, sp, format!("expanding `{}! {{ {} }}`", name, arg)); </ins> } // Which arm's failure should we report? (the one furthest along)


}; // rhs has holes ( `$id` and `$(...)` that need filled) let tts = transcribe(&cx.parse_sess.span_diagnostic, Some(named_matches), rhs); <ins> if cx.trace_macros() { trace_macros_note(cx, sp, format!("to `{}`", tts)); } </ins> let directory = Directory { path: cx.current_expansion.module.directory.clone(), ownership: cx.current_expansion.directory_ownership,


14 |     println!("Hello, World!"); |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ | <del> = note: expands to `println! { "Hello, World!" }` = note: expands to `print! { concat ! ( "Hello, World!" , "/n" ) }` </del> <ins> = note: expanding `println! { "Hello, World!" }` = note: to `print ! ( concat ! ( "Hello, World!" , "/n" ) )` = note: expanding `print! { concat ! ( "Hello, World!" , "/n" ) }` = note: to `$crate :: io :: _print ( format_args ! ( concat ! ( "Hello, World!" , "/n" ) ) )` </ins>


<ins> // Copyright 2017 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 main() { let value = 1; match SomeStruct(value) { StructConst1(_) => { }, //~^ ERROR expected tuple struct/variant, found constant `StructConst1` _ => { }, } struct SomeStruct(u8); const StructConst1 : SomeStruct = SomeStruct(1); const StructConst2 : SomeStruct = SomeStruct(2); } </ins>


<ins> // Copyright 2017 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(associated_consts)] trait Foo { const BAR: i32; fn foo(self) -> &'static i32 { //~^ ERROR the trait bound `Self: std::marker::Sized` is not satisfied &<Self>::BAR } } fn main() {} </ins>


<ins> // Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. macro_rules! get_opt { ($tgt:expr, $field:ident) => { if $tgt.has_$field() {} } } fn main() { get_opt!(bar, foo); //~^ ERROR expected `{`, found `foo` } </ins>


<ins> // Copyright 2017 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 main() { let a = |r: f64| if r != 0.0(r != 0.0) { 1.0 } else { 0.0 }; //~^ ERROR expected function, found `{float}` } </ins>


<ins> // Copyright 2017 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. // #45662 #![feature(repr_align)] #![feature(attr_literals)] #[repr(align(16))] pub struct A { y: i64, } pub extern "C" fn foo(x: A) {} fn main() {} </ins>


<ins> // Copyright 2017 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(conservative_impl_trait)] use std::iter::once; struct Foo { x: i32, } impl Foo { fn inside(&self) -> impl Iterator<Item = &i32> { once(&self.x) } } fn main() { println!("hi"); } </ins>


<ins> // Copyright 2017 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(unsize, coerce_unsized)] #[repr(packed)] struct UnalignedPtr<'a, T: ?Sized> where T: 'a, { data: &'a T, } fn main() { impl<'a, T, U> std::ops::CoerceUnsized<UnalignedPtr<'a, U>> for UnalignedPtr<'a, T> where T: std::marker::Unsize<U> + ?Sized, U: ?Sized, { } let arr = [1, 2, 3]; let arr_unaligned: UnalignedPtr<[i32; 3]> = UnalignedPtr { data: &arr }; let arr_unaligned: UnalignedPtr<[i32]> = arr_unaligned; } </ins>


<ins> // Copyright 2017 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. // #42164 #![feature(decl_macro)] #![allow(dead_code)] pub macro m($inner_str:expr) { #[doc = $inner_str] struct S; } macro_rules! define_f { ($name:expr) => { #[export_name = $name] fn f() {} } } fn main() { define_f!(concat!("exported_", "f")); m!(stringify!(foo)); } </ins>


// option. This file may not be copied, modified, or distributed // except according to those terms. <del> use rustc_serialize::{Encodable, Decodable, Encoder, Decoder}; </del> use rustc_data_structures::stable_hasher; use std::mem; use std::slice; <del> #[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy)] </del> <ins> #[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy, RustcEncodable, RustcDecodable)] </ins> pub struct Fingerprint(u64, u64); impl Fingerprint {


} } <del> impl Encodable for Fingerprint { #[inline] fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { s.emit_u64(self.0.to_le())?; s.emit_u64(self.1.to_le()) } } impl Decodable for Fingerprint { #[inline] fn decode<D: Decoder>(d: &mut D) -> Result<Fingerprint, D::Error> { let _0 = u64::from_le(d.read_u64()?); let _1 = u64::from_le(d.read_u64()?); Ok(Fingerprint(_0, _1)) } } </del> impl ::std::fmt::Display for Fingerprint { fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> { write!(formatter, "{:x}-{:x}", self.0, self.1)


let ast::Path { ref segments, span } = *path; let path: Vec<_> = segments.iter().map(|seg| respan(seg.span, seg.identifier)).collect(); let invocation = self.invocations[&scope]; <del> self.current_module = invocation.module.get(); </del> <ins> let module = invocation.module.get(); self.current_module = if module.is_trait() { module.parent.unwrap() } else { module }; </ins> if path.len() > 1 { if !self.use_extern_macros && self.gated_errors.insert(span) {


<ins> // Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // aux-build:attr-on-trait.rs #![feature(proc_macro)] extern crate attr_on_trait; trait Foo { #[attr_on_trait::foo] fn foo() {} } impl Foo for i32 { fn foo(&self) {} } fn main() { 3i32.foo(); } </ins>


<ins> // Copyright 2017 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. // no-prefer-dynamic #![feature(proc_macro)] #![crate_type = "proc-macro"] extern crate proc_macro; use proc_macro::TokenStream; #[proc_macro_attribute] pub fn foo(attr: TokenStream, item: TokenStream) -> TokenStream { drop(attr); assert_eq!(item.to_string(), "fn foo() { }"); "fn foo(&self);".parse().unwrap() } </ins>


/// # Examples /// /// ```should_panic <del> /// #![feature(panic_col)] </del> /// use std::panic; /// /// panic::set_hook(Box::new(|panic_info| {


/// /// panic!("Normal panic"); /// ``` <del> #[unstable(feature = "panic_col", reason = "recently added", issue = "42939")] </del> <ins> #[stable(feature = "panic_col", since = "1.25")] </ins> pub fn column(&self) -> u32 { self.col }


<ins> // Regression test for https://github.com/rust-lang/rust/issues/43134 // check-pass // compile-flags: --cap-lints allow type Foo<T: Clone> = Option<T>; fn main() {} </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. // only-x86_64 #![allow(dead_code, non_upper_case_globals)] #![feature(asm)] #[repr(C)] pub struct D32x4(f32,f32,f32,f32); impl D32x4 { fn add(&self, vec: Self) -> Self { unsafe { let ret: Self; asm!(" movaps $1, %xmm1 movaps $2, %xmm2 addps %xmm1, %xmm2 movaps $xmm1, $0 " : "=r"(ret) : "1"(self), "2"(vec) : "xmm1", "xmm2" ); ret } } } fn main() { } </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. const C: *const u8 = &0; fn foo(x: *const u8) { match x { C => {} _ => {} } } const D: *const [u8; 4] = b"abcd"; fn main() { match D { D => {} _ => {} } } </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. pub trait Foo<'a> { type Bar; fn foo(&'a self) -> Self::Bar; } impl<'a, 'b, T: 'a> Foo<'a> for &'b T { type Bar = &'a T; fn foo(&'a self) -> &'a T { self } } pub fn uncallable<T, F>(x: T, f: F) where T: for<'a> Foo<'a>, F: for<'a> Fn(<T as Foo<'a>>::Bar) { f(x.foo()); } pub fn catalyst(x: &i32) { broken(x, |_| {}) } pub fn broken<F: Fn(&i32)>(x: &i32, f: F) { uncallable(x, |y| f(y)); } fn main() { } </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. fn main() { let thing = (); let other: typeof(thing) = thing; //~ ERROR attempt to use a non-constant value in a constant //~^ ERROR `typeof` is a reserved keyword but unimplemented [E0516] } fn f(){ let q = 1; <typeof(q)>::N //~ ERROR attempt to use a non-constant value in a constant //~^ ERROR `typeof` is a reserved keyword but unimplemented [E0516] } </ins>


<ins> error[E0435]: attempt to use a non-constant value in a constant --> $DIR/issue-42060.rs:13:23 | LL |     let other: typeof(thing) = thing; //~ ERROR attempt to use a non-constant value in a constant |                       ^^^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant --> $DIR/issue-42060.rs:19:13 | LL |     <typeof(q)>::N //~ ERROR attempt to use a non-constant value in a constant |             ^ non-constant value error[E0516]: `typeof` is a reserved keyword but unimplemented --> $DIR/issue-42060.rs:13:16 | LL |     let other: typeof(thing) = thing; //~ ERROR attempt to use a non-constant value in a constant |                ^^^^^^^^^^^^^ reserved keyword error[E0516]: `typeof` is a reserved keyword but unimplemented --> $DIR/issue-42060.rs:19:6 | LL |     <typeof(q)>::N //~ ERROR attempt to use a non-constant value in a constant |      ^^^^^^^^^ reserved keyword error: aborting due to 4 previous errors Some errors occurred: E0435, E0516. For more information about an error, try `rustc --explain E0435`. </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. fn main() { | } //~^ ERROR expected `|`, found `}` | //~^ ERROR expected item, found `|` </ins>


<ins> error: expected `|`, found `}` --> $DIR/issue-43196.rs:13:1 | LL |     | |      - expected `|` here LL | } | ^ unexpected token error: expected item, found `|` --> $DIR/issue-43196.rs:15:1 | LL | | | ^ expected item error: aborting due to 2 previous errors </ins>


use tvec; use value::Value; <del> use super::MirContext; </del> <ins> use super::{MirContext, LocalRef}; </ins> use super::constant::const_scalar_checked_binop; use super::operand::{OperandRef, OperandValue}; use super::lvalue::LvalueRef;


} mir::Rvalue::Len(ref lvalue) => { <del> let tr_lvalue = self.trans_lvalue(&bcx, lvalue); </del> <ins> let size = self.evaluate_array_len(&bcx, lvalue); </ins> let operand = OperandRef { <del> val: OperandValue::Immediate(tr_lvalue.len(bcx.ccx)), </del> <ins> val: OperandValue::Immediate(size), </ins> ty: bcx.tcx().types.usize, }; (bcx, operand)


} } <ins> fn evaluate_array_len(&mut self, bcx: &Builder<'a, 'tcx>, lvalue: &mir::Lvalue<'tcx>) -> ValueRef { // ZST are passed as operands and require special handling // because trans_lvalue() panics if Local is operand. if let mir::Lvalue::Local(index) = *lvalue { if let LocalRef::Operand(Some(op)) = self.locals[index] { if common::type_is_zero_size(bcx.ccx, op.ty) { if let ty::TyArray(_, n) = op.ty.sty { return common::C_uint(bcx.ccx, n); } } } } // use common size calculation for non zero-sized types let tr_value = self.trans_lvalue(&bcx, lvalue); return tr_value.len(bcx.ccx); } </ins> pub fn trans_scalar_binop(&mut self, bcx: &Builder<'a, 'tcx>, op: mir::BinOp,


<ins> // Copyright 2016 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 main() { &&[()][0]; println!("{:?}", &[(),()][1]); } </ins>


<ins> pub trait Trait<'a> { type Assoc; } pub struct Type; impl<'a> Trait<'a> for Type { type Assoc = (); } pub fn break_me<T, F>(f: F) where T: for<'b> Trait<'b>, F: for<'b> FnMut(<T as Trait<'b>>::Assoc) { break_me::<Type, fn(_)>; //~^ ERROR: type mismatch in function arguments //~| ERROR: type mismatch resolving } fn main() {} </ins>


<ins> error[E0631]: type mismatch in function arguments --> $DIR/issue-43623.rs:14:5 | LL |     break_me::<Type, fn(_)>; |     ^^^^^^^^^^^^^^^^^^^^^^^ |     | |     expected signature of `for<'b> fn(<Type as Trait<'b>>::Assoc) -> _` |     found signature of `fn(_) -> _` | note: required by `break_me` --> $DIR/issue-43623.rs:11:1 | LL | / pub fn break_me<T, F>(f: F) LL | | where T: for<'b> Trait<'b>, LL | |       F: for<'b> FnMut(<T as Trait<'b>>::Assoc) { LL | |     break_me::<Type, fn(_)>; LL | | LL | | LL | | } | |_^ error[E0271]: type mismatch resolving `for<'b> <fn(_) as std::ops::FnOnce<(<Type as Trait<'b>>::Assoc,)>>::Output == ()` --> $DIR/issue-43623.rs:14:5 | LL |     break_me::<Type, fn(_)>; |     ^^^^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'b, found concrete lifetime | note: required by `break_me` --> $DIR/issue-43623.rs:11:1 | LL | / pub fn break_me<T, F>(f: F) LL | | where T: for<'b> Trait<'b>, LL | |       F: for<'b> FnMut(<T as Trait<'b>>::Assoc) { LL | |     break_me::<Type, fn(_)>; LL | | LL | | LL | | } | |_^ error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0271`. </ins>


<ins> use std::ops::Index; struct Test; struct Container(Test); impl Test { fn test(&mut self) {} } impl<'a> Index<&'a bool> for Container { type Output = Test; fn index(&self, _index: &'a bool) -> &Test { &self.0 } } fn main() { let container = Container(Test); let mut val = true; container[&mut val].test(); //~ ERROR: cannot borrow data } </ins>


<ins> error[E0596]: cannot borrow data in an index of `Container` as mutable --> $DIR/issue-44405.rs:21:5 | LL |     container[&mut val].test(); |     ^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable | = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `Container` error: aborting due to previous error For more information about this error, try `rustc --explain E0596`. </ins>


// Building with a static libstdc++ is only supported on linux right now, // not for MSVC or macOS if build.config.llvm_static_stdcpp && <ins> !target.contains("freebsd") && </ins> !target.contains("windows") && !target.contains("apple") { cargo.env("LLVM_STATIC_STDCPP",


libssl-dev  pkg-config <del> COPY dist-i686-freebsd/build-toolchain.sh /tmp/ RUN /tmp/build-toolchain.sh i686 </del> <ins> COPY scripts/freebsd-toolchain.sh /tmp/ RUN /tmp/freebsd-toolchain.sh i686 </ins> COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh ENV  AR_i686_unknown_freebsd=i686-unknown-freebsd10-ar  <del> CC_i686_unknown_freebsd=i686-unknown-freebsd10-gcc  CXX_i686_unknown_freebsd=i686-unknown-freebsd10-g++ </del> <ins> CC_i686_unknown_freebsd=i686-unknown-freebsd10-clang  CXX_i686_unknown_freebsd=i686-unknown-freebsd10-clang++ </ins> ENV HOSTS=i686-unknown-freebsd


FROM ubuntu:16.04 RUN apt-get update && apt-get install -y --no-install-recommends  <del> g++  </del> <ins> clang  </ins> make  file  curl


libssl-dev  pkg-config <del> COPY dist-x86_64-freebsd/build-toolchain.sh /tmp/ RUN /tmp/build-toolchain.sh x86_64 </del> <ins> COPY scripts/freebsd-toolchain.sh /tmp/ RUN /tmp/freebsd-toolchain.sh x86_64 </ins> COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh ENV  AR_x86_64_unknown_freebsd=x86_64-unknown-freebsd10-ar  <del> CC_x86_64_unknown_freebsd=x86_64-unknown-freebsd10-gcc  CXX_x86_64_unknown_freebsd=x86_64-unknown-freebsd10-g++ </del> <ins> CC_x86_64_unknown_freebsd=x86_64-unknown-freebsd10-clang  CXX_x86_64_unknown_freebsd=x86_64-unknown-freebsd10-clang++ </ins> ENV HOSTS=x86_64-unknown-freebsd