<del> error: requires at least a template string argument --> $DIR/parse-error.rs:11:9 | LL |         asm!(); |         ^^^^^^ error: asm template must be a string literal --> $DIR/parse-error.rs:13:14 | LL |         asm!(foo); |              ^^^ error: expected token: `,` --> $DIR/parse-error.rs:15:19 | LL |         asm!("{}" foo); |                   ^^^ expected `,` error: expected operand, clobber_abi, options, or additional template string --> $DIR/parse-error.rs:17:20 | LL |         asm!("{}", foo); |                    ^^^ expected operand, clobber_abi, options, or additional template string error: expected `(`, found `foo` --> $DIR/parse-error.rs:19:23 | LL |         asm!("{}", in foo); |                       ^^^ expected `(` error: expected `)`, found `foo` --> $DIR/parse-error.rs:21:27 | LL |         asm!("{}", in(reg foo)); |                           ^^^ expected `)` error: expected expression, found end of macro arguments --> $DIR/parse-error.rs:23:27 | LL |         asm!("{}", in(reg)); |                           ^ expected expression error: expected register class or explicit register --> $DIR/parse-error.rs:25:26 | LL |         asm!("{}", inout(=) foo => bar); |                          ^ error: expected expression, found end of macro arguments --> $DIR/parse-error.rs:27:37 | LL |         asm!("{}", inout(reg) foo =>); |                                     ^ expected expression error: expected one of `!`, `,`, `.`, `::`, `?`, `{`, or an operator, found `=>` --> $DIR/parse-error.rs:29:32 | LL |         asm!("{}", in(reg) foo => bar); |                                ^^ expected one of 7 possible tokens error: expected a path for argument to `sym` --> $DIR/parse-error.rs:31:24 | LL |         asm!("{}", sym foo + bar); |                        ^^^^^^^^^ error: expected one of `)`, `att_syntax`, `may_unwind`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo` --> $DIR/parse-error.rs:33:26 | LL |         asm!("", options(foo)); |                          ^^^ expected one of 10 possible tokens error: expected one of `)` or `,`, found `foo` --> $DIR/parse-error.rs:35:32 | LL |         asm!("", options(nomem foo)); |                                ^^^ expected one of `)` or `,` error: expected one of `)`, `att_syntax`, `may_unwind`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo` --> $DIR/parse-error.rs:37:33 | LL |         asm!("", options(nomem, foo)); |                                 ^^^ expected one of 10 possible tokens error: at least one abi must be provided as an argument to `clobber_abi` --> $DIR/parse-error.rs:41:30 | LL |         asm!("", clobber_abi()); |                              ^ error: expected string literal --> $DIR/parse-error.rs:43:30 | LL |         asm!("", clobber_abi(foo)); |                              ^^^ not a string literal error: expected one of `)` or `,`, found `foo` --> $DIR/parse-error.rs:45:34 | LL |         asm!("", clobber_abi("C" foo)); |                                  ^^^ expected one of `)` or `,` error: expected string literal --> $DIR/parse-error.rs:47:35 | LL |         asm!("", clobber_abi("C", foo)); |                                   ^^^ not a string literal error: duplicate argument named `a` --> $DIR/parse-error.rs:54:36 | LL |         asm!("{a}", a = const foo, a = const bar); |                     -------------  ^^^^^^^^^^^^^ duplicate argument |                     | |                     previously here error: argument never used --> $DIR/parse-error.rs:54:36 | LL |         asm!("{a}", a = const foo, a = const bar); |                                    ^^^^^^^^^^^^^ argument never used | = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` error: explicit register arguments cannot have names --> $DIR/parse-error.rs:59:18 | LL |         asm!("", a = in("eax") foo); |                  ^^^^^^^^^^^^^^^^^ error: positional arguments cannot follow named arguments or explicit register arguments --> $DIR/parse-error.rs:65:36 | LL |         asm!("{1}", in("eax") foo, const bar); |                     -------------  ^^^^^^^^^ positional argument |                     | |                     explicit register argument error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `lateout`, `options`, `out`, or `sym`, found `""` --> $DIR/parse-error.rs:68:29 | LL |         asm!("", options(), ""); |                             ^^ expected one of 9 possible tokens error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `lateout`, `options`, `out`, or `sym`, found `"{}"` --> $DIR/parse-error.rs:70:33 | LL |         asm!("{}", in(reg) foo, "{}", out(reg) foo); |                                 ^^^^ expected one of 9 possible tokens error: asm template must be a string literal --> $DIR/parse-error.rs:72:14 | LL |         asm!(format!("{{{}}}", 0), in(reg) foo); |              ^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: asm template must be a string literal --> $DIR/parse-error.rs:74:21 | LL |         asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar); |                     ^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: _ cannot be used for input operands --> $DIR/parse-error.rs:76:28 | LL |         asm!("{}", in(reg) _); |                            ^ error: _ cannot be used for input operands --> $DIR/parse-error.rs:78:31 | LL |         asm!("{}", inout(reg) _); |                               ^ error: _ cannot be used for input operands --> $DIR/parse-error.rs:80:35 | LL |         asm!("{}", inlateout(reg) _); |                                   ^ error: requires at least a template string argument --> $DIR/parse-error.rs:87:1 | LL | global_asm!(); | ^^^^^^^^^^^^^ error: asm template must be a string literal --> $DIR/parse-error.rs:89:13 | LL | global_asm!(FOO); |             ^^^ error: expected token: `,` --> $DIR/parse-error.rs:91:18 | LL | global_asm!("{}" FOO); |                  ^^^ expected `,` error: expected operand, options, or additional template string --> $DIR/parse-error.rs:93:19 | LL | global_asm!("{}", FOO); |                   ^^^ expected operand, options, or additional template string error: expected expression, found end of macro arguments --> $DIR/parse-error.rs:95:24 | LL | global_asm!("{}", const); |                        ^ expected expression error: expected one of `,`, `.`, `?`, or an operator, found `FOO` --> $DIR/parse-error.rs:97:30 | LL | global_asm!("{}", const(reg) FOO); |                              ^^^ expected one of `,`, `.`, `?`, or an operator error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` --> $DIR/parse-error.rs:99:25 | LL | global_asm!("", options(FOO)); |                         ^^^ expected one of `)`, `att_syntax`, or `raw` error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` --> $DIR/parse-error.rs:101:25 | LL | global_asm!("", options(nomem FOO)); |                         ^^^^^ expected one of `)`, `att_syntax`, or `raw` error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` --> $DIR/parse-error.rs:103:25 | LL | global_asm!("", options(nomem, FOO)); |                         ^^^^^ expected one of `)`, `att_syntax`, or `raw` error: expected string literal --> $DIR/parse-error.rs:106:29 | LL | global_asm!("", clobber_abi(FOO)); |                             ^^^ not a string literal error: expected one of `)` or `,`, found `FOO` --> $DIR/parse-error.rs:108:33 | LL | global_asm!("", clobber_abi("C" FOO)); |                                 ^^^ expected one of `)` or `,` error: expected string literal --> $DIR/parse-error.rs:110:34 | LL | global_asm!("", clobber_abi("C", FOO)); |                                  ^^^ not a string literal error: `clobber_abi` cannot be used with `global_asm!` --> $DIR/parse-error.rs:112:19 | LL | global_asm!("{}", clobber_abi("C"), const FOO); |                   ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` --> $DIR/parse-error.rs:114:28 | LL | global_asm!("", options(), clobber_abi("C")); |                            ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` --> $DIR/parse-error.rs:116:30 | LL | global_asm!("{}", options(), clobber_abi("C"), const FOO); |                              ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` --> $DIR/parse-error.rs:118:17 | LL | global_asm!("", clobber_abi("C"), clobber_abi("C")); |                 ^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^ error: duplicate argument named `a` --> $DIR/parse-error.rs:120:35 | LL | global_asm!("{a}", a = const FOO, a = const BAR); |                    -------------  ^^^^^^^^^^^^^ duplicate argument |                    | |                    previously here error: argument never used --> $DIR/parse-error.rs:120:35 | LL | global_asm!("{a}", a = const FOO, a = const BAR); |                                   ^^^^^^^^^^^^^ argument never used | = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `""` --> $DIR/parse-error.rs:123:28 | LL | global_asm!("", options(), ""); |                            ^^ expected one of `clobber_abi`, `const`, `options`, or `sym` error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `"{}"` --> $DIR/parse-error.rs:125:30 | LL | global_asm!("{}", const FOO, "{}", const FOO); |                              ^^^^ expected one of `clobber_abi`, `const`, `options`, or `sym` error: asm template must be a string literal --> $DIR/parse-error.rs:127:13 | LL | global_asm!(format!("{{{}}}", 0), const FOO); |             ^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: asm template must be a string literal --> $DIR/parse-error.rs:129:20 | LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); |                    ^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0435]: attempt to use a non-constant value in a constant --> $DIR/parse-error.rs:39:37 | LL |     let mut foo = 0; |     ----------- help: consider using `const` instead of `let`: `const foo` ... LL |         asm!("{}", options(), const foo); |                                     ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant --> $DIR/parse-error.rs:49:44 | LL |     let mut foo = 0; |     ----------- help: consider using `const` instead of `let`: `const foo` ... LL |         asm!("{}", clobber_abi("C"), const foo); |                                            ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant --> $DIR/parse-error.rs:52:55 | LL |     let mut foo = 0; |     ----------- help: consider using `const` instead of `let`: `const foo` ... LL |         asm!("{}", options(), clobber_abi("C"), const foo); |                                                       ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant --> $DIR/parse-error.rs:54:31 | LL |     let mut foo = 0; |     ----------- help: consider using `const` instead of `let`: `const foo` ... LL |         asm!("{a}", a = const foo, a = const bar); |                               ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant --> $DIR/parse-error.rs:54:46 | LL |     let mut bar = 0; |     ----------- help: consider using `const` instead of `let`: `const bar` ... LL |         asm!("{a}", a = const foo, a = const bar); |                                              ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant --> $DIR/parse-error.rs:61:46 | LL |     let mut bar = 0; |     ----------- help: consider using `const` instead of `let`: `const bar` ... LL |         asm!("{a}", in("eax") foo, a = const bar); |                                              ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant --> $DIR/parse-error.rs:63:46 | LL |     let mut bar = 0; |     ----------- help: consider using `const` instead of `let`: `const bar` ... LL |         asm!("{a}", in("eax") foo, a = const bar); |                                              ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant --> $DIR/parse-error.rs:65:42 | LL |     let mut bar = 0; |     ----------- help: consider using `const` instead of `let`: `const bar` ... LL |         asm!("{1}", in("eax") foo, const bar); |                                          ^^^ non-constant value error: aborting due to 59 previous errors For more information about this error, try `rustc --explain E0435`. </del>


<ins> // only-x86_64 #![feature(asm_const)] use std::arch::asm; fn main() { let mut foo = 0; let mut bar = 0; unsafe { asm!("", a = in("eax") foo); //~^ ERROR explicit register arguments cannot have names asm!("{a}", in("eax") foo, a = const bar); //~^ ERROR attempt to use a non-constant value in a constant asm!("{a}", in("eax") foo, a = const bar); //~^ ERROR attempt to use a non-constant value in a constant asm!("{1}", in("eax") foo, const bar); //~^ ERROR positional arguments cannot follow named arguments or explicit register arguments //~^^ ERROR attempt to use a non-constant value in a constant } } </ins>


<ins> error: explicit register arguments cannot have names --> $DIR/x86_64_parse_error.rs:11:18 | LL |         asm!("", a = in("eax") foo); |                  ^^^^^^^^^^^^^^^^^ error: positional arguments cannot follow named arguments or explicit register arguments --> $DIR/x86_64_parse_error.rs:17:36 | LL |         asm!("{1}", in("eax") foo, const bar); |                     -------------  ^^^^^^^^^ positional argument |                     | |                     explicit register argument error[E0435]: attempt to use a non-constant value in a constant --> $DIR/x86_64_parse_error.rs:13:46 | LL |     let mut bar = 0; |     ----------- help: consider using `const` instead of `let`: `const bar` ... LL |         asm!("{a}", in("eax") foo, a = const bar); |                                              ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant --> $DIR/x86_64_parse_error.rs:15:46 | LL |     let mut bar = 0; |     ----------- help: consider using `const` instead of `let`: `const bar` ... LL |         asm!("{a}", in("eax") foo, a = const bar); |                                              ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant --> $DIR/x86_64_parse_error.rs:17:42 | LL |     let mut bar = 0; |     ----------- help: consider using `const` instead of `let`: `const bar` ... LL |         asm!("{1}", in("eax") foo, const bar); |                                          ^^^ non-constant value error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0435`. </ins>


