let mut cargo = Command::new(&self.initial_cargo); let out_dir = self.stage_out(compiler, mode); <del> // command specific path, we call clear_if_dirty with this let mut my_out = match cmd { "build" => self.cargo_out(compiler, mode, target), // This is the intended out directory for crate documentation. "doc" | "rustdoc" =>  self.crate_doc_out(target), _ => self.stage_out(compiler, mode), }; // This is for the original compiler, but if we're forced to use stage 1, then // std/test/rustc stamps won't exist in stage 2, so we need to get those from stage 1, since // we copy the libs forward. let cmp = self.compiler_for(compiler.stage, compiler.host, target); let libstd_stamp = match cmd { "check" | "clippy" | "fix" => check::libstd_stamp(self, cmp, target), _ => compile::libstd_stamp(self, cmp, target), }; let libtest_stamp = match cmd { "check" | "clippy" | "fix" => check::libtest_stamp(self, cmp, target), _ => compile::libtest_stamp(self, cmp, target), }; let librustc_stamp = match cmd { "check" | "clippy" | "fix" => check::librustc_stamp(self, cmp, target), _ => compile::librustc_stamp(self, cmp, target), }; </del> <ins> // Codegen backends are not yet tracked by -Zbinary-dep-depinfo, // so we need to explicitly clear out if they've been updated. for backend in self.codegen_backends(compiler) { self.clear_if_dirty(&out_dir, &backend); } </ins> if cmd == "doc" || cmd == "rustdoc" { <del> if mode == Mode::Rustc || mode == Mode::ToolRustc || mode == Mode::Codegen { </del> <ins> let my_out = match mode { </ins> // This is the intended out directory for compiler documentation. <del> my_out = self.compiler_doc_out(target); } </del> <ins> Mode::Rustc | Mode::ToolRustc | Mode::Codegen => self.compiler_doc_out(target), _ => self.crate_doc_out(target), }; </ins> let rustdoc = self.rustdoc(compiler); self.clear_if_dirty(&my_out, &rustdoc); <del> } else if cmd != "test" { match mode { Mode::Std => { self.clear_if_dirty(&my_out, &self.rustc(compiler)); for backend in self.codegen_backends(compiler) { self.clear_if_dirty(&my_out, &backend); } }, Mode::Test => { self.clear_if_dirty(&my_out, &libstd_stamp); }, Mode::Rustc => { self.clear_if_dirty(&my_out, &self.rustc(compiler)); self.clear_if_dirty(&my_out, &libstd_stamp); self.clear_if_dirty(&my_out, &libtest_stamp); }, Mode::Codegen => { self.clear_if_dirty(&my_out, &librustc_stamp); }, Mode::ToolBootstrap => { }, Mode::ToolStd => { self.clear_if_dirty(&my_out, &libstd_stamp); }, Mode::ToolTest => { self.clear_if_dirty(&my_out, &libstd_stamp); self.clear_if_dirty(&my_out, &libtest_stamp); }, Mode::ToolRustc => { self.clear_if_dirty(&my_out, &libstd_stamp); self.clear_if_dirty(&my_out, &libtest_stamp); self.clear_if_dirty(&my_out, &librustc_stamp); }, } </del> } cargo


}, } <ins> // This tells Cargo (and in turn, rustc) to output more complete // dependency information.  Most importantly for rustbuild, this // includes sysroot artifacts, like libstd, which means that we don't // need to track those in rustbuild (an error prone process!). This // feature is currently unstable as there may be some bugs and such, but // it represents a big improvement in rustbuild's reliability on // rebuilds, so we're using it here. // // For some additional context, see #63470 (the PR originally adding // this), as well as #63012 which is the tracking issue for this // feature on the rustc side. cargo.arg("-Zbinary-dep-depinfo"); </ins> cargo.arg("-j").arg(self.jobs().to_string()); // Remove make-related flags to ensure Cargo can correctly set things up cargo.env_remove("MAKEFLAGS");


let libdir = builder.sysroot_libdir(compiler, target); let hostdir = builder.sysroot_libdir(compiler, compiler.host); add_to_sysroot(&builder, &libdir, &hostdir, &rustdoc_stamp(builder, compiler, target)); <del> builder.cargo(compiler, Mode::ToolRustc, target, "clean"); </del> } }


use std::process::{Command, Stdio, exit}; use std::str; <del> use build_helper::{output, mtime, t, up_to_date}; </del> <ins> use build_helper::{output, t, up_to_date}; </ins> use filetime::FileTime; use serde::Deserialize; use serde_json;


// for reason why the sanitizers are not built in stage0. copy_apple_sanitizer_dylibs(builder, &builder.native_dir(target), "osx", &libdir); } <del> builder.cargo(target_compiler, Mode::ToolStd, target, "clean"); </del> } }


&builder.sysroot_libdir(target_compiler, compiler.host), &libtest_stamp(builder, compiler, target) ); <del> builder.cargo(target_compiler, Mode::ToolTest, target, "clean"); </del> } }


&builder.sysroot_libdir(target_compiler, compiler.host), &librustc_stamp(builder, compiler, target) ); <del> builder.cargo(target_compiler, Mode::ToolRustc, target, "clean"); </del> } }


deps.push((path_to_add.into(), false)); } <del> // Now we want to update the contents of the stamp file, if necessary. First // we read off the previous contents along with its mtime. If our new // contents (the list of files to copy) is different or if any dep's mtime // is newer then we rewrite the stamp file. </del> deps.sort(); <del> let stamp_contents = fs::read(stamp); let stamp_mtime = mtime(&stamp); </del> let mut new_contents = Vec::new(); <del> let mut max = None; let mut max_path = None; </del> for (dep, proc_macro) in deps.iter() { <del> let mtime = mtime(dep); if Some(mtime) > max { max = Some(mtime); max_path = Some(dep.clone()); } </del> new_contents.extend(if *proc_macro { b"h" } else { b"t" }); new_contents.extend(dep.to_str().unwrap().as_bytes()); new_contents.extend(b"0"); } <del> let max = max.unwrap(); let max_path = max_path.unwrap(); let contents_equal = stamp_contents .map(|contents| contents == new_contents) .unwrap_or_default(); if contents_equal && max <= stamp_mtime { builder.verbose(&format!("not updating {:?}; contents equal and {:?} <= {:?}", stamp, max, stamp_mtime)); return deps.into_iter().map(|(d, _)| d).collect() } if max > stamp_mtime { builder.verbose(&format!("updating {:?} as {:?} changed", stamp, max_path)); } else { builder.verbose(&format!("updating {:?} as deps changed", stamp)); } </del> t!(fs::write(&stamp, &new_contents)); deps.into_iter().map(|(d, _)| d).collect() }


fn copy_apple_sanitizer_dylibs(builder: &Builder, native_dir: &Path, platform: &str, into: &Path) { for &sanitizer in &["asan", "tsan"] { <del> let filename = format!("libclang_rt.{}_{}_dynamic.dylib", sanitizer, platform); </del> <ins> let filename = format!("lib__rustc__clang_rt.{}_{}_dynamic.dylib", sanitizer, platform); </ins> let mut src_path = native_dir.join(sanitizer); src_path.push("build"); src_path.push("lib");


pub out_dir: PathBuf, } <ins> impl NativeLibBoilerplate { /// On OSX we don't want to ship the exact filename that compiler-rt builds. /// This conflicts with the system and ours is likely a wildly different /// version, so they can't be substituted. /// /// As a result, we rename it here but we need to also use /// `install_name_tool` on OSX to rename the commands listed inside of it to /// ensure it's linked against correctly. pub fn fixup_sanitizer_lib_name(&self, sanitizer_name: &str) { if env::var("TARGET").unwrap() != "x86_64-apple-darwin" { return } let dir = self.out_dir.join("build/lib/darwin"); let name = format!("clang_rt.{}_osx_dynamic", sanitizer_name); let src = dir.join(&format!("lib{}.dylib", name)); let new_name = format!("lib__rustc__{}.dylib", name); let dst = dir.join(&new_name); println!("{} => {}", src.display(), dst.display()); fs::rename(&src, &dst).unwrap(); let status = Command::new("install_name_tool") .arg("-id") .arg(format!("@rpath/{}", new_name)) .arg(&dst) .status() .expect("failed to execute `install_name_tool`"); assert!(status.success()); } } </ins> impl Drop for NativeLibBoilerplate { fn drop(&mut self) { if !thread::panicking() {


pub fn sanitizer_lib_boilerplate(sanitizer_name: &str) -> Result<(NativeLibBoilerplate, String), ()> { <del> let (link_name, search_path, dynamic) = match &*env::var("TARGET").unwrap() { </del> <ins> let (link_name, search_path, apple) = match &*env::var("TARGET").unwrap() { </ins> "x86_64-unknown-linux-gnu" => ( format!("clang_rt.{}-x86_64", sanitizer_name), "build/lib/linux",


), _ => return Err(()), }; <del> let to_link = if dynamic { format!("dylib={}", link_name) </del> <ins> let to_link = if apple { format!("dylib=__rustc__{}", link_name) </ins> } else { format!("static={}", link_name) };


.out_dir(&native.out_dir) .build_target(&target) .build(); <ins> native.fixup_sanitizer_lib_name("asan"); </ins> } println!("cargo:rerun-if-env-changed=LLVM_CONFIG"); }


.out_dir(&native.out_dir) .build_target(&target) .build(); <ins> native.fixup_sanitizer_lib_name("tsan"); </ins> } println!("cargo:rerun-if-env-changed=LLVM_CONFIG"); }


pub trait Seek { /// Seek to an offset, in bytes, in a stream. /// <del> /// A seek beyond the end of a stream is allowed, but implementation /// defined. </del> <ins> /// A seek beyond the end of a stream is allowed, but behavior is defined /// by the implementation. </ins> /// /// If the seek operation completed successfully, /// this method returns the new position from the start of the stream.


} impl Target { <del> /// Given a function ABI, turn "System" into the correct ABI for this target. </del> <ins> /// Given a function ABI, turn it into the correct ABI for this target. </ins> pub fn adjust_abi(&self, abi: Abi) -> Abi { match abi { Abi::System => {


Abi::C } }, <ins> // These ABI kinds are ignored on non-x86 Windows targets. // See https://docs.microsoft.com/en-us/cpp/cpp/argument-passing-and-naming-conventions // and the individual pages for __stdcall et al. Abi::Stdcall | Abi::Fastcall | Abi::Vectorcall | Abi::Thiscall => { if self.options.is_like_windows && self.arch != "x86" { Abi::C } else { abi } }, </ins> abi => abi } }


// option. This file may not be copied, modified, or distributed // except according to those terms. <del> // ignore-arm // ignore-aarch64 </del> <ins> // Test that `extern "stdcall"` is properly translated. // only-x86 </ins> // compile-flags: -C no-prepopulate-passes


let code_model = to_llvm_code_model(sess.code_model()); <del> let features = attributes::llvm_target_features(sess).collect::<Vec<_>>(); </del> <ins> let mut features = llvm_util::handle_native_features(sess); features.extend(attributes::llvm_target_features(sess).map(|s| s.to_owned())); </ins> let mut singlethread = sess.target.singlethread; // On the wasm target once the `atomics` feature is enabled that means that


PM: &PassManager<'_>, ); <ins> pub fn LLVMGetHostCPUFeatures() -> *mut c_char; pub fn LLVMDisposeMessage(message: *mut c_char); </ins> // Stuff that's in llvm-wrapper/ because it's not upstream yet. /// Opens an object file.


use rustc_session::Session; use rustc_span::symbol::Symbol; use rustc_target::spec::{MergeFunctions, PanicStrategy}; <del> use std::ffi::CString; </del> <ins> use std::ffi::{CStr, CString}; </ins> use std::slice; use std::str;


handle_native(name) } <ins> pub fn handle_native_features(sess: &Session) -> Vec<String> { match sess.opts.cg.target_cpu { Some(ref s) => { if s != "native" { return vec![]; } let features_string = unsafe { let ptr = llvm::LLVMGetHostCPUFeatures(); let features_string = if !ptr.is_null() { CStr::from_ptr(ptr) .to_str() .unwrap_or_else(|e| { bug!("LLVM returned a non-utf8 features string: {}", e); }) .to_owned() } else { bug!("could not allocate host CPU features, LLVM returned a `null` string"); }; llvm::LLVMDisposeMessage(ptr); features_string }; features_string.split(",").map(|s| s.to_owned()).collect() } None => vec![], } } </ins> pub fn tune_cpu(sess: &Session) -> Option<&str> { match sess.opts.debugging_opts.tune_cpu { Some(ref s) => Some(handle_native(&**s)),


ty::RegionKind::ReLateBound(_, _), ) => {} <del> (ty::RegionKind::ReLateBound(_, _), _) => { </del> <ins> (ty::RegionKind::ReLateBound(_, _), _) | (_, ty::RegionKind::ReVar(_)) => { // One of these is true: </ins> // The new predicate has a HRTB in a spot where the old // predicate does not (if they both had a HRTB, the previous <del> // match arm would have executed). </del> <ins> // match arm would have executed). A HRBT is a 'stricter' // bound than anything else, so we want to keep the newer // predicate (with the HRBT) in place of the old predicate. </ins> // <del> // The means we want to remove the older predicate from // user_computed_preds, since having both it and the new </del> <ins> // OR // // The old predicate has a region variable where the new // predicate has some other kind of region. An region // variable isn't something we can actually display to a user, // so we choose ther new predicate (which doesn't have a region // varaible). // // In both cases, we want to remove the old predicate, // from user_computed_preds, and replace it with the new // one. Having both the old and the new </ins> // predicate in a ParamEnv would confuse SelectionContext <ins> // </ins> // We're currently in the predicate passed to 'retain', // so we return 'false' to remove the old predicate from // user_computed_preds return false; } <del> (_, ty::RegionKind::ReLateBound(_, _)) => { // This is the opposite situation as the previous arm - the // old predicate has a HRTB lifetime in a place where the // new predicate does not. We want to leave the old </del> <ins> (_, ty::RegionKind::ReLateBound(_, _)) | (ty::RegionKind::ReVar(_), _) => { // This is the opposite situation as the previous arm. // One of these is true: // // The old predicate has a HRTB lifetime in a place where the // new predicate does not. // // OR // // The new predicate has a region variable where the old // predicate has some other type of region. // // We want to leave the old </ins> // predicate in user_computed_preds, and skip adding // new_pred to user_computed_params. should_add_new = false <del> } </del> <ins> }, </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 ScopeHandle<'scope> {} // @has issue_54705/struct.ScopeFutureContents.html // @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'scope, S>  // Send for ScopeFutureContents<'scope, S> where S: Sync" // // @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'scope, S>  // Sync for ScopeFutureContents<'scope, S> where S: Sync" pub struct ScopeFutureContents<'scope, S> where S: ScopeHandle<'scope>, { dummy: &'scope S, this: Box<ScopeFuture<'scope, S>>, } struct ScopeFuture<'scope, S> where S: ScopeHandle<'scope>, { contents: ScopeFutureContents<'scope, S>, } unsafe impl<'scope, S> Send for ScopeFuture<'scope, S> where S: ScopeHandle<'scope>, {} unsafe impl<'scope, S> Sync for ScopeFuture<'scope, S> where S: ScopeHandle<'scope>, {} </ins>


<ins> error[E0594]: cannot assign to immutable static item `S` --> $DIR/thread-local-mutation.rs:11:5 | LL |     S = "after"; //~ ERROR cannot assign to immutable |     ^^^^^^^^^^^ cannot assign error: aborting due to previous error For more information about this error, try `rustc --explain E0594`. </ins>


<ins> // Regression test for #54901: immutable thread locals could be mutated. See: // https://github.com/rust-lang/rust/issues/29594#issuecomment-328177697 // https://github.com/rust-lang/rust/issues/54901 #![feature(thread_local)] #[thread_local] static S: &str = "before"; fn set_s() { S = "after"; //~ ERROR cannot assign to immutable } fn main() { println!("{}", S); set_s(); println!("{}", S); } </ins>


<ins> error[E0594]: cannot assign to immutable thread-local static item --> $DIR/thread-local-mutation.rs:11:5 | LL |     S = "after"; //~ ERROR cannot assign to immutable |     ^^^^^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0594`. </ins>


hir::ItemKind::Fn(..) | hir::ItemKind::Ty(..) | hir::ItemKind::Static(..) <ins> | hir::ItemKind::Existential(..) </ins> | hir::ItemKind::Const(..) => { intravisit::walk_item(self, &item); }


<ins> // compile-pass #[deny(warnings)] enum Empty { } trait Bar<T> {} impl Bar<Empty> for () {} fn boo() -> impl Bar<Empty> {} fn main() { boo(); } </ins>


fn build_external_function(cx: &DocContext, did: DefId) -> clean::Function { let sig = cx.tcx.fn_sig(did); <del> let constness = if cx.tcx.is_const_fn(did) { </del> <ins> let constness = if cx.tcx.is_min_const_fn(did) { </ins> hir::Constness::Const } else { hir::Constness::NotConst


(self.generics.clean(cx), (&self.decl, self.body).clean(cx)) }); <ins> let did = cx.tcx.hir().local_def_id(self.id); let constness = if cx.tcx.is_min_const_fn(did) { hir::Constness::Const } else { hir::Constness::NotConst }; </ins> Item { name: Some(self.name.clean(cx)), attrs: self.attrs.clean(cx),


visibility: self.vis.clean(cx), stability: self.stab.clean(cx), deprecation: self.depr.clean(cx), <del> def_id: cx.tcx.hir().local_def_id(self.id), </del> <ins> def_id: did, </ins> inner: FunctionItem(Function { decl, generics, <del> header: self.header, </del> <ins> header: hir::FnHeader { constness, ..self.header }, </ins> }), } }


ty::TraitContainer(_) => self.defaultness.has_value() }; if provided { <del> let constness = if cx.tcx.is_const_fn(self.def_id) { </del> <ins> let constness = if cx.tcx.is_min_const_fn(self.def_id) { </ins> hir::Constness::Const } else { hir::Constness::NotConst


<ins> // Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![crate_name = "foo"] #![unstable(feature = "humans", reason = "who ever let humans program computers, we're apparently really bad at it", issue = "0")] #![feature(rustc_const_unstable, const_fn, foo, foo2)] #![feature(min_const_unsafe_fn)] #![feature(staged_api)] // @has 'foo/fn.foo.html' '//pre' 'pub unsafe fn foo() -> u32' #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature="foo")] pub const unsafe fn foo() -> u32 { 42 } // @has 'foo/fn.foo2.html' '//pre' 'pub fn foo2() -> u32' #[unstable(feature = "humans", issue="0")] pub const fn foo2() -> u32 { 42 } // @has 'foo/fn.bar2.html' '//pre' 'pub const fn bar2() -> u32' #[stable(feature = "rust1", since = "1.0.0")] pub const fn bar2() -> u32 { 42 } // @has 'foo/fn.foo2_gated.html' '//pre' 'pub unsafe fn foo2_gated() -> u32' #[unstable(feature = "foo2", issue="0")] pub const unsafe fn foo2_gated() -> u32 { 42 } // @has 'foo/fn.bar2_gated.html' '//pre' 'pub const unsafe fn bar2_gated() -> u32' #[stable(feature = "rust1", since = "1.0.0")] pub const unsafe fn bar2_gated() -> u32 { 42 } // @has 'foo/fn.bar_not_gated.html' '//pre' 'pub unsafe fn bar_not_gated() -> u32' pub const unsafe fn bar_not_gated() -> u32 { 42 } </ins>


) -> Option<(ty::ParamEnv<'c>, ty::ParamEnv<'c>)> { let tcx = infcx.tcx; <del> let mut select = SelectionContext::new(&infcx); </del> <ins> let mut select = SelectionContext::with_negative(&infcx, true); </ins> let mut already_visited = FxHashSet::default(); let mut predicates = VecDeque::new();


match &result { &Ok(Some(ref vtable)) => { <ins> // If we see an explicit negative impl (e.g. 'impl !Send for MyStruct'), // we immediately bail out, since it's impossible for us to continue. match vtable { Vtable::VtableImpl(VtableImplData { impl_def_id, .. }) => { // Blame tidy for the weird bracket placement if infcx.tcx.impl_polarity(*impl_def_id) == hir::ImplPolarity::Negative { debug!("evaluate_nested_obligations: Found explicit negative impl {:?}, bailing out", impl_def_id); return None; } }, _ => {} } </ins> let obligations = vtable.clone().nested_obligations().into_iter(); if !self.evaluate_nested_obligations(


<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. #![feature(optin_builtin_traits)] // @has issue_55321/struct.A.html // @has - '//*[@id="implementations-list"]/*[@class="impl"]//*/code' "impl !Send for A" // @has - '//*[@id="implementations-list"]/*[@class="impl"]//*/code' "impl !Sync for A" pub struct A(); impl !Send for A {} impl !Sync for A {} // @has issue_55321/struct.B.html // @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<T> !Send for  // B<T>" // @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<T> !Sync for  // B<T>" pub struct B<T: ?Sized>(A, Box<T>); </ins>


let mir_node_id = tcx.hir.as_local_node_id(mir_def_id).expect("non-local mir"); <del> let (return_span, mir_description) = if let hir::ExprKind::Closure(_, _, _, span, gen_move) = tcx.hir.expect_expr(mir_node_id).node { ( tcx.sess.source_map().end_point(span), if gen_move.is_some() { " of generator" } else { " of closure" }, ) } else { // unreachable? (mir.span, "") }; </del> <ins> let (return_span, mir_description) = match tcx.hir.get(mir_node_id) { hir::Node::Expr(hir::Expr { node: hir::ExprKind::Closure(_, _, _, span, gen_move), .. }) => ( tcx.sess.source_map().end_point(*span), if gen_move.is_some() { " of generator" } else { " of closure" }, ), hir::Node::ImplItem(hir::ImplItem { node: hir::ImplItemKind::Method(method_sig, _), .. }) => (method_sig.decl.output.span(), ""), _ => (mir.span, ""), }; </ins> Some(RegionName { // This counter value will already have been used, so this function will increment it


<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(nll)] struct Bar; struct Foo<'s> { bar: &'s mut Bar, } impl Foo<'_> { fn new(bar: &mut Bar) -> Self { Foo { bar } } } fn main() { } </ins>


<ins> error: unsatisfied lifetime constraints --> $DIR/issue-55394.rs:21:9 | LL |     fn new(bar: &mut Bar) -> Self { |                 -            ---- return type is Foo<'2> |                 | |                 let's call the lifetime of this reference `'1` LL |         Foo { bar } |         ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` error: aborting due to previous error </ins>


/// implicit closure bindings. It is needed when the closure is /// borrowing or mutating a mutable referent, e.g.: /// <del> ///    let x: &mut isize = ...; ///    let y = || *x += 5; </del> <ins> ///     let x: &mut isize = ...; ///     let y = || *x += 5; </ins> /// /// If we were to try to translate this closure into a more explicit /// form, we'd encounter an error with the code as written: /// <del> ///    struct Env { x: & &mut isize } ///    let x: &mut isize = ...; ///    let y = (&mut Env { &x }, fn_ptr);  // Closure is pair of env and fn ///    fn fn_ptr(env: &mut Env) { **env.x += 5; } </del> <ins> ///     struct Env { x: & &mut isize } ///     let x: &mut isize = ...; ///     let y = (&mut Env { &x }, fn_ptr);  // Closure is pair of env and fn ///     fn fn_ptr(env: &mut Env) { **env.x += 5; } </ins> /// /// This is then illegal because you cannot mutate an `&mut` found /// in an aliasable location. To solve, you'd have to translate with /// an `&mut` borrow: /// <del> ///    struct Env { x: & &mut isize } ///    let x: &mut isize = ...; ///    let y = (&mut Env { &mut x }, fn_ptr); // changed from &x to &mut x ///    fn fn_ptr(env: &mut Env) { **env.x += 5; } </del> <ins> ///     struct Env { x: & &mut isize } ///     let x: &mut isize = ...; ///     let y = (&mut Env { &mut x }, fn_ptr); // changed from &x to &mut x ///     fn fn_ptr(env: &mut Env) { **env.x += 5; } </ins> /// /// Now the assignment to `**env.x` is legal, but creating a /// mutable pointer to `x` is not because `x` is not mutable. We


<ins> error[E0502]: cannot borrow `u.y` as immutable because it is also borrowed as mutable --> $DIR/union-borrow-move-parent-sibling.rs:25:13 | LL |     let a = &mut u.x.0; |             ---------- mutable borrow occurs here LL |     let b = &u.y; //~ ERROR cannot borrow `u.y` |             ^^^^ immutable borrow occurs here LL |     use_borrow(a); |                - mutable borrow later used here </ins> error[E0382]: use of moved value: `u` <del> --> $DIR/union-borrow-move-parent-sibling.rs:29:13 </del> <ins> --> $DIR/union-borrow-move-parent-sibling.rs:32:13 </ins> | LL |     let a = u.x.0; |             ----- value moved here <del> LL |     let a = u.y; //~ ERROR use of moved value: `u.y` </del> <ins> LL |     let b = u.y; //~ ERROR use of moved value: `u.y` </ins> |             ^^^ value used here after move | = note: move occurs because `u` has type `U`, which does not implement the `Copy` trait <ins> error[E0502]: cannot borrow `u.y` as immutable because it is also borrowed as mutable --> $DIR/union-borrow-move-parent-sibling.rs:38:13 | LL |     let a = &mut (u.x.0).0; |             -------------- mutable borrow occurs here LL |     let b = &u.y; //~ ERROR cannot borrow `u.y` |             ^^^^ immutable borrow occurs here LL |     use_borrow(a); |                - mutable borrow later used here </ins> error[E0382]: use of moved value: `u` <del> --> $DIR/union-borrow-move-parent-sibling.rs:41:13 </del> <ins> --> $DIR/union-borrow-move-parent-sibling.rs:45:13 </ins> | LL |     let a = (u.x.0).0; |             --------- value moved here <del> LL |     let a = u.y; //~ ERROR use of moved value: `u.y` </del> <ins> LL |     let b = u.y; //~ ERROR use of moved value: `u.y` </ins> |             ^^^ value used here after move | = note: move occurs because `u` has type `U`, which does not implement the `Copy` trait <ins> error[E0502]: cannot borrow `u.x` as immutable because it is also borrowed as mutable --> $DIR/union-borrow-move-parent-sibling.rs:51:13 | LL |     let a = &mut *u.y; |             --------- mutable borrow occurs here LL |     let b = &u.x; //~ ERROR cannot borrow `u` (via `u.x`) |             ^^^^ immutable borrow occurs here LL |     use_borrow(a); |                - mutable borrow later used here </ins> error[E0382]: use of moved value: `u` <del> --> $DIR/union-borrow-move-parent-sibling.rs:53:13 </del> <ins> --> $DIR/union-borrow-move-parent-sibling.rs:58:13 </ins> | LL |     let a = *u.y; |             ---- value moved here <del> LL |     let a = u.x; //~ ERROR use of moved value: `u.x` </del> <ins> LL |     let b = u.x; //~ ERROR use of moved value: `u.x` </ins> |             ^^^ value used here after move | = note: move occurs because `u` has type `U`, which does not implement the `Copy` trait <del> error: aborting due to 3 previous errors </del> <ins> error: aborting due to 6 previous errors </ins> <del> For more information about this error, try `rustc --explain E0382`. </del> <ins> Some errors occurred: E0382, E0502. For more information about an error, try `rustc --explain E0382`. </ins>


y: Box<Vec<u8>>, } <ins> fn use_borrow<T>(_: &T) {} </ins> unsafe fn parent_sibling_borrow() { let mut u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = &mut u.x.0; <del> let a = &u.y; //~ ERROR cannot borrow `u.y` </del> <ins> let b = &u.y; //~ ERROR cannot borrow `u.y` use_borrow(a); </ins> } unsafe fn parent_sibling_move() { let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = u.x.0; <del> let a = u.y; //~ ERROR use of moved value: `u.y` </del> <ins> let b = u.y; //~ ERROR use of moved value: `u.y` </ins> } unsafe fn grandparent_sibling_borrow() { let mut u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = &mut (u.x.0).0; <del> let a = &u.y; //~ ERROR cannot borrow `u.y` </del> <ins> let b = &u.y; //~ ERROR cannot borrow `u.y` use_borrow(a); </ins> } unsafe fn grandparent_sibling_move() { let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = (u.x.0).0; <del> let a = u.y; //~ ERROR use of moved value: `u.y` </del> <ins> let b = u.y; //~ ERROR use of moved value: `u.y` </ins> } unsafe fn deref_sibling_borrow() { let mut u = U { y: Box::default() }; let a = &mut *u.y; <del> let a = &u.x; //~ ERROR cannot borrow `u` (via `u.x`) </del> <ins> let b = &u.x; //~ ERROR cannot borrow `u` (via `u.x`) use_borrow(a); </ins> } unsafe fn deref_sibling_move() { let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = *u.y; <del> let a = u.x; //~ ERROR use of moved value: `u.x` </del> <ins> let b = u.x; //~ ERROR use of moved value: `u.x` </ins> }


error[E0502]: cannot borrow `u.y` as immutable because `u.x.0` is also borrowed as mutable <del> --> $DIR/union-borrow-move-parent-sibling.rs:23:14 </del> <ins> --> $DIR/union-borrow-move-parent-sibling.rs:25:14 </ins> | LL |     let a = &mut u.x.0; |                  ----- mutable borrow occurs here <del> LL |     let a = &u.y; //~ ERROR cannot borrow `u.y` </del> <ins> LL |     let b = &u.y; //~ ERROR cannot borrow `u.y` </ins> |              ^^^ immutable borrow occurs here <ins> LL |     use_borrow(a); </ins> LL | } | - mutable borrow ends here error[E0382]: use of moved value: `u.y` <del> --> $DIR/union-borrow-move-parent-sibling.rs:29:9 </del> <ins> --> $DIR/union-borrow-move-parent-sibling.rs:32:9 </ins> | LL |     let a = u.x.0; |         - value moved here <del> LL |     let a = u.y; //~ ERROR use of moved value: `u.y` </del> <ins> LL |     let b = u.y; //~ ERROR use of moved value: `u.y` </ins> |         ^ value used here after move | = note: move occurs because `u.y` has type `[type error]`, which does not implement the `Copy` trait error[E0502]: cannot borrow `u.y` as immutable because `u.x.0.0` is also borrowed as mutable <del> --> $DIR/union-borrow-move-parent-sibling.rs:35:14 </del> <ins> --> $DIR/union-borrow-move-parent-sibling.rs:38:14 </ins> | LL |     let a = &mut (u.x.0).0; |                  --------- mutable borrow occurs here <del> LL |     let a = &u.y; //~ ERROR cannot borrow `u.y` </del> <ins> LL |     let b = &u.y; //~ ERROR cannot borrow `u.y` </ins> |              ^^^ immutable borrow occurs here <ins> LL |     use_borrow(a); </ins> LL | } | - mutable borrow ends here error[E0382]: use of moved value: `u.y` <del> --> $DIR/union-borrow-move-parent-sibling.rs:41:9 </del> <ins> --> $DIR/union-borrow-move-parent-sibling.rs:45:9 </ins> | LL |     let a = (u.x.0).0; |         - value moved here <del> LL |     let a = u.y; //~ ERROR use of moved value: `u.y` </del> <ins> LL |     let b = u.y; //~ ERROR use of moved value: `u.y` </ins> |         ^ value used here after move | = note: move occurs because `u.y` has type `[type error]`, which does not implement the `Copy` trait error[E0502]: cannot borrow `u` (via `u.x`) as immutable because `u` is also borrowed as mutable (via `*u.y`) <del> --> $DIR/union-borrow-move-parent-sibling.rs:47:14 </del> <ins> --> $DIR/union-borrow-move-parent-sibling.rs:51:14 </ins> | LL |     let a = &mut *u.y; |                  ---- mutable borrow occurs here (via `*u.y`) <del> LL |     let a = &u.x; //~ ERROR cannot borrow `u` (via `u.x`) </del> <ins> LL |     let b = &u.x; //~ ERROR cannot borrow `u` (via `u.x`) </ins> |              ^^^ immutable borrow occurs here (via `u.x`) <ins> LL |     use_borrow(a); </ins> LL | } | - mutable borrow ends here error[E0382]: use of moved value: `u.x` <del> --> $DIR/union-borrow-move-parent-sibling.rs:53:9 </del> <ins> --> $DIR/union-borrow-move-parent-sibling.rs:58:9 </ins> | LL |     let a = *u.y; |         - value moved here <del> LL |     let a = u.x; //~ ERROR use of moved value: `u.x` </del> <ins> LL |     let b = u.x; //~ ERROR use of moved value: `u.x` </ins> |         ^ value used here after move | = note: move occurs because `u.x` has type `[type error]`, which does not implement the `Copy` trait


match self.tcx().extern_crate(def_id) { Some(&ExternCrate { src, dependency_of, span, .. }) => match (src, dependency_of) { (ExternCrateSource::Extern(def_id), LOCAL_CRATE) => { <del> debug!("try_print_visible_def_path: def_id={:?}", def_id); return Ok(( if !span.is_dummy() { self.print_def_path(def_id, &[])? } else { self.path_crate(cnum)? }, true, )); </del> <ins> // NOTE(eddyb) the only reason `span` might be dummy, // that we're aware of, is that it's the `std`/`core` // `extern crate` injected by default. // FIXME(eddyb) find something better to key this on, // or avoid ending up with `ExternCrateSource::Extern`, // for the injected `std`/`core`. if span.is_dummy() { return Ok((self.path_crate(cnum)?, true)); } // Disable `try_print_trimmed_def_path` behavior within // the `print_def_path` call, to avoid infinite recursion // in cases where the `extern crate foo` has non-trivial // parents, e.g. it's nested in `impl foo::Trait for Bar` // (see also issues #55779 and #87932). self = with_no_visible_paths(|| self.print_def_path(def_id, &[]))?; return Ok((self, true)); </ins> } (ExternCrateSource::Path, LOCAL_CRATE) => { <del> debug!("try_print_visible_def_path: def_id={:?}", def_id); </del> return Ok((self.path_crate(cnum)?, true)); } _ => {}


<ins> pub trait Trait { fn no_op(&self); } </ins>


<ins> pub trait Deserialize { fn deserialize(); } </ins>


<ins> // run-pass // edition:2018 // aux-crate:issue_55779_extern_trait=issue-55779-extern-trait.rs use issue_55779_extern_trait::Trait; struct Local; struct Helper; impl Trait for Local { fn no_op(&self) { // (Unused) extern crate declaration necessary to reproduce bug extern crate issue_55779_extern_trait; // This one works // impl Trait for Helper { fn no_op(&self) { } } // This one infinite-loops const _IMPL_SERIALIZE_FOR_HELPER: () = { // (extern crate can also appear here to reproduce bug, // as in originating example from serde) impl Trait for Helper { fn no_op(&self) { } } }; } } fn main() { } </ins>


<ins> // edition:2018 // aux-crate:issue_87932_a=issue-87932-a.rs pub struct A {} impl issue_87932_a::Deserialize for A { fn deserialize() { extern crate issue_87932_a as _a; } } fn main() { A::deserialize(); //~^ ERROR no function or associated item named `deserialize` found for struct `A` } </ins>


<ins> error[E0599]: no function or associated item named `deserialize` found for struct `A` in the current scope --> $DIR/issue-87932.rs:13:8 | LL | pub struct A {} | ------------ function or associated item `deserialize` not found for this ... LL |     A::deserialize(); |        ^^^^^^^^^^^ function or associated item not found in `A` | = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | LL | use <crate::A as issue_87932_a::Deserialize>::deserialize::_a::Deserialize; | error: aborting due to previous error For more information about this error, try `rustc --explain E0599`. </ins>


<ins> // run-pass // ^-- The above is needed as this issue is related to LLVM/codegen. // min-llvm-version:15.0.0 // ^-- The above is needed as this issue is fixed by the opaque pointers. fn main() { type_error(|x| &x); } fn type_error<T>( _selector: for<'a> fn(&'a Vec<Box<dyn for<'b> Fn(&'b u8)>>) -> &'a Vec<Box<dyn Fn(T)>>, ) { } </ins>


<ins> // check-pass trait Mirror { type Other; } #[derive(Debug)] struct Even(usize); struct Odd; impl Mirror for Even { type Other = Odd; } impl Mirror for Odd { type Other = Even; } trait Dyn<T: Mirror>: AsRef<<T as Mirror>::Other> {} impl Dyn<Odd> for Even {} impl AsRef<Even> for Even { fn as_ref(&self) -> &Even { self } } fn code<T: Mirror>(d: &dyn Dyn<T>) -> &T::Other { d.as_ref() } fn main() { println!("{:?}", code(&Even(22))); } </ins>


<ins> fn t7p<A, B, C>(f: impl Fn(B) -> C, g: impl Fn(A) -> B) -> impl Fn(A) -> C { move |a: A| -> C { f(g(a)) } } fn t8n<A, B, C>(f: impl Fn(A) -> B, g: impl Fn(A) -> C) -> impl Fn(A) -> (B, C) where A: Copy, { move |a: A| -> (B, C) { let b = a; let fa = f(a); let ga = g(b); (fa, ga) } } fn main() { let f = |(_, _)| {}; let g = |(a, _)| a; let t7 = |env| |a| |b| t7p(f, g)(((env, a), b)); let t8 = t8n(t7, t7p(f, g)); //~^ ERROR: expected a `Fn<(_,)>` closure, found `impl Fn<(((_, _), _),)> } </ins>


<ins> error[E0277]: expected a `Fn<(_,)>` closure, found `impl Fn<(((_, _), _),)>` --> $DIR/issue-59494.rs:21:22 | LL | fn t8n<A, B, C>(f: impl Fn(A) -> B, g: impl Fn(A) -> C) -> impl Fn(A) -> (B, C) |                                             ---------- required by this bound in `t8n` ... LL |     let t8 = t8n(t7, t7p(f, g)); |                      ^^^^^^^^^ expected an `Fn<(_,)>` closure, found `impl Fn<(((_, _), _),)>` | = help: the trait `Fn<(_,)>` is not implemented for `impl Fn<(((_, _), _),)>` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. </ins>


<ins> // check-pass pub trait Trait1 { type C; } struct T1; impl Trait1 for T1 { type C = usize; } pub trait Callback<T: Trait1>: FnMut(<T as Trait1>::C) {} impl<T: Trait1, F: FnMut(<T as Trait1>::C)> Callback<T> for F {} pub struct State<T: Trait1> { callback: Option<Box<dyn Callback<T>>>, } impl<T: Trait1> State<T> { fn new() -> Self { Self { callback: None } } fn test_cb(&mut self, d: <T as Trait1>::C) { (self.callback.as_mut().unwrap())(d) } } fn main() { let mut s = State::<T1>::new(); s.test_cb(1); } </ins>


<ins> // check-pass fn any<T>() -> T { loop {} } trait Foo { type V; } trait Callback<T: Foo>: Fn(&T, &T::V) {} impl<T: Foo, F: Fn(&T, &T::V)> Callback<T> for F {} struct Bar<T: Foo> { callback: Box<dyn Callback<T>>, } impl<T: Foo> Bar<T> { fn event(&self) { (self.callback)(any(), any()); } } struct A; struct B; impl Foo for A { type V = B; } fn main() { let foo = Bar::<A> { callback: Box::new(|_: &A, _: &B| ()) }; foo.event(); } </ins>


bx.store_with_flags(val, dest.llval, dest.align, flags); } OperandValue::Pair(a, b) => { <del> for (i, &x) in [a, b].iter().enumerate() { let llptr = bx.struct_gep(dest.llval, i as u64); let val = base::from_immediate(bx, x); bx.store_with_flags(val, llptr, dest.align, flags); } </del> <ins> let (a_scalar, b_scalar) = match dest.layout.abi { layout::Abi::ScalarPair(ref a, ref b) => (a, b), _ => bug!("store_with_flags: invalid ScalarPair layout: {:#?}", dest.layout) }; let b_offset = a_scalar.value.size(bx).align_to(b_scalar.value.align(bx).abi); let llptr = bx.struct_gep(dest.llval, 0); let val = base::from_immediate(bx, a); let align = dest.align; bx.store_with_flags(val, llptr, align, flags); let llptr = bx.struct_gep(dest.llval, 1); let val = base::from_immediate(bx, b); let align = dest.align.restrict_for_offset(b_offset); bx.store_with_flags(val, llptr, align, flags); </ins> } } }


<ins> // compile-flags: -C no-prepopulate-passes #![crate_type="rlib"] #[allow(dead_code)] pub struct Foo<T> { foo: u64, bar: T, } // The store writing to bar.1 should have alignment 4. Not checking // other stores here, as the alignment will be platform-dependent. // CHECK: store i32 [[TMP1:%.+]], i32* [[TMP2:%.+]], align 4 #[no_mangle] pub fn test(x: (i32, i32)) -> Foo<(i32, i32)> { Foo { foo: 0, bar: x } } </ins>


println!("cargo:rustc-link-lib=advapi32"); println!("cargo:rustc-link-lib=ws2_32"); println!("cargo:rustc-link-lib=userenv"); <del> println!("cargo:rustc-link-lib=shell32"); </del> } else if target.contains("fuchsia") { println!("cargo:rustc-link-lib=zircon"); println!("cargo:rustc-link-lib=fdio");


#![allow(dead_code)] // runtime init functions not used during testing use os::windows::prelude::*; <ins> use sys::windows::os::current_exe; </ins> use sys::c; <del> use slice; use ops::Range; </del> use ffi::OsString; <del> use libc::{c_int, c_void}; </del> use fmt; <ins> use vec; use core::iter; use slice; use path::PathBuf; </ins> pub unsafe fn init(_argc: isize, _argv: *const *const u8) { }


pub fn args() -> Args { unsafe { <del> let mut nArgs: c_int = 0; let lpCmdLine = c::GetCommandLineW(); let szArgList = c::CommandLineToArgvW(lpCmdLine, &mut nArgs); // szArcList can be NULL if CommandLinToArgvW failed, // but in that case nArgs is 0 so we won't actually // try to read a null pointer Args { cur: szArgList, range: 0..(nArgs as isize) } </del> <ins> let lp_cmd_line = c::GetCommandLineW(); let parsed_args_list = parse_lp_cmd_line( lp_cmd_line as *const u16, || current_exe().map(PathBuf::into_os_string).unwrap_or_else(|_| OsString::new())); Args { parsed_args_list: parsed_args_list.into_iter() } </ins> } } <ins> /// Implements the Windows command-line argument parsing algorithm. /// /// Microsoft's documentation for the Windows CLI argument format can be found at /// <https://docs.microsoft.com/en-us/previous-versions//17w5ykft(v=vs.85)>. /// /// Windows includes a function to do this in shell32.dll, /// but linking with that DLL causes the process to be registered as a GUI application. /// GUI applications add a bunch of overhead, even if no windows are drawn. See /// <https://randomascii.wordpress.com/2018/12/03/a-not-called-function-can-cause-a-5x-slowdown/>. /// /// This function was tested for equivalence to the shell32.dll implementation in /// Windows 10 Pro v1803, using an exhaustive test suite available at /// <https://gist.github.com/notriddle/dde431930c392e428055b2dc22e638f5> or /// <https://paste.gg/p/anonymous/47d6ed5f5bd549168b1c69c799825223>. unsafe fn parse_lp_cmd_line<F: Fn() -> OsString>(lp_cmd_line: *const u16, exe_name: F) -> Vec<OsString> { const BACKSLASH: u16 = '' as u16; const QUOTE: u16 = '"' as u16; const TAB: u16 = 't' as u16; const SPACE: u16 = ' ' as u16; let mut ret_val = Vec::new(); if lp_cmd_line.is_null() || *lp_cmd_line == 0 { ret_val.push(exe_name()); return ret_val; } let mut cmd_line = { let mut end = 0; while *lp_cmd_line.offset(end) != 0 { end += 1; } slice::from_raw_parts(lp_cmd_line, end as usize) }; // The executable name at the beginning is special. cmd_line = match cmd_line[0] { // The executable name ends at the next quote mark, // no matter what. QUOTE => { let args = { let mut cut = cmd_line[1..].splitn(2, |&c| c == QUOTE); if let Some(exe) = cut.next() { ret_val.push(OsString::from_wide(exe)); } cut.next() }; if let Some(args) = args { args } else { return ret_val; } } // Implement quirk: when they say whitespace here, // they include the entire ASCII control plane: // "However, if lpCmdLine starts with any amount of whitespace, CommandLineToArgvW // will consider the first argument to be an empty string. Excess whitespace at the // end of lpCmdLine is ignored." 0...SPACE => { ret_val.push(OsString::new()); &cmd_line[1..] }, // The executable name ends at the next whitespace, // no matter what. _ => { let args = { let mut cut = cmd_line.splitn(2, |&c| c > 0 && c <= SPACE); if let Some(exe) = cut.next() { ret_val.push(OsString::from_wide(exe)); } cut.next() }; if let Some(args) = args { args } else { return ret_val; } } }; let mut cur = Vec::new(); let mut in_quotes = false; let mut was_in_quotes = false; let mut backslash_count: usize = 0; for &c in cmd_line { match c { // backslash BACKSLASH => { backslash_count += 1; was_in_quotes = false; }, QUOTE if backslash_count % 2 == 0 => { cur.extend(iter::repeat(b'' as u16).take(backslash_count / 2)); backslash_count = 0; if was_in_quotes { cur.push('"' as u16); was_in_quotes = false; } else { was_in_quotes = in_quotes; in_quotes = !in_quotes; } } QUOTE if backslash_count % 2 != 0 => { cur.extend(iter::repeat(b'' as u16).take(backslash_count / 2)); backslash_count = 0; was_in_quotes = false; cur.push(b'"' as u16); } SPACE | TAB if !in_quotes => { cur.extend(iter::repeat(b'' as u16).take(backslash_count)); if !cur.is_empty() || was_in_quotes { ret_val.push(OsString::from_wide(&cur[..])); cur.truncate(0); } backslash_count = 0; was_in_quotes = false; } _ => { cur.extend(iter::repeat(b'' as u16).take(backslash_count)); backslash_count = 0; was_in_quotes = false; cur.push(c); } } } cur.extend(iter::repeat(b'' as u16).take(backslash_count)); // include empty quoted strings at the end of the arguments list if !cur.is_empty() || was_in_quotes || in_quotes { ret_val.push(OsString::from_wide(&cur[..])); } ret_val } </ins> pub struct Args { <del> range: Range<isize>, cur: *mut *mut u16, </del> <ins> parsed_args_list: vec::IntoIter<OsString>, </ins> } pub struct ArgsInnerDebug<'a> {


impl<'a> fmt::Debug for ArgsInnerDebug<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { <del> f.write_str("[")?; let mut first = true; for i in self.args.range.clone() { if !first { f.write_str(", ")?; } first = false; // Here we do allocation which could be avoided. fmt::Debug::fmt(&unsafe { os_string_from_ptr(*self.args.cur.offset(i)) }, f)?; } f.write_str("]")?; Ok(()) </del> <ins> self.args.parsed_args_list.as_slice().fmt(f) </ins> } }


} } <del> unsafe fn os_string_from_ptr(ptr: *mut u16) -> OsString { let mut len = 0; while *ptr.offset(len) != 0 { len += 1; } // Push it onto the list. let ptr = ptr as *const u16; let buf = slice::from_raw_parts(ptr, len as usize); OsStringExt::from_wide(buf) } </del> impl Iterator for Args { type Item = OsString; <del> fn next(&mut self) -> Option<OsString> { self.range.next().map(|i| unsafe { os_string_from_ptr(*self.cur.offset(i)) } ) } fn size_hint(&self) -> (usize, Option<usize>) { self.range.size_hint() } </del> <ins> fn next(&mut self) -> Option<OsString> { self.parsed_args_list.next() } fn size_hint(&self) -> (usize, Option<usize>) { self.parsed_args_list.size_hint() } </ins> } impl DoubleEndedIterator for Args { <del> fn next_back(&mut self) -> Option<OsString> { self.range.next_back().map(|i| unsafe { os_string_from_ptr(*self.cur.offset(i)) } ) } </del> <ins> fn next_back(&mut self) -> Option<OsString> { self.parsed_args_list.next_back() } </ins> } impl ExactSizeIterator for Args { <del> fn len(&self) -> usize { self.range.len() } </del> <ins> fn len(&self) -> usize { self.parsed_args_list.len() } </ins> } <del> impl Drop for Args { fn drop(&mut self) { // self.cur can be null if CommandLineToArgvW previously failed, // but LocalFree ignores NULL pointers unsafe { c::LocalFree(self.cur as *mut c_void); } </del> <ins> #[cfg(test)] mod tests { use sys::windows::args::*; use ffi::OsString; fn chk(string: &str, parts: &[&str]) { let mut wide: Vec<u16> = OsString::from(string).encode_wide().collect(); wide.push(0); let parsed = unsafe { parse_lp_cmd_line(wide.as_ptr() as *const u16, || OsString::from("TEST.EXE")) }; let expected: Vec<OsString> = parts.iter().map(|k| OsString::from(k)).collect(); assert_eq!(parsed.as_slice(), expected.as_slice()); } #[test] fn empty() { chk("", &["TEST.EXE"]); chk("0", &["TEST.EXE"]); } #[test] fn single_words() { chk("EXE one_word", &["EXE", "one_word"]); chk("EXE a", &["EXE", "a"]); chk("EXE 😅", &["EXE", "😅"]); chk("EXE 😅🤦", &["EXE", "😅🤦"]); } #[test] fn official_examples() { chk(r#"EXE "abc" d e"#, &["EXE", "abc", "d", "e"]); chk(r#"EXE ab d"e f"g h"#, &["EXE", r#"ab"#, "de fg", "h"]); chk(r#"EXE a"b c d"#, &["EXE", r#"a"b"#, "c", "d"]); chk(r#"EXE a"b c" d e"#, &["EXE", r#"ab c"#, "d", "e"]); } #[test] fn whitespace_behavior() { chk(r#" test"#, &["", "test"]); chk(r#"  test"#, &["", "test"]); chk(r#" test test2"#, &["", "test", "test2"]); chk(r#" test  test2"#, &["", "test", "test2"]); chk(r#"test test2 "#, &["test", "test2"]); chk(r#"test  test2 "#, &["test", "test2"]); chk(r#"test "#, &["test"]); } #[test] fn genius_quotes() { chk(r#"EXE "" """#, &["EXE", "", ""]); chk(r#"EXE "" """"#, &["EXE", "", """]); chk( r#"EXE "this is """all""" in the same argument""#, &["EXE", "this is "all" in the same argument"] ); chk(r#"EXE "a"""#, &["EXE", "a""]); chk(r#"EXE "a"" a"#, &["EXE", "a"", "a"]); // quotes cannot be escaped in command names chk(r#""EXE" check"#, &["EXE", "check"]); chk(r#""EXE check""#, &["EXE check"]); chk(r#""EXE """for""" check"#, &["EXE ", r#"for""#, "check"]); chk(r#""EXE "for" check"#, &[r#"EXE "#, r#"for""#,  "check"]); </ins> } }


pub fn SetLastError(dwErrCode: DWORD); pub fn GetCommandLineW() -> *mut LPCWSTR; <del> pub fn LocalFree(ptr: *mut c_void); pub fn CommandLineToArgvW(lpCmdLine: *mut LPCWSTR, pNumArgs: *mut c_int) -> *mut *mut u16; </del> pub fn GetTempPathW(nBufferLength: DWORD, lpBuffer: LPCWSTR) -> DWORD; pub fn OpenProcessToken(ProcessHandle: HANDLE,


# Extra flags needed to compile a working executable with the standard library ifdef IS_WINDOWS ifdef IS_MSVC <del> EXTRACFLAGS := ws2_32.lib userenv.lib shell32.lib advapi32.lib </del> <ins> EXTRACFLAGS := ws2_32.lib userenv.lib advapi32.lib </ins> else EXTRACFLAGS := -lws2_32 -luserenv endif


perf  debuginfo  doc  <del> $(foreach docname,$(DOC_TEST_NAMES),$(docname))  </del> <ins> $(foreach docname,$(DOC_TEST_NAMES),doc-$(docname))  </ins> pretty  pretty-rpass  pretty-rpass-full


/// ``` #[lang = "index"] #[rustc_on_unimplemented( <ins> on( _Self="&str", note="you can use `.chars().nth()` or `.bytes().nth()` see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>" ), on( _Self="str", note="you can use `.chars().nth()` or `.bytes().nth()` see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>" ), on( _Self="std::string::String", note="you can use `.chars().nth()` or `.bytes().nth()` see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>" ), </ins> message="the type `{Self}` cannot be indexed by `{Idx}`", label="`{Self}` cannot be indexed by `{Idx}`", )]


/// ``` #[lang = "index_mut"] #[rustc_on_unimplemented( <ins> on( _Self="&str", note="you can use `.chars().nth()` or `.bytes().nth()` see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>" ), on( _Self="str", note="you can use `.chars().nth()` or `.bytes().nth()` see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>" ), on( _Self="std::string::String", note="you can use `.chars().nth()` or `.bytes().nth()` see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>" ), </ins> message="the type `{Self}` cannot be mutably indexed by `{Idx}`", label="`{Self}` cannot be mutably indexed by `{Idx}`", )]


|                 ^^^^ `str` cannot be indexed by `{integer}` | = help: the trait `std::ops::Index<{integer}>` is not implemented for `str` <ins> = note: you can use `.chars().nth()` or `.bytes().nth()` see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings> </ins> error: aborting due to previous error


|     ^^^^^^^^^ `str` cannot be mutably indexed by `usize` | = help: the trait `std::ops::IndexMut<usize>` is not implemented for `str` <ins> = note: you can use `.chars().nth()` or `.bytes().nth()` see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings> </ins> error: aborting due to 3 previous errors


///     assert_eq!(v.len(), 42); /// } /// ``` <del> /// should be </del> <ins> /// </ins> /// ```rust <ins> /// // should be </ins> /// fn foo(v: &[i32]) { ///     assert_eq!(v.len(), 42); /// }


!preds.is_empty() && { let ty_empty_region = cx.tcx.mk_imm_ref(cx.tcx.lifetimes.re_root_empty, ty); preds.iter().all(|t| { <del> let ty_params = &t.skip_binder().trait_ref.substs.iter().skip(1).collect::<Vec<_>>(); </del> <ins> let ty_params = &t .skip_binder() .trait_ref .substs .iter() .skip(1) .collect::<Vec<_>>(); </ins> implements_trait(cx, ty_empty_region, t.def_id(), ty_params) }) },


/// /// **Example:** /// ```rust <del> /// // Bad </del> /// println!(""); <del> /// /// // Good /// println!(); </del> /// ``` pub PRINTLN_EMPTY_STRING, style,


declare_clippy_lint! { /// **What it does:** This lint warns when you use `print!()` with a format <del> /// string that ends in a newline. </del> <ins> /// string that /// ends in a newline. </ins> /// /// **Why is this bad?** You should use `println!()` instead, which appends the /// newline.


/// ```rust /// # use std::fmt::Write; /// # let mut buf = String::new(); <del> /// /// // Bad </del> /// writeln!(buf, ""); <del> /// /// // Good /// writeln!(buf); </del> /// ``` pub WRITELN_EMPTY_STRING, style,


/// # use std::fmt::Write; /// # let mut buf = String::new(); /// # let name = "World"; <del> /// /// // Bad </del> /// write!(buf, "Hello {}!n", name); <del> /// /// // Good /// writeln!(buf, "Hello {}!", name); </del> /// ``` pub WRITE_WITH_NEWLINE, style,


/// ```rust /// # use std::fmt::Write; /// # let mut buf = String::new(); <del> /// /// // Bad </del> /// writeln!(buf, "{}", "foo"); <del> /// /// // Good /// writeln!(buf, "foo"); </del> /// ``` pub WRITE_LITERAL, style,


if let (Some(fmt_str), expr) = self.check_tts(cx, &mac.args.inner_tokens(), true) { if fmt_str.symbol == Symbol::intern("") { let mut applicability = Applicability::MachineApplicable; <del> let suggestion = if let Some(e) = expr { snippet_with_applicability(cx, e.span, "v", &mut applicability) } else { applicability = Applicability::HasPlaceholders; Cow::Borrowed("v") </del> <ins> let suggestion = match expr { Some(expr) => snippet_with_applicability(cx, expr.span, "v", &mut applicability), None => { applicability = Applicability::HasPlaceholders; Cow::Borrowed("v") }, </ins> }; span_lint_and_sugg(


} fn run_ui_cargo(config: &mut compiletest::Config) { <ins> if cargo::is_rustc_test_suite() { return; } </ins> fn run_tests( config: &compiletest::Config, filter: &Option<String>,


<ins> #!/bin/sh CARGO_TARGET_DIR=$(pwd)/target/ export CARGO_TARGET_DIR echo 'Deprecated! `util/dev` usage is deprecated, please use `cargo dev` instead.' cd clippy_dev && cargo run -- "$@" </ins>


); // See https://github.com/rust-lang/rust/issues/32354 <del> if old_binding.is_import() || new_binding.is_import() { let binding = if new_binding.is_import() && !new_binding.span.is_dummy() { new_binding </del> <ins> let directive = match (&new_binding.kind, &old_binding.kind) { (NameBindingKind::Import { directive, .. }, _) if !new_binding.span.is_dummy() => Some((directive, new_binding.span)), (_, NameBindingKind::Import { directive, .. }) if !old_binding.span.is_dummy() => Some((directive, old_binding.span)), _ => None, }; if let Some((directive, binding_span)) = directive { let suggested_name = if name.as_str().chars().next().unwrap().is_uppercase() { format!("Other{}", name) </ins> } else { <del> old_binding </del> <ins> format!("other_{}", name) </ins> }; <del> let cm = self.session.source_map(); let rename_msg = "you can use `as` to change the binding name of the import"; if let ( Ok(snippet), NameBindingKind::Import { directive, ..}, _dummy @ false, ) = ( cm.span_to_snippet(binding.span), binding.kind.clone(), binding.span.is_dummy(), ) { let suggested_name = if name.as_str().chars().next().unwrap().is_uppercase() { format!("Other{}", name) } else { format!("other_{}", name) }; </del> <ins> let mut suggestion = None; match directive.subclass { ImportDirectiveSubclass::SingleImport { type_ns_only: true, .. } => suggestion = Some(format!("self as {}", suggested_name)), ImportDirectiveSubclass::SingleImport { source, .. } => { if let Some(pos) = source.span.hi().0.checked_sub(binding_span.lo().0) .map(|pos| pos as usize) { if let Ok(snippet) = self.session.source_map() .span_to_snippet(binding_span) { if pos <= snippet.len() { suggestion = Some(format!( "{} as {}{}", &snippet[..pos], suggested_name, if snippet.ends_with(";") { ";" } else { "" } )) } } } } ImportDirectiveSubclass::ExternCrate { source, target, .. } => suggestion = Some(format!( "extern crate {} as {};", source.unwrap_or(target.name), suggested_name, )), _ => unreachable!(), } let rename_msg = "you can use `as` to change the binding name of the import"; if let Some(suggestion) = suggestion { </ins> err.span_suggestion_with_applicability( <del> binding.span, &rename_msg, match directive.subclass { ImportDirectiveSubclass::SingleImport { type_ns_only: true, .. } => format!("self as {}", suggested_name), ImportDirectiveSubclass::SingleImport { source, .. } => format!( "{} as {}{}", &snippet[..((source.span.hi().0 - binding.span.lo().0) as usize)], suggested_name, if snippet.ends_with(";") { ";" } else { "" } ), ImportDirectiveSubclass::ExternCrate { source, target, .. } => format!( "extern crate {} as {};", source.unwrap_or(target.name), suggested_name, ), _ => unreachable!(), }, </del> <ins> binding_span, rename_msg, suggestion, </ins> Applicability::MaybeIncorrect, ); } else { <del> err.span_label(binding.span, rename_msg); </del> <ins> err.span_label(binding_span, rename_msg); </ins> } }


<ins> macro_rules! import { ( $($name:ident),* ) => { $( mod $name; pub use self::$name; //~^ ERROR the name `issue_56411_aux` is defined multiple times //~| ERROR `issue_56411_aux` is private, and cannot be re-exported )* } } import!(issue_56411_aux); fn main() { println!("Hello, world!"); } </ins>


<ins> error[E0255]: the name `issue_56411_aux` is defined multiple times --> $DIR/issue-56411.rs:5:21 | LL |             mod $name; |             ---------- previous definition of the module `issue_56411_aux` here LL |             pub use self::$name; |                     ^^^^^^^^^^^ |                     | |                     `issue_56411_aux` reimported here |                     you can use `as` to change the binding name of the import ... LL | import!(issue_56411_aux); | ------------------------- in this macro invocation | = note: `issue_56411_aux` must be defined only once in the type namespace of this module error[E0365]: `issue_56411_aux` is private, and cannot be re-exported --> $DIR/issue-56411.rs:5:21 | LL |             pub use self::$name; |                     ^^^^^^^^^^^ re-export of private `issue_56411_aux` ... LL | import!(issue_56411_aux); | ------------------------- in this macro invocation | = note: consider declaring type or module `issue_56411_aux` with `pub` error: aborting due to 2 previous errors Some errors occurred: E0255, E0365. For more information about an error, try `rustc --explain E0255`. </ins>


<ins> // compile-pass struct T {} fn main() {} </ins>


/// /// The following return false: /// <del> /// - private address (10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16) /// - the loopback address (127.0.0.0/8) /// - the link-local address (169.254.0.0/16) /// - the broadcast address (255.255.255.255/32) /// - test addresses used for documentation (192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24) /// - the unspecified address (0.0.0.0) </del> <ins> /// - private addresses (see [`is_private()`](#method.is_private)) /// - the loopback address (see [`is_loopback()`](#method.is_loopback)) /// - the link-local address (see [`is_link_local()`](#method.is_link_local)) /// - the broadcast address (see [`is_broadcast()`](#method.is_broadcast)) /// - addresses used for documentation (see [`is_documentation()`](#method.is_documentation)) /// - the unspecified address (see [`is_unspecified()`](#method.is_unspecified)), and the whole ///   0.0.0.0/8 block /// - addresses reserved for future protocols (see /// [`is_ietf_protocol_assignment()`](#method.is_ietf_protocol_assignment), except /// `192.0.0.9/32` and `192.0.0.10/32` which are globally routable /// - addresses reserved for future use (see [`is_reserved()`](#method.is_reserved) /// - addresses reserved for networking devices benchmarking (see /// [`is_benchmarking`](#method.is_benchmarking)) </ins> /// /// [ipv4-sr]: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml /// [`true`]: ../../std/primitive.bool.html


/// use std::net::Ipv4Addr; /// /// fn main() { <ins> ///     // private addresses are not global </ins> ///     assert_eq!(Ipv4Addr::new(10, 254, 0, 0).is_global(), false); ///     assert_eq!(Ipv4Addr::new(192, 168, 10, 65).is_global(), false); ///     assert_eq!(Ipv4Addr::new(172, 16, 10, 65).is_global(), false); <ins> /// ///     // the 0.0.0.0/8 block is not global ///     assert_eq!(Ipv4Addr::new(0, 1, 2, 3).is_global(), false); ///     // in particular, the unspecified address is not global </ins> ///     assert_eq!(Ipv4Addr::new(0, 0, 0, 0).is_global(), false); <ins> /// ///     // the loopback address is not global ///     assert_eq!(Ipv4Addr::new(127, 0, 0, 1).is_global(), false); /// ///     // link local addresses are not global ///     assert_eq!(Ipv4Addr::new(169, 254, 45, 1).is_global(), false); /// ///     // the broadcast address is not global ///     assert_eq!(Ipv4Addr::new(255, 255, 255, 255).is_global(), false); /// ///     // the broadcast address is not global ///     assert_eq!(Ipv4Addr::new(192, 0, 2, 255).is_global(), false); ///     assert_eq!(Ipv4Addr::new(198, 51, 100, 65).is_global(), false); ///     assert_eq!(Ipv4Addr::new(203, 0, 113, 6).is_global(), false); /// ///     // shared addresses are not global ///     assert_eq!(Ipv4Addr::new(100, 100, 0, 0).is_global(), false); /// ///     // addresses reserved for protocol assignment are not global ///     assert_eq!(Ipv4Addr::new(192, 0, 0, 0).is_global(), false); ///     assert_eq!(Ipv4Addr::new(192, 0, 0, 255).is_global(), false); /// ///     // addresses reserved for future use are not global ///     assert_eq!(Ipv4Addr::new(250, 10, 20, 30).is_global(), false); /// ///     // addresses reserved for network devices benchmarking are not global ///     assert_eq!(Ipv4Addr::new(198, 18, 0, 0).is_global(), false); /// ///     // All the other addresses are global ///     assert_eq!(Ipv4Addr::new(1, 1, 1, 1).is_global(), true); </ins> ///     assert_eq!(Ipv4Addr::new(80, 9, 12, 3).is_global(), true); /// } /// ``` pub fn is_global(&self) -> bool { <del> !self.is_private() && !self.is_loopback() && !self.is_link_local() && !self.is_broadcast() && !self.is_documentation() && !self.is_unspecified() </del> <ins> // check if this address is 192.0.0.9 or 192.0.0.10. These addresses are the only two // globally routable addresses in the 192.0.0.0/24 range. if u32::from(*self) == 0xc0000009 || u32::from(*self) == 0xc000000a { return true; } !self.is_private() && !self.is_loopback() && !self.is_link_local() && !self.is_broadcast() && !self.is_documentation() && !self.is_shared() && !self.is_ietf_protocol_assignment() && !self.is_reserved() && !self.is_benchmarking() // Make sure the address is not in 0.0.0.0/8 && self.octets()[0] != 0 } /// Returns [`true`] if this address is part of the Shared Address Space defined in /// [IETF RFC 6598] (`100.64.0.0/10`). /// /// [IETF RFC 6598]: https://tools.ietf.org/html/rfc6598 /// [`true`]: ../../std/primitive.bool.html /// /// # Examples /// /// ``` /// #![feature(ip)] /// use std::net::Ipv4Addr; /// /// fn main() { ///     assert_eq!(Ipv4Addr::new(100, 64, 0, 0).is_shared(), true); ///     assert_eq!(Ipv4Addr::new(100, 127, 255, 255).is_shared(), true); ///     assert_eq!(Ipv4Addr::new(100, 128, 0, 0).is_shared(), false); /// } /// ``` pub fn is_shared(&self) -> bool { self.octets()[0] == 100 && (self.octets()[1] & 0b1100_0000 == 0b0100_0000) } /// Returns [`true`] if this address is part of `192.0.0.0/24`, which is reserved to /// IANA for IETF protocol assignments, as documented in [IETF RFC 6890]. /// /// Note that parts of this block are in use: /// /// - `192.0.0.8/32` is the "IPv4 dummy address" (see [IETF RFC 7600]) /// - `192.0.0.9/32` is the "Port Control Protocol Anycast" (see [IETF RFC 7723]) /// - `192.0.0.10/32` is used for NAT traversal (see [IETF RFC 8155]) /// /// [IETF RFC 6890]: https://tools.ietf.org/html/rfc6890 /// [IETF RFC 7600]: https://tools.ietf.org/html/rfc7600 /// [IETF RFC 7723]: https://tools.ietf.org/html/rfc7723 /// [IETF RFC 8155]: https://tools.ietf.org/html/rfc8155 /// [`true`]: ../../std/primitive.bool.html /// /// # Examples /// /// ``` /// #![feature(ip)] /// use std::net::Ipv4Addr; /// /// fn main() { ///     assert_eq!(Ipv4Addr::new(192, 0, 0, 0).is_ietf_protocol_assignment(), true); ///     assert_eq!(Ipv4Addr::new(192, 0, 0, 8).is_ietf_protocol_assignment(), true); ///     assert_eq!(Ipv4Addr::new(192, 0, 0, 9).is_ietf_protocol_assignment(), true); ///     assert_eq!(Ipv4Addr::new(192, 0, 0, 255).is_ietf_protocol_assignment(), true); ///     assert_eq!(Ipv4Addr::new(192, 0, 1, 0).is_ietf_protocol_assignment(), false); ///     assert_eq!(Ipv4Addr::new(191, 255, 255, 255).is_ietf_protocol_assignment(), false); /// } /// ``` pub fn is_ietf_protocol_assignment(&self) -> bool { self.octets()[0] == 192 && self.octets()[1] == 0 && self.octets()[2] == 0 } /// Returns [`true`] if this address part of the `198.18.0.0/15` range, which is reserved for /// network devices benchmarking. This range is defined in [IETF RFC 2544] as `192.18.0.0` /// through `198.19.255.255` but [errata 423] corrects it to `198.18.0.0/15`. /// /// [IETF RFC 1112]: https://tools.ietf.org/html/rfc1112 /// [errate 423]: https://www.rfc-editor.org/errata/eid423 /// [`true`]: ../../std/primitive.bool.html /// /// # Examples /// /// ``` /// #![feature(ip)] /// use std::net::Ipv4Addr; /// /// fn main() { ///     assert_eq!(Ipv4Addr::new(198, 17, 255, 255).is_benchmarking(), false); ///     assert_eq!(Ipv4Addr::new(198, 18, 0, 0).is_benchmarking(), true); ///     assert_eq!(Ipv4Addr::new(198, 19, 255, 255).is_benchmarking(), true); ///     assert_eq!(Ipv4Addr::new(198, 20, 0, 0).is_benchmarking(), false); /// } /// ``` pub fn is_benchmarking(&self) -> bool { self.octets()[0] == 198 && (self.octets()[1] & 0xfe) == 18 } /// Returns [`true`] if this address is reserved by IANA for future use. [IETF RFC 1112] /// defines the block of reserved addresses as `240.0.0.0/4`. This range normally includes the /// broadcast address `255.255.255.255`, but this implementation explicitely excludes it, since /// it is obviously not reserved for future use. /// /// [IETF RFC 1112]: https://tools.ietf.org/html/rfc1112 /// [`true`]: ../../std/primitive.bool.html /// /// # Examples /// /// ``` /// #![feature(ip)] /// use std::net::Ipv4Addr; /// /// fn main() { ///     assert_eq!(Ipv4Addr::new(240, 0, 0, 0).is_reserved(), true); ///     assert_eq!(Ipv4Addr::new(255, 255, 255, 254).is_reserved(), true); /// ///     assert_eq!(Ipv4Addr::new(239, 255, 255, 255).is_reserved(), false); ///     // The broadcast address is not considered as reserved for future use by this ///     // implementation ///     assert_eq!(Ipv4Addr::new(255, 255, 255, 255).is_reserved(), false); /// } /// ``` pub fn is_reserved(&self) -> bool { self.octets()[0] & 240 == 240 && !self.is_broadcast() </ins> } /// Returns [`true`] if this is a multicast address (224.0.0.0/4).


} } <del> /// Returns [`true`] if this is a unique local address (fc00::/7). </del> <ins> /// Returns [`true`] if this is a unique local address (`fc00::/7`). </ins> /// /// This property is defined in [IETF RFC 4193]. ///


(self.segments()[0] & 0xfe00) == 0xfc00 } <del> /// Returns [`true`] if the address is unicast and link-local (fe80::/10). </del> <ins> /// Returns [`true`] if the address is a unicast link-local address (`fe80::/64`). </ins> /// <del> /// This property is defined in [IETF RFC 4291]. </del> <ins> /// A common mis-conception is to think that "unicast link-local addresses start with /// `fe80::`", but the [IETF RFC 4291] actually defines a stricter format for these addresses: /// /// ```no_rust /// |   10     | /// |  bits    |         54 bits         |          64 bits           | /// +----------+-------------------------+----------------------------+ /// |1111111010|           0             |       interface ID         | /// +----------+-------------------------+----------------------------+ /// ``` /// /// This method validates the format defined in the RFC and won't recognize the following /// addresses such as `fe80:0:0:1::` or `fe81::` as unicast link-local addresses for example. /// If you need a less strict validation use [`is_unicast_link_local()`] instead. /// /// # Examples /// /// ``` /// #![feature(ip)] /// /// use std::net::Ipv6Addr; /// /// fn main() { ///     let ip = Ipv6Addr::new(0xfe80, 0, 0, 0, 0, 0, 0, 0); ///     assert!(ip.is_unicast_link_local_strict()); /// ///     let ip = Ipv6Addr::new(0xfe80, 0, 0, 0, 0xffff, 0xffff, 0xffff, 0xffff); ///     assert!(ip.is_unicast_link_local_strict()); /// ///     let ip = Ipv6Addr::new(0xfe80, 0, 0, 1, 0, 0, 0, 0); ///     assert!(!ip.is_unicast_link_local_strict()); ///     assert!(ip.is_unicast_link_local()); /// ///     let ip = Ipv6Addr::new(0xfe81, 0, 0, 0, 0, 0, 0, 0); ///     assert!(!ip.is_unicast_link_local_strict()); ///     assert!(ip.is_unicast_link_local()); /// } /// ``` /// /// # See also /// /// - [IETF RFC 4291 section 2.5.6] /// - [RFC 4291 errata 4406] /// - [`is_unicast_link_local()`] </ins> /// /// [IETF RFC 4291]: https://tools.ietf.org/html/rfc4291 <ins> /// [IETF RFC 4291 section 2.5.6]: https://tools.ietf.org/html/rfc4291#section-2.5.6 </ins> /// [`true`]: ../../std/primitive.bool.html <ins> /// [RFC 4291 errata 4406]: https://www.rfc-editor.org/errata/eid4406 /// [`is_unicast_link_local()`]: ../../std/net/struct.Ipv6Addr.html#method.is_unicast_link_local /// pub fn is_unicast_link_local_strict(&self) -> bool { (self.segments()[0] & 0xffff) == 0xfe80 && (self.segments()[1] & 0xffff) == 0 && (self.segments()[2] & 0xffff) == 0 && (self.segments()[3] & 0xffff) == 0 } /// Returns [`true`] if the address is a unicast link-local address (`fe80::/10`). /// /// This method returns [`true`] for addresses in the range reserved by [RFC 4291 section 2.4], /// i.e. addresses with the following format: /// /// ```no_rust /// |   10     | /// |  bits    |         54 bits         |          64 bits           | /// +----------+-------------------------+----------------------------+ /// |1111111010|    arbitratry value     |       interface ID         | /// +----------+-------------------------+----------------------------+ /// ``` /// /// As a result, this method consider addresses such as `fe80:0:0:1::` or `fe81::` to be /// unicast link-local addresses, whereas [`is_unicast_link_local_strict()`] does not. If you /// need a strict validation fully compliant with the RFC, use /// [`is_unicast_link_local_strict()`]. </ins> /// /// # Examples ///


/// use std::net::Ipv6Addr; /// /// fn main() { <del> ///     assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unicast_link_local(), ///                false); ///     assert_eq!(Ipv6Addr::new(0xfe8a, 0, 0, 0, 0, 0, 0, 0).is_unicast_link_local(), true); </del> <ins> ///     let ip = Ipv6Addr::new(0xfe80, 0, 0, 0, 0, 0, 0, 0); ///     assert!(ip.is_unicast_link_local()); /// ///     let ip = Ipv6Addr::new(0xfe80, 0, 0, 0, 0xffff, 0xffff, 0xffff, 0xffff); ///     assert!(ip.is_unicast_link_local()); /// ///     let ip = Ipv6Addr::new(0xfe80, 0, 0, 1, 0, 0, 0, 0); ///     assert!(ip.is_unicast_link_local()); ///     assert!(!ip.is_unicast_link_local_strict()); /// ///     let ip = Ipv6Addr::new(0xfe81, 0, 0, 0, 0, 0, 0, 0); ///     assert!(ip.is_unicast_link_local()); ///     assert!(!ip.is_unicast_link_local_strict()); </ins> /// } /// ``` <ins> /// /// # See also /// /// - [IETF RFC 4291 section 2.4] /// - [RFC 4291 errata 4406] /// /// [IETF RFC 4291 section 2.4]: https://tools.ietf.org/html/rfc4291#section-2.4 /// [`true`]: ../../std/primitive.bool.html /// [RFC 4291 errata 4406]: https://www.rfc-editor.org/errata/eid4406 /// [`is_unicast_link_local_strict()`]: ../../std/net/struct.Ipv6Addr.html#method.is_unicast_link_local_strict /// </ins> pub fn is_unicast_link_local(&self) -> bool { (self.segments()[0] & 0xffc0) == 0xfe80 } <del> /// Returns [`true`] if this is a deprecated unicast site-local address /// (fec0::/10). </del> <ins> /// Returns [`true`] if this is a deprecated unicast site-local address (fec0::/10). The /// unicast site-local address format is defined in [RFC 4291 section 2.5.7] as: /// /// ```no_rust /// |   10     | /// |  bits    |         54 bits         |         64 bits            | /// +----------+-------------------------+----------------------------+ /// |1111111011|        subnet ID        |       interface ID         | /// +----------+-------------------------+----------------------------+ /// ``` </ins> /// /// [`true`]: ../../std/primitive.bool.html <ins> /// [RFC 4291 section 2.5.7]: https://tools.ietf.org/html/rfc4291#section-2.5.7 </ins> /// /// # Examples ///


/// /// - the loopback address /// - the link-local addresses <del> /// - the (deprecated) site-local addresses </del> /// - unique local addresses /// - the unspecified address /// - the address range reserved for documentation /// <ins> /// This method returns [`true`] for site-local addresses as per [RFC 4291 section 2.5.7] /// /// ```no_rust /// The special behavior of [the site-local unicast] prefix defined in [RFC3513] must no longer /// be supported in new implementations (i.e., new implementations must treat this prefix as /// Global Unicast). /// ``` /// </ins> /// [`true`]: ../../std/primitive.bool.html <ins> /// [RFC 4291 section 2.5.7]: https://tools.ietf.org/html/rfc4291#section-2.5.7 </ins> /// /// # Examples ///


/// ``` pub fn is_unicast_global(&self) -> bool { !self.is_multicast() <del> && !self.is_loopback() && !self.is_unicast_link_local() && !self.is_unicast_site_local() && !self.is_unique_local() && !self.is_unspecified() && !self.is_documentation() </del> <ins> && !self.is_loopback() && !self.is_unicast_link_local() && !self.is_unique_local() && !self.is_unspecified() && !self.is_documentation() </ins> } /// Returns the address's multicast scope if the address is multicast.


<ins> // Regression test for issue #57611 // Ensures that we don't ICE // FIXME: This should compile, but it currently doesn't #![feature(trait_alias)] #![feature(type_alias_impl_trait)] trait Foo { type Bar: Baz<Self, Self>; fn bar(&self) -> Self::Bar; } struct X; impl Foo for X { type Bar = impl Baz<Self, Self>; //~ ERROR type mismatch in closure arguments //~^ ERROR type mismatch resolving fn bar(&self) -> Self::Bar { |x| x } } trait Baz<A, B> = Fn(&A) -> &B; fn main() {} </ins>


<ins> error[E0631]: type mismatch in closure arguments --> $DIR/issue-57611-trait-alias.rs:17:5 | LL |     type Bar = impl Baz<Self, Self>; |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected signature of `for<'r> fn(&'r X) -> _` ... LL |         |x| x |         ----- found signature of `fn(_) -> _` | = note: the return type of a function must have a statically known size error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/issue-57611-trait-alias.rs:21:9: 21:14] as std::ops::FnOnce<(&'r X,)>>::Output == &'r X` --> $DIR/issue-57611-trait-alias.rs:17:5 | LL |     type Bar = impl Baz<Self, Self>; |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter, found concrete lifetime | = note: the return type of a function must have a statically known size error: aborting due to 2 previous errors Some errors have detailed explanations: E0271, E0631. For more information about an error, try `rustc --explain E0271`. </ins>


<ins> // Regression test for issue #57807 - ensure // that we properly unify associated types within // a type alias impl trait // check-pass #![feature(type_alias_impl_trait)] trait Bar { type A; } impl Bar for () { type A = (); } trait Foo { type A; type B: Bar<A = Self::A>; fn foo() -> Self::B; } impl Foo for () { type A = (); type B = impl Bar<A = Self::A>; fn foo() -> Self::B { () } } fn main() {} </ins>


[[package]] name = "compiler_builtins" <del> version = "0.1.32" </del> <ins> version = "0.1.35" </ins> source = "registry+https://github.com/rust-lang/crates.io-index" <del> checksum = "7bc4ac2c824d2bfc612cba57708198547e9a26943af0632aff033e0693074d5c" </del> <ins> checksum = "e3fcd8aba10d17504c87ef12d4f62ef404c6a4703d16682a9eb5543e6cf24455" </ins> dependencies = [ "cc", "rustc-std-workspace-core",


panic_abort = { path = "../panic_abort" } core = { path = "../core" } libc = { version = "0.2.74", default-features = false, features = ['rustc-dep-of-std'] } <del> compiler_builtins = { version = "0.1.32" } </del> <ins> compiler_builtins = { version = "0.1.35" } </ins> profiler_builtins = { path = "../profiler_builtins", optional = true } unwind = { path = "../unwind" } hashbrown = { version = "0.8.1", default-features = false, features = ['rustc-dep-of-std'] }


<ins> // check-pass #![feature(existential_type)] existential type A: Iterator; fn def_a() -> A { 0..1 } pub fn use_a() { def_a().map(|x| x); } fn main() {} </ins>


} // walk type and init value <del> self.visit_ty(typ); if let Some(expr) = expr { self.visit_expr(expr); } </del> <ins> self.nest_tables(id, |v| { v.visit_ty(typ); if let Some(expr) = expr { v.visit_expr(expr); } }); </ins> } // FIXME tuple structs should generate tuple-specific data.


<ins> // compile-flags: -Zsave-analysis // Check that this doesn't ICE when processing associated const (field expr). pub fn f() { trait Trait {} impl Trait { const FLAG: u32 = bogus.field; //~ ERROR cannot find value `bogus` } } fn main() {} </ins>


<ins> error[E0425]: cannot find value `bogus` in this scope --> $DIR/issue-59134-0.rs:8:27 | LL |         const FLAG: u32 = bogus.field; |                           ^^^^^ not found in this scope error: aborting due to previous error For more information about this error, try `rustc --explain E0425`. </ins>


<ins> // compile-flags: -Zsave-analysis // Check that this doesn't ICE when processing associated const (type). fn func() { trait Trait { type MyType; const CONST: Self::MyType = bogus.field; //~ ERROR cannot find value `bogus` } } fn main() {} </ins>


<ins> error[E0425]: cannot find value `bogus` in this scope --> $DIR/issue-59134-1.rs:8:37 | LL |         const CONST: Self::MyType = bogus.field; |                                     ^^^^^ not found in this scope error: aborting due to previous error For more information about this error, try `rustc --explain E0425`. </ins>


<ins> // check-pass #![feature(impl_trait_in_bindings)] #![allow(incomplete_features)] struct A<'a>(&'a ()); trait Trait<T> {} impl<T> Trait<T> for () {} pub fn foo<'a>() { let _x: impl Trait<A<'a>> = (); } fn main() {} </ins>


<ins> #![feature(never_type, specialization)] #![allow(incomplete_features)] use std::iter::{self, Empty}; trait Trait { type Out: Iterator<Item = u32>; fn f(&self) -> Option<Self::Out>; } impl<T> Trait for T { default type Out = !; //~ ERROR: `!` is not an iterator default fn f(&self) -> Option<Self::Out> { None } } struct X; impl Trait for X { type Out = Empty<u32>; fn f(&self) -> Option<Self::Out> { Some(iter::empty()) } } fn f<T: Trait>(a: T) { if let Some(iter) = a.f() { println!("Some"); for x in iter { println!("x = {}", x); } } } pub fn main() { f(10); } </ins>


<ins> error[E0277]: `!` is not an iterator --> $DIR/issue-51506.rs:13:5 | LL |     type Out: Iterator<Item = u32>; |     ------------------------------- required by `Trait::Out` ... LL |     default type Out = !; |     ^^^^^^^^^^^^^^^^^^^^^ `!` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `!` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. </ins>


<ins> #![crate_type = "lib"] #![feature(specialization)] #![feature(unsize, coerce_unsized)] #![allow(incomplete_features)] use std::ops::CoerceUnsized; pub struct SmartassPtr<A: Smartass+?Sized>(A::Data); pub trait Smartass { type Data; type Data2: CoerceUnsized<*const [u8]>; } pub trait MaybeObjectSafe {} impl MaybeObjectSafe for () {} impl<T> Smartass for T { type Data = <Self as Smartass>::Data2; default type Data2 = (); //~^ ERROR: the trait bound `(): std::ops::CoerceUnsized<*const [u8]>` is not satisfied } impl Smartass for () { type Data2 = *const [u8; 1]; } impl Smartass for dyn MaybeObjectSafe { type Data = *const [u8]; type Data2 = *const [u8; 0]; } impl<U: Smartass+?Sized, T: Smartass+?Sized> CoerceUnsized<SmartassPtr<T>> for SmartassPtr<U> where <U as Smartass>::Data: std::ops::CoerceUnsized<<T as Smartass>::Data> {} pub fn conv(s: SmartassPtr<()>) -> SmartassPtr<dyn MaybeObjectSafe> { s } </ins>


<ins> error[E0277]: the trait bound `(): std::ops::CoerceUnsized<*const [u8]>` is not satisfied --> $DIR/issue-44861.rs:21:5 | LL |     type Data2: CoerceUnsized<*const [u8]>; |     --------------------------------------- required by `Smartass::Data2` ... LL |     default type Data2 = (); |     ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::CoerceUnsized<*const [u8]>` is not implemented for `()` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. </ins>


<ins> #![feature(specialization)] #![allow(incomplete_features)] struct MyStruct {} trait MyTrait { type MyType: Default; } impl MyTrait for i32 { default type MyType = MyStruct; //~^ ERROR: the trait bound `MyStruct: std::default::Default` is not satisfied } fn main() { let _x: <i32 as MyTrait>::MyType = <i32 as MyTrait>::MyType::default(); } </ins>


<ins> error[E0277]: the trait bound `MyStruct: std::default::Default` is not satisfied --> $DIR/issue-59435.rs:11:5 | LL |     type MyType: Default; |     --------------------- required by `MyTrait::MyType` ... LL |     default type MyType = MyStruct; |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `MyStruct` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. </ins>


per_local.insert(local); } } <del> cx.per_local[IsNotPromotable].insert(local); </del> <ins> cx.per_local[IsNotConst].insert(local); </ins> } LocalKind::Var if mode == Mode::Fn => {


} LocalKind::Temp if !temps[local].is_promotable() => { <del> cx.per_local[IsNotPromotable].insert(local); </del> <ins> cx.per_local[IsNotConst].insert(local); </ins> } _ => {}


} } <del> // Ensure the `IsNotPromotable` qualification is preserved. </del> <ins> // Ensure the `IsNotConst` qualification is preserved. </ins> // NOTE(eddyb) this is actually unnecessary right now, as // we never replace the local's qualif, but we might in // the future, and so it serves to catch changes that unset


// be replaced with calling `insert` to re-set the bit). if kind == LocalKind::Temp { if !self.temp_promotion_state[index].is_promotable() { <del> assert!(self.cx.per_local[IsNotPromotable].contains(index)); </del> <ins> assert!(self.cx.per_local[IsNotConst].contains(index)); </ins> } } }


<ins> // only-x86_64 #[cfg(target_arch = "x86")] use std::arch::x86::*; #[cfg(target_arch = "x86_64")] use std::arch::x86_64::*; unsafe fn pclmul(a: __m128i, b: __m128i) -> __m128i { let imm8 = 3; _mm_clmulepi64_si128(a, b, imm8) //~ ERROR argument 3 is required to be a constant } fn main() {} </ins>


<ins> error: argument 3 is required to be a constant --> $DIR/const_arg_local.rs:10:5 | LL |     _mm_clmulepi64_si128(a, b, imm8) |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error </ins>


<ins> // only-x86_64 #[cfg(target_arch = "x86")] use std::arch::x86::*; #[cfg(target_arch = "x86_64")] use std::arch::x86_64::*; unsafe fn pclmul(a: __m128i, b: __m128i) -> __m128i { _mm_clmulepi64_si128(a, b, *&mut 42) //~ ERROR argument 3 is required to be a constant } fn main() {} </ins>


<ins> error: argument 3 is required to be a constant --> $DIR/const_arg_promotable.rs:9:5 | LL |     _mm_clmulepi64_si128(a, b, *&mut 42) |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error </ins>


<ins> // only-x86_64 #[cfg(target_arch = "x86")] use std::arch::x86::*; #[cfg(target_arch = "x86_64")] use std::arch::x86_64::*; unsafe fn pclmul(a: __m128i, b: __m128i, imm8: i32) -> __m128i { _mm_clmulepi64_si128(a, b, imm8) //~ ERROR argument 3 is required to be a constant } fn main() {} </ins>


<ins> error: argument 3 is required to be a constant --> $DIR/const_arg_wrapper.rs:9:5 | LL |     _mm_clmulepi64_si128(a, b, imm8) |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error </ins>


<del> use errors::DiagnosticBuilder; </del> <ins> use errors::{Applicability, DiagnosticBuilder}; </ins> use syntax::ast::{self, *}; use syntax::source_map::Spanned; use syntax::ext::base::*; use syntax::ext::build::AstBuilder; use syntax::parse::token; <ins> use syntax::parse::parser::Parser; </ins> use syntax::print::pprust; use syntax::ptr::P; use syntax::symbol::Symbol;


return Err(err); } <del> Ok(Assert { cond_expr: parser.parse_expr()?, custom_message: if parser.eat(&token::Comma) { let ts = parser.parse_tokens(); if !ts.is_empty() { Some(ts) } else { None } } else { None }, }) </del> <ins> let cond_expr = parser.parse_expr()?; // Some crates use the `assert!` macro in the following form (note extra semicolon): // // assert!( //     my_function(); // ); // // Warn about semicolon and suggest removing it. Eventually, this should be turned into an // error. if parser.token == token::Semi { let mut err = cx.struct_span_warn(sp, "macro requires an expression as an argument"); err.span_suggestion( parser.span, "try removing semicolon", String::new(), Applicability::MaybeIncorrect ); err.note("this is going to be an error in the future"); err.emit(); parser.bump(); } // Some crates use the `assert!` macro in the following form (note missing comma before // message): // // assert!(true "error message"); // // Parse this as an actual message, and suggest inserting a comma. Eventually, this should be // turned into an error. let custom_message = if let token::Literal(token::Lit::Str_(_), _) = parser.token { let mut err = cx.struct_span_warn(parser.span, "unexpected string literal"); let comma_span = cx.source_map().next_point(parser.prev_span); err.span_suggestion_short( comma_span, "try adding a comma", ", ".to_string(), Applicability::MaybeIncorrect ); err.note("this is going to be an error in the future"); err.emit(); parse_custom_message(&mut parser) } else if parser.eat(&token::Comma) { parse_custom_message(&mut parser) } else { None }; if parser.token != token::Eof { parser.expect_one_of(&[], &[])?; unreachable!(); } Ok(Assert { cond_expr, custom_message }) } fn parse_custom_message<'a>(parser: &mut Parser<'a>) -> Option<TokenStream> { let ts = parser.parse_tokens(); if !ts.is_empty() { Some(ts) } else { None } </ins> }


<ins> // Ensure assert macro does not ignore trailing garbage. // // See https://github.com/rust-lang/rust/issues/60024 for details. fn main() { assert!(true some extra junk, "whatever"); //~^ ERROR expected one of assert!(true some extra junk); //~^ ERROR expected one of assert!(true, "whatever" blah); //~^ ERROR no rules expected assert!(true "whatever" blah); //~^ WARN unexpected string literal //~^^ ERROR no rules expected assert!(true;); //~^ WARN macro requires an expression assert!(false || true "error message"); //~^ WARN unexpected string literal } </ins>


<ins> error: expected one of `,`, `.`, `?`, or an operator, found `some` --> $DIR/assert-trailing-junk.rs:6:18 | LL |     assert!(true some extra junk, "whatever"); |                  ^^^^ expected one of `,`, `.`, `?`, or an operator here error: expected one of `,`, `.`, `?`, or an operator, found `some` --> $DIR/assert-trailing-junk.rs:9:18 | LL |     assert!(true some extra junk); |                  ^^^^ expected one of `,`, `.`, `?`, or an operator here error: no rules expected the token `blah` --> $DIR/assert-trailing-junk.rs:12:30 | LL |     assert!(true, "whatever" blah); |                             -^^^^ no rules expected this token in macro call |                             | |                             help: missing comma here warning: unexpected string literal --> $DIR/assert-trailing-junk.rs:15:18 | LL |     assert!(true "whatever" blah); |                 -^^^^^^^^^^ |                 | |                 help: try adding a comma | = note: this is going to be an error in the future error: no rules expected the token `blah` --> $DIR/assert-trailing-junk.rs:15:29 | LL |     assert!(true "whatever" blah); |                            -^^^^ no rules expected this token in macro call |                            | |                            help: missing comma here warning: macro requires an expression as an argument --> $DIR/assert-trailing-junk.rs:19:5 | LL |     assert!(true;); |     ^^^^^^^^^^^^-^^ |                 | |                 help: try removing semicolon | = note: this is going to be an error in the future warning: unexpected string literal --> $DIR/assert-trailing-junk.rs:22:27 | LL |     assert!(false || true "error message"); |                          -^^^^^^^^^^^^^^^ |                          | |                          help: try adding a comma | = note: this is going to be an error in the future error: aborting due to 4 previous errors </ins>


let predicates_of = tcx.predicates_of(def_id); debug!("instantiate_opaque_types: predicates={:#?}", predicates_of,); let bounds = predicates_of.instantiate(tcx, substs); <ins> let param_env = tcx.param_env(def_id); let InferOk { value: bounds, obligations } = infcx.partially_normalize_associated_types_in(span, self.body_id, param_env, &bounds); self.obligations.extend(obligations); </ins> debug!("instantiate_opaque_types: bounds={:?}", bounds); let required_region_bounds = tcx.required_region_bounds(ty, bounds.predicates.clone());


&declared_ret_ty, decl.output.span(), ); <ins> debug!("check_fn: declared_ret_ty: {}, revealed_ret_ty: {}", declared_ret_ty, revealed_ret_ty); </ins> fcx.ret_coercion = Some(RefCell::new(CoerceMany::new(revealed_ret_ty))); fn_sig = fcx.tcx.mk_fn_sig( fn_sig.inputs().iter().cloned(),


<ins> // check-pass // edition:2018 #![feature(async_await)] // See issue 60414 trait Trait { type Assoc; } async fn foo<T: Trait<Assoc=()>>() -> T::Assoc { () } fn main() {} </ins>


<ins> // compile-fail // edition:2018 #![feature(async_await)] #![feature(existential_type)] #![feature(impl_trait_in_bindings)] //~^ WARNING the feature `impl_trait_in_bindings` is incomplete // See issue 60414 ///////////////////////////////////////////// // Reduction to `impl Trait` struct Foo<T>(T); trait FooLike { type Output; } impl<T> FooLike for Foo<T> { type Output = T; } mod impl_trait { use super::*; trait Trait { type Assoc; } /// `T::Assoc` can't be normalized any further here. fn foo_fail<T: Trait>() -> impl FooLike<Output=T::Assoc> { //~^ ERROR: type mismatch Foo(()) } } ///////////////////////////////////////////// // Same with lifetimes in the trait mod lifetimes { use super::*; trait Trait<'a> { type Assoc; } /// Missing bound constraining `Assoc`, `T::Assoc` can't be normalized further. fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output=T::Assoc> { //~^ ERROR: type mismatch Foo(()) } } fn main() {} </ins>


<ins> warning: the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash --> $DIR/bound-normalization-fail.rs:6:12 | LL | #![feature(impl_trait_in_bindings)] |            ^^^^^^^^^^^^^^^^^^^^^^ error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as impl_trait::Trait>::Assoc` --> $DIR/bound-normalization-fail.rs:30:32 | LL |     fn foo_fail<T: Trait>() -> impl FooLike<Output=T::Assoc> { |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found associated type | = note: expected type `()` found type `<T as impl_trait::Trait>::Assoc` = note: the return type of a function must have a statically known size error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'static>>::Assoc` --> $DIR/bound-normalization-fail.rs:47:41 | LL |     fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output=T::Assoc> { |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found associated type | = note: expected type `()` found type `<T as lifetimes::Trait<'static>>::Assoc` = note: the return type of a function must have a statically known size error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0271`. </ins>


<ins> // check-pass // edition:2018 #![feature(async_await)] #![feature(existential_type)] #![feature(impl_trait_in_bindings)] //~^ WARNING the feature `impl_trait_in_bindings` is incomplete // See issue 60414 ///////////////////////////////////////////// // Reduction to `impl Trait` struct Foo<T>(T); trait FooLike { type Output; } impl<T> FooLike for Foo<T> { type Output = T; } mod impl_trait { use super::*; trait Trait { type Assoc; } /// `T::Assoc` should be normalized to `()` here. fn foo_pass<T: Trait<Assoc=()>>() -> impl FooLike<Output=T::Assoc> { Foo(()) } } ///////////////////////////////////////////// // Same with lifetimes in the trait mod lifetimes { use super::*; trait Trait<'a> { type Assoc; } /// Like above. /// /// FIXME(#51525) -- the shorter notation `T::Assoc` winds up referencing `'static` here fn foo2_pass<'a, T: Trait<'a, Assoc=()> + 'a>( ) -> impl FooLike<Output=<T as Trait<'a>>::Assoc> + 'a { Foo(()) } /// Normalization to type containing bound region. /// /// FIXME(#51525) -- the shorter notation `T::Assoc` winds up referencing `'static` here fn foo2_pass2<'a, T: Trait<'a, Assoc=&'a ()> + 'a>( ) -> impl FooLike<Output=<T as Trait<'a>>::Assoc> + 'a { Foo(&()) } } ///////////////////////////////////////////// // Reduction using `impl Trait` in bindings mod impl_trait_in_bindings { struct Foo; trait FooLike { type Output; } impl FooLike for Foo { type Output = u32; } trait Trait { type Assoc; } fn foo<T: Trait<Assoc=u32>>() { let _: impl FooLike<Output=T::Assoc> = Foo; } } ///////////////////////////////////////////// // The same applied to `existential type`s mod existential_types { trait Implemented { type Assoc; } impl<T> Implemented for T { type Assoc = u8; } trait Trait { type Out; } impl Trait for () { type Out = u8; } existential type Ex: Trait<Out = <() as Implemented>::Assoc>; fn define() -> Ex { () } } fn main() {} </ins>


<ins> warning: the feature `impl_trait_in_bindings` is incomplete and may cause the compiler to crash --> $DIR/bound-normalization-pass.rs:6:12 | LL | #![feature(impl_trait_in_bindings)] |            ^^^^^^^^^^^^^^^^^^^^^^ </ins>


visit::walk_generics(this, generics); // Walk the generated arguments for the `async fn`. <del> for a in arguments { </del> <ins> for (i, a) in arguments.iter().enumerate() { </ins> use visit::Visitor; if let Some(arg) = &a.arg { this.visit_ty(&arg.ty); <ins> } else { this.visit_ty(&decl.inputs[i].ty); </ins> } }


<ins> // compile-pass // edition:2018 #![feature(async_await)] // This is a regression test to ensure that simple bindings (where replacement arguments aren't // created during async fn lowering) that have their DefId used during HIR lowering (such as impl // trait) are visited during def collection and thus have a DefId. async fn foo(ws: impl Iterator<Item = ()>) {} fn main() {} </ins>


if !fail { return None; } <del> bug!("unexpected const parent path def {:?}", x); </del> <ins> tcx.sess.delay_span_bug( DUMMY_SP, &format!( "unexpected const parent path def {:?}", x ), ); tcx.types.err </ins> } } }


if !fail { return None; } <del> bug!("unexpected const parent path {:?}", x); </del> <ins> tcx.sess.delay_span_bug( DUMMY_SP, &format!( "unexpected const parent path {:?}", x ), ); tcx.types.err </ins> } } }


