Auto merge of #68118 - skinny121:eager_lit_eval, r=varkor
perf: Eagerly convert literals to consts Previousely even literal constants were being converted to an `Unevaluted` constant for evaluation later. This seems unecessary as no more information is needed to be able to convert the literal to a mir constant. Hopefully this will also minimise the performance impact of #67717, as far less constant evaluations are needed.
This commit is contained in:
commit
4b172cc73f
19 changed files with 173 additions and 115 deletions
|
|
@ -11,7 +11,7 @@ pub struct Simd<T, const WIDTH: usize> {
|
|||
inner: T,
|
||||
}
|
||||
|
||||
// @has foo/struct.Simd.html '//div[@id="implementations-list"]/h3/code' 'impl Add<Simd<u8, 16>> for Simd<u8, 16>'
|
||||
// @has foo/struct.Simd.html '//div[@id="implementations-list"]/h3/code' 'impl Add<Simd<u8, 16usize>> for Simd<u8, 16>'
|
||||
impl Add for Simd<u8, 16> {
|
||||
type Output = Self;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ LL | / const OUT_OF_BOUNDS_PTR: NonNull<u8> = { unsafe {
|
|||
LL | | let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it does not dangle
|
||||
LL | | // Use address-of-element for pointer arithmetic. This could wrap around to NULL!
|
||||
LL | | let out_of_bounds_ptr = &ptr[255];
|
||||
| | ^^^^^^^^^ Memory access failed: pointer must be in-bounds at offset 256, but is outside bounds of allocation 9 which has size 1
|
||||
| | ^^^^^^^^^ Memory access failed: pointer must be in-bounds at offset 256, but is outside bounds of allocation 8 which has size 1
|
||||
LL | | mem::transmute(out_of_bounds_ptr)
|
||||
LL | | } };
|
||||
| |____-
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ error[E0223]: ambiguous associated type
|
|||
--> $DIR/bad-assoc-ty.rs:1:10
|
||||
|
|
||||
LL | type A = [u8; 4]::AssocTy;
|
||||
| ^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<[u8; _] as Trait>::AssocTy`
|
||||
| ^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<[u8; 4] as Trait>::AssocTy`
|
||||
|
||||
error[E0223]: ambiguous associated type
|
||||
--> $DIR/bad-assoc-ty.rs:5:10
|
||||
|
|
|
|||
|
|
@ -1,71 +1,71 @@
|
|||
error: symbol-name(_ZN5impl13foo3Foo3bar17h92cf46db76791039E)
|
||||
--> $DIR/impl1.rs:14:9
|
||||
--> $DIR/impl1.rs:16:9
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling(impl1::foo::Foo::bar::h92cf46db76791039)
|
||||
--> $DIR/impl1.rs:14:9
|
||||
--> $DIR/impl1.rs:16:9
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling-alt(impl1::foo::Foo::bar)
|
||||
--> $DIR/impl1.rs:14:9
|
||||
--> $DIR/impl1.rs:16:9
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: def-path(foo::Foo::bar)
|
||||
--> $DIR/impl1.rs:21:9
|
||||
--> $DIR/impl1.rs:23:9
|
||||
|
|
||||
LL | #[rustc_def_path]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: symbol-name(_ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz17h90c4a800b1aa0df0E)
|
||||
--> $DIR/impl1.rs:32:9
|
||||
--> $DIR/impl1.rs:34:9
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling(impl1::bar::<impl impl1::foo::Foo>::baz::h90c4a800b1aa0df0)
|
||||
--> $DIR/impl1.rs:32:9
|
||||
--> $DIR/impl1.rs:34:9
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling-alt(impl1::bar::<impl impl1::foo::Foo>::baz)
|
||||
--> $DIR/impl1.rs:32:9
|
||||
--> $DIR/impl1.rs:34:9
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: def-path(bar::<impl foo::Foo>::baz)
|
||||
--> $DIR/impl1.rs:39:9
|
||||
--> $DIR/impl1.rs:41:9
|
||||
|
|
||||
LL | #[rustc_def_path]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: symbol-name(_ZN209_$LT$$u5b$$RF$dyn$u20$impl1..Foo$u2b$Assoc$u20$$u3d$$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RF$u8$C$$u20$...$RP$$u2b$impl1..AutoTrait$u3b$$u20$_$u5d$$u20$as$u20$impl1..main..$u7b$$u7b$closure$u7d$$u7d$..Bar$GT$6method17hf07584432cd4d8beE)
|
||||
--> $DIR/impl1.rs:62:13
|
||||
error: symbol-name(_ZN209_$LT$$u5b$$RF$dyn$u20$impl1..Foo$u2b$Assoc$u20$$u3d$$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RF$u8$C$$u20$...$RP$$u2b$impl1..AutoTrait$u3b$$u20$3$u5d$$u20$as$u20$impl1..main..$u7b$$u7b$closure$u7d$$u7d$..Bar$GT$6method17SYMBOL_HASHE)
|
||||
--> $DIR/impl1.rs:64:13
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; _] as impl1::main::{{closure}}::Bar>::method::hf07584432cd4d8be)
|
||||
--> $DIR/impl1.rs:62:13
|
||||
error: demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method::SYMBOL_HASH)
|
||||
--> $DIR/impl1.rs:64:13
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling-alt(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; _] as impl1::main::{{closure}}::Bar>::method)
|
||||
--> $DIR/impl1.rs:62:13
|
||||
error: demangling-alt(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method)
|
||||
--> $DIR/impl1.rs:64:13
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: def-path(<[&dyn Foo<Assoc = for<'r> extern "C" fn(&'r u8, ...)> + AutoTrait; _] as main::{{closure}}#1::Bar>::method)
|
||||
--> $DIR/impl1.rs:69:13
|
||||
error: def-path(<[&dyn Foo<Assoc = for<'r> extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as main::{{closure}}#1::Bar>::method)
|
||||
--> $DIR/impl1.rs:71:13
|
||||
|
|
||||
LL | #[rustc_def_path]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
// revisions: legacy v0
|
||||
//[legacy]compile-flags: -Z symbol-mangling-version=legacy
|
||||
//[v0]compile-flags: -Z symbol-mangling-version=v0
|
||||
//[legacy]normalize-stderr-32bit: "hdb62078998ce7ea8" -> "SYMBOL_HASH"
|
||||
//[legacy]normalize-stderr-64bit: "h62e540f14f879d56" -> "SYMBOL_HASH"
|
||||
|
||||
#![feature(optin_builtin_traits, rustc_attrs)]
|
||||
#![allow(dead_code)]
|
||||
|
|
@ -60,15 +62,15 @@ fn main() {
|
|||
// Test type mangling, by putting them in an `impl` header.
|
||||
impl Bar for [&'_ (dyn Foo<Assoc = extern fn(&u8, ...)> + AutoTrait); 3] {
|
||||
#[rustc_symbol_name]
|
||||
//[legacy]~^ ERROR symbol-name(_ZN209_$LT$$u5b$$RF$dyn$u20$impl1..Foo$u2b$Assoc$u20$$u3d$$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RF$u8$C$$u20$...$RP$$u2b$impl1..AutoTrait$u3b$$u20$_$u5d$$u20$as$u20$impl1..main..$u7b$$u7b$closure$u7d$$u7d$..Bar$GT$6method
|
||||
//[legacy]~| ERROR demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; _] as impl1::main::{{closure}}::Bar>::method
|
||||
//[legacy]~| ERROR demangling-alt(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; _] as impl1::main::{{closure}}::Bar>::method)
|
||||
//[legacy]~^ ERROR symbol-name(_ZN209_$LT$$u5b$$RF$dyn$u20$impl1..Foo$u2b$Assoc$u20$$u3d$$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RF$u8$C$$u20$...$RP$$u2b$impl1..AutoTrait$u3b$$u20$3$u5d$$u20$as$u20$impl1..main..$u7b$$u7b$closure$u7d$$u7d$..Bar$GT$6method
|
||||
//[legacy]~| ERROR demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method
|
||||
//[legacy]~| ERROR demangling-alt(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method)
|
||||
//[v0]~^^^^ ERROR symbol-name(_RNvXNCNvCs4fqI2P2rA04_5impl14mains_0ARDNtB6_3Foop5AssocFG_KCRL0_hvEuNtB6_9AutoTraitEL_j3_NtB2_3Bar6method)
|
||||
//[v0]~| ERROR demangling(<[&dyn impl1[317d481089b8c8fe]::Foo<Assoc = for<'a> extern "C" fn(&'a u8, ...)> + impl1[317d481089b8c8fe]::AutoTrait; 3: usize] as impl1[317d481089b8c8fe]::main::{closure#1}::Bar>::method)
|
||||
//[v0]~| ERROR demangling-alt(<[&dyn impl1::Foo<Assoc = for<'a> extern "C" fn(&'a u8, ...)> + impl1::AutoTrait; 3] as impl1::main::{closure#1}::Bar>::method)
|
||||
#[rustc_def_path]
|
||||
//[legacy]~^ ERROR def-path(<[&dyn Foo<Assoc = for<'r> extern "C" fn(&'r u8, ...)> + AutoTrait; _] as main::{{closure}}#1::Bar>::method)
|
||||
//[v0]~^^ ERROR def-path(<[&dyn Foo<Assoc = for<'r> extern "C" fn(&'r u8, ...)> + AutoTrait; _] as main::{{closure}}#1::Bar>::method)
|
||||
//[legacy]~^ ERROR def-path(<[&dyn Foo<Assoc = for<'r> extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as main::{{closure}}#1::Bar>::method)
|
||||
//[v0]~^^ ERROR def-path(<[&dyn Foo<Assoc = for<'r> extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as main::{{closure}}#1::Bar>::method)
|
||||
fn method(&self) {}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,71 +1,71 @@
|
|||
error: symbol-name(_RNvMNtCs4fqI2P2rA04_5impl13fooNtB2_3Foo3bar)
|
||||
--> $DIR/impl1.rs:14:9
|
||||
--> $DIR/impl1.rs:16:9
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling(<impl1[317d481089b8c8fe]::foo::Foo>::bar)
|
||||
--> $DIR/impl1.rs:14:9
|
||||
--> $DIR/impl1.rs:16:9
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling-alt(<impl1::foo::Foo>::bar)
|
||||
--> $DIR/impl1.rs:14:9
|
||||
--> $DIR/impl1.rs:16:9
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: def-path(foo::Foo::bar)
|
||||
--> $DIR/impl1.rs:21:9
|
||||
--> $DIR/impl1.rs:23:9
|
||||
|
|
||||
LL | #[rustc_def_path]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: symbol-name(_RNvMNtCs4fqI2P2rA04_5impl13barNtNtB4_3foo3Foo3baz)
|
||||
--> $DIR/impl1.rs:32:9
|
||||
--> $DIR/impl1.rs:34:9
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling(<impl1[317d481089b8c8fe]::foo::Foo>::baz)
|
||||
--> $DIR/impl1.rs:32:9
|
||||
--> $DIR/impl1.rs:34:9
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling-alt(<impl1::foo::Foo>::baz)
|
||||
--> $DIR/impl1.rs:32:9
|
||||
--> $DIR/impl1.rs:34:9
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: def-path(bar::<impl foo::Foo>::baz)
|
||||
--> $DIR/impl1.rs:39:9
|
||||
--> $DIR/impl1.rs:41:9
|
||||
|
|
||||
LL | #[rustc_def_path]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: symbol-name(_RNvXNCNvCs4fqI2P2rA04_5impl14mains_0ARDNtB6_3Foop5AssocFG_KCRL0_hvEuNtB6_9AutoTraitEL_j3_NtB2_3Bar6method)
|
||||
--> $DIR/impl1.rs:62:13
|
||||
--> $DIR/impl1.rs:64:13
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling(<[&dyn impl1[317d481089b8c8fe]::Foo<Assoc = for<'a> extern "C" fn(&'a u8, ...)> + impl1[317d481089b8c8fe]::AutoTrait; 3: usize] as impl1[317d481089b8c8fe]::main::{closure#1}::Bar>::method)
|
||||
--> $DIR/impl1.rs:62:13
|
||||
--> $DIR/impl1.rs:64:13
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling-alt(<[&dyn impl1::Foo<Assoc = for<'a> extern "C" fn(&'a u8, ...)> + impl1::AutoTrait; 3] as impl1::main::{closure#1}::Bar>::method)
|
||||
--> $DIR/impl1.rs:62:13
|
||||
--> $DIR/impl1.rs:64:13
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: def-path(<[&dyn Foo<Assoc = for<'r> extern "C" fn(&'r u8, ...)> + AutoTrait; _] as main::{{closure}}#1::Bar>::method)
|
||||
--> $DIR/impl1.rs:69:13
|
||||
error: def-path(<[&dyn Foo<Assoc = for<'r> extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as main::{{closure}}#1::Bar>::method)
|
||||
--> $DIR/impl1.rs:71:13
|
||||
|
|
||||
LL | #[rustc_def_path]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue