<ins> error: to use a constant of type `Vec<u8>` in a pattern, `Vec<u8>` must be annotated with `#[derive(PartialEq, Eq)]` --> $DIR/issue-115599.rs:5:12 | LL |     if let CONST_STRING = empty_str {} |            ^^^^^^^^^^^^ | = note: the traits must be derived, manual `impl`s are not sufficient = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: aborting due to previous error </ins>


/// Takes a path to a source file and cleans the path to it. This canonicalizes /// things like ".." to components which preserve the "top down" hierarchy of a <del> /// static HTML tree. </del> <ins> /// static HTML tree. Each component in the cleaned path will be passed as an /// argument to `f`. The very last component of the path (ie the file name) will /// be passed to `f` if `keep_filename` is true, and ignored otherwise. </ins> // FIXME (#9639): The closure should deal with &[u8] instead of &str // FIXME (#9639): This is too conservative, rejecting non-UTF-8 paths <del> fn clean_srcpath<F>(src_root: &Path, p: &Path, mut f: F) where </del> <ins> fn clean_srcpath<F>(src_root: &Path, p: &Path, keep_filename: bool, mut f: F) where </ins> F: FnMut(&str), { // make it relative, if possible let p = p.relative_from(src_root).unwrap_or(p); <del> for c in p.iter().map(|x| x.to_str().unwrap()) { </del> <ins> let mut iter = p.iter().map(|x| x.to_str().unwrap()).peekable(); while let Some(c) = iter.next() { if !keep_filename && iter.peek().is_none() { break; } </ins> if ".." == c { f("up"); } else {


pub use reexports::foo; // @has 'foo/outer/inner/fn.foo_crate.html' '//pre[@class="rust item-decl"]' 'pub(crate) fn foo_crate()' pub(crate) use reexports::foo_crate; <del> // @has 'foo/outer/inner/fn.foo_super.html' '//pre[@class="rust item-decl"]' 'pub(in outer) fn foo_super( )' </del> <ins> // @has 'foo/outer/inner/fn.foo_super.html' '//pre[@class="rust item-decl"]' 'pub(in outer) fn foo_super()' </ins> pub(super) use::reexports::foo_super; // @!has 'foo/outer/inner/fn.foo_self.html' pub(self) use reexports::foo_self;