if !fail { return None; } <del> bug!("unexpected const parent in type_of_def_id(): {:?}", x); </del> <ins> tcx.sess.delay_span_bug( DUMMY_SP, &format!( "unexpected const parent in type_of_def_id(): {:?}", x ), ); tcx.types.err </ins> } } }


<ins> #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash // We should probably be able to infer the types here. However, this test is checking that we don't // get an ICE in this case. It may be modified later to not be an error. struct Foo<const NUM_BYTES: usize>(pub [u8; NUM_BYTES]); fn main() { let _ = Foo::<3>([1, 2, 3]); //~ ERROR type annotations needed } </ins>


<ins> warning: the feature `const_generics` is incomplete and may cause the compiler to crash --> $DIR/cannot-infer-type-for-const-param.rs:1:12 | LL | #![feature(const_generics)] |            ^^^^^^^^^^^^^^ error[E0282]: type annotations needed --> $DIR/cannot-infer-type-for-const-param.rs:10:19 | LL |     let _ = Foo::<3>([1, 2, 3]); |                   ^ cannot infer type for `{integer}` error: aborting due to previous error For more information about this error, try `rustc --explain E0282`. </ins>


<ins> use std::convert::TryInto; struct S; fn main() { let _: u32 = 5i32.try_into::<32>().unwrap(); //~ ERROR wrong number of const arguments S.f::<0>(); //~ ERROR no method named `f` S::<0>; //~ ERROR  wrong number of const arguments } </ins>


<ins> error[E0107]: wrong number of const arguments: expected 0, found 1 --> $DIR/invalid-const-arg-for-type-param.rs:6:34 | LL |     let _: u32 = 5i32.try_into::<32>().unwrap(); |                                  ^^ unexpected const argument error[E0599]: no method named `f` found for type `S` in the current scope --> $DIR/invalid-const-arg-for-type-param.rs:7:7 | LL | struct S; | --------- method `f` not found for this ... LL |     S.f::<0>(); |       ^ error[E0107]: wrong number of const arguments: expected 0, found 1 --> $DIR/invalid-const-arg-for-type-param.rs:8:9 | LL |     S::<0>; |         ^ unexpected const argument error: aborting due to 3 previous errors Some errors have detailed explanations: E0107, E0599. For more information about an error, try `rustc --explain E0107`. </ins>


/// Given that a [`panic!`] will call `drop` as it unwinds, any [`panic!`] /// in a `drop` implementation will likely abort. /// <ins> /// Note that even if this panics, the value is considered to be dropped; /// you must not cause `drop` to be called again. This is normally automatically /// handled by the compiler, but when using unsafe code, can sometimes occur /// unintentionally, particularly when using [`std::ptr::drop_in_place`]. /// </ins> /// [E0040]: ../../error-index.html#E0040 /// [`panic!`]: ../macro.panic.html /// [`std::mem::drop`]: ../../std/mem/fn.drop.html <ins> /// [`std::ptr::drop_in_place`]: ../../std/ptr/fn.drop_in_place.html </ins> #[stable(feature = "rust1", since = "1.0.0")] fn drop(&mut self); }


/// extract function takes three arguments: a string slice containing the source, an index in /// the slice for the beginning of the span and an index in the slice for the end of the span. fn span_to_source<F>(&self, sp: Span, extract_source: F) -> Result<String, SpanSnippetError> <del> where F: Fn(&str, usize, usize) -> String </del> <ins> where F: Fn(&str, usize, usize) -> Result<String, SpanSnippetError> </ins> { if sp.lo() > sp.hi() { return Err(SpanSnippetError::IllFormedSpan(sp));


} if let Some(ref src) = local_begin.sf.src { <del> return Ok(extract_source(src, start_index, end_index)); </del> <ins> return extract_source(src, start_index, end_index); </ins> } else if let Some(src) = local_begin.sf.external_src.borrow().get_source() { <del> return Ok(extract_source(src, start_index, end_index)); </del> <ins> return extract_source(src, start_index, end_index); </ins> } else { return Err(SpanSnippetError::SourceNotAvailable { filename: local_begin.sf.name.clone()