// They can denote both statically and dynamically-sized byte arrays. let mut pat_ty = ty; if let hir::ExprKind::Lit(Spanned { node: ast::LitKind::ByteStr(..), .. }) = lt.kind { <del> if let ty::Ref(_, inner_ty, _) = *self.structurally_resolved_type(span, expected).kind() && self.structurally_resolved_type(span, inner_ty).is_slice() </del> <ins> let expected = self.structurally_resolved_type(span, expected); if let ty::Ref(_, inner_ty, _) = expected.kind() && matches!(inner_ty.kind(), ty::Slice(_)) </ins> { let tcx = self.tcx; trace!(?lt.hir_id.local_id, "polymorphic byte string lit");


<ins> // check-pass fn load<L>() -> Option<L> { todo!() } fn main() { while let Some(tag) = load() { match &tag { b"NAME" => {} b"DATA" => {} _ => {} } } } </ins>


// compile-flags: -Ztrait-solver=next <del> // check-pass </del> <ins> // known-bug: rust-lang/trait-system-refactor-initiative#38 </ins> fn test(s: &[u8]) { match &s[0..3] {


<ins> error[E0271]: type mismatch resolving `[u8; 3] <: <Range<usize> as SliceIndex<[u8]>>::Output` --> $DIR/slice-match-byte-lit.rs:6:9 | LL |     match &s[0..3] { |           -------- this expression has type `&<std::ops::Range<usize> as SliceIndex<[u8]>>::Output` LL |         b"uwu" => {} |         ^^^^^^ types differ error: aborting due to previous error For more information about this error, try `rustc --explain E0271`. </ins>


map.insert("toggle-all-docs".into(), 1); map.insert("all-types".into(), 1); map.insert("default-settings".into(), 1); <del> map.insert("rustdoc-vars".into(), 1); </del> map.insert("sidebar-vars".into(), 1); map.insert("copy-path".into(), 1); map.insert("TOC".into(), 1);


// Local js definitions: /* global addClass, getCurrentValue, onEachLazy, removeClass, browserSupportsHistoryApi */ <del> /* global updateLocalStorage */ </del> <ins> /* global updateLocalStorage, getVar */ </ins> "use strict"; (function() { <del> const rootPath = document.getElementById("rustdoc-vars").attributes["data-root-path"].value; </del> <ins> const rootPath = getVar("root-path"); </ins> const NAME_OFFSET = 0; const DIRS_OFFSET = 1;


// Get a value from the rustdoc-vars div, which is used to convey data from // Rust to the JS. If there is no such element, return null. const getVar = (function getVar(name) { <del> const el = document.getElementById("rustdoc-vars"); </del> <ins> const el = document.querySelector("head > meta[name='rustdoc-vars']"); </ins> return el ? el.attributes["data-" + name].value : null; });


{% endfor %} ></script> {# #} {% endif %} <del> <div id="rustdoc-vars" {#+ #} </del> <ins> <meta name="rustdoc-vars" {#+ #} </ins> data-root-path="{{page.root_path|safe}}" {#+ #} data-static-root-path="{{static_root_path|safe}}" {#+ #} data-current-crate="{{layout.krate}}" {#+ #}


data-theme-dark-css="{{files.theme_dark_css}}" {#+ #} data-theme-ayu-css="{{files.theme_ayu_css}}" {#+ #} > {# #} <del> </div> {# #} </del> <script src="{{static_root_path|safe}}{{files.storage_js}}"></script> {# #} {% if page.css_class.contains("crate") %} <script defer src="{{page.root_path|safe}}crates{{page.resource_suffix}}.js"></script> {# #}


// @has test.css // @has foo/struct.Foo.html <del> // @has - '//*[@id="rustdoc-vars"]/@data-themes' 'test' </del> <ins> // @has - '//*[@name="rustdoc-vars"]/@data-themes' 'test' </ins> pub struct Foo;


<del> // check-pass trait A { type Assoc; } impl A for () { // FIXME: it would be nice for this to at least cause a warning. type Assoc = Foo<()>; } struct Foo<T: A>(T::Assoc); fn main() {} </del>


<del> // build-fail //~^ ERROR cycle detected when computing layout of `Foo<()>` trait A { type Assoc: ?Sized; } impl A for () { type Assoc = Foo<()>; } struct Foo<T: A>(T::Assoc); fn main() { let x: Foo<()>; } </del>


<del> error[E0391]: cycle detected when computing layout of `Foo<()>` | = note: ...which requires computing layout of `<() as A>::Assoc`... = note: ...which again requires computing layout of `Foo<()>`, completing the cycle note: cycle used when elaborating drops for `main` --> $DIR/recursive-type-2.rs:11:1 | LL | fn main() { | ^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0391`. </del>


<ins> // build-fail //~^ ERROR cycle detected when computing layout of `Foo<()>` trait A { type Assoc: ?Sized; } impl A for () { type Assoc = Foo<()>; } struct Foo<T: A>(T::Assoc); fn main() { let x: Foo<()>; } </ins>


<ins> error[E0391]: cycle detected when computing layout of `Foo<()>` | = note: ...which requires computing layout of `<() as A>::Assoc`... = note: ...which again requires computing layout of `Foo<()>`, completing the cycle note: cycle used when elaborating drops for `main` --> $DIR/recursive-type-binding.rs:11:1 | LL | fn main() { | ^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0391`. </ins>


<ins> // build-fail //~^ ERROR cycle detected when computing layout of `Foo<()>` // Regression test for a stack overflow: https://github.com/rust-lang/rust/issues/113197 trait A { type Assoc; } impl A for () { type Assoc = Foo<()>; } struct Foo<T: A>(T::Assoc); fn main() { Foo::<()>(todo!()); } </ins>


<ins> error[E0391]: cycle detected when computing layout of `Foo<()>` | = note: ...which requires computing layout of `<() as A>::Assoc`... = note: ...which again requires computing layout of `Foo<()>`, completing the cycle note: cycle used when elaborating drops for `main` --> $DIR/recursive-type-coercion-from-never.rs:14:1 | LL | fn main() { | ^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0391`. </ins>


<ins> // check-pass trait A { type Assoc; } impl A for () { // FIXME: it would be nice for this to at least cause a warning. type Assoc = Foo<()>; } struct Foo<T: A>(T::Assoc); fn main() {} </ins>


use rustc_hir as hir; use rustc_hir::def::Res; use rustc_hir::def_id::DefId; <del> use rustc_infer::traits::ObligationCauseCode; </del> <ins> use rustc_infer::{infer::type_variable::TypeVariableOriginKind, traits::ObligationCauseCode}; </ins> use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor}; use rustc_span::{self, symbol::kw, Span}; use rustc_trait_selection::traits;


type BreakTy = ty::GenericArg<'tcx>; fn visit_ty(&mut self, ty: Ty<'tcx>) -> std::ops::ControlFlow<Self::BreakTy> { if let Some(origin) = self.0.type_var_origin(ty) <del> && let rustc_infer::infer::type_variable::TypeVariableOriginKind::TypeParameterDefinition(_, def_id) = origin.kind </del> <ins> && let TypeVariableOriginKind::TypeParameterDefinition(_, def_id) = origin.kind </ins> && let generics = self.0.tcx.generics_of(self.1) && let Some(index) = generics.param_def_id_to_index(self.0.tcx, def_id) && let Some(subst) = ty::GenericArgs::identity_for_item(self.0.tcx, self.1)


let ty_vars = infcx_inner.type_variables(); let var_origin = ty_vars.var_origin(ty_vid); if let TypeVariableOriginKind::TypeParameterDefinition(name, def_id) = var_origin.kind <del> && !var_origin.span.from_expansion() </del> <ins> && name != kw::SelfUpper && !var_origin.span.from_expansion() </ins> { let generics = infcx.tcx.generics_of(infcx.tcx.parent(def_id)); let idx = generics.param_def_id_to_index(infcx.tcx, def_id).unwrap();


// If there is only one implementation of the trait, suggest using it. // Otherwise, use a placeholder comment for the implementation. let (message, impl_suggestion) = if non_blanket_impl_count == 1 {( <del> "use the fully-qualified path to the only available implementation".to_string(), </del> <ins> "use the fully-qualified path to the only available implementation", </ins> format!("<{} as ", self.tcx.type_of(impl_def_id).instantiate_identity()) <del> )} else {( format!( "use a fully-qualified path to a specific available implementation ({} found)", non_blanket_impl_count ), "</* self type */ as ".to_string() </del> <ins> )} else { ("use a fully-qualified path to a specific available implementation", "</* self type */ as ".to_string() </ins> )}; let mut suggestions = vec![( path.span.shrink_to_lo(),


LL |     let cont: u32 = Generator::create(); |                     ^^^^^^^^^^^^^^^^^ cannot call associated function of trait | <del> help: use a fully-qualified path to a specific available implementation (2 found) </del> <ins> help: use a fully-qualified path to a specific available implementation </ins> | LL |     let cont: u32 = </* self type */ as Generator>::create(); |                     +++++++++++++++++++          +


LL |     MyTrait2::my_fn(); |     ^^^^^^^^^^^^^^^ cannot call associated function of trait | <del> help: use a fully-qualified path to a specific available implementation (2 found) </del> <ins> help: use a fully-qualified path to a specific available implementation </ins> | LL |     </* self type */ as MyTrait2>::my_fn(); |     +++++++++++++++++++         +


<ins> // Regression test for #113610 where we ICEd when trying to print // inference variables created by instantiating the self type parameter. fn main() { let _ = (Default::default(),); //~^ ERROR cannot call associated function on trait } </ins>


<ins> error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type --> $DIR/infer-var-for-self-param.rs:5:14 | LL |     let _ = (Default::default(),); |              ^^^^^^^^^^^^^^^^ cannot call associated function of trait | help: use a fully-qualified path to a specific available implementation | LL |     let _ = (</* self type */ as Default>::default(),); |              +++++++++++++++++++        + error: aborting due to previous error For more information about this error, try `rustc --explain E0790`. </ins>


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::io; use std::vec; pub struct Container<'a> { reader: &'a mut Reader //~ ERROR explicit lifetime bound required } impl<'a> Container<'a> { pub fn wrap<'s>(reader: &'s mut Reader) -> Container<'s> { Container { reader: reader } } pub fn read_to(&mut self, vec: &mut [u8]) { self.reader.read(vec); } } pub fn for_stdin<'a>() -> Container<'a> { let mut r = io::stdin(); Container::wrap(&mut r as &mut Reader) } fn main() { let mut c = for_stdin(); let mut v = vec::Vec::from_elem(10, 0u8); c.read_to(v.as_mut_slice()); } </ins>


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn blah() -> int { //~ ERROR not all control paths return a value 1i ; //~ NOTE consider removing this semicolon: } fn main() { } </ins>


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(struct_variant)] mod a { pub enum Enum { EnumStructVariant { x: u8, y: u8, z: u8 } } pub fn get_enum_struct_variant() -> () { EnumStructVariant { x: 1, y: 2, z: 3 } //~^ ERROR mismatched types: expected `()`, found `a::Enum` (expected (), found enum a::Enum) } } mod b { mod test { use a; fn test_enum_struct_variant() { let enum_struct_variant = ::a::get_enum_struct_variant(); match enum_struct_variant { a::EnumStructVariant { x, y, z } => { //~^ ERROR error: mismatched types: expected `()`, found a structure pattern } } } } } fn main() {} </ins>


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn main() { let mut array = [1, 2, 3]; //~^ ERROR cannot determine a type for this local variable: cannot determine the type of this integ let pie_slice = array.slice(1, 2); } </ins>


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. pub fn foo(params: Option<&[&str]>) -> uint { params.unwrap().head().unwrap().len() } fn main() { let name = "Foo"; let msg = foo(Some(&[name.as_slice()])); //~^ ERROR mismatched types: expected `core::option::Option<&[&str]>` assert_eq!(msg, 3); } </ins>


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn main() { let v = &[]; //~ ERROR cannot determine a type for this local variable: unconstrained type let it = v.iter(); } </ins>


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // error-pattern:explicit failure pub fn main() { fail!(); println!("{}", 1i); } </ins>


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // error-pattern:bad input fn main() { Some("foo").unwrap_or(fail!("bad input")).to_string(); } </ins>


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. pub mod two_tuple { trait T {} struct P<'a>(&'a T + 'a, &'a T + 'a); pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> { P(car, cdr) } } pub mod two_fields { trait T {} struct P<'a> { car: &'a T + 'a, cdr: &'a T + 'a } pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> { P{ car: car, cdr: cdr } } } fn main() {} </ins>


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn main() { if true { proc(_) {} } else { proc(_: &mut ()) {} }; } </ins>


} _ => {} } <del> // If someone calls a const fn, they can extract that call out into a separate constant (or a const // block in the future), so we check that to tell them that in the diagnostic. Does not affect typeck. let is_const_fn = match element.kind { </del> <ins> // If someone calls a const fn or constructs a const value, they can extract that // out into a separate constant (or a const block in the future), so we check that // to tell them that in the diagnostic. Does not affect typeck. let is_constable = match element.kind { </ins> hir::ExprKind::Call(func, _args) => match *self.node_ty(func.hir_id).kind() { <del> ty::FnDef(def_id, _) => tcx.is_const_fn(def_id), _ => false, </del> <ins> ty::FnDef(def_id, _) if tcx.is_const_fn(def_id) => traits::IsConstable::Fn, _ => traits::IsConstable::No, </ins> }, <del> _ => false, </del> <ins> hir::ExprKind::Path(qpath) => { match self.typeck_results.borrow().qpath_res(&qpath, element.hir_id) { Res::Def(DefKind::Ctor(_, CtorKind::Const), _) => traits::IsConstable::Ctor, _ => traits::IsConstable::No, } } _ => traits::IsConstable::No, </ins> }; // If the length is 0, we don't create any elements, so we don't copy any. If the length is 1, we // don't copy that one element, we move it. Only check for Copy if the length is larger. if count.try_eval_target_usize(tcx, self.param_env).map_or(true, |len| len > 1) { let lang_item = self.tcx.require_lang_item(LangItem::Copy, None); <del> let code = traits::ObligationCauseCode::RepeatElementCopy { is_const_fn }; </del> <ins> let code = traits::ObligationCauseCode::RepeatElementCopy { is_constable, elt_type: element_ty, elt_span: element.span, elt_stmt_span: self .tcx .hir() .parent_iter(element.hir_id) .find_map(|(_, node)| match node { hir::Node::Item(it) => Some(it.span), hir::Node::Stmt(stmt) => Some(stmt.span), _ => None, }) .expect("array repeat expressions must be inside an item or statement"), }; </ins> self.require_type_meets(element_ty, element.span, code, lang_item); } }


InlineAsmSized, /// `[expr; N]` requires `type_of(expr): Copy`. RepeatElementCopy { <del> /// If element is a `const fn` we display a help message suggesting to move the /// function call to a new `const` item while saying that `T` doesn't implement `Copy`. is_const_fn: bool, </del> <ins> /// If element is a `const fn` or const ctor we display a help message suggesting /// to move it to a new `const` item while saying that `T` doesn't implement `Copy`. is_constable: IsConstable, elt_type: Ty<'tcx>, elt_span: Span, /// Span of the statement/item in which the repeat expression occurs. We can use this to /// place a `const` declaration before it elt_stmt_span: Span, </ins> }, /// Types of fields (other than the last, except for packed structs) in a struct must be sized.


TypeAlias(InternedObligationCauseCode<'tcx>, Span, DefId), } <ins> /// Whether a value can be extracted into a const. /// Used for diagnostics around array repeat expressions. #[derive(Copy, Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)] pub enum IsConstable { No, /// Call to a const fn Fn, /// Use of a const ctor Ctor, } crate::TrivialTypeTraversalAndLiftImpls! { IsConstable, } </ins> /// The 'location' at which we try to perform HIR-based wf checking. /// This information is used to obtain an `hir::Ty`, which /// we can walk in order to obtain precise spans for any


use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::infer::{DefineOpaqueTypes, InferOk, LateBoundRegionConversionTime}; use rustc_middle::hir::map; <ins> use rustc_middle::traits::IsConstable; </ins> use rustc_middle::ty::error::TypeError::{self, Sorts}; use rustc_middle::ty::{ self, suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind,


)); } } <del> ObligationCauseCode::RepeatElementCopy { is_const_fn } => { </del> <ins> ObligationCauseCode::RepeatElementCopy { is_constable, elt_type, elt_span, elt_stmt_span } => { </ins> err.note( "the `Copy` trait is required because this value will be copied for each element of the array", ); <del> if is_const_fn { err.help( "consider creating a new `const` item and initializing it with the result  of the function call to be used in the repeat position, like  `const VAL: Type = const_fn();` and `let x = [VAL; 42];`", ); </del> <ins> let value_kind = match is_constable { IsConstable::Fn => Some("the result of the function call"), IsConstable::Ctor => Some("the result of the constructor"), _ => None }; let sm = tcx.sess.source_map(); if let Some(value_kind) = value_kind && let Ok(snip) = sm.span_to_snippet(elt_span) { let help_msg = format!( "consider creating a new `const` item and initializing it with {value_kind}  to be used in the repeat position"); let indentation = sm.indentation_before(elt_stmt_span).unwrap_or_default(); err.multipart_suggestion(help_msg, vec![ (elt_stmt_span.shrink_to_lo(), format!("const ARRAY_REPEAT_VALUE: {elt_type} = {snip};n{indentation}")), (elt_span, "ARRAY_REPEAT_VALUE".to_string()) ], Applicability::MachineApplicable); </ins> } <del> if self.tcx.sess.is_nightly_build() && is_const_fn { </del> <ins> if self.tcx.sess.is_nightly_build() && matches!(is_constable, IsConstable::Fn|IsConstable::Ctor) { </ins> err.help( "create an inline `const` block, see RFC #2920  <https://github.com/rust-lang/rfcs/pull/2920> for more information",


| = note: required for `Option<Bar>` to implement `Copy` = note: the `Copy` trait is required because this value will be copied for each element of the array <del> = help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];` </del> = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information help: consider annotating `Bar` with `#[derive(Copy)]` | LL + #[derive(Copy)] LL | struct Bar; | <ins> help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position | LL ~     const ARRAY_REPEAT_VALUE: Option<Bar> = no_copy(); LL ~     let _: [Option<Bar>; 2] = [ARRAY_REPEAT_VALUE; 2]; | </ins> error: aborting due to previous error


LL | #[derive(Copy, Clone)] |          ^^^^ unsatisfied trait bound introduced in this `derive` macro = note: the `Copy` trait is required because this value will be copied for each element of the array <del> = help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];` </del> = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) <ins> help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position | LL ~     const ARRAY_REPEAT_VALUE: Foo<String> = Foo(String::new()); LL ~     [ARRAY_REPEAT_VALUE; 4]; | </ins> error: aborting due to previous error


<ins> static _MAYBE_STRINGS: [Option<String>; 5] = [None; 5]; //~^ ERROR the trait bound `String: Copy` is not satisfied </ins> fn main() { // should hint to create an inline `const` block // or to create a new `const` item <del> let strings: [String; 5] = [String::new(); 5]; </del> <ins> let _strings: [String; 5] = [String::new(); 5]; //~^ ERROR the trait bound `String: Copy` is not satisfied let _maybe_strings: [Option<String>; 5] = [None; 5]; </ins> //~^ ERROR the trait bound `String: Copy` is not satisfied <del> println!("{:?}", strings); </del> }


error[E0277]: the trait bound `String: Copy` is not satisfied <del> --> $DIR/const-fn-in-vec.rs:4:33 </del> <ins> --> $DIR/const-fn-in-vec.rs:1:47 </ins> | <del> LL |     let strings: [String; 5] = [String::new(); 5]; |                                 ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` </del> <ins> LL | static _MAYBE_STRINGS: [Option<String>; 5] = [None; 5]; |                                               ^^^^ the trait `Copy` is not implemented for `String` </ins> | <ins> = note: required for `Option<String>` to implement `Copy` </ins> = note: the `Copy` trait is required because this value will be copied for each element of the array <del> = help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];` </del> = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information <ins> help: consider creating a new `const` item and initializing it with the result of the constructor to be used in the repeat position | LL + const ARRAY_REPEAT_VALUE: Option<String> = None; LL ~ static _MAYBE_STRINGS: [Option<String>; 5] = [ARRAY_REPEAT_VALUE; 5]; | error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/const-fn-in-vec.rs:7:34 | LL |     let _strings: [String; 5] = [String::new(); 5]; |                                  ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` | = note: the `Copy` trait is required because this value will be copied for each element of the array = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position | LL ~     const ARRAY_REPEAT_VALUE: String = String::new(); LL ~     let _strings: [String; 5] = [ARRAY_REPEAT_VALUE; 5]; | error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/const-fn-in-vec.rs:9:48 | LL |     let _maybe_strings: [Option<String>; 5] = [None; 5]; |                                                ^^^^ the trait `Copy` is not implemented for `String` | = note: required for `Option<String>` to implement `Copy` = note: the `Copy` trait is required because this value will be copied for each element of the array = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information help: consider creating a new `const` item and initializing it with the result of the constructor to be used in the repeat position | LL ~     const ARRAY_REPEAT_VALUE: Option<String> = None; LL ~     let _maybe_strings: [Option<String>; 5] = [ARRAY_REPEAT_VALUE; 5]; | </ins> <del> error: aborting due to previous error </del> <ins> error: aborting due to 3 previous errors </ins> For more information about this error, try `rustc --explain E0277`.


Self::new(List::empty(), self.reveal()) } <del> /// Creates a suitable environment in which to perform trait /// queries on the given value. When type-checking, this is simply /// the pair of the environment plus value. But when reveal is set to /// All, then if `value` does not reference any type parameters, we will /// pair it with the empty environment. This improves caching and is generally /// invisible. /// /// N.B., we preserve the environment when type-checking because it /// is possible for the user to have wacky where-clauses like /// `where Box<u32>: Copy`, which are clearly never /// satisfiable. We generally want to behave as if they were true, /// although the surrounding function is never reachable. </del> <ins> /// Creates a pair of param-env and value for use in queries. </ins> pub fn and<T: TypeVisitable<TyCtxt<'tcx>>>(self, value: T) -> ParamEnvAnd<'tcx, T> { <del> match self.reveal() { Reveal::UserFacing => ParamEnvAnd { param_env: self, value }, Reveal::All => { if value.is_global() { ParamEnvAnd { param_env: self.without_caller_bounds(), value } } else { ParamEnvAnd { param_env: self, value } } } } </del> <ins> ParamEnvAnd { param_env: self, value } </ins> } }


<ins> // check-pass trait Bar<'a> { type Assoc: 'static; } impl<'a> Bar<'a> for () { type Assoc = (); } struct ImplsStatic<CG: Bar<'static>> { d: &'static <CG as Bar<'static>>::Assoc, } fn caller(b: ImplsStatic<()>) where for<'a> (): Bar<'a> { let _: &<() as Bar<'static>>::Assoc = b.d; } fn main() {} </ins>


fn __rust_alloc_error_handler(size: usize, align: usize) -> !; } <del> /// Abort on memory allocation error or failure. </del> <ins> /// Signal a memory allocation error. </ins> /// <del> /// Callers of memory allocation APIs wishing to abort computation </del> <ins> /// Callers of memory allocation APIs wishing to cease execution </ins> /// in response to an allocation error are encouraged to call this function, <del> /// rather than directly invoking `panic!` or similar. </del> <ins> /// rather than directly invoking [`panic!`] or similar. </ins> /// <del> /// The default behavior of this function is to print a message to standard error /// and abort the process. /// It can be replaced with [`set_alloc_error_hook`] and [`take_alloc_error_hook`]. </del> <ins> /// This function is guaranteed to diverge (not return normally with a value), but depending on /// global configuration, it may either panic (resulting in unwinding or aborting as per /// configuration for all panics), or abort the process (with no unwinding). /// /// The default behavior is: /// ///  * If the binary links against `std` (typically the case), then ///   print a message to standard error and abort the process. ///   This behavior can be replaced with [`set_alloc_error_hook`] and [`take_alloc_error_hook`]. ///   Future versions of Rust may panic by default instead. /// /// * If the binary does not link against `std` (all of its crates are marked ///   [`#![no_std]`][no_std]), then call [`panic!`] with a message. ///   [The panic handler] applies as to any panic. </ins> /// /// [`set_alloc_error_hook`]: ../../std/alloc/fn.set_alloc_error_hook.html /// [`take_alloc_error_hook`]: ../../std/alloc/fn.take_alloc_error_hook.html <ins> /// [The panic handler]: https://doc.rust-lang.org/reference/runtime.html#the-panic_handler-attribute /// [no_std]: https://doc.rust-lang.org/reference/names/preludes.html#the-no_std-attribute </ins> #[stable(feature = "global_alloc", since = "1.28.0")] #[rustc_const_unstable(feature = "const_alloc_error", issue = "92523")] #[cfg(all(not(no_global_oom_handling), not(test)))]


/// Registers a custom allocation error hook, replacing any that was previously registered. /// <del> /// The allocation error hook is invoked when an infallible memory allocation fails, before /// the runtime aborts. The default hook prints a message to standard error, /// but this behavior can be customized with the [`set_alloc_error_hook`] and /// [`take_alloc_error_hook`] functions. </del> <ins> /// The allocation error hook is invoked when an infallible memory allocation fails — that is, /// as a consequence of calling [`handle_alloc_error`] — before the runtime aborts. </ins> /// <del> /// The hook is provided with a `Layout` struct which contains information </del> <ins> /// The allocation error hook is a global resource. [`take_alloc_error_hook`] may be used to /// retrieve a previously registered hook and wrap or discard it. /// /// # What the provided `hook` function should expect /// /// The hook function is provided with a [`Layout`] struct which contains information </ins> /// about the allocation that failed. /// <del> /// The allocation error hook is a global resource. </del> <ins> /// The hook function may choose to panic or abort; in the event that it returns normally, this /// will cause an immediate abort. /// /// Since [`take_alloc_error_hook`] is a safe function that allows retrieving the hook, the hook /// function must be _sound_ to call even if no memory allocations were attempted. /// /// # The default hook /// /// The default hook, used if [`set_alloc_error_hook`] is never called, prints a message to /// standard error (and then returns, causing the runtime to abort the process). /// Compiler options may cause it to panic instead, and the default behavior may be changed /// to panicking in future versions of Rust. </ins> /// /// # Examples ///


tracked!(profile_emit, Some(PathBuf::from("abc"))); tracked!(profile_sample_use, Some(PathBuf::from("abc"))); tracked!(profiler_runtime, "abc".to_string()); <del> tracked!(relax_elf_relocations, Some(false)); </del> <ins> tracked!(relax_elf_relocations, Some(true)); </ins> tracked!(relro_level, Some(RelroLevel::Full)); tracked!(remap_cwd_prefix, Some(PathBuf::from("abc"))); tracked!(report_delayed_bugs, true);


mcount: "mcount".into(), llvm_mcount_intrinsic: None, llvm_abiname: "".into(), <del> relax_elf_relocations: true, </del> <ins> relax_elf_relocations: false, </ins> llvm_args: cvs![], use_ctors_section: false, eh_frame_header: true,


position_independent_executables: true, pre_link_args, override_export_symbols: Some(EXPORT_SYMBOLS.iter().cloned().map(Cow::from).collect()), <ins> relax_elf_relocations: true, </ins> ..Default::default() }; Target {


let mut fmt = Cow::Borrowed(fmt); if self.tcx.sess.opts.unstable_opts.flatten_format_args { fmt = flatten_format_args(fmt); <del> fmt = inline_literals(fmt); </del> <ins> fmt = self.inline_literals(fmt); </ins> } expand_format_args(self, sp, &fmt, allow_const) } <ins> /// Try to convert a literal into an interned string fn try_inline_lit(&self, lit: token::Lit) -> Option<Symbol> { match LitKind::from_token_lit(lit) { Ok(LitKind::Str(s, _)) => Some(s), Ok(LitKind::Int(n, ty)) => { match ty { // unsuffixed integer literals are assumed to be i32's LitIntType::Unsuffixed => { (n <= i32::MAX as u128).then_some(Symbol::intern(&n.to_string())) } LitIntType::Signed(int_ty) => { let max_literal = self.int_ty_max(int_ty); (n <= max_literal).then_some(Symbol::intern(&n.to_string())) } LitIntType::Unsigned(uint_ty) => { let max_literal = self.uint_ty_max(uint_ty); (n <= max_literal).then_some(Symbol::intern(&n.to_string())) } } } _ => None, } } /// Get the maximum value of int_ty. It is platform-dependent due to the byte size of isize fn int_ty_max(&self, int_ty: IntTy) -> u128 { match int_ty { IntTy::Isize => self.tcx.data_layout.pointer_size.signed_int_max() as u128, IntTy::I8 => i8::MAX as u128, IntTy::I16 => i16::MAX as u128, IntTy::I32 => i32::MAX as u128, IntTy::I64 => i64::MAX as u128, IntTy::I128 => i128::MAX as u128, } } /// Get the maximum value of uint_ty. It is platform-dependent due to the byte size of usize fn uint_ty_max(&self, uint_ty: UintTy) -> u128 { match uint_ty { UintTy::Usize => self.tcx.data_layout.pointer_size.unsigned_int_max(), UintTy::U8 => u8::MAX as u128, UintTy::U16 => u16::MAX as u128, UintTy::U32 => u32::MAX as u128, UintTy::U64 => u64::MAX as u128, UintTy::U128 => u128::MAX as u128, } } /// Inline literals into the format string. /// /// Turns /// /// `format_args!("Hello, {}! {} {}", "World", 123, x)` /// /// into /// /// `format_args!("Hello, World! 123 {}", x)`. fn inline_literals<'fmt>(&self, mut fmt: Cow<'fmt, FormatArgs>) -> Cow<'fmt, FormatArgs> { let mut was_inlined = vec![false; fmt.arguments.all_args().len()]; let mut inlined_anything = false; for i in 0..fmt.template.len() { let FormatArgsPiece::Placeholder(placeholder) = &fmt.template[i] else { continue }; let Ok(arg_index) = placeholder.argument.index else { continue }; let mut literal = None; if let FormatTrait::Display = placeholder.format_trait && placeholder.format_options == Default::default() && let arg = fmt.arguments.all_args()[arg_index].expr.peel_parens_and_refs() && let ExprKind::Lit(lit) = arg.kind { literal = self.try_inline_lit(lit); } if let Some(literal) = literal { // Now we need to mutate the outer FormatArgs. // If this is the first time, this clones the outer FormatArgs. let fmt = fmt.to_mut(); // Replace the placeholder with the literal. fmt.template[i] = FormatArgsPiece::Literal(literal); was_inlined[arg_index] = true; inlined_anything = true; } } // Remove the arguments that were inlined. if inlined_anything { let fmt = fmt.to_mut(); let mut remove = was_inlined; // Don't remove anything that's still used. for_all_argument_indexes(&mut fmt.template, |index| remove[*index] = false); // Drop all the arguments that are marked for removal. let mut remove_it = remove.iter(); fmt.arguments.all_args_mut().retain(|_| remove_it.next() != Some(&true)); // Calculate the mapping of old to new indexes for the remaining arguments. let index_map: Vec<usize> = remove .into_iter() .scan(0, |i, remove| { let mapped = *i; *i += !remove as usize; Some(mapped) }) .collect(); // Correct the indexes that refer to arguments that have shifted position. for_all_argument_indexes(&mut fmt.template, |index| *index = index_map[*index]); } fmt } </ins> } /// Flattens nested `format_args!()` into one.


fmt } <del> /// Inline literals into the format string. /// /// Turns /// /// `format_args!("Hello, {}! {} {}", "World", 123, x)` /// /// into /// /// `format_args!("Hello, World! 123 {}", x)`. fn inline_literals(mut fmt: Cow<'_, FormatArgs>) -> Cow<'_, FormatArgs> { let mut was_inlined = vec![false; fmt.arguments.all_args().len()]; let mut inlined_anything = false; for i in 0..fmt.template.len() { let FormatArgsPiece::Placeholder(placeholder) = &fmt.template[i] else { continue }; let Ok(arg_index) = placeholder.argument.index else { continue }; let mut literal = None; if let FormatTrait::Display = placeholder.format_trait && placeholder.format_options == Default::default() && let arg = fmt.arguments.all_args()[arg_index].expr.peel_parens_and_refs() && let ExprKind::Lit(lit) = arg.kind { if let token::LitKind::Str | token::LitKind::StrRaw(_) = lit.kind && let Ok(LitKind::Str(s, _)) = LitKind::from_token_lit(lit) { literal = Some(s); } else if let token::LitKind::Integer = lit.kind && let Ok(LitKind::Int(n, _)) = LitKind::from_token_lit(lit) { literal = Some(Symbol::intern(&n.to_string())); } } if let Some(literal) = literal { // Now we need to mutate the outer FormatArgs. // If this is the first time, this clones the outer FormatArgs. let fmt = fmt.to_mut(); // Replace the placeholder with the literal. fmt.template[i] = FormatArgsPiece::Literal(literal); was_inlined[arg_index] = true; inlined_anything = true; } } // Remove the arguments that were inlined. if inlined_anything { let fmt = fmt.to_mut(); let mut remove = was_inlined; // Don't remove anything that's still used. for_all_argument_indexes(&mut fmt.template, |index| remove[*index] = false); // Drop all the arguments that are marked for removal. let mut remove_it = remove.iter(); fmt.arguments.all_args_mut().retain(|_| remove_it.next() != Some(&true)); // Calculate the mapping of old to new indexes for the remaining arguments. let index_map: Vec<usize> = remove .into_iter() .scan(0, |i, remove| { let mapped = *i; *i += !remove as usize; Some(mapped) }) .collect(); // Correct the indexes that refer to arguments that have shifted position. for_all_argument_indexes(&mut fmt.template, |index| *index = index_map[*index]); } fmt } </del> #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] enum ArgumentType { Format(FormatTrait),


<ins> //@ only-64bit fn main() { format_args!("{}", 0x8f_i8); // issue #115423 //~^ ERROR literal out of range for `i8` format_args!("{}", 0xffff_ffff_u8); // issue #116633 //~^ ERROR literal out of range for `u8` format_args!("{}", 0xffff_ffff_ffff_ffff_ffff_usize); //~^ ERROR literal out of range for `usize` format_args!("{}", 0x8000_0000_0000_0000_isize); //~^ ERROR literal out of range for `isize` format_args!("{}", 0xffff_ffff); // treat unsuffixed literals as i32 //~^ ERROR literal out of range for `i32` } </ins>


<ins> error: literal out of range for `i8` --> $DIR/no-inline-literals-out-of-range.rs:4:24 | LL |     format_args!("{}", 0x8f_i8); // issue #115423 |                        ^^^^^^^ | = note: the literal `0x8f_i8` (decimal `143`) does not fit into the type `i8` and will become `-113i8` = note: `#[deny(overflowing_literals)]` on by default help: consider using the type `u8` instead | LL |     format_args!("{}", 0x8f_u8); // issue #115423 |                        ~~~~~~~ help: to use as a negative number (decimal `-113`), consider using the type `u8` for the literal and cast it to `i8` | LL |     format_args!("{}", 0x8f_u8 as i8); // issue #115423 |                        ~~~~~~~~~~~~~ error: literal out of range for `u8` --> $DIR/no-inline-literals-out-of-range.rs:6:24 | LL |     format_args!("{}", 0xffff_ffff_u8); // issue #116633 |                        ^^^^^^^^^^^^^^ help: consider using the type `u32` instead: `0xffff_ffff_u32` | = note: the literal `0xffff_ffff_u8` (decimal `4294967295`) does not fit into the type `u8` and will become `255u8` error: literal out of range for `usize` --> $DIR/no-inline-literals-out-of-range.rs:8:24 | LL |     format_args!("{}", 0xffff_ffff_ffff_ffff_ffff_usize); |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the literal `0xffff_ffff_ffff_ffff_ffff_usize` (decimal `1208925819614629174706175`) does not fit into the type `usize` and will become `18446744073709551615usize` error: literal out of range for `isize` --> $DIR/no-inline-literals-out-of-range.rs:10:24 | LL |     format_args!("{}", 0x8000_0000_0000_0000_isize); |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the literal `0x8000_0000_0000_0000_isize` (decimal `9223372036854775808`) does not fit into the type `isize` and will become `-9223372036854775808isize` error: literal out of range for `i32` --> $DIR/no-inline-literals-out-of-range.rs:12:24 | LL |     format_args!("{}", 0xffff_ffff); // treat unsuffixed literals as i32 |                        ^^^^^^^^^^^ | = note: the literal `0xffff_ffff` (decimal `4294967295`) does not fit into the type `i32` and will become `-1i32` = help: consider using the type `u32` instead help: to use as a negative number (decimal `-1`), consider using the type `u32` for the literal and cast it to `i32` | LL |     format_args!("{}", 0xffff_ffffu32 as i32); // treat unsuffixed literals as i32 |                        ~~~~~~~~~~~~~~~~~~~~~ error: aborting due to 5 previous errors </ins>


n /= 10; exponent += 1; } let (added_precision, subtracted_precision) = match f.precision() { Some(fmt_prec) => { // number of decimal digits minus 1


let rem = n % 10; n /= 10; exponent += 1; <del> // round up last digit if rem >= 5 { </del> <ins> // round up last digit, round to even on a tie if rem > 5 || (rem == 5 && (n % 2 != 0 || subtracted_precision > 1 )) { </ins> n += 1; <ins> // if the digit is rounded to the next power // instead adjust the exponent if n.ilog10() > (n - 1).ilog10() { n /= 10; exponent += 1; } </ins> } } (n, exponent, exponent, added_precision)


let big_int: u32 = 314_159_265; assert_eq!(format!("{big_int:.1e}"), format!("{:.1e}", f64::from(big_int))); <del> //test adding precision </del> <ins> // test adding precision </ins> assert_eq!(format!("{:.10e}", i8::MIN), "-1.2800000000e2"); assert_eq!(format!("{:.10e}", i16::MIN), "-3.2768000000e4"); assert_eq!(format!("{:.10e}", i32::MIN), "-2.1474836480e9"); assert_eq!(format!("{:.20e}", i64::MIN), "-9.22337203685477580800e18"); assert_eq!(format!("{:.40e}", i128::MIN), "-1.7014118346046923173168730371588410572800e38"); <del> //test rounding </del> <ins> // test rounding </ins> assert_eq!(format!("{:.1e}", i8::MIN), "-1.3e2"); assert_eq!(format!("{:.1e}", i16::MIN), "-3.3e4"); assert_eq!(format!("{:.1e}", i32::MIN), "-2.1e9"); assert_eq!(format!("{:.1e}", i64::MIN), "-9.2e18"); assert_eq!(format!("{:.1e}", i128::MIN), "-1.7e38"); <del> //test huge precision </del> <ins> // test huge precision </ins> assert_eq!(format!("{:.1000e}", 1), format!("1.{}e0", "0".repeat(1000))); //test zero precision assert_eq!(format!("{:.0e}", 1), format!("1e0",)); assert_eq!(format!("{:.0e}", 35), format!("4e1",)); <del> //test padding with precision (and sign) </del> <ins> // test padding with precision (and sign) </ins> assert_eq!(format!("{:+10.3e}", 1), "  +1.000e0"); <ins> // test precision remains correct when rounding to next power for i in i16::MIN..=i16::MAX { for p in 0..=5 { assert_eq!( format!("{i:.p$e}"), format!("{:.p$e}", f32::from(i)), "integer {i} at precision {p}" ); } } </ins> } #[test]


#[cfg(unix)] use crate::os::unix::fs::symlink as symlink_junction; #[cfg(windows)] <del> use crate::os::windows::fs::{symlink_dir, symlink_file}; </del> <ins> use crate::os::windows::fs::{symlink_dir, symlink_file, OpenOptionsExt}; </ins> #[cfg(windows)] use crate::sys::fs::symlink_junction; #[cfg(target_os = "macos")]


assert_eq!(socket_path.try_exists().unwrap(), true); assert_eq!(socket_path.metadata().is_ok(), true); } <ins> #[cfg(windows)] #[test] fn test_hidden_file_truncation() { // Make sure that File::create works on an existing hidden file. See #115745. let tmpdir = tmpdir(); let path = tmpdir.join("hidden_file.txt"); // Create a hidden file. const FILE_ATTRIBUTE_HIDDEN: u32 = 2; let mut file = OpenOptions::new() .write(true) .create_new(true) .attributes(FILE_ATTRIBUTE_HIDDEN) .open(&path) .unwrap(); file.write("hidden world!".as_bytes()).unwrap(); file.flush().unwrap(); drop(file); // Create a new file by truncating the existing one. let file = File::create(&path).unwrap(); let metadata = file.metadata().unwrap(); assert_eq!(metadata.len(), 0); } </ins>


Windows.Win32.Storage.FileSystem.FILE_ADD_FILE Windows.Win32.Storage.FileSystem.FILE_ADD_SUBDIRECTORY Windows.Win32.Storage.FileSystem.FILE_ALL_ACCESS <ins> Windows.Win32.Storage.FileSystem.FILE_ALLOCATION_INFO </ins> Windows.Win32.Storage.FileSystem.FILE_APPEND_DATA Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_ARCHIVE Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_COMPRESSED


pub type FILE_ACCESS_RIGHTS = u32; pub const FILE_ADD_FILE: FILE_ACCESS_RIGHTS = 2u32; pub const FILE_ADD_SUBDIRECTORY: FILE_ACCESS_RIGHTS = 4u32; <ins> #[repr(C)] pub struct FILE_ALLOCATION_INFO { pub AllocationSize: i64, } impl ::core::marker::Copy for FILE_ALLOCATION_INFO {} impl ::core::clone::Clone for FILE_ALLOCATION_INFO { fn clone(&self) -> Self { *self } } </ins> pub const FILE_ALL_ACCESS: FILE_ACCESS_RIGHTS = 2032127u32; pub const FILE_APPEND_DATA: FILE_ACCESS_RIGHTS = 4u32; pub const FILE_ATTRIBUTE_ARCHIVE: FILE_FLAGS_AND_ATTRIBUTES = 32u32;


use crate::os::windows::prelude::*; use crate::borrow::Cow; <del> use crate::ffi::OsString; </del> <ins> use crate::ffi::{c_void, OsString}; </ins> use crate::fmt; use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom}; use crate::mem::{self, MaybeUninit};


use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::thread; <del> use core::ffi::c_void; </del> use super::path::maybe_verbatim; use super::to_u16s;


(false, false, false) => c::OPEN_EXISTING, (true, false, false) => c::OPEN_ALWAYS, (false, true, false) => c::TRUNCATE_EXISTING, <del> (true, true, false) => c::CREATE_ALWAYS, </del> <ins> // `CREATE_ALWAYS` has weird semantics so we emulate it using // `OPEN_ALWAYS` and a manual truncation step. See #115745. (true, true, false) => c::OPEN_ALWAYS, </ins> (_, _, true) => c::CREATE_NEW, }) }


impl File { pub fn open(path: &Path, opts: &OpenOptions) -> io::Result<File> { let path = maybe_verbatim(path)?; <ins> let creation = opts.get_creation_mode()?; </ins> let handle = unsafe { c::CreateFileW( path.as_ptr(), opts.get_access_mode()?, opts.share_mode, opts.security_attributes, <del> opts.get_creation_mode()?, </del> <ins> creation, </ins> opts.get_flags_and_attributes(), ptr::null_mut(), ) }; let handle = unsafe { HandleOrInvalid::from_raw_handle(handle) }; <del> if let Ok(handle) = handle.try_into() { </del> <ins> if let Ok(handle) = OwnedHandle::try_from(handle) { // Manual truncation. See #115745. if opts.truncate && creation == c::OPEN_ALWAYS && unsafe { c::GetLastError() } == c::ERROR_ALREADY_EXISTS { unsafe { // Setting the allocation size to zero also sets the // EOF position to zero. let alloc = c::FILE_ALLOCATION_INFO { AllocationSize: 0 }; let result = c::SetFileInformationByHandle( handle.as_raw_handle(), c::FileAllocationInfo, ptr::addr_of!(alloc).cast::<c_void>(), mem::size_of::<c::FILE_ALLOCATION_INFO>() as u32, ); if result == 0 { return Err(io::Error::last_os_error()); } } } </ins> Ok(File { handle: Handle::from_inner(handle) }) } else { Err(Error::last_os_error())


/// Shortens the deque, keeping the first `len` elements and dropping /// the rest. /// <del> /// If `len` is greater than the deque's current length, this has no /// effect. </del> <ins> /// If `len` is greater or equal to the deque's current length, this has /// no effect. </ins> /// /// # Examples ///


/// Shortens the vector, keeping the first `len` elements and dropping /// the rest. /// <del> /// If `len` is greater than the vector's current length, this has no /// effect. </del> <ins> /// If `len` is greater or equal to the vector's current length, this has /// no effect. </ins> /// /// The [`drain`] method can emulate `truncate`, but causes the excess /// elements to be returned instead of dropped.


if libc::sched_getaffinity(0, mem::size_of::<libc::cpu_set_t>(), &mut set) == 0 { let count = libc::CPU_COUNT(&set) as usize; let count = count.min(quota); <del> // SAFETY: affinity mask can't be empty and the quota gets clamped to a minimum of 1 return Ok(NonZeroUsize::new_unchecked(count)); </del> <ins> // reported to occur on MIPS kernels older than our minimum supported kernel version for those targets let count = NonZeroUsize::new(count) .expect("CPU count must be > 0. This may be a bug in sched_getaffinity(); try upgrading the kernel."); return Ok(count); </ins> } } }


let reachable_context = ReachableContext::new(tcx, method_map); // Step 1: Seed the worklist with all nodes which were found to be public as <del> //         a result of the privacy pass </del> <ins> //         a result of the privacy pass along with all local lang items. If //         other crates link to us, they're going to expect to be able to //         use the lang items, so we need to be sure to mark them as //         exported. let mut worklist = reachable_context.worklist.borrow_mut(); </ins> for &id in exported_items.iter() { <del> let mut worklist = reachable_context.worklist.borrow_mut(); </del> worklist.get().push(id); } <ins> for (_, item) in tcx.lang_items.items() { match *item { Some(did) if is_local(did) => { worklist.get().push(did.node); } _ => {} } } drop(worklist); </ins> // Step 2: Mark all symbols that the symbols on the worklist touch. reachable_context.propagate();


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #[no_std]; #[lang="fail_"] fn fail(_: *i8, _: *i8, _: uint) -> ! { loop {} } #[no_mangle] pub extern "C" fn rust_stack_exhausted() {} </ins>


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // aux-build:lang-item-public.rs // ignore-fast // ignore-android #[no_std]; extern crate lang_lib = "lang-item-public"; #[cfg(target_os = "linux")] #[link(name = "c")] extern {} #[cfg(target_os = "android")] #[link(name = "c")] extern {} #[cfg(target_os = "freebsd")] #[link(name = "execinfo")] extern {} #[cfg(target_os = "macos")] #[link(name = "System")] extern {} #[start] fn main(_: int, _: **u8) -> int { 1 % 1 } </ins>


///     surprising results upon inspecting the bit patterns, ///     as the same calculations might produce NaNs with different bit patterns. /// <del> /// When the number resulting from a primitive operation (addition, /// subtraction, multiplication, or division) on this type is not exactly /// representable as `f32`, it is rounded according to the roundTiesToEven /// direction defined in IEEE 754-2008. That means: </del> <ins> /// When a primitive operation (addition, subtraction, multiplication, or /// division) is performed on this type, the result is rounded according to the /// roundTiesToEven direction defined in IEEE 754-2008. That means: </ins> /// /// - The result is the representable value closest to the true value, if there ///   is a unique closest representable value.


/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` − ///   `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the ///   true value's sign). <ins> /// - If the result of a sum exactly equals zero, the outcome is +0.0 unless ///   both arguments were negative, then it is -0.0. Subtraction `a - b` is ///   regarded as a sum `a + (-b)`. </ins> /// /// For more information on floating point numbers, see [Wikipedia][wikipedia]. ///


use cell::RefCell; use intrinsics; use sync::StaticRwLock; <ins> use sync::atomic::{AtomicBool, Ordering}; </ins> use sys::stdio::Stderr; use sys_common::backtrace; use sys_common::thread_info;


static HANDLER_LOCK: StaticRwLock = StaticRwLock::new(); static mut HANDLER: Handler = Handler::Default; <ins> static FIRST_PANIC: AtomicBool = AtomicBool::new(true); </ins> /// Registers a custom panic handler, replacing any that was previously /// registered.


let write = |err: &mut ::io::Write| { let _ = writeln!(err, "thread '{}' panicked at '{}', {}:{}", name, msg, file, line); if log_backtrace { let _ = backtrace::write(err); <ins> } else if FIRST_PANIC.compare_and_swap(true, false, Ordering::SeqCst) { let _ = writeln!(err, "note: Run with `RUST_BACKTRACE=1` for a backtrace."); </ins> } };


<ins> // Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn main() { let args: Vec<String> = std::env::args().collect(); if args.len() > 1 && args[1] == "run_test" { let _ = std::thread::spawn(|| { panic!(); }).join(); panic!(); } else { let test = std::process::Command::new(&args[0]).arg("run_test").output().unwrap(); assert!(!test.status.success()); let err = String::from_utf8_lossy(&test.stderr); let mut it = err.lines(); assert_eq!(it.next().map(|l| l.starts_with("thread '<unnamed>' panicked at")), Some(true)); assert_eq!(it.next(), Some("note: Run with `RUST_BACKTRACE=1` for a backtrace.")); assert_eq!(it.next().map(|l| l.starts_with("thread '<main>' panicked at")), Some(true)); assert_eq!(it.next(), None); } } </ins>


<ins> // test for #117058 - check that attributes are validated on various kinds of statements. struct A; fn func() {} fn main() { #[allow(two-words)] //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` if true { } else { } #[allow(two-words)] //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` (1); #[allow(two-words)] //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` match 1 { _ => {} } #[allow(two-words)] //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` while false {} #[allow(two-words)] //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` {} #[allow(two-words)] //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` A {}; #[allow(two-words)] //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` func(); #[allow(two-words)] //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` A; #[allow(two-words)] //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` loop {} } </ins>


<ins> error: expected one of `(`, `,`, `::`, or `=`, found `-` --> $DIR/statement-attribute-validation.rs:8:16 | LL |     #[allow(two-words)] |                ^ expected one of `(`, `,`, `::`, or `=` error: expected one of `(`, `,`, `::`, or `=`, found `-` --> $DIR/statement-attribute-validation.rs:13:16 | LL |     #[allow(two-words)] |                ^ expected one of `(`, `,`, `::`, or `=` error: expected one of `(`, `,`, `::`, or `=`, found `-` --> $DIR/statement-attribute-validation.rs:16:16 | LL |     #[allow(two-words)] |                ^ expected one of `(`, `,`, `::`, or `=` error: expected one of `(`, `,`, `::`, or `=`, found `-` --> $DIR/statement-attribute-validation.rs:21:16 | LL |     #[allow(two-words)] |                ^ expected one of `(`, `,`, `::`, or `=` error: expected one of `(`, `,`, `::`, or `=`, found `-` --> $DIR/statement-attribute-validation.rs:24:16 | LL |     #[allow(two-words)] |                ^ expected one of `(`, `,`, `::`, or `=` error: expected one of `(`, `,`, `::`, or `=`, found `-` --> $DIR/statement-attribute-validation.rs:27:16 | LL |     #[allow(two-words)] |                ^ expected one of `(`, `,`, `::`, or `=` error: expected one of `(`, `,`, `::`, or `=`, found `-` --> $DIR/statement-attribute-validation.rs:30:16 | LL |     #[allow(two-words)] |                ^ expected one of `(`, `,`, `::`, or `=` error: expected one of `(`, `,`, `::`, or `=`, found `-` --> $DIR/statement-attribute-validation.rs:33:16 | LL |     #[allow(two-words)] |                ^ expected one of `(`, `,`, `::`, or `=` error: expected one of `(`, `,`, `::`, or `=`, found `-` --> $DIR/statement-attribute-validation.rs:36:16 | LL |     #[allow(two-words)] |                ^ expected one of `(`, `,`, `::`, or `=` error: aborting due to 9 previous errors </ins>


expected: Ty<'tcx>, found: Ty<'tcx>, ) -> bool { <del> let ty::Adt(adt, args) = found.kind() else { return false }; </del> <ins> let ty::Adt(adt, args) = found.kind() else { return false; }; </ins> let ret_ty_matches = |diagnostic_item| { <del> if let Some(ret_ty) = self .ret_coercion .as_ref() .map(|c| self.resolve_vars_if_possible(c.borrow().expected_ty())) && let ty::Adt(kind, _) = ret_ty.kind() && self.tcx.get_diagnostic_item(diagnostic_item) == Some(kind.did()) { true } else { false } </del> <ins> let Some(sig) = self.body_fn_sig() else { return false; }; let ty::Adt(kind, _) = sig.output().kind() else { return false; }; self.tcx.is_diagnostic_item(diagnostic_item, kind.did()) </ins> }; // don't suggest anything like `Ok(ok_val).unwrap()` , `Some(some_val).unwrap()`,


<ins> // edition: 2021 async fn dont_suggest() -> i32 { if false { return Ok(6); //~^ ERROR mismatched types } 5 } async fn do_suggest() -> i32 { if false { let s = Ok(6); return s; //~^ ERROR mismatched types } 5 } fn main() {} </ins>


<ins> error[E0308]: mismatched types --> $DIR/async-unwrap-suggestion.rs:5:16 | LL |         return Ok(6); |                ^^^^^ expected `i32`, found `Result<{integer}, _>` | = note: expected type `i32` found enum `Result<{integer}, _>` error[E0308]: mismatched types --> $DIR/async-unwrap-suggestion.rs:15:16 | LL |         return s; |                ^ expected `i32`, found `Result<{integer}, _>` | = note: expected type `i32` found enum `Result<{integer}, _>` help: consider using `Result::expect` to unwrap the `Result<{integer}, _>` value, panicking if the value is a `Result::Err` | LL |         return s.expect("REASON"); |                 +++++++++++++++++ error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. </ins>


("macro_registrar", Active), ("log_syntax", Active), ("trace_macros", Active), <ins> ("simd", Active), </ins> // These are used to test this portion of the compiler, they don't actually // mean anything


} } <ins> ast::ItemStruct(..) => { if attr::contains_name(i.attrs, "simd") { self.gate_feature("simd", i.span, "SIMD types are experimental and possibly buggy"); } } </ins> _ => {} }


html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://static.rust-lang.org/doc/master")]; <del> #[feature(macro_rules, globs, asm, managed_boxes, thread_local, link_args)]; </del> <ins> #[feature(macro_rules, globs, asm, managed_boxes, thread_local, link_args, simd)]; </ins> // Don't link to std. We are std. #[no_std]; #[deny(non_camel_case_types)]; #[deny(missing_doc)]; <ins> #[allow(unknown_features)]; </ins> // When testing libstd, bring in libuv as the I/O backend so tests can print // things and all of the std::io tests have an I/O interface to run on top


#[allow(non_camel_case_types)]; <ins> #[experimental] </ins> #[simd] pub struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8); <ins> #[experimental] </ins> #[simd] pub struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); <ins> #[experimental] </ins> #[simd] pub struct i32x4(i32, i32, i32, i32); <ins> #[experimental] </ins> #[simd] pub struct i64x2(i64, i64); <ins> #[experimental] </ins> #[simd] pub struct u8x16(u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8); <ins> #[experimental] </ins> #[simd] pub struct u16x8(u16, u16, u16, u16, u16, u16, u16, u16); <ins> #[experimental] </ins> #[simd] pub struct u32x4(u32, u32, u32, u32); <ins> #[experimental] </ins> #[simd] pub struct u64x2(u64, u64); <ins> #[experimental] </ins> #[simd] pub struct f32x4(f32, f32, f32, f32); <ins> #[experimental] </ins> #[simd] pub struct f64x2(f64, f64);


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #[simd] pub struct i64x2(i64, i64); //~ ERROR: SIMD types are experimental fn main() {} </ins>  No newline at end of file


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // xfail-test FIXME #11741 tuple structs ignore stability attributes #[deny(experimental)]; use std::unstable::simd; fn main() { let _ = simd::i64x2(0, 0); //~ ERROR: experimental } </ins>


<ins> #[feature(simd)]; </ins> #[simd] struct vec4<T>(T, T, T, T); //~ ERROR SIMD vector cannot be generic


// option. This file may not be copied, modified, or distributed // except according to those terms. <ins> #[allow(experimental)]; </ins> use std::unstable::simd::{i32x4, f32x4}; fn test_int(e: i32) -> i32 {


<ins> // xfail-fast feature doesn't work #[feature(simd)]; </ins> #[simd] struct RGBA { r: f32,


// types are fine though. ty::ConstKind::Value(_) => c.ty().is_primitive(), ty::ConstKind::Unevaluated(..) | ty::ConstKind::Expr(..) => false, <ins> // This can happen if evaluation of a constant failed. The result does not matter // much since compilation is doomed. ty::ConstKind::Error(..) => false, </ins> // Should not appear in runtime MIR. ty::ConstKind::Infer(..) | ty::ConstKind::Bound(..) <del> | ty::ConstKind::Placeholder(..) | ty::ConstKind::Error(..) => bug!(), </del> <ins> | ty::ConstKind::Placeholder(..) => bug!(), </ins> }, Const::Unevaluated(..) => false, // If the same slice appears twice in the MIR, we cannot guarantee that we will


<ins> error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed --> $DIR/issue-50814-2.rs:16:24 | LL |     const BAR: usize = [5, 6, 7][T::BOO]; |                        ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 note: erroneous constant encountered --> $DIR/issue-50814-2.rs:20:6 | LL |     &<A<T> as Foo<T>>::BAR |      ^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered --> $DIR/issue-50814-2.rs:20:5 | LL |     &<A<T> as Foo<T>>::BAR |     ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. </ins>


<ins> error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed --> $DIR/issue-50814-2.rs:16:24 | LL |     const BAR: usize = [5, 6, 7][T::BOO]; |                        ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 note: erroneous constant encountered --> $DIR/issue-50814-2.rs:20:6 | LL |     &<A<T> as Foo<T>>::BAR |      ^^^^^^^^^^^^^^^^^^^^^ note: the above error was encountered while instantiating `fn foo::<()>` --> $DIR/issue-50814-2.rs:32:22 | LL |     println!("{:x}", foo::<()>() as *const usize as usize); |                      ^^^^^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. </ins>


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


<del> error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed --> $DIR/issue-50814-2.rs:14:24 | LL |     const BAR: usize = [5, 6, 7][T::BOO]; |                        ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 note: erroneous constant encountered --> $DIR/issue-50814-2.rs:18:6 | LL |     &<A<T> as Foo<T>>::BAR |      ^^^^^^^^^^^^^^^^^^^^^ note: the above error was encountered while instantiating `fn foo::<()>` --> $DIR/issue-50814-2.rs:30:22 | LL |     println!("{:x}", foo::<()>() as *const usize as usize); |                      ^^^^^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. </del>


// - use std::lazy for `Lazy` // - use std::cell for `OnceCell` // Once they get stabilized and reach beta. <ins> use build_helper::ci::CiEnv; </ins> use clap::ValueEnum; use once_cell::sync::{Lazy, OnceCell};


self.clear_if_dirty(&out_dir, &backend); } <del> if cmd == "doc" || cmd == "rustdoc" { </del> <ins> if cmd == "doc" || cmd == "rustdoc" // FIXME: We shouldn't need to check this. // ref https://github.com/rust-lang/rust/issues/117430#issuecomment-1788160523 && !CiEnv::is_ci() { </ins> let my_out = match mode { // This is the intended out directory for compiler documentation. Mode::Rustc | Mode::ToolRustc => self.compiler_doc_out(target),


} fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> { <del> if builder.config.dry_run() { return None; } </del> // This prevents rustc_codegen_cranelift from being built for "dist" // or "install" on the stable/beta channels. It is not yet stable and // should not be included.


return None; } <del> if !builder.config.rust_codegen_backends.contains(&self.backend) { return None; } </del> if self.backend == "cranelift" { if !target_supports_cranelift_backend(self.compiler.host) { builder.info("target not supported by rustc_codegen_cranelift. skipping");


let backends_dst = PathBuf::from("lib").join(&backends_rel); let backend_name = format!("rustc_codegen_{}", backend); <del> let mut found_backend = false; </del> for backend in fs::read_dir(&backends_src).unwrap() { let file_name = backend.unwrap().file_name(); if file_name.to_str().unwrap().contains(&backend_name) { tarball.add_file(backends_src.join(file_name), &backends_dst, 0o644); <del> found_backend = true; </del> } } <del> assert!(found_backend); </del> Some(tarball.generate()) }


--env DIST_TRY_BUILD  --env PR_CI_JOB  --env OBJDIR_ON_HOST="$objdir"  <del> --env CODEGEN_BACKENDS  </del> --init  --rm  rust-ci


match err { LayoutError::Unknown(..) | LayoutError::ReferencesError(..) => Self::UnknownLayout, LayoutError::SizeOverflow(..) => Self::SizeOverflow, <ins> LayoutError::Cycle(err) => Self::TypeError(*err), </ins> err => unimplemented!("{:?}", err), } }


<ins> //~ ERROR: cycle detected //! Safe transmute did not handle cycle errors that could occur during //! layout computation. This test checks that we do not ICE in such //! situations (see #117491). #![crate_type = "lib"] #![feature(transmutability)] #![allow(dead_code, incomplete_features, non_camel_case_types)] mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; pub fn is_maybe_transmutable<Src, Dst>() where Dst: BikeshedIntrinsicFrom<Src, Context>, { } } fn should_pad_explicitly_packed_field() { #[repr(C)] struct ExplicitlyPadded(ExplicitlyPadded); //~^ ERROR: recursive type assert::is_maybe_transmutable::<ExplicitlyPadded, ()>(); } </ins>


<ins> error[E0072]: recursive type `ExplicitlyPadded` has infinite size --> $DIR/transmute_infinitely_recursive_type.rs:22:5 | LL |     struct ExplicitlyPadded(ExplicitlyPadded); |     ^^^^^^^^^^^^^^^^^^^^^^^ ---------------- recursive without indirection | help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle | LL |     struct ExplicitlyPadded(Box<ExplicitlyPadded>); |                             ++++                + error[E0391]: cycle detected when computing layout of `should_pad_explicitly_packed_field::ExplicitlyPadded` | = note: ...which immediately requires computing layout of `should_pad_explicitly_packed_field::ExplicitlyPadded` again = note: cycle used when evaluating trait selection obligation `(): core::mem::transmutability::BikeshedIntrinsicFrom<should_pad_explicitly_packed_field::ExplicitlyPadded, assert::Context, core::mem::transmutability::Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 2 previous errors Some errors have detailed explanations: E0072, E0391. For more information about an error, try `rustc --explain E0072`. </ins>


span, if span_to_replace.is_some() { constraint.clone() <ins> } else if constraint.starts_with("<") { constraint.to_string() </ins> } else if bound_list_non_empty { format!(" + {constraint}") } else {


<ins> // run-rustfix pub trait MyTrait { type T; fn bar(self) -> Self::T; } pub fn foo<A: MyTrait<T = B>, B>(a: A) -> B { return a.bar(); //~ ERROR mismatched types } fn main() {} </ins>


<ins> // run-rustfix pub trait MyTrait { type T; fn bar(self) -> Self::T; } pub fn foo<A: MyTrait, B>(a: A) -> B { return a.bar(); //~ ERROR mismatched types } fn main() {} </ins>


<ins> error[E0308]: mismatched types --> $DIR/restrict-assoc-type-of-generic-bound.rs:9:12 | LL | pub fn foo<A: MyTrait, B>(a: A) -> B { |                        -           - expected `B` because of return type |                        | |                        expected this type parameter LL |     return a.bar(); |            ^^^^^^^ expected type parameter `B`, found associated type | = note: expected type parameter `B` found associated type `<A as MyTrait>::T` help: consider further restricting this bound | LL | pub fn foo<A: MyTrait<T = B>, B>(a: A) -> B { |                      +++++++ error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. </ins>


use super::{BorrowedBuf, BufReader, BufWriter, Read, Result, Write, DEFAULT_BUF_SIZE}; use crate::alloc::Allocator; use crate::cmp; <ins> use crate::cmp::min; </ins> use crate::collections::VecDeque; use crate::io::IoSlice; use crate::mem::MaybeUninit;


fn copy_from<R: Read + ?Sized>(&mut self, reader: &mut R) -> Result<u64> { let mut bytes = 0; <del> // avoid allocating before we have determined that there's anything to read if self.capacity() == 0 { bytes = stack_buffer_copy(&mut reader.take(DEFAULT_BUF_SIZE as u64), self)?; if bytes == 0 { return Ok(0); </del> <ins> // avoid inflating empty/small vecs before we have determined that there's anything to read if self.capacity() < DEFAULT_BUF_SIZE { let stack_read_limit = DEFAULT_BUF_SIZE as u64; bytes = stack_buffer_copy(&mut reader.take(stack_read_limit), self)?; // fewer bytes than requested -> EOF reached if bytes < stack_read_limit { return Ok(bytes); </ins> } } <ins> // don't immediately offer the vec's whole spare capacity, otherwise // we might have to fully initialize it if the reader doesn't have a custom read_buf() impl let mut max_read_size = DEFAULT_BUF_SIZE; </ins> loop { self.reserve(DEFAULT_BUF_SIZE); <del> let mut buf: BorrowedBuf<'_> = self.spare_capacity_mut().into(); match reader.read_buf(buf.unfilled()) { Ok(()) => {} Err(e) if e.is_interrupted() => continue, Err(e) => return Err(e), }; </del> <ins> let mut initialized_spare_capacity = 0; </ins> <del> let read = buf.filled().len(); if read == 0 { break; } </del> <ins> loop { let buf = self.spare_capacity_mut(); let read_size = min(max_read_size, buf.len()); let mut buf = BorrowedBuf::from(&mut buf[..read_size]); // SAFETY: init is either 0 or the init_len from the previous iteration. unsafe { buf.set_init(initialized_spare_capacity); } match reader.read_buf(buf.unfilled()) { Ok(()) => { let bytes_read = buf.len(); </ins> <del> // SAFETY: BorrowedBuf guarantees all of its filled bytes are init // and the number of read bytes can't exceed the spare capacity since // that's what the buffer is borrowing from. unsafe { self.set_len(self.len() + read) }; bytes += read as u64; } </del> <ins> // EOF if bytes_read == 0 { return Ok(bytes); } </ins> <del> Ok(bytes) </del> <ins> // the reader is returning short reads but it doesn't call ensure_init() if buf.init_len() < buf.capacity() { max_read_size = usize::MAX; } // the reader hasn't returned short reads so far if bytes_read == buf.capacity() { max_read_size *= 2; } initialized_spare_capacity = buf.init_len() - bytes_read; bytes += bytes_read as u64; // SAFETY: BorrowedBuf guarantees all of its filled bytes are init // and the number of read bytes can't exceed the spare capacity since // that's what the buffer is borrowing from. unsafe { self.set_len(self.len() + bytes_read) }; // spare capacity full, reserve more if self.len() == self.capacity() { break; } } Err(e) if e.is_interrupted() => continue, Err(e) => return Err(e), } } } </ins> } }


// Equate the headers to find their intersection (the general type, with infer vars, // that may apply both impls). <del> let Some(_equate_obligations) = </del> <ins> let Some(equate_obligations) = </ins> equate_impl_headers(infcx, param_env, &impl1_header, &impl2_header) else { return false;


plug_infer_with_placeholders(infcx, universe, (impl1_header.impl_args, impl2_header.impl_args)); <ins> // FIXME(with_negative_coherence): the infcx has constraints from equating // the impl headers. We should use these constraints as assumptions, not as // requirements, when proving the negated where clauses below. drop(equate_obligations); drop(infcx.take_registered_region_obligations()); drop(infcx.take_and_reset_region_constraints()); </ins> util::elaborate(tcx, tcx.predicates_of(impl2_def_id).instantiate(tcx, impl2_header.impl_args)) .any(|(clause, _)| try_prove_negated_where_clause(infcx, clause, param_env)) }


return false; }; <del> // FIXME(with_negative_coherence): the infcx has region contraints from equating // the impl headers as requirements. Given that the only region constraints we // get are involving inference regions in the root, it shouldn't matter, but // still sus. // // We probably should just throw away the region obligations registered up until // now, or ideally use them as assumptions when proving the region obligations // that we get from proving the negative predicate below. </del> let ref infcx = root_infcx.fork(); let ocx = ObligationCtxt::new(infcx);


<ins> error: conflicting implementations of trait `FnMarker` for type `fn(&_)` --> $DIR/negative-coherence-placeholder-region-constraints-on-unification.rs:21:1 | LL | impl<T: ?Sized + Marker> FnMarker for fn(T) {} | ------------------------------------------- first implementation here LL | impl<T: ?Sized> FnMarker for fn(&T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `fn(&_)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105> = note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details note: the lint level is defined here --> $DIR/negative-coherence-placeholder-region-constraints-on-unification.rs:4:11 | LL | #![forbid(coherence_leak_check)] |           ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error </ins>


<ins> // revisions: explicit implicit //[implicit] check-pass #![forbid(coherence_leak_check)] #![feature(negative_impls, with_negative_coherence)] pub trait Marker {} #[cfg(implicit)] impl<T: ?Sized> !Marker for &T {} #[cfg(explicit)] impl<'a, T: ?Sized + 'a> !Marker for &'a T {} trait FnMarker {} // Unifying these two impls below results in a `T: '!0` obligation // that we shouldn't need to care about. Ideally, we'd treat that // as an assumption when proving `&'!0 T: Marker`... impl<T: ?Sized + Marker> FnMarker for fn(T) {} impl<T: ?Sized> FnMarker for fn(&T) {} //[explicit]~^ ERROR conflicting implementations of trait `FnMarker` for type `fn(&_)` //[explicit]~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! fn main() {} </ins>


let (param_env, unevaluated) = unevaluated.prepare_for_eval(tcx, param_env); // try to resolve e.g. associated constants to their definition on an impl, and then // evaluate the const. <del> let c = tcx.const_eval_resolve_for_typeck(param_env, unevaluated, span)?; Ok(c.expect("`ty::Const::eval` called on a non-valtree-compatible type")) </del> <ins> let Some(c) = tcx.const_eval_resolve_for_typeck(param_env, unevaluated, span)? else { // This can happen when we run on ill-typed code. let e = tcx.sess.span_delayed_bug( span.unwrap_or(DUMMY_SP), "`ty::Const::eval` called on a non-valtree-compatible type", ); return Err(e.into()); }; Ok(c) </ins> } ConstKind::Value(val) => Ok(val), ConstKind::Error(g) => Err(g.into()),


<ins> struct Checked<const F: fn(usize) -> bool>; //~^ ERROR function pointers as const generic parameters is forbidden fn not_one(val: usize) -> bool { val != 1 } const _: Checked<not_one> = Checked::<not_one>; fn main() {} </ins>


<ins> error: using function pointers as const generic parameters is forbidden --> $DIR/ice-118285-fn-ptr-value.rs:1:25 | LL | struct Checked<const F: fn(usize) -> bool>; |                         ^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` error: aborting due to 1 previous error </ins>