self.suggest_cloning(err, ty, expr, None, Some(move_spans)); } } <del> if let Some(pat) = finder.pat { </del> <ins> self.suggest_ref_for_dbg_args(expr, place, move_span, err); // it's useless to suggest inserting `ref` when the span don't comes from local code if let Some(pat) = finder.pat && !move_span.is_dummy() && !self.infcx.tcx.sess.source_map().is_imported(move_span) { </ins> *in_pattern = true; let mut sugg = vec![(pat.span.shrink_to_lo(), "ref ".to_string())]; if let Some(pat) = finder.parent_pat {


match outlives_bound { OutlivesBound::RegionSubRegion(r1, r2) => { <ins> // `where Type:` is lowered to `where Type: 'empty` so that // we check `Type` is well formed, but there's no use for // this bound here. if let ty::ReEmpty = r1 { return; } </ins> // The bound says that `r1 <= r2`; we store `r2: r1`. let r1 = self.universal_regions.to_region_vid(r1); let r2 = self.universal_regions.to_region_vid(r2);


} /// `parent_module` refers to the parent of the re-export, not the original item <del> fn merge_attrs( </del> <ins> pub(crate) fn merge_attrs( </ins> cx: &mut DocContext<'_>, parent_module: Option<DefId>, old_attrs: Attrs<'_>,


<ins> // Nested impl-traits can impose different member constraints on the same region variable. // check-pass trait Cap<'a> {} impl<T> Cap<'_> for T {} // Assuming the hidden type is `[&'_#15r u8; 1]`, we have two distinct member constraints: // - '_#15r member ['static, 'a, 'b] // from outer impl-trait // - '_#15r member ['static, 'a]     // from inner impl-trait // To satisfy both we can only choose 'a. fn pass_early_bound<'s, 'a, 'b>(a: &'s u8) -> impl IntoIterator<Item = impl Cap<'a>> + Cap<'b> where 's: 'a, 's: 'b, { [a] } // Same as the above but with late-bound regions. fn pass_late_bound<'s, 'a, 'b>( a: &'s u8, _: &'a &'s u8, _: &'b &'s u8, ) -> impl IntoIterator<Item = impl Cap<'a>> + Cap<'b> { [a] } fn main() {} </ins>


.chain(indeterminate_imports.iter().map(|i| (true, i))) { let unresolved_import_error = self.finalize_import(*import); // If this import is unresolved then create a dummy import // resolution for it so that later resolve stages won't complain. self.import_dummy_binding(*import, is_indeterminate);


<ins> // Documents that Rust currently does not permit the coercion &mut &mut T -> *mut *mut T // Making this compile was a feature request in rust-lang/rust#34117 but this is currently // "working as intended". Allowing "deep pointer coercion" seems footgun-prone, and would // require proceeding carefully. use std::ops::{Deref, DerefMut}; struct Foo(i32); struct SmartPtr<T>(*mut T); impl<T> SmartPtr<T> { fn get_addr(&mut self) -> &mut *mut T { &mut self.0 } } impl<T> Deref for SmartPtr<T> { type Target = T; fn deref(&self) -> &T { unsafe { &*self.0 } } } impl<T> DerefMut for SmartPtr<T> { fn deref_mut(&mut self) -> &mut T { unsafe { &mut *self.0 } } } /// Puts a Foo into the pointer provided by the caller fn make_foo(_: *mut *mut Foo) { unimplemented!() } fn main() { let mut result: SmartPtr<Foo> = SmartPtr(std::ptr::null_mut()); make_foo(&mut &mut *result); //~ mismatched types //~^ expected `*mut *mut Foo`, found `&mut &mut Foo` make_foo(out(&mut result)); // works, but makes one wonder why above coercion cannot happen } fn out<T>(ptr: &mut SmartPtr<T>) -> &mut *mut T { ptr.get_addr() } </ins>


// handled by the lint emitting logic above. } None => { <del> // This is an 'unmarked' API, which should not exist // in the standard library. if self.sess.features.borrow().unmarked_api { self.sess.struct_span_warn(span, "use of unmarked library feature") .span_note(span, "this is either a bug in the library you are  using or a bug in the compiler - please  report it in both places") .emit() } else { self.sess.struct_span_err(span, "use of unmarked library feature") .span_note(span, "this is either a bug in the library you are  using or a bug in the compiler - please  report it in both places") .span_note(span, "use #![feature(unmarked_api)] in the  crate attributes to override this") .emit() } </del> <ins> span_bug!(span, "encountered unmarked API"); </ins> } } }


<ins> error: unexpected `...` --> $DIR/issue-70388-recover-dotdotdot-rest-pat.rs:4:13 | LL |     let Foo(...) = Foo(0); |             ^^^ |             | |             not a valid pattern |             help: for a rest pattern, use `..` instead of `...` error: unexpected `...` --> $DIR/issue-70388-recover-dotdotdot-rest-pat.rs:5:13 | LL |     let [_, ..., _] = [0, 1]; |             ^^^ |             | |             not a valid pattern |             help: for a rest pattern, use `..` instead of `...` error[E0308]: mismatched types --> $DIR/issue-70388-recover-dotdotdot-rest-pat.rs:6:33 | LL |     let _recovery_witness: () = 0; |                            --   ^ expected `()`, found integer |                            | |                            expected due to this error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0308`. </ins>


#![feature(core_private_bignum)] #![feature(core_private_diy_float)] #![feature(dec2flt)] <del> #![feature(div_duration)] </del> #![feature(duration_abs_diff)] #![feature(duration_consts_float)] #![feature(duration_constants)]


let mut colon_span = None; let bounds = if self.eat(&token::Colon) { colon_span = Some(self.prev_token.span); <ins> // recover from `impl Trait` in type param bound if self.token.is_keyword(kw::Impl) { let impl_span = self.token.span; let snapshot = self.create_snapshot_for_diagnostic(); match self.parse_ty() { Ok(p) => { if let TyKind::ImplTrait(_, bounds) = &(*p).kind { let span = impl_span.to(self.token.span.shrink_to_lo()); let mut err = self.struct_span_err( span, "expected trait bound, found `impl Trait` type", ); err.span_label(span, "not a trait"); if let [bound, ..] = &bounds[..] { err.span_suggestion_verbose( impl_span.until(bound.span()), "use the trait bounds directly", String::new(), Applicability::MachineApplicable, ); } err.emit(); return Err(err); } } Err(err) => { err.cancel(); } } self.restore_snapshot(snapshot); } </ins> self.parse_generic_bounds(colon_span)? } else { Vec::new() }; let default = if self.eat(&token::Eq) { Some(self.parse_ty()?) } else { None }; Ok(GenericParam { ident, id: ast::DUMMY_NODE_ID,


<ins> error[E0433]: failed to resolve: use of undeclared crate or module `n` --> $DIR/issue-120856.rs:1:37 | LL | pub type Archived<T> = <m::Alias as n::Trait>::Archived; |                                     ^ |                                     | |                                     use of undeclared crate or module `n` |                                     help: a trait with a similar name exists: `Fn` error[E0433]: failed to resolve: use of undeclared crate or module `m` --> $DIR/issue-120856.rs:1:25 | LL | pub type Archived<T> = <m::Alias as n::Trait>::Archived; |                         ^ |                         | |                         use of undeclared crate or module `m` |                         help: a type parameter with a similar name exists: `T` error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0433`. </ins>


<ins> fn main() { let a_longer_variable_name = 1; println!("{}", a_variable_longer_name); //~ ERROR E0425 } </ins>


<ins> const CONST_STRING: String = String::new(); fn main() { let empty_str = String::from(""); if let CONST_STRING = empty_str {} //~^ ERROR to use a constant of type `Vec<u8>` in a pattern, `Vec<u8>` must be annotated with `#[derive(PartialEq, Eq)]` } </ins>


<ins> // Regression test of #86483. #![feature(generic_associated_types)] #![allow(incomplete_features)] pub trait IceIce<T> //~ ERROR: the parameter type `T` may not live long enough where for<'a> T: 'a, { type Ice<'v>: IntoIterator<Item = &'v T>; //~^ ERROR: the parameter type `T` may not live long enough //~| ERROR: the parameter type `T` may not live long enough } fn main() {} </ins>


<ins> // compile-flags: -O // run-pass // Regression test for https://github.com/rust-lang/rust/issues/118328 #![allow(unused_assignments)] struct SizeOfConst<T>(std::marker::PhantomData<T>); impl<T> SizeOfConst<T> { const SIZE: usize = std::mem::size_of::<T>(); } fn size_of<T>() -> usize { let mut a = 0; a = SizeOfConst::<T>::SIZE; a } fn main() { assert_eq!(size_of::<u32>(), std::mem::size_of::<u32>()); } </ins>


// to accidentally sneak into our dependency graph, in order to ensure we keep our CI times // under control. "cargo", <del> "rustc-ap-rustc_ast", </del> ]; /// Dependency checks.


F: FnOnce(Block<'blk, 'tcx>, ValueRef, Ty<'tcx>) -> Block<'blk, 'tcx>, { let _icx = push_ctxt("tvec::iter_vec_loop"); <del> let fcx = bcx.fcx; </del> <ins> if bcx.unreachable.get() { return bcx; } let fcx = bcx.fcx; </ins> let loop_bcx = fcx.new_temp_block("expr_repeat"); let next_bcx = fcx.new_temp_block("expr_repeat: next");


<ins> error: struct `T9` is never constructed --> $DIR/unconstructible-pub-struct.rs:30:12 | LL | pub struct T9<X> { |            ^^ | note: the lint level is defined here --> $DIR/unconstructible-pub-struct.rs:2:9 | LL | #![deny(dead_code)] |         ^^^^^^^^^ error: aborting due to 1 previous error </ins>


let parse_only = matches.opt_present("parse-only"); let no_trans = matches.opt_present("no-trans"); let no_analysis = matches.opt_present("no-analysis"); <ins> let no_rpath = matches.opt_present("no-rpath"); </ins> let lint_levels = [lint::allow, lint::warn, lint::deny, lint::forbid];


Note that the `target_env = "p1"` condition first appeared in Rust 1.80. Prior to Rust 1.80 the `target_env` condition was not set. <ins> ## Enabled WebAssembly features The default set of WebAssembly features enabled for compilation is currently the same as [`wasm32-unknown-unknown`](./wasm32-unknown-unknown.md). See the documentation there for more information. </ins>


/// ``` /// /// ```rust <del> /// #![feature(fmt_as_str)] /// </del> /// assert_eq!(format_args!("hello").as_str(), Some("hello")); /// assert_eq!(format_args!("").as_str(), Some("")); /// assert_eq!(format_args!("{}", 1).as_str(), None); /// ``` <del> #[unstable(feature = "fmt_as_str", issue = "74442")] </del> <ins> #[stable(feature = "fmt_as_str", since = "1.52.0")] </ins> #[inline] pub fn as_str(&self) -> Option<&'static str> { match (self.pieces, self.args) {


write!(f, "{}: ", input.name)?; input.type_.print(cx).fmt(f)?; } <ins> match (line_wrapping_indent, last_input_index) { (_, None) => (), (None, Some(last_i)) if i != last_i => write!(f, ", ")?, (None, Some(_)) => (), (Some(n), Some(last_i)) if i != last_i => write!(f, ",n{}", Indent(n + 4))?, (Some(_), Some(_)) => write!(f, ",n")?, } </ins> } if self.c_variadic { match line_wrapping_indent { None => write!(f, ", ...")?, <del> Some(n) => write!(f, "n{}...", Indent(n + 4))?, </del> <ins> Some(n) => write!(f, "{}...n", Indent(n + 4))?, </ins> }; } match line_wrapping_indent { None => write!(f, ")")?, <del> Some(n) => write!(f, "n{})", Indent(n))?, </del> <ins> Some(n) => write!(f, "{})", Indent(n))?, </ins> }; self.print_output(cx).fmt(f)


#![feature(const_float_bits_conv)] #![feature(const_float_classify)] <ins> #![feature(f16)] #![feature(f128)] </ins> #![allow(unused_macro_rules)] // Don't promote const fn nop<T>(x: T) -> T { x }


<ins> error: constant expression depends on a generic parameter --> $DIR/issue-50439.rs:25:22 | LL |         let _ = [(); 0 - !!(<Bears<T> as ReflectDrop>::REFLECT_DROP) as usize]; |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this may fail depending on what value the parameter takes error: aborting due to previous error </ins>


use crate::cmp; use crate::io::{self, Initializer, IoSlice, IoSliceMut, Read}; use crate::mem; <del> use crate::sync::atomic::{AtomicBool, Ordering}; </del> use crate::sys::cvt; use crate::sys_common::AsInner;


A(i32), B(i32), } <del> // CHECK: %Enum4 = type { [2 x i32] } </del> <ins> // CHECK: %Enum4 = type { [0 x i32], i32, [1 x i32] } // CHECK: %"Enum4::A" = type { [1 x i32], i32, [0 x i32] } </ins> pub enum Enum64 { A(Align64), B(i32), } <del> // CHECK: %Enum64 = type { [16 x i64] } </del> <ins> // CHECK: %Enum64 = type { [0 x i32], i32, [31 x i32] } </ins> // CHECK: %"Enum64::A" = type { [8 x i64], %Align64, [0 x i64] } // CHECK-LABEL: @align64


}, ); <del> // Construct the list of in-scope lifetime parameters for async lowering. // We include all lifetime parameters, either named or "Fresh". // The order of those parameters does not matter, as long as it is // deterministic. if let Some((async_node_id, _)) = async_node_id { let mut extra_lifetime_params = this .r .extra_lifetime_params_map .get(&fn_id) .cloned() .unwrap_or_default(); for rib in this.lifetime_ribs.iter().rev() { extra_lifetime_params.extend( rib.bindings .iter() .map(|(&ident, &(node_id, res))| (ident, node_id, res)), ); match rib.kind { LifetimeRibKind::Item => break, LifetimeRibKind::AnonymousCreateParameter { binder, .. } => { if let Some(earlier_fresh) = this.r.extra_lifetime_params_map.get(&binder) { extra_lifetime_params.extend(earlier_fresh); } } _ => {} } } this.r .extra_lifetime_params_map .insert(async_node_id, extra_lifetime_params); } </del> <ins> this.record_lifetime_params_for_async(fn_id, async_node_id); </ins> if let Some(body) = body { // Ignore errors in function bodies if this is rustdoc


self.truncate(0) } <del> /// Returns the number of elements in the vector. </del> <ins> /// Returns the number of elements in the vector, also referred to /// as its 'length'. </ins> /// /// # Examples ///


<ins> fn main() { transmute(); // does not ICE } extern "rust-intrinsic" fn transmute() {} //~^ ERROR intrinsic has wrong number of type parameters: found 0, expected 2 //~| ERROR intrinsics are subject to change //~| ERROR intrinsic must be in `extern "rust-intrinsic" { ... }` block </ins>


// Types of fields (other than the last) in a struct must be sized. FieldSized, <ins> // Constant expressions must be sized. ConstSized, </ins> // static items must have `Sync` type SharedStatic,


pub fn list_file_metadata(os: Os, path: &Path, out: &mut io::Writer) -> io::IoResult<()> { match get_metadata_section(os, path) { <del> Some(bytes) => decoder::list_crate_metadata(bytes.as_slice(), out), None => write!(out, "could not find metadata in {}.n", path.display()) </del> <ins> Some(bytes) => decoder::list_crate_metadata(bytes.as_slice(), out), None => { write!(out, "could not find metadata in {}.n", path.display()) } </ins> } }


# is a separate choice from whether to pass `-g` when building the # compiler and standard library themselves. CTEST_RUSTC_FLAGS := $$(subst -g,,$$(CTEST_RUSTC_FLAGS)) <ins> CTEST_RUSTC_FLAGS := $$(subst -Cdebuginfo=1,,$$(CTEST_RUSTC_FLAGS)) </ins> ifdef CFG_ENABLE_DEBUGINFO_TESTS CTEST_RUSTC_FLAGS += -g endif


<ins> --- name: Documentation problem about: Create a report for a documentation problem. labels: A-docs --- <!-- Thank you for finding a documentation problem! 📚 Documentation problems might be grammatical issues, typos, or unclear wording, please provide details regarding the documentation including where it is present. --> ### Location ### Summary </ins>


<ins> error: lifetime may not live long enough --> $DIR/account-for-lifetimes-in-closure-suggestion.rs:13:22 | LL |     Thing.enter_scope(|ctx| { |                        --- |                        | |                        has type `TwoThings<'_, '1>` |                        has type `TwoThings<'2, '_>` LL |         SameLifetime(ctx); |                      ^^^ this usage requires that `'1` must outlive `'2` | = note: requirement occurs because of the type `TwoThings<'_, '_>`, which makes the generic argument `'_` invariant = note: the struct `TwoThings<'a, 'b>` is invariant over the parameter `'a` = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance error: aborting due to 1 previous error </ins>


<ins> // Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // compile-flags: -D warnings -D unknown-lints #![allow(unknown_lints)] #![allow(random_lint_name)] fn main() {} </ins>


#[inline] fn plain_summary_line(s: Option<&str>) -> String { <del> let md = markdown::plain_summary_line(s.unwrap_or("")); shorter(Some(&md)).replace("n", " ") </del> <ins> let line = shorter(s).replace("n", " "); markdown::plain_summary_line(&line[..]) </ins> } fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {


}; debug!("make_shim({:?}) = untransformed {:?}", instance, result); <del> pm::run_passes( </del> <ins> // We don't validate MIR here because the shims may generate code that's // only valid in a reveal-all param-env. However, since we do initial // validation with the MirBuilt phase, which uses a user-facing param-env. // This causes validation errors when TAITs are involved. pm::run_passes_no_validate( </ins> tcx, &mut result, &[


| LL |     opaque!; |           + <ins> help: a unit struct with a similar name exists | LL |     Opaque; |     ~~~~~~ </ins> error: aborting due to 3 previous errors


} } } else if let &Safety::Unsafe(span) = safety { <del> this.dcx().emit_err(errors::UnsafeItem { span, kind: "extern block" }); </del> <ins> let mut diag = this .dcx() .create_err(errors::UnsafeItem { span, kind: "extern block" }); rustc_session::parse::add_feature_diagnostics( &mut diag, self.session, sym::unsafe_extern_blocks, ); diag.emit(); </ins> } if abi.is_none() {


<ins> // Regression test for <https://github.com/rust-lang/rust/issues/98658> #![no_std] // @has blanket_impls.json // @has - "$.index[*][?(@.name=='Error')].kind" "assoc_type" // @has - "$.index[*][?(@.name=='Error')].inner.default.kind" "resolved_path" // @has - "$.index[*][?(@.name=='Error')].inner.default.inner.name" "Infallible" pub struct ForBlanketTryFromImpl; </ins>


<del> Subproject commit 3bf51f591f7ffdd45f51cd1d42a4002482af2bd5 </del> <ins> Subproject commit c388361cc2db82568d5e90fefea864f0af8d35e9 </ins>


// build-fail <ins> // revisions: normal mir-opt // [mir-opt]compile-flags: -Zmir-opt-level=4 </ins> trait C { const BOO: usize;


<del> Subproject commit 412fb00b37afb6b7f7fa96a35f2315c7e640b916 </del> <ins> Subproject commit d9aa23a43ad29e3a10551a1425ef5d5baef28d70 </ins>


// figure out which generic parameter it corresponds to and return // the relevant type. let generics = match path.res { <del> Res::Def(DefKind::Ctor(..), def_id) => { </del> <ins> Res::Def(DefKind::Ctor(..), def_id) | Res::Def(DefKind::AssocTy, def_id) => { </ins> tcx.generics_of(tcx.parent(def_id).unwrap()) } Res::Def(_, def_id) => tcx.generics_of(def_id), <del> Res::Err => return tcx.types.err, </del> res => { tcx.sess.delay_span_bug( DUMMY_SP, <del> &format!("unexpected const parent path def {:?}", res,), </del> <ins> &format!( "unexpected const parent path def, parent: {:?}, def: {:?}", parent_node, res ), </ins> ); return tcx.types.err; }


impl Deref for Thing { //~^ ERROR not all trait items implemented, missing: `Target` [E0046] fn deref(&self) -> i8 { self.0 } <del> //~^ ERROR method `deref` has an incompatible type for trait: expected &-ptr, found i8 [E0053] </del> <ins> //~^ ERROR method `deref` has an incompatible type for trait //~| expected &-ptr //~| found i8 [E0053] </ins> } let thing = Thing(72);


let mut span = None; let mut accum = 0u64; <del> for (index, arg_def) in fn_sig.inputs().iter().enumerate() { let layout = tcx.layout_of(ParamEnv::reveal_all().and(*arg_def.skip_binder()))?; </del> <ins> // this type is only used for layout computation, which does not rely on regions let fn_sig = tcx.instantiate_bound_regions_with_erased(fn_sig); for (index, ty) in fn_sig.inputs().iter().enumerate() { let layout = tcx.layout_of(ParamEnv::reveal_all().and(*ty))?; </ins> let align = layout.layout.align().abi.bytes(); let size = layout.layout.size().bytes();


fn visit_item(&mut self, item: &'tcx Item) { let mut item_hir_id = None; self.lctx.with_hir_id_owner(item.id, |lctx| { <del> if let Some(hir_item) = lctx.lower_item(item) { item_hir_id = Some(hir_item.hir_id); lctx.insert_item(hir_item); } </del> <ins> lctx.without_in_scope_lifetime_defs(|lctx| { if let Some(hir_item) = lctx.lower_item(item) { item_hir_id = Some(hir_item.hir_id); lctx.insert_item(hir_item); } }) </ins> }); if let Some(hir_id) = item_hir_id {


self.resolve_expr(elem, Some(expr)); self.visit_expr(idx); } <del> ExprKind::Assign(..) => { let old = self.diagnostic_metadata.in_assignment.replace(expr); visit::walk_expr(self, expr); self.diagnostic_metadata.in_assignment = old; </del> <ins> ExprKind::Assign(ref lhs, ref rhs, _) => { if !self.diagnostic_metadata.is_assign_rhs { self.diagnostic_metadata.in_assignment = Some(expr); } self.visit_expr(lhs); self.diagnostic_metadata.is_assign_rhs = true; self.diagnostic_metadata.in_assignment = None; self.visit_expr(rhs); self.diagnostic_metadata.is_assign_rhs = false; </ins> } _ => { visit::walk_expr(self, expr);


return Ok(cycle_result); } <del> let (result, dep_node) = self.in_task(|this| this.evaluate_stack(&stack)); </del> <ins> let (result, dep_node) = self.in_task(|this| { let mut result = this.evaluate_stack(&stack)?; // fix issue #103563, we don't normalize // nested obligations which produced by `TraitDef` candidate // (i.e. using bounds on assoc items as assumptions). // because we don't have enough information to // normalize these obligations before evaluating. // so we will try to normalize the obligation and evaluate again. // we will replace it with new solver in the future. if EvaluationResult::EvaluatedToErr == result && fresh_trait_pred.has_projections() && fresh_trait_pred.is_global() { let mut nested_obligations = Vec::new(); let predicate = try_normalize_with_depth_to( this, param_env, obligation.cause.clone(), obligation.recursion_depth + 1, obligation.predicate, &mut nested_obligations, ); if predicate != obligation.predicate { let mut nested_result = EvaluationResult::EvaluatedToOk; for obligation in nested_obligations { nested_result = cmp::max( this.evaluate_predicate_recursively(stack.list(), obligation)?, nested_result, ); } if nested_result.must_apply_modulo_regions() { let obligation = obligation.with(this.tcx(), predicate); result = cmp::max( nested_result, this.evaluate_trait_predicate_recursively(stack.list(), obligation)?, ); } } } Ok::<_, OverflowError>(result) }); </ins> let result = result?; if !result.must_apply_modulo_regions() {


!source_file.is_imported() }) .map(|source_file| { <del> // When exporting SourceFiles, we expand all paths to absolute // paths because any relative paths are potentially relative to // a wrong directory. // However, if a path has been modified via // `--remap-path-prefix` we assume the user has already set // things up the way they want and don't touch the path values // anymore. </del> match source_file.name { <ins> // This path of this SourceFile has been modified by // path-remapping, so we use it verbatim (and avoid // cloning the whole map in the process). _  if source_file.name_was_remapped => source_file.clone(), // Otherwise expand all paths to absolute paths because // any relative paths are potentially relative to a // wrong directory. </ins> FileName::Real(ref name) => { <del> if source_file.name_was_remapped || (name.is_relative() && working_dir_was_remapped) { // This path of this SourceFile has been modified by // path-remapping, so we use it verbatim (and avoid cloning // the whole map in the process). source_file.clone() } else { let mut adapted = (**source_file).clone(); adapted.name = Path::new(&working_dir).join(name).into(); adapted.name_hash = { let mut hasher: StableHasher<u128> = StableHasher::new(); adapted.name.hash(&mut hasher); hasher.finish() }; Lrc::new(adapted) } </del> <ins> let mut adapted = (**source_file).clone(); adapted.name = Path::new(&working_dir).join(name).into(); adapted.name_hash = { let mut hasher: StableHasher<u128> = StableHasher::new(); adapted.name.hash(&mut hasher); hasher.finish() }; Lrc::new(adapted) </ins> }, // expanded code, not from a file _ => source_file.clone(), }


impl<T: for<'a> ApplyL<'a>> LambdaL for T {} <del> // HACK(eddyb) work around projection limitations with a newtype // FIXME(#52812) replace with `&'a mut <T as ApplyL<'b>>::Out` pub struct RefMutL<'a, 'b, T: LambdaL>(&'a mut <T as ApplyL<'b>>::Out); impl<'a, 'b, T: LambdaL> Deref for RefMutL<'a, 'b, T> { type Target = <T as ApplyL<'b>>::Out; fn deref(&self) -> &Self::Target { self.0 } } impl<'a, 'b, T: LambdaL> DerefMut for RefMutL<'a, 'b, T> { fn deref_mut(&mut self) -> &mut Self::Target { self.0 } } </del> pub struct ScopedCell<T: LambdaL>(Cell<<T as ApplyL<'static>>::Out>); impl<T: LambdaL> ScopedCell<T> {


// mir. match tcx.at(expr.span).lit_to_const(lit_input) { Ok(c) => return Some(c), <ins> Err(_) if lit_input.ty.has_aliases() => { // allow the `ty` to be an alias type, though we cannot handle it here return None; } </ins> Err(e) => { tcx.dcx().span_delayed_bug( expr.span,


assert-css: ("#help-button .popover", {"display": "block"}) press-key: "Escape" assert-css: ("#help-button .popover", {"display": "none"}) <ins> // Checking doc collapse and expand. // It should be displaying a "-": assert-text: ("#toggle-all-docs", "[u2212]") press-key: "-" wait-for-text: ("#toggle-all-docs", "[+]") assert-attribute: ("#toggle-all-docs", {"class": "will-expand"}) // Pressing it again shouldn't do anything. press-key: "-" assert-text: ("#toggle-all-docs", "[+]") assert-attribute: ("#toggle-all-docs", {"class": "will-expand"}) // Expanding now. press-key: "+" wait-for-text: ("#toggle-all-docs", "[u2212]") assert-attribute: ("#toggle-all-docs", {"class": ""}) // Pressing it again shouldn't do anything. press-key: "+" assert-text: ("#toggle-all-docs", "[u2212]") assert-attribute: ("#toggle-all-docs", {"class": ""}) </ins>


} } } <ins> fn expr_as_call_operand( &mut self, mut block: BasicBlock, scope: Option<region::Scope>, expr: Expr<'tcx>, ) -> BlockAnd<Operand<'tcx>> { debug!("expr_as_call_operand(block={:?}, expr={:?})", block, expr); let this = self; if let ExprKind::Scope { region_scope, lint_level, value } = expr.kind { let source_info = this.source_info(expr.span); let region_scope = (region_scope, source_info); return this.in_scope(region_scope, lint_level, |this| { this.as_call_operand(block, scope, value) }); } let tcx = this.hir.tcx(); if tcx.features().unsized_locals { let ty = expr.ty; let span = expr.span; let param_env = this.hir.param_env; if !ty.is_sized(tcx.at(span), param_env) { // !sized means !copy, so this is an unsized move assert!(!ty.is_copy_modulo_regions(tcx, param_env, span)); // As described above, detect the case where we are passing a value of unsized // type, and that value is coming from the deref of a box. if let ExprKind::Deref { ref arg } = expr.kind { let arg = this.hir.mirror(arg.clone()); // Generate let tmp0 = arg0 let operand = unpack!(block = this.as_temp(block, scope, arg, Mutability::Mut)); // Return the operand *tmp0 to be used as the call argument let place = Place { local: operand, projection: tcx.intern_place_elems(&[PlaceElem::Deref]), }; return block.and(Operand::Move(place)); } } } this.expr_as_operand(block, scope, expr) } </ins> }


let pat = self.mk_pat(lo.to(self.prev_span), pat); let pat = self.maybe_recover_from_bad_qpath(pat, true)?; <ins> let pat = self.recover_intersection_pat(pat)?; </ins> if !allow_range_pat { self.ban_pat_range_if_ambiguous(&pat)?


<ins> fn main() {} #[cfg(FALSE)] fn container() { const unsafe WhereIsFerris Now() {} //~^ ERROR expected one of `extern` or `fn` } </ins>


use fn_ctxt::FnCtxt; use rustc_data_structures::unord::UnordSet; use rustc_errors::codes::*; <del> use rustc_errors::{struct_span_code_err, Applicability, ErrorGuaranteed}; </del> <ins> use rustc_errors::{pluralize, struct_span_code_err, Applicability, ErrorGuaranteed}; </ins> use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::intravisit::Visitor;


<del> //@ known-bug: #97501 #![feature(core_intrinsics)] use std::intrinsics::wrapping_add; #[derive(Clone, Copy)] struct WrapInt8 { value: u8 } impl std::ops::Add for WrapInt8 { type Output = WrapInt8; fn add(self, other: WrapInt8) -> WrapInt8 { wrapping_add(self, other) } } fn main() { let p = WrapInt8 { value: 123 }; let q = WrapInt8 { value: 234 }; println!("{}", (p + q).value); } </del>


_ => None }; if let Some(def_id) = maybe_def_id { <del> fn_warned = check_must_use(cx, def_id, s.span, "return value of ", ""); </del> <ins> fn_warned = check_must_use_def(cx, def_id, s.span, "return value of ", ""); </ins> } else if type_permits_lack_of_use { // We don't warn about unused unit or uninhabited types. // (See https://github.com/rust-lang/rust/issues/43806 for details.)


Ok(()) } <del> pub fn remove_dir_all(p: &Path) -> io::Result<()> { </del> <ins> fn remove_dir_all_modern(p: &Path) -> io::Result<()> { </ins> // We cannot just call remove_dir_all_recursive() here because that would not delete a passed // symlink. No need to worry about races, because remove_dir_all_recursive() does not recurse // into symlinks.


<ins> // edition:2021 fn main() { &[1, 2, 3][1:2]; //~^ ERROR: expected one of //~| HELP: you might have meant a range expression } </ins>


#[stable] pub trait Any: 'static { /// Get the `TypeId` of `self` <del> #[stable] </del> <ins> #[experimental = "this method will likely be replaced by an associated static"] </ins> fn get_type_id(&self) -> TypeId; }


let x = self.parse_seq_to_before_end( &token::Gt, SeqSep::trailing_allowed(token::Comma), <del> |p| p.parse_generic_arg(None), </del> <ins> |p| match p.parse_generic_arg(None)? { Some(arg) => Ok(arg), // If we didn't eat a generic arg, then we should error. None => p.unexpected_any(), }, </ins> ); match x { Ok((_, _, Recovered::No)) => {


let mut diag = cx.tcx.struct_span_lint_hir( lint::builtin::PRIVATE_DOC_TESTS, hir_id, <del> span_of_attrs(&item.attrs), </del> <ins> span_of_attrs(&item.attrs).unwrap_or(item.source.span()), </ins> "Documentation test in private item"); diag.emit(); } } /// Returns a span encompassing all the given attributes. <del> crate fn span_of_attrs(attrs: &clean::Attributes) -> Span { </del> <ins> crate fn span_of_attrs(attrs: &clean::Attributes) -> Option<Span> { </ins> if attrs.doc_strings.is_empty() { <del> return DUMMY_SP; </del> <ins> return None; </ins> } let start = attrs.doc_strings[0].span(); <ins> if start == DUMMY_SP { return None; } </ins> let end = attrs.doc_strings.last().expect("No doc strings provided").span(); <del> start.to(end) </del> <ins> Some(start.to(end)) </ins> } /// Attempts to match a range of bytes from parsed markdown to a `Span` in the source code.


.collect(), _ => Vec::new(), }; <del> candidates.retain(|candidate| *candidate != self.tcx.parent(result.callee.def_id)); </del> return Err(IllegalSizedBound(candidates, needs_mut, span)); }


<ins> // check-pass #![feature(c_variadic)] #![warn(function_item_references)] use std::fmt::Pointer; use std::fmt::Formatter; fn nop() { } fn foo() -> u32 { 42 } fn bar(x: u32) -> u32 { x } fn baz(x: u32, y: u32) -> u32 { x + y } unsafe fn unsafe_fn() { } extern "C" fn c_fn() { } unsafe extern "C" fn unsafe_c_fn() { } unsafe extern fn variadic(_x: u32, _args: ...) { } //function references passed to these functions should never lint fn call_fn(f: &dyn Fn(u32) -> u32, x: u32) { f(x); } fn parameterized_call_fn<F: Fn(u32) -> u32>(f: &F, x: u32) { f(x); } //function references passed to these functions should lint fn print_ptr<F: Pointer>(f: F) { println!("{:p}", f); } fn bound_by_ptr_trait<F: Pointer>(_f: F) { } fn bound_by_ptr_trait_tuple<F: Pointer, G: Pointer>(_t: (F, G)) { } fn implicit_ptr_trait<F>(f: &F) { println!("{:p}", f); } //case found in tinyvec that triggered a compiler error in an earlier version of the lint checker trait HasItem { type Item; fn assoc_item(&self) -> Self::Item; } fn _format_assoc_item<T: HasItem>(data: T, f: &mut Formatter) -> std::fmt::Result where T::Item: Pointer { //when the arg type bound by `Pointer` is an associated type, we shouldn't attempt to normalize Pointer::fmt(&data.assoc_item(), f) } //simple test to make sure that calls to `Pointer::fmt` aren't double counted fn _call_pointer_fmt(f: &mut Formatter) -> std::fmt::Result { let zst_ref = &foo; Pointer::fmt(&zst_ref, f) //~^ WARNING taking a reference to a function item does not give a function pointer } fn main() { //`let` bindings with function references shouldn't lint let _ = &foo; let _ = &mut foo; let zst_ref = &foo; let fn_item = foo; let indirect_ref = &fn_item; let _mut_zst_ref = &mut foo; let mut mut_fn_item = foo; let _mut_indirect_ref = &mut mut_fn_item; let cast_zst_ptr = &foo as *const _; let coerced_zst_ptr: *const _ = &foo; let _mut_cast_zst_ptr = &mut foo as *mut _; let _mut_coerced_zst_ptr: *mut _ = &mut foo; let _cast_zst_ref = &foo as &dyn Fn() -> u32; let _coerced_zst_ref: &dyn Fn() -> u32 = &foo; let _mut_cast_zst_ref = &mut foo as &mut dyn Fn() -> u32; let _mut_coerced_zst_ref: &mut dyn Fn() -> u32 = &mut foo; //the suggested way to cast to a function pointer let fn_ptr = foo as fn() -> u32; //correct ways to print function pointers println!("{:p}", foo as fn() -> u32); println!("{:p}", fn_ptr); //potential ways to incorrectly try printing function pointers println!("{:p}", &foo); //~^ WARNING taking a reference to a function item does not give a function pointer print!("{:p}", &foo); //~^ WARNING taking a reference to a function item does not give a function pointer format!("{:p}", &foo); //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", &foo as *const _); //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", zst_ref); //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", cast_zst_ptr); //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", coerced_zst_ptr); //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", &fn_item); //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", indirect_ref); //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", &nop); //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", &bar); //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", &baz); //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", &unsafe_fn); //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", &c_fn); //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", &unsafe_c_fn); //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", &variadic); //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p}", &std::env::var::<String>); //~^ WARNING taking a reference to a function item does not give a function pointer println!("{:p} {:p} {:p}", &nop, &foo, &bar); //~^ WARNING taking a reference to a function item does not give a function pointer //~^^ WARNING taking a reference to a function item does not give a function pointer //~^^^ WARNING taking a reference to a function item does not give a function pointer //using a function reference to call a function shouldn't lint (&bar)(1); //passing a function reference to an arbitrary function shouldn't lint call_fn(&bar, 1); parameterized_call_fn(&bar, 1); std::mem::size_of_val(&foo); unsafe { //potential ways to incorrectly try transmuting function pointers std::mem::transmute::<_, usize>(&foo); //~^ WARNING taking a reference to a function item does not give a function pointer std::mem::transmute::<_, (usize, usize)>((&foo, &bar)); //~^ WARNING taking a reference to a function item does not give a function pointer //~^^ WARNING taking a reference to a function item does not give a function pointer //the correct way to transmute function pointers std::mem::transmute::<_, usize>(foo as fn() -> u32); std::mem::transmute::<_, (usize, usize)>((foo as fn() -> u32, bar as fn(u32) -> u32)); } //function references as arguments required to be bound by std::fmt::Pointer should lint print_ptr(&bar); //~^ WARNING taking a reference to a function item does not give a function pointer bound_by_ptr_trait(&bar); //~^ WARNING taking a reference to a function item does not give a function pointer bound_by_ptr_trait_tuple((&foo, &bar)); //~^ WARNING taking a reference to a function item does not give a function pointer //~^^ WARNING taking a reference to a function item does not give a function pointer implicit_ptr_trait(&bar); // ignore //correct ways to pass function pointers as arguments bound by std::fmt::Pointer print_ptr(bar as fn(u32) -> u32); bound_by_ptr_trait(bar as fn(u32) -> u32); bound_by_ptr_trait_tuple((foo as fn() -> u32, bar as fn(u32) -> u32)); } </ins>


"ban_nonexisting_field: field={:?}, base={:?}, expr={:?}, expr_ty={:?}", field, base, expr, expr_t ); <del> let mut err = self.no_such_field_err(field.span, field, expr_t); </del> <ins> let mut err = self.no_such_field_err(field, expr_t); </ins> match *expr_t.peel_refs().kind() { ty::Array(_, len) => {


<ins> error: expected one of `extern` or `fn`, found `WhereIsFerris` --> $DIR/issue-68062-const-extern-fns-dont-need-fn-specifier-2.rs:5:18 | LL |     const unsafe WhereIsFerris Now() {} |                  ^^^^^^^^^^^^^ expected one of `extern` or `fn` error: aborting due to previous error </ins>


// the MIR body will be constructed well. let coroutine_ty = body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty; <del> let ty::Coroutine(_, args) = *coroutine_ty.kind() else { bug!("{body:#?}") }; </del> <ins> let ty::Coroutine(_, args) = *coroutine_ty.kind() else { bug!("tried to create by-move body of non-coroutine receiver"); }; </ins> let args = args.as_coroutine(); let coroutine_kind = args.kind_ty().to_opt_closure_kind().unwrap();


<del> #define CFG_RELEASE_NUM GetEnv("CFG_RELEASE_NUM") #define CFG_RELEASE GetEnv("CFG_RELEASE") #define CFG_PACKAGE_NAME GetEnv("CFG_PACKAGE_NAME") #define CFG_BUILD GetEnv("CFG_BUILD") [Setup] SetupIconFile=rust-logo.ico AppName=Rust AppVersion={#CFG_RELEASE} AppCopyright=Copyright (C) 2006-2014 Mozilla Foundation, MIT license AppPublisher=Mozilla Foundation AppPublisherURL=http://www.rust-lang.org VersionInfoVersion={#CFG_RELEASE_NUM} LicenseFile=LICENSE.txt PrivilegesRequired=lowest DisableWelcomePage=true DisableProgramGroupPage=true DisableReadyPage=true DisableStartupPrompt=true OutputDir=. SourceDir=. OutputBaseFilename={#CFG_PACKAGE_NAME}-{#CFG_BUILD} DefaultDirName={sd}Rust Compression=lzma2/normal InternalCompressLevel=normal SolidCompression=no ChangesEnvironment=true ChangesAssociations=no AllowUNCPath=false AllowNoIcons=true Uninstallable=yes [Tasks] Name: modifypath; Description: &Add {app}bin to your PATH (recommended) [Components] Name: rust; Description: "Rust compiler and standard crates"; Types: full compact custom; Flags: fixed #ifdef MINGW Name: gcc; Description: "Linker and platform libraries"; Types: full #endif Name: docs; Description: "HTML documentation"; Types: full Name: cargo; Description: "Cargo, the Rust package manager"; Types: full Name: std; Description: "The Rust Standard Library"; Types: full // tool-rls-start Name: rls; Description: "RLS, the Rust Language Server" // tool-rls-end [Files] Source: "rustc/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: rust #ifdef MINGW Source: "rust-mingw/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: gcc #endif Source: "rust-docs/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: docs Source: "cargo/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: cargo Source: "rust-std/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: std // tool-rls-start Source: "rls/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: rls Source: "rust-analysis/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: rls // tool-rls-end [Code] const ModPathName = 'modifypath'; ModPathType = 'user'; function ModPathDir(): TArrayOfString; begin setArrayLength(Result, 1) Result[0] := ExpandConstant('{app}bin'); end; #include "modpath.iss" #include "upgrade.iss" // Both modpath.iss and upgrade.iss want to overload CurStepChanged. // This version does the overload then delegates to each. procedure CurStepChanged(CurStep: TSetupStep); begin UpgradeCurStepChanged(CurStep); ModPathCurStepChanged(CurStep); end; </del>


use rustc_infer::infer::{self, InferOk}; use rustc_middle::traits::ObligationCause; use rustc_middle::ty::subst::{InternalSubsts, SubstsRef}; <del> use rustc_middle::ty::{self, DefIdTree, GenericParamDefKind, Ty, TypeVisitable}; </del> <ins> use rustc_middle::ty::{self, GenericParamDefKind, Ty, TypeVisitable}; </ins> use rustc_span::symbol::Ident; use rustc_span::Span; use rustc_trait_selection::traits;


return None; }; <del> if new_ty.references_error() { return None; } </del> self.state.steps.push((self.state.cur_ty, kind)); debug!( "autoderef stage #{:?} is {:?} from {:?}",


/// # Examples /// /// ``` <del> /// # #![feature(vec_remove_item)] </del> /// let mut vec = vec![1, 2, 3, 1]; /// /// vec.remove_item(&1); /// /// assert_eq!(vec, vec![2, 3, 1]); /// ``` <del> #[unstable(feature = "vec_remove_item", reason = "recently added", issue = "40062")] </del> <ins> #[stable(feature = "vec_remove_item", since = "1.42.0")] </ins> pub fn remove_item<V>(&mut self, item: &V) -> Option<T> where T: PartialEq<V>,


_ => None, } } <ins> fn host_dll_subdir() -> Option<&'static str> { if cfg!(target_arch = "x86_64") { Some("amd64") } else if cfg!(target_arch = "x86") { Some("") } else { None } } </ins> } // If we're not on Windows, then there's no registry to search through and MSVC // wouldn't be able to run, so we just call `link.exe` and hope for the best. #[cfg(not(windows))] <del> pub fn link_exe_cmd(_sess: &Session) -> Command { Command::new("link.exe") </del> <ins> mod platform { use std::path::PathBuf; use std::process::Command; use session::Session; pub fn link_exe_cmd(_sess: &Session) -> Command { Command::new("link.exe") } pub fn host_dll_path() -> Option<PathBuf> { None } </ins> } <ins> pub use self::platform::*; </ins>


let len = self.buf.len(); let mut ret = Ok(()); while written < len { <del> match self.inner.as_mut().unwrap().write(&self.buf[written..]) { </del> <ins> self.panicked = true; let r = self.inner.as_mut().unwrap().write(&self.buf[written..]); self.panicked = false; match r { </ins> Ok(0) => { ret = Err(Error::new(ErrorKind::WriteZero, "failed to write the buffered data"));


}, value_ns: match self.resolve( path_str, <ins> disambiguator, </ins> ValueNS, &current_item, base_node,


<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. // Tests the rustdoc --sort-modules-by-appearance option, that allows module declarations to appear // in the order they are declared in the source code, rather than only alphabetically. // compile-flags: -Z unstable-options --sort-modules-by-appearance pub mod module_b {} pub mod module_c {} pub mod module_a {} // @matches 'sort_modules_by_appearance/index.html' '(?s)module_b.*module_c.*module_a' // @matches 'sort_modules_by_appearance/sidebar-items.js' '"module_b".*"module_c".*"module_a"' </ins>


<ins> error[E0609]: no field `c` on type `Foo` --> $DIR/non-existent-field-present-in-subfield.rs:37:24 | LL |     let _test = &fooer.c; |                        ^ unknown field | = note: available fields are: `first`, `_second`, `_third` help: one of the expressions' fields has a field of the same name | LL |     let _test = &fooer.first.bar.c; |                        ^^^^^^^^^^ error[E0609]: no field `test` on type `Foo` --> $DIR/non-existent-field-present-in-subfield.rs:40:24 | LL |     let _test2 = fooer.test; |                        ^^^^ unknown field | = note: available fields are: `first`, `_second`, `_third` help: one of the expressions' fields has a field of the same name | LL |     let _test2 = fooer.first.bar.c.test; |                        ^^^^^^^^^^^^ error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0609`. </ins>


mod stripper; pub(crate) use stripper::*; <ins> mod strip_aliased_non_local; pub(crate) use self::strip_aliased_non_local::STRIP_ALIASED_NON_LOCAL; </ins> mod strip_hidden; pub(crate) use self::strip_hidden::STRIP_HIDDEN;


} fn test_26444() { <del> assert_eq!("a , b , c , d , e", foo_26444!(a, b; c; d, e)); </del> <ins> assert_eq!("a, b, c, d, e", foo_26444!(a, b; c; d, e)); </ins> assert_eq!("f", foo_26444!(; f ;)); }


# one is MSI installers and one is EXE, but they're not used so frequently at # this point anyway so perhaps it's a wash! - script: | <del> powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf is-install.exe https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2017-08-22-is.exe" is-install.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- </del> echo ##vso[task.prependpath]C:Program Files (x86)Inno Setup 5 <ins> curl.exe -o is-install.exe https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/rustc/2017-08-22-is.exe is-install.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- </ins> displayName: Install InnoSetup condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))


let maybe_sysroot = matches.opt_str("sysroot").map(PathBuf::from); let display_warnings = matches.opt_present("display-warnings"); let linker = matches.opt_str("linker").map(PathBuf::from); <ins> let sort_modules_alphabetically = !matches.opt_present("sort-modules-by-appearance"); </ins> match (should_test, markdown_input) { (true, true) => {


} macro_rules! tool_check_step { <del> ($name:ident, $path:literal, $($alias:literal, )* $source_type:path $(, $default:literal )?) => { </del> <ins> ( $name:ident, $display_name:literal, $path:literal, $($alias:literal, )* $source_type:path $(, $default:literal )? ) => { </ins> #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct $name { pub target: TargetSelection,


"extra arguments to prepend to the linker invocation (space separated)"), profile: bool = (false, parse_bool, [TRACKED], "insert profiling code"), <del> disable_instrumentation_preinliner: bool = (false, parse_bool, [TRACKED], "Disable the instrumentation pre-inliner, useful for profiling / PGO."), </del> relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED], "choose which RELRO level to use"), nll_facts: bool = (false, parse_bool, [UNTRACKED],


use rustc_middle::bug; use rustc_middle::hir::nested_filter::OnlyBodies; use rustc_middle::mir::tcx::PlaceTy; <ins> use rustc_middle::mir::VarDebugInfoContents; </ins> use rustc_middle::mir::{ self, AggregateKind, BindingForm, BorrowKind, CallSource, ClearCrossCrate, ConstraintCategory, FakeBorrowKind, FakeReadCause, LocalDecl, LocalInfo, LocalKind, Location, MutBorrowKind,


) -> Item { let target_attrs = inline::load_attrs(cx, def_id); let attrs = if let Some(import_id) = import_id { <ins> // glob reexports are treated the same as `#[doc(inline)]` items. // // For glob re-exports the item may or may not exist to be re-exported (potentially the cfgs // on the path up until the glob can be removed, and only cfgs on the globbed item itself // matter), for non-inlined re-exports see #85043. </ins> let is_inline = inline::load_attrs(cx, import_id.to_def_id()) .lists(sym::doc) .get_word_attr(sym::inline) <del> .is_some(); </del> <ins> .is_some() || (is_glob_import(cx.tcx, import_id) && (cx.render_options.document_hidden || !cx.tcx.is_doc_hidden(def_id))); </ins> let mut attrs = get_all_import_attributes(cx, import_id, def_id, is_inline); add_without_unwanted_attributes(&mut attrs, target_attrs, is_inline, None); attrs


/// # Examples /// /// ``` <del> /// #![feature(vec_spare_capacity)] /// </del> /// // Allocate vector big enough for 10 elements. /// let mut v = Vec::with_capacity(10); ///


LL | fn bak<I: Iterator + std::fmt::Debug>(constraints: I) where <I as Iterator>::Item: Debug { |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^              ^  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <del> error: aborting due to 5 previous errors </del> <ins> error[E0277]: `<impl Iterator as Iterator>::Item` doesn't implement `Debug` --> $DIR/impl-trait-with-missing-bounds.rs:45:13 | LL |         qux(constraint); |             ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug` ... LL | fn qux(_: impl std::fmt::Debug) {} |                --------------- required by this bound in `qux` | = help: the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item` help: introduce a type parameter with a trait bound instead of using `impl Trait` | LL | fn baw<I: Iterator>(constraints: I) where <I as Iterator>::Item: Debug { |       ^^^^^^^^^^^^^              ^  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors </ins> For more information about this error, try `rustc --explain E0277`.


/// Creates an iterator that skips the first `n` elements. /// /// After they have been consumed, the rest of the elements are yielded. <ins> /// Rather than overriding this method directly, instead override the `nth` method. </ins> /// /// # Examples ///


} } <del> /// Constructs a new `Rc<T>` using a closure `data_fn` that has access to a /// weak reference to the constructing `Rc<T>`. </del> <ins> /// Constructs a new `Rc<T>` while giving you a `Weak<T>` to the allocation, /// to allow you to construct a `T` which holds a weak pointer to itself. </ins> /// /// Generally, a structure circularly referencing itself, either directly or <del> /// indirectly, should not hold a strong reference to prevent a memory leak. /// In `data_fn`, initialization of `T` can make use of the weak reference /// by cloning and storing it inside `T` for use at a later time. </del> <ins> /// indirectly, should not hold a strong reference to itself to prevent a memory leak. /// Using this function, you get access to the weak pointer during the /// initialization of `T`, before the `Rc<T>` is created, such that you can /// clone and store it inside the `T`. /// /// `new_cyclic` first allocates the managed allocation for the `Rc<T>`, /// then calls your closure, giving it a `Weak<T>` to this allocation, /// and only afterwards completes the construction of the `Rc<T>` by placing /// the `T` returned from your closure into the allocation. </ins> /// /// Since the new `Rc<T>` is not fully-constructed until `Rc<T>::new_cyclic` <del> /// returns, calling [`upgrade`] on the weak reference inside `data_fn` will </del> <ins> /// returns, calling [`upgrade`] on the weak reference inside your closure will </ins> /// fail and result in a `None` value. /// /// # Panics <ins> /// </ins> /// If `data_fn` panics, the panic is propagated to the caller, and the /// temporary [`Weak<T>`] is dropped normally. ///


// stripping away any starting or ending parenthesis characters—hence this // test of the JSON error format. <del> #![warn(unused_parens)] </del> <ins> #![deny(unused_parens)] </ins> #![allow(unreachable_code)] fn main() { // We want to suggest the properly-balanced expression `1 / (2 + 3)`, not // the malformed `1 / (2 + 3` <del> let _a = 1 / (2 + 3); </del> <ins> let _a = 1 / (2 + 3); //~ERROR unnecessary parentheses </ins> f(); }


<ins> //~ ERROR overflow evaluating the requirement `([isize; 0], _): Sized </ins> trait Foo<A> { fn get(&self, A: &A) { } }


} fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) { <del> let scope = self.region_scope_tree.temporary_scope(expr.hir_id.local_id); </del> match &expr.kind { ExprKind::Call(callee, args) => match &callee.kind { ExprKind::Path(qpath) => {


<ins> error: expected `while`, `for`, `loop` or `{` after a label --> $DIR/str-as-char-butchered.rs:4:21 | LL |     let _: &str = 'β; |                     ^ expected `while`, `for`, `loop` or `{` after a label | help: add `'` to close the char literal | LL |     let _: &str = 'β'; |                     + error[E0308]: mismatched types --> $DIR/str-as-char-butchered.rs:4:19 | LL |     let _: &str = 'β; |            ----   ^^ expected `&str`, found `char` |            | |            expected due to this error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. </ins>


#[inline] unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 { let mut out = ptr::null_mut(); <del> let ret = libc::posix_memalign(&mut out, layout.align(), layout.size()); </del> <ins> // posix_memalign requires that the alignment be a multiple of `sizeof(void*)`. // Since these are all powers of 2, we can just use max. let align = layout.align().max(crate::mem::size_of::<usize>()); let ret = libc::posix_memalign(&mut out, align, layout.size()); </ins> if ret != 0 { ptr::null_mut() } else {


// Explicitly check for lints associated with 'closure_id', since // it does not have a corresponding AST node <del> if let ast::ExprKind::Closure(_, asyncness, ..) = e.kind { if let ast::Async::Yes { closure_id, .. } = asyncness { self.check_id(closure_id); } </del> <ins> match e.kind { ast::ExprKind::Closure(_, ast::Async::Yes { closure_id, .. }, ..) | ast::ExprKind::Async(_, closure_id, ..) => self.check_id(closure_id), _ => {} </ins> } }


ignore_fmt.add(&format!("!/{}", untracked_path)).expect(&untracked_path); } if !check && paths.is_empty() { <del> if let Some(files) = get_modified_files(build) { </del> <ins> if let Some(files) = get_modified_rs_files(build) { </ins> for file in files { println!("formatting modified file {file}"); ignore_fmt.add(&format!("/{file}")).expect(&file);


<ins> // check-pass use std::error::Error as StdError; use std::pin::Pin; use std::task::{Context, Poll}; pub trait Stream { type Item; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>; fn size_hint(&self) -> (usize, Option<usize>) { (0, None) } } pub trait TryStream: Stream { type Ok; type Error; fn try_poll_next( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Self::Ok, Self::Error>>>; } impl<S, T, E> TryStream for S where S: ?Sized + Stream<Item = Result<T, E>>, { type Ok = T; type Error = E; fn try_poll_next( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Self::Ok, Self::Error>>> { self.poll_next(cx) } } pub trait ServerSentEvent: Sized + Send + Sync + 'static {} impl<T: Send + Sync + 'static> ServerSentEvent for T {} struct SseKeepAlive<S> { event_stream: S, } struct SseComment<T>(T); impl<S> Stream for SseKeepAlive<S> where S: TryStream + Send + 'static, S::Ok: ServerSentEvent, S::Error: StdError + Send + Sync + 'static, { type Item = Result<SseComment<&'static str>, ()>; fn poll_next(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<Option<Self::Item>> { unimplemented!() } } pub fn keep<S>( event_stream: S, ) -> impl TryStream<Ok = impl ServerSentEvent + Send + 'static, Error = ()> + Send + 'static where S: TryStream + Send + 'static, S::Ok: ServerSentEvent + Send, S::Error: StdError + Send + Sync + 'static, { SseKeepAlive { event_stream } } fn main() {} </ins>


/// // Calculate how many bytes can be written without flushing /// let without_flush = capacity - buf_writer.buffer().len(); /// ``` <del> #[unstable(feature = "buffered_io_capacity", issue = "68833")] </del> <ins> #[stable(feature = "buffered_io_capacity", since = "1.46.0")] </ins> pub fn capacity(&self) -> usize { self.buf.capacity() }


<ins> // edition:2021 // run-rustfix #![allow(dead_code)] async fn a() {} async fn foo() -> Result<(), i32> { Ok(a().await) //~ ERROR mismatched types } fn main() {} </ins>


/// # Examples /// /// ``` <del> /// #![feature(osstring_ascii)] </del> /// use std::ffi::OsString; /// let s = OsString::from("Grüße, Jürgen ❤"); /// /// assert_eq!("grüße, jürgen ❤", s.to_ascii_lowercase()); /// ``` <del> #[unstable(feature = "osstring_ascii", issue = "70516")] </del> <ins> #[stable(feature = "osstring_ascii", since = "1.53.0")] </ins> pub fn to_ascii_lowercase(&self) -> OsString { OsString::from_inner(self.inner.to_ascii_lowercase()) }


--codeblock-error-color: rgba(255, 0, 0, .5); --codeblock-ignore-hover-color: rgb(255, 142, 0); --codeblock-ignore-color: rgba(255, 142, 0, .6); <ins> --warning-border-color: rgb(255, 142, 0); </ins> --type-link-color: #ad378a; --trait-link-color: #6e4fc9; --assoc-item-link-color: #3873ad;


<ins> use rustc::hir::def_id::DefId; use rustc::mir; use rustc::ty::layout::HasTyCtxt; use rustc::ty::{self, Ty, TyCtxt}; use std::borrow::{Borrow, Cow}; use std::collections::hash_map::Entry; use std::hash::Hash; use rustc_data_structures::fx::FxHashMap; use syntax::source_map::Span; use crate::interpret::{ self, snapshot, AllocId, Allocation, AssertMessage, GlobalId, ImmTy, InterpCx, InterpResult, Memory, MemoryKind, OpTy, PlaceTy, Pointer, Scalar, }; use super::error::*; impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> { /// Evaluate a const function where all arguments (if any) are zero-sized types. /// The evaluation is memoized thanks to the query system. /// /// Returns `true` if the call has been evaluated. fn try_eval_const_fn_call( &mut self, instance: ty::Instance<'tcx>, ret: Option<(PlaceTy<'tcx>, mir::BasicBlock)>, args: &[OpTy<'tcx>], ) -> InterpResult<'tcx, bool> { trace!("try_eval_const_fn_call: {:?}", instance); // Because `#[track_caller]` adds an implicit non-ZST argument, we also cannot // perform this optimization on items tagged with it. if instance.def.requires_caller_location(self.tcx()) { return Ok(false); } // For the moment we only do this for functions which take no arguments // (or all arguments are ZSTs) so that we don't memoize too much. if args.iter().any(|a| !a.layout.is_zst()) { return Ok(false); } let gid = GlobalId { instance, promoted: None }; let place = self.const_eval_raw(gid)?; let dest = match ret { Some((dest, _)) => dest, // Don't memoize diverging function calls. None => return Ok(false), }; self.copy_op(place.into(), dest)?; self.return_to_block(ret.map(|r| r.1))?; self.dump_place(*dest); return Ok(true); } } /// Number of steps until the detector even starts doing anything. /// Also, a warning is shown to the user when this number is reached. const STEPS_UNTIL_DETECTOR_ENABLED: isize = 1_000_000; /// The number of steps between loop detector snapshots. /// Should be a power of two for performance reasons. const DETECTOR_SNAPSHOT_PERIOD: isize = 256; // Extra machine state for CTFE, and the Machine instance pub struct CompileTimeInterpreter<'mir, 'tcx> { /// When this value is negative, it indicates the number of interpreter /// steps *until* the loop detector is enabled. When it is positive, it is /// the number of steps after the detector has been enabled modulo the loop /// detector period. pub(super) steps_since_detector_enabled: isize, /// Extra state to detect loops. pub(super) loop_detector: snapshot::InfiniteLoopDetector<'mir, 'tcx>, } #[derive(Copy, Clone, Debug)] pub struct MemoryExtra { /// Whether this machine may read from statics can_access_statics: bool, } impl<'mir, 'tcx> CompileTimeInterpreter<'mir, 'tcx> { fn new() -> Self { CompileTimeInterpreter { loop_detector: Default::default(), steps_since_detector_enabled: -STEPS_UNTIL_DETECTOR_ENABLED, } } } impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxHashMap<K, V> { #[inline(always)] fn contains_key<Q: ?Sized + Hash + Eq>(&mut self, k: &Q) -> bool where K: Borrow<Q>, { FxHashMap::contains_key(self, k) } #[inline(always)] fn insert(&mut self, k: K, v: V) -> Option<V> { FxHashMap::insert(self, k, v) } #[inline(always)] fn remove<Q: ?Sized + Hash + Eq>(&mut self, k: &Q) -> Option<V> where K: Borrow<Q>, { FxHashMap::remove(self, k) } #[inline(always)] fn filter_map_collect<T>(&self, mut f: impl FnMut(&K, &V) -> Option<T>) -> Vec<T> { self.iter().filter_map(move |(k, v)| f(k, &*v)).collect() } #[inline(always)] fn get_or<E>(&self, k: K, vacant: impl FnOnce() -> Result<V, E>) -> Result<&V, E> { match self.get(&k) { Some(v) => Ok(v), None => { vacant()?; bug!("The CTFE machine shouldn't ever need to extend the alloc_map when reading") } } } #[inline(always)] fn get_mut_or<E>(&mut self, k: K, vacant: impl FnOnce() -> Result<V, E>) -> Result<&mut V, E> { match self.entry(k) { Entry::Occupied(e) => Ok(e.into_mut()), Entry::Vacant(e) => { let v = vacant()?; Ok(e.insert(v)) } } } } crate type CompileTimeEvalContext<'mir, 'tcx> = InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>; impl interpret::MayLeak for ! { #[inline(always)] fn may_leak(self) -> bool { // `self` is uninhabited self } } impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, 'tcx> { type MemoryKinds = !; type PointerTag = (); type ExtraFnVal = !; type FrameExtra = (); type MemoryExtra = MemoryExtra; type AllocExtra = (); type MemoryMap = FxHashMap<AllocId, (MemoryKind<!>, Allocation)>; const STATIC_KIND: Option<!> = None; // no copying of statics allowed // We do not check for alignment to avoid having to carry an `Align` // in `ConstValue::ByRef`. const CHECK_ALIGN: bool = false; #[inline(always)] fn enforce_validity(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool { false // for now, we don't enforce validity } fn find_mir_or_eval_fn( ecx: &mut InterpCx<'mir, 'tcx, Self>, instance: ty::Instance<'tcx>, args: &[OpTy<'tcx>], ret: Option<(PlaceTy<'tcx>, mir::BasicBlock)>, _unwind: Option<mir::BasicBlock>, // unwinding is not supported in consts ) -> InterpResult<'tcx, Option<&'mir mir::Body<'tcx>>> { debug!("find_mir_or_eval_fn: {:?}", instance); // Only check non-glue functions if let ty::InstanceDef::Item(def_id) = instance.def { // Execution might have wandered off into other crates, so we cannot do a stability- // sensitive check here.  But we can at least rule out functions that are not const // at all. if ecx.tcx.is_const_fn_raw(def_id) { // If this function is a `const fn` then under certain circumstances we // can evaluate call via the query system, thus memoizing all future calls. if ecx.try_eval_const_fn_call(instance, ret, args)? { return Ok(None); } } else { // Some functions we support even if they are non-const -- but avoid testing // that for const fn!  We certainly do *not* want to actually call the fn // though, so be sure we return here. return if ecx.hook_panic_fn(instance, args, ret)? { Ok(None) } else { throw_unsup_format!("calling non-const function `{}`", instance) }; } } // This is a const fn. Call it. Ok(Some(match ecx.load_mir(instance.def, None) { Ok(body) => *body, Err(err) => { if let err_unsup!(NoMirFor(ref path)) = err.kind { return Err(ConstEvalError::NeedsRfc(format!( "calling extern function `{}`", path )) .into()); } return Err(err); } })) } fn call_extra_fn( _ecx: &mut InterpCx<'mir, 'tcx, Self>, fn_val: !, _args: &[OpTy<'tcx>], _ret: Option<(PlaceTy<'tcx>, mir::BasicBlock)>, _unwind: Option<mir::BasicBlock>, ) -> InterpResult<'tcx> { match fn_val {} } fn call_intrinsic( ecx: &mut InterpCx<'mir, 'tcx, Self>, span: Span, instance: ty::Instance<'tcx>, args: &[OpTy<'tcx>], ret: Option<(PlaceTy<'tcx>, mir::BasicBlock)>, _unwind: Option<mir::BasicBlock>, ) -> InterpResult<'tcx> { if ecx.emulate_intrinsic(span, instance, args, ret)? { return Ok(()); } // An intrinsic that we do not support let intrinsic_name = ecx.tcx.item_name(instance.def_id()); Err(ConstEvalError::NeedsRfc(format!("calling intrinsic `{}`", intrinsic_name)).into()) } fn assert_panic( ecx: &mut InterpCx<'mir, 'tcx, Self>, _span: Span, msg: &AssertMessage<'tcx>, _unwind: Option<mir::BasicBlock>, ) -> InterpResult<'tcx> { use rustc::mir::interpret::PanicInfo::*; Err(match msg { BoundsCheck { ref len, ref index } => { let len = ecx .read_immediate(ecx.eval_operand(len, None)?) .expect("can't eval len") .to_scalar()? .to_machine_usize(&*ecx)?; let index = ecx .read_immediate(ecx.eval_operand(index, None)?) .expect("can't eval index") .to_scalar()? .to_machine_usize(&*ecx)?; err_panic!(BoundsCheck { len, index }) } Overflow(op) => err_panic!(Overflow(*op)), OverflowNeg => err_panic!(OverflowNeg), DivisionByZero => err_panic!(DivisionByZero), RemainderByZero => err_panic!(RemainderByZero), ResumedAfterReturn(generator_kind) => err_panic!(ResumedAfterReturn(*generator_kind)), ResumedAfterPanic(generator_kind) => err_panic!(ResumedAfterPanic(*generator_kind)), Panic { .. } => bug!("`Panic` variant cannot occur in MIR"), } .into()) } fn ptr_to_int(_mem: &Memory<'mir, 'tcx, Self>, _ptr: Pointer) -> InterpResult<'tcx, u64> { Err(ConstEvalError::NeedsRfc("pointer-to-integer cast".to_string()).into()) } fn binary_ptr_op( _ecx: &InterpCx<'mir, 'tcx, Self>, _bin_op: mir::BinOp, _left: ImmTy<'tcx>, _right: ImmTy<'tcx>, ) -> InterpResult<'tcx, (Scalar, bool, Ty<'tcx>)> { Err(ConstEvalError::NeedsRfc("pointer arithmetic or comparison".to_string()).into()) } fn find_foreign_static( _tcx: TyCtxt<'tcx>, _def_id: DefId, ) -> InterpResult<'tcx, Cow<'tcx, Allocation<Self::PointerTag>>> { throw_unsup!(ReadForeignStatic) } #[inline(always)] fn init_allocation_extra<'b>( _memory_extra: &MemoryExtra, _id: AllocId, alloc: Cow<'b, Allocation>, _kind: Option<MemoryKind<!>>, ) -> (Cow<'b, Allocation<Self::PointerTag>>, Self::PointerTag) { // We do not use a tag so we can just cheaply forward the allocation (alloc, ()) } #[inline(always)] fn tag_static_base_pointer(_memory_extra: &MemoryExtra, _id: AllocId) -> Self::PointerTag { () } fn box_alloc( _ecx: &mut InterpCx<'mir, 'tcx, Self>, _dest: PlaceTy<'tcx>, ) -> InterpResult<'tcx> { Err(ConstEvalError::NeedsRfc("heap allocations via `box` keyword".to_string()).into()) } fn before_terminator(ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> { { let steps = &mut ecx.machine.steps_since_detector_enabled; *steps += 1; if *steps < 0 { return Ok(()); } *steps %= DETECTOR_SNAPSHOT_PERIOD; if *steps != 0 { return Ok(()); } } let span = ecx.frame().span; ecx.machine.loop_detector.observe_and_analyze(*ecx.tcx, span, &ecx.memory, &ecx.stack[..]) } #[inline(always)] fn stack_push(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> { Ok(()) } fn before_access_static( memory_extra: &MemoryExtra, _allocation: &Allocation, ) -> InterpResult<'tcx> { if memory_extra.can_access_statics { Ok(()) } else { Err(ConstEvalError::ConstAccessesStatic.into()) } } } // Please do not add any code below the above `Machine` trait impl. I (oli-obk) plan more cleanups // so we can end up having a file with just that impl, but for now, let's keep the impl discoverable // at the bottom of this file. </ins>


<del> // no-prefer-dynamic </del> fn main() { let _ = std::io::stdin(); let _ = std::io::stdout();


/// Returns the number of leading zeros in the binary representation of `self`. /// <ins> /// Depending on what you're doing with the value, you might also be interested in the /// [`ilog2`] function which returns a consistent number, even if the type widens. /// </ins> /// # Examples /// /// Basic usage:


<ins> fn main() { let x = (1, 2, 3); match x { (_a, _x @ ..) => {} _ => {} } } //~^^^^ ERROR `_x @` is not allowed in a tuple </ins>


<del> // no-prefer-dynamic </del> static mut DROP_RAN: isize = 0; struct Foo;


return; } <del> if self.in_scope_lifetimes.contains(&ident.modern()) { </del> <ins> if self.in_scope_lifetimes.contains(&ParamName::Plain(ident.modern())) { </ins> return; }


<ins> mod b { pub struct A(u32); } trait Id { type Assoc; } impl Id for b::A { type Assoc = b::A; } impl Id for u32 { type Assoc = u32; } trait Trait<T> { fn method(&self) where T: Id<Assoc = b::A>; } impl<T: Id> Trait<T> for <T as Id>::Assoc { fn method(&self) where T: Id<Assoc = b::A>, { let Self(a) = self; //~^ ERROR: tuple struct constructor `A` is private println!("{a}"); } } fn main() {} </ins>


--set target.x86_64-unknown-linux-gnu.ranlib=/rustroot/bin/llvm-ranlib  --set llvm.thin-lto=true  --set llvm.ninja=false  <del> --set llvm.use-linker=lld  --set rust.use-lld=true  </del> --set rust.jemalloc <del> ENV SCRIPT ../src/ci/pgo.sh python3 ../x.py dist  </del> <ins> ENV SCRIPT ../src/ci/pgo.sh python2.7 ../x.py dist  </ins> --host $HOSTS --target $HOSTS  --include-default-paths  src/tools/build-manifest


<ins> // Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. struct Foo<'r>(&'r mut i32); impl<'r> Drop for Foo<'r> { fn drop(&mut self) { *self.0 += 1; } } trait Trait {} impl<'r> Trait for Foo<'r> {} struct Holder<T: ?Sized>(T); fn main() { let mut drops = 0; { let y = &Holder([Foo(&mut drops)]) as &Holder<[Foo]>; // this used to cause an extra drop of the Foo instance let x = &y.0; } assert_eq!(1, drops); drops = 0; { let y = &Holder(Foo(&mut drops)) as &Holder<Trait>; // this used to cause an extra drop of the Foo instance let x = &y.0; } assert_eq!(1, drops); } </ins>


7331 })); assert_eq!(foo, 42); <ins> // Test trailing comma: assert_eq!(("Yeah",), dbg!(("Yeah",))); // Test multiple arguments: assert_eq!((1u8, 2u32), dbg!(1, 2)); // Test multiple arguments + trailing comma: assert_eq!((1u8, 2u32, "Yeah"), dbg!(1u8, 2u32, "Yeah",)); </ins> } fn validate_stderr(stderr: Vec<String>) {


Prior to Rust 1.80 the `target_env = "p1"` key was not set. Currently the `target_feature = "atomics"` is Nightly-only. Note that the precise `#[cfg]` necessary to detect this target may change as the target becomes more stable. <ins> ## Enabled WebAssembly features The default set of WebAssembly features enabled for compilation includes two more features in addition to that which [`wasm32-unknown-unknown`](./wasm32-unknown-unknown.md) enables: * `bulk-memory` * `atomics` For more information about features see the documentation for [`wasm32-unknown-unknown`](./wasm32-unknown-unknown.md), but note that the `mvp` CPU in LLVM does not support this target as it's required that `bulk-memory`, `atomics`, and `mutable-globals` are all enabled. </ins>


//! Types/fns concerning URLs (see RFC 3986) #![crate_name = "url"] <del> #![experimental] </del> <ins> #![deprecated="This is being removed. Use rust-url instead. http://servo.github.io/rust-url/"] </ins> #![crate_type = "rlib"] #![crate_type = "dylib"] #![license = "MIT/ASL2"]


(accepted, macros_in_extern, "1.40.0", Some(49476), None), /// Allows future-proofing enums/structs with the `#[non_exhaustive]` attribute (RFC 2008). (accepted, non_exhaustive, "1.40.0", Some(44109), None), <ins> /// Allows calling constructor functions in `const fn`. (accepted, const_constructor, "1.40.0", Some(61456), None), </ins> // ------------------------------------------------------------------------- // feature-group-end: accepted features


<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>


<del> //@ known-bug: #111699 //@ edition:2021 //@ compile-flags: -Copt-level=0 #![feature(core_intrinsics)] use std::intrinsics::offset; fn main() { let a = [1u8, 2, 3]; let ptr: *const u8 = a.as_ptr(); unsafe { assert_eq!(*offset(ptr, 0), 1); } } </del>


"arch": "x86_64", "cpu": "x86-64", "crt-static-respected": true, <del> "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", </del> <ins> "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", </ins> "dynamic-linking": true, "env": "gnu", "has-rpath": true,


) -> R { I::with_global_cache(self, mode, f) } <ins> fn evaluation_is_concurrent(&self) -> bool { self.evaluation_is_concurrent() } </ins> }


<ins> // build-fail #![feature(track_caller)] fn main() { (0..) .map( #[target_feature(enable = "")] //~^ ERROR: the feature named `` is not valid for this target //~| ERROR: `#[target_feature(..)]` can only be applied to `unsafe` functions #[track_caller] //~^ ERROR: `#[track_caller]` requires Rust ABI |_| (), ) .next(); } </ins>


} _ => bug!("Detected `&*` but didn't find `&*`!"), }; <del> *rvalue = Rvalue::Use(match mtbl { Mutability::Mut => Operand::Move(new_place), Mutability::Not => Operand::Copy(new_place), }); </del> <ins> *rvalue = Rvalue::Use(Operand::Copy(new_place)) </ins> } if let Some(constant) = self.optimizations.arrays_lengths.remove(&location) {


<ins> error[E0412]: cannot find type `Oper` in this scope --> $DIR/issue-54966.rs:3:27 | LL | fn generate_duration() -> Oper<impl FnMut()> {} |                           ^^^^ not found in this scope error: aborting due to previous error For more information about this error, try `rustc --explain E0412`. </ins>


<ins> // run-rustfix fn main() { let a: usize = 123; let b: &usize = &a; if true { a } else { *b //~ ERROR `if` and `else` have incompatible types [E0308] }; if true { 1 } else { 1 //~ ERROR `if` and `else` have incompatible types [E0308] }; if true { 1 } else { 1 //~ ERROR `if` and `else` have incompatible types [E0308] }; } </ins>


<ins> error: argument to `panic!()` in a const context must have type `&str` --> $DIR/issue-66693-panic-in-array-len.rs:8:20 | LL |     let _ = [0i32; panic!(2f32)]; |                    ^^^^^^^^^^^^ | = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/issue-66693-panic-in-array-len.rs:12:21 | LL |     let _ = [false; panic!()]; |                     ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-66693-panic-in-array-len.rs:12:21 | = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. </ins>


tinfo: *const TypeInfo, dest: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void, ) -> !; <del> fn __gxx_personality_v0( version: c_int, actions: uw::_Unwind_Action, exception_class: uw::_Unwind_Exception_Class, exception_object: *mut uw::_Unwind_Exception, context: *mut uw::_Unwind_Context, ) -> uw::_Unwind_Reason_Code; </del> }


// except according to those terms. struct Foo { <ins> field1: i32, //~ NOTE `field1` first declared here </ins> field1: i32, <del> field1: i32, //~ ERROR E0124 </del> <ins> //~^ ERROR field `field1` is already declared [E0124] //~| NOTE field already declared </ins> } fn main() {


// for closures and async closures, respectively. match closure_kind { hir::ClosureKind::Closure <del> if self.tcx.fn_trait_kind_from_def_id(trait_def_id).is_some() => {} </del> <ins> if self.tcx.fn_trait_kind_from_def_id(trait_def_id).is_some() => { self.extract_sig_from_projection(cause_span, projection) } hir::ClosureKind::CoroutineClosure(hir::CoroutineDesugaring::Async) if self.tcx.async_fn_trait_kind_from_def_id(trait_def_id).is_some() => { self.extract_sig_from_projection(cause_span, projection) } // It's possible we've passed the closure to a (somewhat out-of-fashion) // `F: FnOnce() -> Fut, Fut: Future<Output = T>` style bound. Let's still // guide inference here, since it's beneficial for the user. </ins> hir::ClosureKind::CoroutineClosure(hir::CoroutineDesugaring::Async) <del> if self.tcx.async_fn_trait_kind_from_def_id(trait_def_id).is_some() => {} _ => return None, </del> <ins> if self.tcx.fn_trait_kind_from_def_id(trait_def_id).is_some() => { self.extract_sig_from_projection_and_future_bound(cause_span, projection) } _ => None, </ins> } <ins> } /// Given an `FnOnce::Output` or `AsyncFn::Output` projection, extract the args /// and return type to infer a [`ty::PolyFnSig`] for the closure. fn extract_sig_from_projection( &self, cause_span: Option<Span>, projection: ty::PolyProjectionPredicate<'tcx>, ) -> Option<ExpectedSig<'tcx>> { let projection = self.resolve_vars_if_possible(projection); </ins> let arg_param_ty = projection.skip_binder().projection_term.args.type_at(1); <del> let arg_param_ty = self.resolve_vars_if_possible(arg_param_ty); </del> debug!(?arg_param_ty); let ty::Tuple(input_tys) = *arg_param_ty.kind() else {


match &mut fields { Fields::Vec(pats) => { for (i, pat) in new_pats { <del> pats[i] = pat </del> <ins> if let Some(p) = pats.get_mut(i) { *p = pat; } </ins> } } Fields::Filtered { fields, .. } => {


/// /// # Panics /// <del> /// When the number is negative, zero, or if the base is not at least 2; it /// panics in debug mode and the return value is 0 in release /// mode. </del> <ins> /// This function will panic if `self` is less than or equal to zero, /// or if `base` is less then 2. </ins> /// /// # Examples ///


let lookup = &lookup.as_str(); let max_dist = dist.unwrap_or_else(|| cmp::max(lookup.len(), 3) / 3); <del> let (case_insensitive_match, levenshtein_match) = name_vec </del> <ins> // Priority of matches: // 1. Exact case insensitive match // 2. Levenshtein distance match // 3. Sorted word match if let Some(case_insensitive_match) = name_vec.iter().find(|candidate| candidate.as_str().to_uppercase() == lookup.to_uppercase()) { return Some(*case_insensitive_match); } let levenshtein_match = name_vec </ins> .iter() .filter_map(|&name| { let dist = lev_distance(lookup, &name.as_str()); if dist <= max_dist { Some((name, dist)) } else { None } }) // Here we are collecting the next structure: <del> // (case_insensitive_match, (levenshtein_match, levenshtein_distance)) .fold((None, None), |result, (candidate, dist)| { ( if candidate.as_str().to_uppercase() == lookup.to_uppercase() { Some(candidate) } else { result.0 }, match result.1 { None => Some((candidate, dist)), Some((c, d)) => Some(if dist < d { (candidate, dist) } else { (c, d) }), }, ) </del> <ins> // (levenshtein_match, levenshtein_distance) .fold(None, |result, (candidate, dist)| match result { None => Some((candidate, dist)), Some((c, d)) => Some(if dist < d { (candidate, dist) } else { (c, d) }), </ins> }); <del> // Priority of matches: // 1. Exact case insensitive match // 2. Levenshtein distance match // 3. Sorted word match if let Some(candidate) = case_insensitive_match { Some(candidate) } else if levenshtein_match.is_some() { </del> <ins> if levenshtein_match.is_some() { </ins> levenshtein_match.map(|(candidate, _)| candidate) } else { find_match_by_sorted_words(name_vec, lookup)


= note: this expectation will create a diagnostic with the default lint level warning: this lint expectation is unfulfilled <del> --> $DIR/expect_unfulfilled_expectation.rs:24:22 </del> <ins> --> $DIR/expect_unfulfilled_expectation.rs:17:14 | LL |     #[expect(unused_mut, reason = "this expectation will create a diagnostic with the default lint level")] |              ^^^^^^^^^^ | = note: this expectation will create a diagnostic with the default lint level = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` warning: this lint expectation is unfulfilled --> $DIR/expect_unfulfilled_expectation.rs:27:22 | LL |     #[expect(unused, unfulfilled_lint_expectations, reason = "the expectation for `unused` should be fulfilled")] |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the expectation for `unused` should be fulfilled = note: the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message warning: this lint expectation is unfulfilled --> $DIR/expect_unfulfilled_expectation.rs:27:22 </ins> | LL |     #[expect(unused, unfulfilled_lint_expectations, reason = "the expectation for `unused` should be fulfilled")] |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the expectation for `unused` should be fulfilled = note: the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message <ins> = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` </ins> <del> warning: 4 warnings emitted </del> <ins> warning: 6 warnings emitted </ins>


severity: ChangeSeverity::Info, summary: "The `build.profiler` option now tries to use source code from `download-ci-llvm` if possible, instead of checking out the `src/llvm-project` submodule.", }, <ins> ChangeInfo { change_id: 129152, severity: ChangeSeverity::Info, summary: "New option `build.cargo-clippy` added for supporting the use of custom/external clippy.", }, </ins> ];


// `Iterator::__iterator_get_unchecked`. unsafe { (self.a.__iterator_get_unchecked(idx), self.b.__iterator_get_unchecked(idx)) } } <ins> #[inline] fn fold<Acc, F>(mut self, init: Acc, mut f: F) -> Acc where F: FnMut(Acc, Self::Item) -> Acc, { let mut accum = init; let len = ZipImpl::size_hint(&self).0; for i in 0..len { // SAFETY: since Self: TrustedRandomAccessNoCoerce we can trust the size-hint to // calculate the length and then use that to do unchecked iteration. // fold consumes the iterator so we don't need to fixup any state. unsafe { accum = f(accum, self.get_unchecked(i)); } } accum } </ins> } #[doc(hidden)]


let fid = ccx.tcx.map.local_def_id(f.id); let dup_span = seen_fields.get(&f.name).cloned(); if let Some(prev_span) = dup_span { <del> let mut err = struct_span_err!(ccx.tcx.sess, f.span, E0124, "field `{}` is already declared", f.name); span_note!(&mut err, prev_span, "previously declared here"); err.emit(); </del> <ins> struct_span_err!(ccx.tcx.sess, f.span, E0124, "field `{}` is already declared", f.name) .span_label(f.span, &"field already declared") .span_label(prev_span, &format!("`{}` first declared here", f.name)) .emit(); </ins> } else { seen_fields.insert(f.name, f.span); }


<ins> error[E0792]: expected generic lifetime parameter, found `'_` --> $DIR/issue-109054.rs:18:9 | LL | type ReturnType<'a> = impl std::future::Future<Output = u32> + 'a; |                 -- this generic parameter must be used with a generic lifetime parameter ... LL |         &inner |         ^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0792`. </ins>


<ins> // check-pass // Regression test for #78507. fn foo() -> Option<fn() -> Option<bool>> { Some(|| Some(true)) } fn main() {} </ins>


--codeblock-error-color: rgba(255, 0, 0, .5); --codeblock-ignore-hover-color: rgb(255, 142, 0); --codeblock-ignore-color: rgba(255, 142, 0, .6); <ins> --warning-border-color: rgb(255, 142, 0); </ins> --type-link-color: #2dbfb8; --trait-link-color: #b78cf2; --assoc-item-link-color: #d2991d;


} } <ins> fn is_dir_writable_for_user(dir: &PathBuf) -> bool { let tmp_file = dir.join(".tmp"); match fs::File::create(&tmp_file) { Ok(_) => { fs::remove_file(tmp_file).unwrap(); true } Err(e) => { if e.kind() == std::io::ErrorKind::PermissionDenied { false } else { panic!("Failed the write access check for the current user. {}", e); } } } } </ins> fn install_sh( builder: &Builder<'_>, package: &str,


sugar for dynamic allocations via `malloc` and `free`: ```rust,ignore (libc-is-finicky) <del> #![feature(lang_items, box_syntax, start, libc, core_intrinsics, rustc_private)] </del> <ins> #![feature(lang_items, start, libc, core_intrinsics, rustc_private, rustc_attrs)] </ins> #![no_std] use core::intrinsics; use core::panic::PanicInfo; <ins> use core::ptr::NonNull; </ins> extern crate libc; <del> struct Unique<T>(*mut T); </del> <ins> struct Unique<T>(NonNull<T>); </ins> #[lang = "owned_box"] pub struct Box<T>(Unique<T>); <ins> impl<T> Box<T> { pub fn new(x: T) -> Self { #[rustc_box] Box::new(x) } } </ins> #[lang = "exchange_malloc"] unsafe fn allocate(size: usize, _align: usize) -> *mut u8 { let p = libc::malloc(size as libc::size_t) as *mut u8;


<ins> error: literal out of range for `u16` --> $DIR/issue-63364.rs:6:14 | LL |     for n in 100_000.. { |              ^^^^^^^ | = note: `#[deny(overflowing_literals)]` on by default error: aborting due to previous error </ins>


<ins> error[E0107]: missing generics for struct `Vec` --> $DIR/issue-92305.rs:5:45 | LL | fn f<T>(data: &[T]) -> impl Iterator<Item = Vec> { |                                             ^^^ expected at least 1 generic argument | note: struct defined here, with at least 1 generic parameter: `T` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | LL | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> { |            ^^^ - help: add missing generic argument | LL | fn f<T>(data: &[T]) -> impl Iterator<Item = Vec<T>> { |                                             ~~~~~~ error[E0282]: type annotations needed --> $DIR/issue-92305.rs:7:5 | LL |     iter::empty() |     ^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the function `empty` error[E0282]: type annotations needed --> $DIR/issue-92305.rs:10:35 | LL | fn g<T>(data: &[T], target: T) -> impl Iterator<Item = Vec<T>> { |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type error: aborting due to 3 previous errors Some errors have detailed explanations: E0107, E0282. For more information about an error, try `rustc --explain E0107`. </ins>


specs.insert(*id, (level, src)); } } <ins> _ if !self.warn_about_weird_lints => {} </ins> CheckLintNameResult::Warning(ref msg) => { <del> if self.warn_about_weird_lints { self.struct_lint(builtin::RENAMED_AND_REMOVED_LINTS, Some(li.span.into()), msg) .emit(); } </del> <ins> let lint = builtin::RENAMED_AND_REMOVED_LINTS; let (level, src) = self.sets.get_lint_level(lint, self.cur, Some(&specs)); lint::struct_lint_level(self.sess, lint, level, src, Some(li.span.into()), msg) .emit(); </ins> } CheckLintNameResult::NoLint => { <del> if self.warn_about_weird_lints { self.struct_lint(builtin::UNKNOWN_LINTS, Some(li.span.into()), &format!("unknown lint: `{}`", name)) .emit(); } </del> <ins> let lint = builtin::UNKNOWN_LINTS; let (level, src) = self.sets.get_lint_level(lint, self.cur, Some(&specs)); let msg = format!("unknown lint: `{}`", name); lint::struct_lint_level(self.sess, lint, level, src, Some(li.span.into()), &msg) .emit(); </ins> } } }


ty::ty_struct(id, _) => { for field in fields { self.check_field(pattern.span, id, <del> NamedField(field.node.ident)); </del> <ins> NamedField(field.node.ident.name)); </ins> } } ty::ty_enum(_, _) => {


margin: 0 auto; padding: 0 15px; font-size: 18px; <del> color: #333; </del> <ins> color: #000; </ins> line-height: 1.428571429; -webkit-box-sizing: unset; -moz-box-sizing: unset; box-sizing: unset; <ins> background: #fff; </ins> } @media (min-width: 768px) { body {


<ins> // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Make sure this compiles without getting a linker error because of missing // drop-glue because the collector missed adding drop-glue for the closure: fn create_fn() -> Box<Fn()> { let text = String::new(); Box::new(move || { let _ = &text; }) } fn main() { let _ = create_fn(); } </ins>


true } }) <ins> // ensure that we don't suggest unstable methods .filter(|candidate| { // note that `DUMMY_SP` is ok here because it is only used for // suggestions and macro stuff which isn't applicable here. !matches!( self.tcx.eval_stability(candidate.item.def_id, None, DUMMY_SP, None), stability::EvalResult::Deny { .. } ) }) </ins> .map(|candidate| candidate.item.ident(self.tcx)) .filter(|&name| set.insert(name)) .collect();


} as usize; if k == n && c::GetLastError() == c::ERROR_INSUFFICIENT_BUFFER { n *= 2; <del> } else if k >= n { </del> <ins> } else if k > n { </ins> n = k; <ins> } else if k == n { // It is impossible to reach this point. // On success, k is the returned string length excluding the null. // On failure, k is the required buffer length including the null. // Therefore k never equals n. unreachable!(); </ins> } else { return Ok(f2(&buf[..k])); }


/// The root of the normal must_use lint with an optional message. Def(Span, DefId, Option<Symbol>), Boxed(Box<Self>), <ins> Pinned(Box<Self>), </ins> Opaque(Box<Self>), TraitObject(Box<Self>), TupleElement(Vec<(usize, Self)>),


<ins> // Test for <https://github.com/rust-lang/rust/issues/66756> // check-pass #![feature(const_if_match)] enum E { A, B, C } const fn f(e: E) { match e { E::A => {} E::B => {} E::C => {} } } fn main() {} </ins>


pub trait Index<Idx: ?Sized> { /// The returned type after indexing. #[stable(feature = "rust1", since = "1.0.0")] <ins> #[rustc_diagnostic_item = "IndexOutput"] </ins> type Output: ?Sized; /// Performs the indexing (`container[index]`) operation.


sidebarElems.appendChild(ul); } <ins> function expandAllDocs() { const innerToggle = document.getElementById(toggleAllDocsId); removeClass(innerToggle, "will-expand"); onEachLazy(document.getElementsByClassName("rustdoc-toggle"), e => { if (!hasClass(e, "type-contents-toggle")) { e.open = true; } }); innerToggle.title = "collapse all docs"; innerToggle.children[0].innerText = "u2212"; // "u2212" is "−" minus sign } </ins> <del> function labelForToggleButton(sectionIsCollapsed) { if (sectionIsCollapsed) { // button will expand the section return "+"; } // button will collapse the section // note that this text is also set in the HTML template in ../render/mod.rs return "u2212"; // "u2212" is "−" minus sign </del> <ins> function collapseAllDocs() { const innerToggle = document.getElementById(toggleAllDocsId); addClass(innerToggle, "will-expand"); onEachLazy(document.getElementsByClassName("rustdoc-toggle"), e => { if (e.parentNode.id !== "implementations-list" || (!hasClass(e, "implementors-toggle") && !hasClass(e, "type-contents-toggle")) ) { e.open = false; } }); innerToggle.title = "expand all docs"; innerToggle.children[0].innerText = "+"; </ins> } function toggleAllDocs() {


string.push(CodePoint::from_u32(0xD800).unwrap()); check_utf8_boundary(&string, 3); } <ins> #[test] fn wobbled_wtf8_plus_bytes_isnt_utf8() { let mut string: Wtf8Buf = unsafe { Wtf8::from_bytes_unchecked(b"xEDxA0x80").to_owned() }; assert!(!string.is_known_utf8); string.extend_from_slice(b"some utf-8"); assert!(!string.is_known_utf8); } #[test] fn wobbled_wtf8_plus_str_isnt_utf8() { let mut string: Wtf8Buf = unsafe { Wtf8::from_bytes_unchecked(b"xEDxA0x80").to_owned() }; assert!(!string.is_known_utf8); string.push_str("some utf-8"); assert!(!string.is_known_utf8); } #[test] fn unwobbly_wtf8_plus_utf8_is_utf8() { let mut string: Wtf8Buf = Wtf8Buf::from_str("hello world"); assert!(string.is_known_utf8); string.push_str("some utf-8"); assert!(string.is_known_utf8); } </ins>


// check that a comma comes after every field if !ate_comma { <del> let mut err = self.dcx().create_err(ExpectedCommaAfterPatternField { span: self.token.span }); </del> <ins> let err = if self.token == token::At { let prev_field = fields .last() .expect("Unreachable on first iteration, not empty otherwise") .ident; self.report_misplaced_at_in_struct_pat(prev_field) } else { let mut err = self .dcx() .create_err(ExpectedCommaAfterPatternField { span: self.token.span }); self.recover_misplaced_pattern_modifiers(&fields, &mut err); err }; </ins> if let Some(delayed) = delayed_err { delayed.emit(); } <del> self.recover_misplaced_pattern_modifiers(&fields, &mut err); </del> return Err(err); } ate_comma = false;


<ins> // compile-flags: --edition 2018 #![feature(label_break_value, try_blocks)] // run-pass fn main() { let _: Result<(), ()> = try { 'foo: { Err(())?; break 'foo; } }; } </ins>


<del> A type parameter that is specified for `impl` is not constrained. </del> <ins> A type, const or lifetime parameter that is specified for `impl` is not constrained. </ins> Erroneous code example:


impl<'a, T> Fn<(&'a T,)> for Foo { extern "rust-call" fn call(&self, (_,): (T,)) {} <del> //~^ ERROR: has an incompatible type for trait: expected &-ptr </del> <ins> //~^ ERROR: has an incompatible type for trait //~| expected &-ptr </ins> } impl<'a, T> FnMut<(&'a T,)> for Foo { extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {} <del> //~^ ERROR: has an incompatible type for trait: expected &-ptr </del> <ins> //~^ ERROR: has an incompatible type for trait //~| expected &-ptr </ins> } impl<'a, T> FnOnce<(&'a T,)> for Foo { type Output = (); extern "rust-call" fn call_once(self, (_,): (T,)) {} <del> //~^ ERROR: has an incompatible type for trait: expected &-ptr </del> <ins> //~^ ERROR: has an incompatible type for trait //~| expected &-ptr </ins> } fn main() {}


if let Some(trait_def_id) = trait_def_id { let found_kind = match closure_kind { hir::ClosureKind::Closure => self.tcx.fn_trait_kind_from_def_id(trait_def_id), <del> hir::ClosureKind::CoroutineClosure(hir::CoroutineDesugaring::Async) => { self.tcx.async_fn_trait_kind_from_def_id(trait_def_id) } </del> <ins> hir::ClosureKind::CoroutineClosure(hir::CoroutineDesugaring::Async) => self .tcx .async_fn_trait_kind_from_def_id(trait_def_id) .or_else(|| self.tcx.fn_trait_kind_from_def_id(trait_def_id)), </ins> _ => None, };


buf.len() as DWORD, ptr::null()); if res == 0 { <del> fail!("[{}] FormatMessage failure", errno()); </del> <ins> // Sometimes FormatMessageW can fail e.g. system doesn't like langId, let fm_err = errno(); return format!("OS Error {} (FormatMessageW() returned error {})", err, fm_err); </ins> } <del> str::from_utf16(str::truncate_utf16_at_nul(buf)) .expect("FormatMessageW returned invalid UTF-16") </del> <ins> let msg = str::from_utf16(str::truncate_utf16_at_nul(buf)); match msg { Some(msg) => format!("OS Error {}: {}", err, msg), None => format!("OS Error {} (FormatMessageW() returned invalid UTF-16)", err), } </ins> } }


crate fn unexpected<T>(&mut self) -> PResult<'a, T> { match self.expect_one_of(&[], &[]) { Err(e) => Err(e), <del> Ok(_) => unreachable!(), </del> <ins> // We can get `Ok(true)` from `recover_closing_delimiter` // which is called in `expected_one_of_not_found`. Ok(_) => FatalError.raise(), </ins> } }


<ins> error: functions cannot be both `const` and `gen` --> $DIR/const_gen_fn.rs:6:1 | LL | const gen fn a() {} | ^^^^^-^^^---------- | |     | | |     `gen` because of this | `const` because of this error: functions cannot be both `const` and `async gen` --> $DIR/const_gen_fn.rs:9:1 | LL | const async gen fn b() {} | ^^^^^-^^^^^^^^^---------- | |     | | |     `async gen` because of this | `const` because of this error: aborting due to 2 previous errors </ins>


ty::note_and_explain_type_err(tcx, terr); } } <ins> // Finally, resolve all regions. This catches wily misuses of lifetime // parameters. infcx.resolve_regions_and_report_errors(); </ins> } fn check_cast(fcx: &FnCtxt,


/// # Example /// /// ```rust <ins> /// # #![allow(deprecated)] </ins> /// use url::get_scheme; /// /// let scheme = match get_scheme("https://example.com/") {


} fn struct_all_fields_are_public(tcx: TyCtxt<'_>, id: LocalDefId) -> bool { <del> // treat PhantomData and positional ZST as public, // we don't want to lint types which only have them, // cause it's a common way to use such types to check things like well-formedness tcx.adt_def(id).all_fields().all(|field| { </del> <ins> let adt_def = tcx.adt_def(id); // skip types contain fields of unit and never type, // it's usually intentional to make the type not constructible let not_require_constructor = adt_def.all_fields().any(|field| { </ins> let field_type = tcx.type_of(field.did).instantiate_identity(); <del> if field_type.is_phantom_data() { return true; } let is_positional = field.name.as_str().starts_with(|c: char| c.is_ascii_digit()); if is_positional && tcx .layout_of(tcx.param_env(field.did).and(field_type)) .map_or(true, |layout| layout.is_zst()) { return true; } field.vis.is_public() }) </del> <ins> field_type.is_unit() || field_type.is_never() }); not_require_constructor || adt_def.all_fields().all(|field| { let field_type = tcx.type_of(field.did).instantiate_identity(); // skip fields of PhantomData, // cause it's a common way to check things like well-formedness if field_type.is_phantom_data() { return true; } field.vis.is_public() }) </ins> } /// check struct and its fields are public or not,